Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • cApiArticleLanguageVersion
  • cApiArticleLanguageVersionCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiContentVersion
  • cApiContentVersionCollection
  • 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
  • cApiMetaTagVersion
  • cApiMetaTagVersionCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserPasswordRequest
  • cApiUserPasswordRequestCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the template collection and item class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GenericDB_Model
  8:  * @author Timo Hummel
  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:  * Template collection
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class cApiTemplateCollection extends ItemCollection {
 24: 
 25:     /**
 26:      * Constructor to create an instance of this class.
 27:      *
 28:      * @param string $select [optional]
 29:      *         where clause to use for selection (see ItemCollection::select())
 30:      */
 31:     public function __construct($select = false) {
 32:         global $cfg;
 33:         parent::__construct($cfg['tab']['tpl'], 'idtpl');
 34:         $this->_setItemClass('cApiTemplate');
 35: 
 36:         // set the join partners so that joins can be used via link() method
 37:         $this->_setJoinPartner('cApiLayoutCollection');
 38:         $this->_setJoinPartner('cApiTemplateCollection');
 39:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 40: 
 41:         if ($select !== false) {
 42:             $this->select($select);
 43:         }
 44:     }
 45: 
 46:     /**
 47:      * Creates a template entry.
 48:      *
 49:      * @param int $idclient
 50:      * @param int $idlay
 51:      * @param int $idtplcfg
 52:      *         Either a valid template configuration id or an empty string
 53:      * @param string $name
 54:      * @param string $description
 55:      * @param int $deletable [optional]
 56:      * @param int $status [optional]
 57:      * @param int $defaulttemplate [optional]
 58:      * @param string $author [optional]
 59:      * @param string $created [optional]
 60:      * @param string $lastmodified [optional]
 61:      * @return cApiTemplate
 62:      */
 63:     public function create($idclient, $idlay, $idtplcfg, $name, $description,
 64:             $deletable = 1, $status = 0, $defaulttemplate = 0, $author = '',
 65:             $created = '', $lastmodified = '') {
 66:         if (empty($author)) {
 67:             $auth = cRegistry::getAuth();
 68:             $author = $auth->auth['uname'];
 69:         }
 70:         if (empty($created)) {
 71:             $created = date('Y-m-d H:i:s');
 72:         }
 73:         if (empty($lastmodified)) {
 74:             $lastmodified = date('Y-m-d H:i:s');
 75:         }
 76: 
 77:         $oItem = $this->createNewItem();
 78: 
 79:         $oItem->set('idclient', $idclient);
 80:         $oItem->set('idlay', $idlay);
 81:         $oItem->set('idtplcfg', $idtplcfg);
 82:         $oItem->set('name', $name);
 83:         $oItem->set('description', $description);
 84:         $oItem->set('deletable', $deletable);
 85:         $oItem->set('status', $status);
 86:         $oItem->set('defaulttemplate', $defaulttemplate);
 87:         $oItem->set('author', $author);
 88:         $oItem->set('created', $created);
 89:         $oItem->set('lastmodified', $lastmodified);
 90:         $oItem->store();
 91: 
 92:         return $oItem;
 93:     }
 94: 
 95:     /**
 96:      * Returns the default template configuration item
 97:      *
 98:      * @param int $idclient
 99:      * @return cApiTemplateConfiguration|NULL
100:      */
101:     public function selectDefaultTemplate($idclient) {
102:         $this->select('defaulttemplate = 1 AND idclient = ' . (int) $idclient);
103:         return $this->next();
104:     }
105: 
106:     /**
107:      * Returns all templates having passed layout id.
108:      *
109:      * @param int $idlay
110:      * @return array
111:      */
112:     public function fetchByIdLay($idlay) {
113:         $this->select('idlay = ' . (int) $idlay);
114:         $entries = array();
115:         while (($entry = $this->next()) !== false) {
116:             $entries[] = clone $entry;
117:         }
118:         return $entries;
119:     }
120: }
121: 
122: /**
123:  * Template item
124:  *
125:  * @package Core
126:  * @subpackage GenericDB_Model
127:  */
128: class cApiTemplate extends Item {
129: 
130:     /**
131:      * Constructor to create an instance of this class.
132:      *
133:      * @param mixed $mId [optional]
134:      *         Specifies the ID of item to load
135:      */
136:     public function __construct($mId = false) {
137:         global $cfg;
138:         parent::__construct($cfg['tab']['tpl'], 'idtpl');
139:         $this->setFilters(array(), array());
140:         if ($mId !== false) {
141:             $this->loadByPrimaryKey($mId);
142:         }
143:     }
144: 
145:     /**
146:      * Load a template based on article, category, language and client id
147:      *
148:      * @param int $idart
149:      *         article id
150:      * @param int $idcat
151:      *         category id
152:      * @param int $lang
153:      *         language id
154:      * @param int $client
155:      *         client id
156:      * @return bool
157:      */
158:     public function loadByArticleOrCategory($idart, $idcat, $lang, $client) {
159: 
160:         // get ID of template configuration that is used for
161:         // either the article language or the category language
162:         $idtplcfg = conGetTemplateConfigurationIdForArticle($idart, $idcat, $lang, $client);
163:         if (!is_numeric($idtplcfg) || $idtplcfg == 0) {
164:             $idtplcfg = conGetTemplateConfigurationIdForCategory($idcat, $lang, $client);
165:         }
166:         if (is_null($idtplcfg)) {
167:             return false;
168:         }
169: 
170:         // load template configuration to get its template ID
171:         $templateConfiguration = new cApiTemplateConfiguration($idtplcfg);
172:         if (!$templateConfiguration->isLoaded()) {
173:             return false;
174:         }
175: 
176:         // try to load template by determined ID
177:         $idtpl = $templateConfiguration->get('idtpl');
178:         $this->loadByPrimaryKey($idtpl);
179:         
180:         return true;
181:     }
182: 
183:     /**
184:      * Userdefined setter for template fields.
185:      *
186:      * @param string $name
187:      * @param mixed $value
188:      * @param bool $bSafe [optional]
189:      *         Flag to run defined inFilter on passed value
190:      *
191:      * @return bool
192:      */
193:     public function setField($name, $value, $bSafe = true) {
194:         switch ($name) {
195:             case 'deletable':
196:             case 'status':
197:             case 'defaulttemplate':
198:                 $value = ($value == 1) ? 1 : 0;
199:                 break;
200:             case 'idclient':
201:             case 'idlay':
202:                 $value = (int) $value;
203:                 break;
204:             case 'idtplcfg':
205:                 if (!is_numeric($value)) {
206:                     $value = '';
207:                 }
208:                 break;
209:         }
210: 
211:         return parent::setField($name, $value, $bSafe);
212:     }
213: 
214: }
215: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0