1: <?php
2: /**
3: * This file contains the cContentTypeImgdescr 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_IMGDESCR which displays the description of the selected
20: * image.
21: *
22: * @package Core
23: * @subpackage ContentType
24: */
25: class cContentTypeImgdescr extends cContentTypeImgeditor {
26:
27: /**
28: * Initialises class attributes and handles store events.
29: *
30: * @param string $rawSettings the raw settings in an XML structure or as
31: * plaintext
32: * @param integer $id ID of the content type, e.g. 3 if CMS_DATE[3] is
33: * used
34: * @param array $contentTypes array containing the values of all content
35: * types
36: * @return void
37: */
38: public function __construct($rawSettings, $id, array $contentTypes) {
39: // there are no raw settings here, because the image description is now
40: // saved in con_upl_meta
41: // so compute the appropriate raw settings and call the parent
42: // constructor with them
43:
44: // if the content type value is not passed, get it from the DB
45: if (!isset($contentTypes['CMS_IMGEDITOR'][$id])) {
46: $idArtLang = cRegistry::getArticleLanguageId();
47: // get the idtype of the CMS_IMGEDITOR content type
48: $typeItem = new cApiType();
49: $typeItem->loadByType('CMS_IMGEDITOR');
50: $idtype = $typeItem->get('idtype');
51: // first load the appropriate content entry in order to get the
52: // idupl
53: $content = new cApiContent();
54: $content->loadByMany(array(
55: 'idartlang' => $idArtLang,
56: 'idtype' => $idtype,
57: 'typeid' => $id
58: ));
59: $rawSettings = $content->get('value');
60: } else {
61: $rawSettings = $contentTypes['CMS_IMGEDITOR'][$id];
62: }
63:
64: parent::__construct($rawSettings, $id, $contentTypes);
65: }
66:
67: /**
68: * Generates the code which should be shown if this content type is shown in
69: * the frontend.
70: *
71: * @return string escaped HTML code which sould be shown if content type is
72: * shown in frontend
73: */
74: public function generateViewCode() {
75: return $this->_encodeForOutput($this->_description);
76: }
77:
78: /**
79: * Generates the code which should be shown if this content type is edited.
80: *
81: * @return string escaped HTML code which should be shown if content type is
82: * edited
83: */
84: public function generateEditCode() {
85: return $this->generateViewCode();
86: }
87:
88: }