Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cApiAction
  • cApiActionCollection
  • cApiActionlog
  • cApiActionlogCollection
  • cApiArea
  • cApiAreaCollection
  • cApiArticle
  • cApiArticleCollection
  • cApiArticleLanguage
  • cApiArticleLanguageCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiDbfs
  • cApiDbfsCollection
  • cApiFile
  • cApiFileCollection
  • cApiFileInformation
  • cApiFileInformationCollection
  • cApiFrameFile
  • cApiFrameFileCollection
  • cApiFrontendGroup
  • cApiFrontendGroupCollection
  • cApiFrontendGroupMember
  • cApiFrontendGroupMemberCollection
  • cApiFrontendPermission
  • cApiFrontendPermissionCollection
  • cApiFrontendUser
  • cApiFrontendUserCollection
  • cApiGroup
  • cApiGroupCollection
  • cApiGroupMember
  • cApiGroupMemberCollection
  • cApiGroupProperty
  • cApiGroupPropertyCollection
  • cApiInUse
  • cApiInUseCollection
  • cApiIso3166
  • cApiIso3166Collection
  • cApiIso6392
  • cApiIso6392Collection
  • cApiKeyword
  • cApiKeywordCollection
  • cApiLanguage
  • cApiLanguageCollection
  • cApiLayout
  • cApiLayoutCollection
  • cApiMailLog
  • cApiMailLogCollection
  • cApiMailLogSuccess
  • cApiMailLogSuccessCollection
  • cApiMetaTag
  • cApiMetaTagCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  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:     /**
 27:      * Create a new collection of items.
 28:      *
 29:      * @param string $select where clause to use for selection (see
 30:      *        ItemCollection::select())
 31:      */
 32:     public function __construct($select = false) {
 33:         global $cfg;
 34:         parent::__construct($cfg['tab']['tpl'], 'idtpl');
 35:         $this->_setItemClass('cApiTemplate');
 36: 
 37:         // set the join partners so that joins can be used via link() method
 38:         $this->_setJoinPartner('cApiLayoutCollection');
 39:         $this->_setJoinPartner('cApiTemplateCollection');
 40:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 41: 
 42:         if ($select !== false) {
 43:             $this->select($select);
 44:         }
 45:     }
 46: 
 47:     /**
 48:      * Creates a template entry.
 49:      *
 50:      * @param int $idclient
 51:      * @param int $idlay
 52:      * @param int $idtplcfg  Either a valid template configuration id or an empty string
 53:      * @param string $name
 54:      * @param string $description
 55:      * @param int $deletable
 56:      * @param int $status
 57:      * @param int $defaulttemplate
 58:      * @param string $author
 59:      * @param string $created
 60:      * @param string $lastmodified
 61:      * @return cApiTemplate
 62:      */
 63:     public function create($idclient, $idlay, $idtplcfg, $name, $description, $deletable = 1, $status = 0, $defaulttemplate = 0, $author = '', $created = '', $lastmodified = '') {
 64:         if (empty($author)) {
 65:             $auth = cRegistry::getAuth();
 66:             $author = $auth->auth['uname'];
 67:         }
 68:         if (empty($created)) {
 69:             $created = date('Y-m-d H:i:s');
 70:         }
 71:         if (empty($lastmodified)) {
 72:             $lastmodified = date('Y-m-d H:i:s');
 73:         }
 74: 
 75:         $oItem = parent::createNewItem();
 76: 
 77:         $oItem->set('idclient', $idclient);
 78:         $oItem->set('idlay', $idlay);
 79:         $oItem->set('idtplcfg', $idtplcfg);
 80:         $oItem->set('name', $name);
 81:         $oItem->set('description', $description);
 82:         $oItem->set('deletable', $deletable);
 83:         $oItem->set('status', $status);
 84:         $oItem->set('defaulttemplate', $defaulttemplate);
 85:         $oItem->set('author', $author);
 86:         $oItem->set('created', $created);
 87:         $oItem->set('lastmodified', $lastmodified);
 88:         $oItem->store();
 89: 
 90:         return $oItem;
 91:     }
 92: 
 93:     /**
 94:      * Returns the default template configuration item
 95:      *
 96:      * @param int $idclient
 97:      * @return cApiTemplateConfiguration NULL
 98:      */
 99:     public function selectDefaultTemplate($idclient) {
100:         $this->select('defaulttemplate = 1 AND idclient = ' . (int) $idclient);
101:         return $this->next();
102:     }
103: 
104:     /**
105:      * Returns all templates having passed layout id.
106:      *
107:      * @param int $idlay
108:      * @return cApiTemplate[]
109:      */
110:     public function fetchByIdLay($idlay) {
111:         $this->select('idlay = ' . (int) $idlay);
112:         $entries = array();
113:         while (($entry = $this->next()) !== false) {
114:             $entries[] = clone $entry;
115:         }
116:         return $entries;
117:     }
118: }
119: 
120: /**
121:  * Template item
122:  *
123:  * @package Core
124:  * @subpackage GenericDB_Model
125:  */
126: class cApiTemplate extends Item {
127: 
128:     /**
129:      * Constructor Function
130:      *
131:      * @param mixed $mId Specifies the ID of item to load
132:      */
133:     public function __construct($mId = false) {
134:         global $cfg;
135:         parent::__construct($cfg['tab']['tpl'], 'idtpl');
136:         $this->setFilters(array(), array());
137:         if ($mId !== false) {
138:             $this->loadByPrimaryKey($mId);
139:         }
140:     }
141: 
142:     /**
143:      * Userdefined setter for template fields.
144:      *
145:      * @param string $name
146:      * @param mixed $value
147:      * @param bool $bSafe Flag to run defined inFilter on passed value
148:      * @todo should return return value of overloaded method
149:      */
150:     public function setField($name, $value, $bSafe = true) {
151:         switch ($name) {
152:             case 'deletable':
153:             case 'status':
154:             case 'defaulttemplate':
155:                 $value = ($value == 1) ? 1 : 0;
156:                 break;
157:             case 'idclient':
158:             case 'idlay':
159:                 $value = (int) $value;
160:                 break;
161:             case 'idtplcfg':
162:                 if (!is_numeric($value)) {
163:                     $value = '';
164:                 }
165:                 break;
166:         }
167: 
168:         parent::setField($name, $value, $bSafe);
169:     }
170: 
171: }
172: 
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0