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

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