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 content type generator class.
  4:  * TODO: This class needs more documentation.
  5:  *
  6:  * @package Core
  7:  * @subpackage ContentType
  8:  * @version SVN Revision $Rev:$
  9:  *
 10:  * @author Alexander Scheider
 11:  * @copyright four for business AG <www.4fb.de>
 12:  * @license http://www.contenido.org/license/LIZENZ.txt
 13:  * @link http://www.4fb.de
 14:  * @link http://www.contenido.org
 15:  */
 16: 
 17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 18: 
 19: /**
 20:  * This class generates content types.
 21:  *
 22:  * @package Core
 23:  * @subpackage ContentType
 24:  */
 25: class cTypeGenerator {
 26: 
 27:     /**
 28:      *
 29:      * @var array
 30:      */
 31:     private $cfg = NULL;
 32: 
 33:     /**
 34:      *
 35:      * @var cDb
 36:      */
 37:     private static $db = NULL;
 38: 
 39:     /**
 40:      *
 41:      * @var array
 42:      */
 43:     private static $a_content = array();
 44: 
 45:     /**
 46:      *
 47:      * @var int
 48:      */
 49:     private $_idart = NULL;
 50: 
 51:     /**
 52:      *
 53:      * @var int
 54:      */
 55:     private $_idlang = NULL;
 56: 
 57:     /**
 58:      * Constructor function
 59:      */
 60:     public function __construct() {
 61:         $this->_idart = cRegistry::getArticleId(true);
 62:         $this->_idlang = cRegistry::getLanguageId(true);
 63:         $this->cfg = cRegistry::getConfig();
 64: 
 65:         if (self::$db === NULL) {
 66:             self::$db = cRegistry::getDb();
 67:         }
 68:         if (!isset(self::$a_content[$this->_idart])) {
 69:             $this->fillContent();
 70:         }
 71:     }
 72: 
 73:     /**
 74:      * Returns the classname for a content type.
 75:      *
 76:      * @param string $type Content type, e. g. CMS_HTMLHEAD
 77:      * @return string The classname e. g. cContentTypeHtmlhead for content type
 78:      *         CMS_HTMLHEAD
 79:      */
 80:     protected function _getContentTypeClassName($type) {
 81:         $typeClassName = 'cContentType' . ucfirst(strtolower(str_replace('CMS_', '', $type)));
 82:         return $typeClassName;
 83:     }
 84: 
 85:     public static function getContentTypeClassName($type)  {
 86:         $contentType = substr($type, 4);
 87:         return 'cContentType' . strtoupper($contentType[0]) . strtolower(substr($contentType, 1));
 88:     }
 89: 
 90:     /**
 91:      * Returns the full path to the include file name of a content type.
 92:      *
 93:      * @param string $type Content type, e. g. CMS_HTMLHEAD
 94:      * @return string The full path e. g.
 95:      *
 96:      *         {path_to_contenido_includes}/type/code/include.CMS_HTMLHEAD.code.php
 97:      *         for content type CMS_HTMLHEAD
 98:      */
 99:     protected function _getContentTypeCodeFilePathName($type) {
100:         global $cfg;
101:         $typeCodeFile = cRegistry::getBackendPath() . $cfg['path']['includes'] . 'type/code/include.' . $type . '.code.php';
102:         return $typeCodeFile;
103:     }
104: 
105:     /**
106:      * Fill content from db for current article
107:      */
108:     private function fillContent() {
109:         self::$a_content[$this->_idart] = array();
110: 
111:         $sql = "SELECT
112:                     *
113:                 FROM
114:                     " . $this->cfg["tab"]["content"] . " AS A,
115:                     " . $this->cfg["tab"]["art_lang"] . " AS B,
116:                     " . $this->cfg["tab"]["type"] . " AS C
117:                 WHERE
118:                     A.idtype    = C.idtype AND
119:                     A.idartlang = B.idartlang AND
120:                     B.idart     = '" . cSecurity::toInteger($this->_idart) . "' AND
121:                     B.idlang    = '" . cSecurity::toInteger($this->_idlang) . "'";
122: 
123:         self::$db->query($sql);
124: 
125:         while (self::$db->next_record()) {
126:             self::$a_content[$this->_idart][self::$db->f("type")][self::$db->f("typeid")] = self::$db->f("value");
127:         }
128:     }
129: 
130:     /**
131:      *
132:      * @param string $type
133:      * @param int $index
134:      * @return string
135:      */
136:     private function _processCmsTags($type, $index) {
137:         $oTypeColl = new cApiTypeCollection();
138:         $oTypeColl->select();
139: 
140:         $typeList = array();
141:         while (false !== $oType = $oTypeColl->next()) {
142:             $typeList[] = $oType->toObject();
143:         }
144: 
145:         // Replace all CMS_TAGS[]
146:         foreach ($typeList as $typeItem) {
147: 
148:             if ($type === $typeItem->type) {
149: 
150:                 $items[] = $typeItem->type;
151: 
152:                 $typeClassName = $this->_getContentTypeClassName($typeItem->type);
153:                 $typeCodeFile = $this->_getContentTypeCodeFilePathName($typeItem->type);
154: 
155:                 $cTypeObject = new $typeClassName(self::$a_content[$this->_idart][$typeItem->type][$index], $index, $items);
156:                 if (cRegistry::isBackendEditMode()) {
157:                     $tmp = $cTypeObject->generateEditCode();
158:                 } else {
159:                     $tmp = $cTypeObject->generateViewCode();
160:                 }
161: 
162:                 return $tmp;
163:             }
164:         }
165:     }
166: 
167:     /**
168:      * Helper function to call a private function
169:      *
170:      * @param string $type
171:      * @param int $index
172:      *
173:      * @return array
174:      */
175:     public function getGeneratedCmsTag($type, $index) {
176:         return $this->_processCmsTags($type, $index);
177:     }
178: }
179: 
180: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen