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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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 = $this->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:      * Load a template based on article, category, language and client id
144:      * 
145:      * @param int $idart article id
146:      * @param int $idcat category id
147:      * @param int $lang language id
148:      * @param int $client client id
149:      */
150:     public function loadByArticleOrCategory($idart, $idcat, $lang, $client) {
151: 
152:         // get ID of template configuration that is used for
153:         // either the article language or the category language
154:         $idtplcfg = conGetTemplateConfigurationIdForArticle($idart, $idcat, $lang, $client);
155:         if (!is_numeric($idtplcfg) || $idtplcfg == 0) {
156:             $idtplcfg = conGetTemplateConfigurationIdForCategory($idcat, $lang, $client);
157:         }
158:         if (is_null($idtplcfg)) {
159:             return false;
160:         }
161: 
162:         // load template configuration to get its template ID
163:         $templateConfiguration = new cApiTemplateConfiguration($idtplcfg);
164:         if (!$templateConfiguration->isLoaded()) {
165:             return;
166:         }
167: 
168:         // try to load template by determined ID
169:         $idtpl = $templateConfiguration->get('idtpl');
170:         $this->loadByPrimaryKey($idtpl);
171:     }
172: 
173:     /**
174:      * Userdefined setter for template fields.
175:      *
176:      * @param string $name
177:      * @param mixed $value
178:      * @param bool $bSafe Flag to run defined inFilter on passed value
179:      * @todo should return return value of overloaded method
180:      */
181:     public function setField($name, $value, $bSafe = true) {
182:         switch ($name) {
183:             case 'deletable':
184:             case 'status':
185:             case 'defaulttemplate':
186:                 $value = ($value == 1) ? 1 : 0;
187:                 break;
188:             case 'idclient':
189:             case 'idlay':
190:                 $value = (int) $value;
191:                 break;
192:             case 'idtplcfg':
193:                 if (!is_numeric($value)) {
194:                     $value = '';
195:                 }
196:                 break;
197:         }
198: 
199:         parent::setField($name, $value, $bSafe);
200:     }
201: 
202: }
203: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen