1: <?php
2: /**
3: * This file contains the cContentTypeImg class.
4: *
5: * @package Core
6: * @subpackage ContentType
7: * @version SVN Revision $Rev:$
8: *
9: * @author Simon Sprankel
10: * @copyright four for business AG <www.4fb.de>
11: * @license http://www.contenido.org/license/LIZENZ.txt
12: * @link http://www.4fb.de
13: * @link http://www.contenido.org
14: */
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: /**
19: * Content type CMS_IMG which displays the path to the selected image.
20: *
21: * @package Core
22: * @subpackage ContentType
23: */
24: class cContentTypeImg extends cContentTypeImgeditor {
25:
26: /**
27: * Initialises class attributes and handles store events.
28: *
29: * @param string $rawSettings the raw settings in an XML structure or as
30: * plaintext
31: * @param integer $id ID of the content type, e.g. 3 if CMS_DATE[3] is
32: * used
33: * @param array $contentTypes array containing the values of all content
34: * types
35: * @return void
36: */
37: public function __construct($rawSettings, $id, array $contentTypes) {
38: // there are no raw settings here, because CMS_IMG is not saved
39: // separately any more
40: // so compute the appropriate raw settings and call the parent
41: // constructor with them
42:
43: // if the content type value is not passed, get it from the DB
44: if (!isset($contentTypes['CMS_IMGEDITOR'][$id])) {
45: $idArtLang = cRegistry::getArticleLanguageId();
46: // get the idtype of the CMS_IMGEDITOR content type
47: $typeItem = new cApiType();
48: $typeItem->loadByType('CMS_IMGEDITOR');
49: $idtype = $typeItem->get('idtype');
50: // first load the appropriate content entry in order to get the
51: // idupl
52: $content = new cApiContent();
53: $content->loadByMany(array(
54: 'idartlang' => $idArtLang,
55: 'idtype' => $idtype,
56: 'typeid' => $id
57: ));
58: $rawSettings = $content->get('value');
59: } else {
60: $rawSettings = $contentTypes['CMS_IMGEDITOR'][$id];
61: }
62:
63: parent::__construct($rawSettings, $id, $contentTypes);
64: }
65:
66: /**
67: * Generates the code which should be shown if this content type is shown in
68: * the frontend.
69: *
70: * @return string escaped HTML code which sould be shown if content type is
71: * shown in frontend
72: */
73: public function generateViewCode() {
74: return $this->_encodeForOutput($this->_imagePath);
75: }
76:
77: /**
78: * Generates the code which should be shown if this content type is edited.
79: *
80: * @return string escaped HTML code which should be shown if content type is
81: * edited
82: */
83: public function generateEditCode() {
84: return $this->generateViewCode();
85: }
86:
87: }