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