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

  • cCategoryHelper
  • cFrontendHelper
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the frontend helper class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Frontend_Util
  7:  * @author Dominik Ziegler
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * This class contains functions for the frontend helper class in CONTENIDO.
 18:  *
 19:  * @package Core
 20:  * @subpackage Frontend_Util
 21:  * @deprecated [2015-05-21]
 22:  *         This class is no longer supported
 23:  */
 24: class cFrontendHelper {
 25: 
 26:     /**
 27:      * Instance of the helper class.
 28:      *
 29:      * @var cFrontendHelper
 30:      */
 31:     private static $_instance = NULL;
 32: 
 33:     /**
 34:      * Returns the instance of this class.
 35:      *
 36:      * @deprecated [2015-05-21]
 37:      *         This method is no longer supported (no replacement)
 38:      * @return cFrontendHelper
 39:      */
 40:     public static function getInstance() {
 41:         cDeprecated("The cFrontendHelper getInstance method are no longer supported.");
 42: 
 43:         if (self::$_instance === NULL) {
 44:             self::$_instance = new self();
 45:         }
 46: 
 47:         return self::$_instance;
 48:     }
 49: 
 50:     /**
 51:      * Constructor to create an instance of this class.
 52:      *
 53:      * @deprecated [2015-05-21]
 54:      *         This method is no longer supported (no replacement)
 55:      */
 56:     protected function __construct() {
 57:         cDeprecated("The cFrontendHelper classes are no longer supported.");
 58:     }
 59: 
 60:     /**
 61:      * Fetches the requested category tree.
 62:      *
 63:      * @deprecated [2015-05-21]
 64:      *         This method is no longer supported (no replacement)
 65:      * @param int $baseCategoryId
 66:      *         root category ID
 67:      * @param int $depth
 68:      *         maximum depth
 69:      * @param int $currentCategoryId
 70:      *         the current category ID
 71:      * @throws cUnexpectedValueException
 72:      *         if given category ID is not greater than 0
 73:      * @return array
 74:      *         category tree
 75:      */
 76:     protected function _fetchCategoryTree($baseCategoryId, $depth, $currentCategoryId) {
 77:         cDeprecated("The cFrontendHelper _fetchCategoryTree method are no longer supported.");
 78: 
 79:         if ((int) $baseCategoryId == 0) {
 80:             throw new cUnexpectedValueException("Expect category ID greater than 0.");
 81:         }
 82: 
 83:         $categoryHelper = cCategoryHelper::getInstance();
 84:         $categoryHelper->setAuth(cRegistry::getAuth());
 85: 
 86:         $categoryTree = $categoryHelper->getSubCategories($baseCategoryId, $depth);
 87: 
 88:         $tree = array();
 89: 
 90:         $parentCategories = $categoryHelper->getParentCategoryIds($currentCategoryId);
 91: 
 92:         foreach ($categoryTree as $treeData) {
 93:             $catId = $treeData['idcat'];
 94: 
 95:             $firstChildId = $lastChildId = 0;
 96:             if (count($treeData['subcats']) > 0) {
 97:                 $lastIndex = count($treeData['subcats']) - 1;
 98: 
 99:                 $firstChildId = $treeData['subcats'][0]['idcat'];
100:                 $lastChildId = $treeData['subcats'][$lastIndex]['idcat'];
101:             }
102: 
103:             $markActive = ($currentCategoryId == $catId);
104:             if ($markActive == false && in_array($catId, $parentCategories)) {
105:                 $markActive = true;
106:             }
107: 
108:             $treeItem['first_child_id'] = $firstChildId;
109:             $treeItem['last_child_id'] = $lastChildId;
110:             $treeItem['tree_data'] = $treeData;
111:             $treeItem['active'] = $markActive;
112:             $tree[] = $treeItem;
113:         }
114: 
115:         return $tree;
116:     }
117: 
118:     /**
119:      * Helper function to render the navigation.
120:      *
121:      * @deprecated [2015-05-21]
122:      *         This method is no longer supported (no replacement)
123:      * @param int $baseCategoryId
124:      *         root category ID
125:      * @param int $depth
126:      *         maximum depth
127:      * @param int $currentCategoryId
128:      *         the current category ID
129:      * @return array
130:      *         category tree
131:      */
132:     public function renderNavigation($baseCategoryId, $depth, $currentCategoryId) {
133:         cDeprecated("The cFrontendHelper renderNavigation method are no longer supported.");
134: 
135:         $tree = $this->_fetchCategoryTree($baseCategoryId, $depth, $currentCategoryId);
136: 
137:         return $tree;
138:     }
139: 
140:     /**
141:      * Helper function to render the sitemap.
142:      *
143:      * @deprecated [2015-05-21]
144:      *         This method is no longer supported (no replacement)
145:      * @param int $baseCategoryId
146:      *         root category ID
147:      * @param int $depth
148:      *         maximum depth
149:      * @param cTemplate $tpl
150:      *         template reference
151:      */
152:     public function renderSitemap($baseCategoryId, $depth, cTemplate &$tpl) {
153:         cDeprecated("The cFrontendHelper renderSitemap method are no longer supported.");
154: 
155:         $tree = $this->_fetchCategoryTree($baseCategoryId, $depth, 0);
156: 
157:         foreach ($tree as $treeItem) {
158:             $treeData = $treeItem['tree_data'];
159:             $catId = $treeData['idcat'];
160: 
161:             $firstChildId = $treeItem['first_child_id'];
162: 
163:             $tpl->set('d', 'name', $treeData['item']->getField('name'));
164:             $tpl->set('d', 'css_level', $treeData['level']);
165:             $tpl->set('d', 'url', $treeData['item']->getLink());
166:             $tpl->next();
167: 
168:             if ($firstChildId != 0) {
169:                 $this->renderSitemap($catId, $depth, $tpl);
170:             }
171:         }
172:     }
173: }
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0