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