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: * Generates the encoded code for the tab menu.
26: *
27: * @param array $tabs
28: * associative array mapping the tab IDs to the tab names
29: *
30: * @return string
31: * the encoded code for the tab menu
32: * @throws cInvalidArgumentException
33: */
34: protected function _generateTabMenuCode(array $tabs) {
35: $template = new cTemplate();
36:
37: // iterate over all tabs and set dynamic template placeholder for each
38: foreach ($tabs as $id => $name) {
39: $template->set('d', 'TAB_ID', $id);
40: $template->set('d', 'TAB_NAME', $name);
41: $template->next();
42: }
43: $code = $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tab_menu.html', true);
44:
45: return $this->_encodeForOutput($code);
46: }
47:
48: /**
49: * Return the raw settings of a content type
50: *
51: * @param string $contentTypeName
52: * Content type name
53: * @param int $id
54: * ID of the content type
55: * @param array $contentTypes
56: * Content type array
57: *
58: * @return mixed
59: * @throws cDbException
60: * @throws cException
61: */
62: protected function _getRawSettings($contentTypeName, $id, array $contentTypes) {
63: if (!isset($contentTypes[$contentTypeName][$id])) {
64: $idArtLang = cRegistry::getArticleLanguageId();
65: // get the idtype of the content type
66: $typeItem = new cApiType();
67: $typeItem->loadByType($contentTypeName);
68: $idtype = $typeItem->get('idtype');
69: // first load the appropriate content entry in order to get the
70: // settings
71: $content = new cApiContent();
72: $content->loadByMany(array(
73: 'idartlang' => $idArtLang,
74: 'idtype' => $idtype,
75: 'typeid' => $id
76: ));
77: return $content->get('value');
78: } else {
79: return $contentTypes[$contentTypeName][$id];
80: }
81: }
82:
83: /**
84: * Generates the code for the action buttons (save and cancel).
85: *
86: * @return string
87: * the encoded code for the action buttons
88: * @throws cInvalidArgumentException
89: */
90: protected function _generateActionCode() {
91: $template = new cTemplate();
92:
93: $code = $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_action.html', true);
94:
95: return $this->_encodeForOutput($code);
96: }
97:
98: }
99: