1: <?php
2: /**
3: * This file contains the template collection and item class.
4: *
5: * @package Core
6: * @subpackage GenericDB_Model
7: * @version SVN Revision $Rev:$
8: *
9: * @author Timo Hummel
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: * Template collection
20: *
21: * @package Core
22: * @subpackage GenericDB_Model
23: */
24: class cApiTemplateCollection extends ItemCollection {
25:
26: public function __construct($select = false) {
27: global $cfg;
28: parent::__construct($cfg['tab']['tpl'], 'idtpl');
29: $this->_setItemClass('cApiTemplate');
30:
31: // set the join partners so that joins can be used via link() method
32: $this->_setJoinPartner('cApiLayoutCollection');
33: $this->_setJoinPartner('cApiTemplateCollection');
34: $this->_setJoinPartner('cApiTemplateConfigurationCollection');
35:
36: if ($select !== false) {
37: $this->select($select);
38: }
39: }
40:
41: /**
42: * Returns the default template configuration item
43: *
44: * @param int $idclient return cApiTemplateConfiguration|null
45: */
46: public function selectDefaultTemplate($idclient) {
47: $this->select('defaulttemplate = 1 AND idclient = ' . $idclient);
48: return $this->next();
49: }
50:
51: /**
52: * Returns all templates having passed layout id.
53: *
54: * @param int $idlay
55: * @return cApiTemplate[]
56: */
57: public function fetchByIdLay($idlay) {
58: $this->select('idlay = ' . $idlay);
59: $entries = array();
60: while (($entry = $this->next()) !== false) {
61: $entries[] = clone $entry;
62: }
63: return $entries;
64: }
65:
66: }
67:
68: /**
69: * Template item
70: *
71: * @package Core
72: * @subpackage GenericDB_Model
73: */
74: class cApiTemplate extends Item {
75:
76: /**
77: * Constructor Function
78: *
79: * @param mixed $mId Specifies the ID of item to load
80: */
81: public function __construct($mId = false) {
82: global $cfg;
83: parent::__construct($cfg['tab']['tpl'], 'idtpl');
84: $this->setFilters(array(), array());
85: if ($mId !== false) {
86: $this->loadByPrimaryKey($mId);
87: }
88: }
89: }
90: