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