Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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
  • cContentTypeTeaser
  • cContentTypeText
  • cTypeGenerator
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  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:     /**
 86:      * Returns the full path to the include file name of a content type.
 87:      *
 88:      * @param string $type Content type, e. g. CMS_HTMLHEAD
 89:      * @return string The full path e. g.
 90:      *
 91:      *         {path_to_contenido_includes}/type/code/include.CMS_HTMLHEAD.code.php
 92:      *         for content type CMS_HTMLHEAD
 93:      */
 94:     protected function _getContentTypeCodeFilePathName($type) {
 95:         global $cfg;
 96:         $typeCodeFile = cRegistry::getBackendPath() . $cfg['path']['includes'] . 'type/code/include.' . $type . '.code.php';
 97:         return $typeCodeFile;
 98:     }
 99: 
100:     /**
101:      * Fill content from db for current article
102:      */
103:     private function fillContent() {
104:         self::$a_content[$this->_idart] = array();
105: 
106:         $sql = "SELECT
107:                     *
108:                 FROM
109:                     " . $this->cfg["tab"]["content"] . " AS A,
110:                     " . $this->cfg["tab"]["art_lang"] . " AS B,
111:                     " . $this->cfg["tab"]["type"] . " AS C
112:                 WHERE
113:                     A.idtype    = C.idtype AND
114:                     A.idartlang = B.idartlang AND
115:                     B.idart     = '" . cSecurity::toInteger($this->_idart) . "' AND
116:                     B.idlang    = '" . cSecurity::toInteger($this->_idlang) . "'";
117: 
118:         self::$db->query($sql);
119: 
120:         while (self::$db->next_record()) {
121:             self::$a_content[$this->_idart][self::$db->f("type")][self::$db->f("typeid")] = self::$db->f("value");
122:         }
123:     }
124: 
125:     /**
126:      *
127:      * @param string $type
128:      * @param int $index
129:      * @return string
130:      */
131:     private function _processCmsTags($type, $index) {
132:         $oTypeColl = new cApiTypeCollection();
133:         $oTypeColl->select();
134: 
135:         $typeList = array();
136:         while (false !== $oType = $oTypeColl->next()) {
137:             $typeList[] = $oType->toObject();
138:         }
139: 
140:         // Replace all CMS_TAGS[]
141:         foreach ($typeList as $typeItem) {
142: 
143:             if ($type === $typeItem->type) {
144: 
145:                 $items[] = $typeItem->type;
146: 
147:                 $typeClassName = $this->_getContentTypeClassName($typeItem->type);
148:                 $typeCodeFile = $this->_getContentTypeCodeFilePathName($typeItem->type);
149: 
150:                 $cTypeObject = new $typeClassName(self::$a_content[$this->_idart][$typeItem->type][$index], $index, $items);
151:                 if (cRegistry::isBackendEditMode()) {
152:                     $tmp = $cTypeObject->generateEditCode();
153:                 } else {
154:                     $tmp = $cTypeObject->generateViewCode();
155:                 }
156: 
157:                 return $tmp;
158:             }
159:         }
160:     }
161: 
162:     /**
163:      * Helper function to call a private function
164:      *
165:      * @param string $type
166:      * @param int $index
167:      *
168:      * @return array
169:      */
170:     public function getGeneratedCmsTag($type, $index) {
171:         return $this->_processCmsTags($type, $index);
172:     }
173: }
174: 
175: ?>
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0