1: <?php
2:
3: /**
4: * This file contains the cContentTypeAbstractTabbed class.
5: *
6: * @package Core
7: * @subpackage ContentType
8: * @author Simon Sprankel
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * Abstract content type for content types which are edited in a tabbed popup.
19: *
20: * @package Core
21: * @subpackage ContentType
22: */
23: abstract class cContentTypeAbstractTabbed extends cContentTypeAbstract {
24:
25: /**
26: * Generates the encoded code for the tab menu.
27: *
28: * @param array $tabs
29: * associative array mapping the tab IDs to the tab names
30: * @return string
31: * the encoded code for the tab menu
32: */
33: protected function _generateTabMenuCode(array $tabs) {
34: $template = new cTemplate();
35:
36: // iterate over all tabs and set dynamic template placeholder for each
37: foreach ($tabs as $id => $name) {
38: $template->set('d', 'TAB_ID', $id);
39: $template->set('d', 'TAB_NAME', $name);
40: $template->next();
41: }
42: $code = $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tab_menu.html', true);
43:
44: return $this->_encodeForOutput($code);
45: }
46:
47: /**
48: * Return the raw settings of a content type
49: *
50: * @param string $contentTypeName
51: * Content type name
52: * @param int $id
53: * ID of the content type
54: * @param array $contentTypes
55: * Content type array
56: * @return mixed
57: */
58: protected function _getRawSettings($contentTypeName, $id, array $contentTypes) {
59: if (!isset($contentTypes[$contentTypeName][$id])) {
60: $idArtLang = cRegistry::getArticleLanguageId();
61: // get the idtype of the content type
62: $typeItem = new cApiType();
63: $typeItem->loadByType($contentTypeName);
64: $idtype = $typeItem->get('idtype');
65: // first load the appropriate content entry in order to get the
66: // settings
67: $content = new cApiContent();
68: $content->loadByMany(array(
69: 'idartlang' => $idArtLang,
70: 'idtype' => $idtype,
71: 'typeid' => $id
72: ));
73: return $content->get('value');
74: } else {
75: return $contentTypes[$contentTypeName][$id];
76: }
77: }
78:
79: /**
80: * Generates the code for the action buttons (save and cancel).
81: *
82: * @return string
83: * the encoded code for the action buttons
84: */
85: protected function _generateActionCode() {
86: $template = new cTemplate();
87:
88: $code = $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_action.html', true);
89:
90: return $this->_encodeForOutput($code);
91: }
92:
93: }
94: