1: <?php
2: /**
3: * This file contains the cContentTypeLink 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_LINK which displays the raw link.
20: *
21: * @package Core
22: * @subpackage ContentType
23: */
24: class cContentTypeLink extends cContentTypeLinkeditor {
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_LINK 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_LINKEDITOR'][$id])) {
45: $idArtLang = cRegistry::getArticleLanguageId();
46: // get the idtype of the CMS_LINKEDITOR content type
47: $typeItem = new cApiType();
48: $typeItem->loadByType('CMS_LINKEDITOR');
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_LINKEDITOR'][$id];
61: }
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->_generateHref());
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: }