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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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:      *
 66:      * @param int $baseCategoryId
 67:      *         root category ID
 68:      * @param int $depth
 69:      *         maximum depth
 70:      * @param int $currentCategoryId
 71:      *         the current category ID
 72:      *
 73:      * @return array
 74:      *         category tree
 75:      * 
 76:      * @throws cDbException
 77:      * @throws cException
 78:      * @throws cInvalidArgumentException
 79:      * @throws cUnexpectedValueException if given category ID is not greater than 0
 80:      */
 81:     protected function _fetchCategoryTree($baseCategoryId, $depth, $currentCategoryId) {
 82:         cDeprecated("The cFrontendHelper _fetchCategoryTree method are no longer supported.");
 83: 
 84:         if ((int) $baseCategoryId == 0) {
 85:             throw new cUnexpectedValueException("Expect category ID greater than 0.");
 86:         }
 87: 
 88:         $categoryHelper = cCategoryHelper::getInstance();
 89:         $categoryHelper->setAuth(cRegistry::getAuth());
 90: 
 91:         $categoryTree = $categoryHelper->getSubCategories($baseCategoryId, $depth);
 92: 
 93:         $tree = array();
 94: 
 95:         $parentCategories = $categoryHelper->getParentCategoryIds($currentCategoryId);
 96: 
 97:         foreach ($categoryTree as $treeData) {
 98:             $catId = $treeData['idcat'];
 99: 
100:             $firstChildId = $lastChildId = 0;
101:             if (count($treeData['subcats']) > 0) {
102:                 $lastIndex = count($treeData['subcats']) - 1;
103: 
104:                 $firstChildId = $treeData['subcats'][0]['idcat'];
105:                 $lastChildId = $treeData['subcats'][$lastIndex]['idcat'];
106:             }
107: 
108:             $markActive = ($currentCategoryId == $catId);
109:             if ($markActive == false && in_array($catId, $parentCategories)) {
110:                 $markActive = true;
111:             }
112: 
113:             $treeItem['first_child_id'] = $firstChildId;
114:             $treeItem['last_child_id'] = $lastChildId;
115:             $treeItem['tree_data'] = $treeData;
116:             $treeItem['active'] = $markActive;
117:             $tree[] = $treeItem;
118:         }
119: 
120:         return $tree;
121:     }
122: 
123:     /**
124:      * Helper function to render the navigation.
125:      *
126:      * @deprecated [2015-05-21]
127:      *         This method is no longer supported (no replacement)
128:      *
129:      * @param int $baseCategoryId
130:      *         root category ID
131:      * @param int $depth
132:      *         maximum depth
133:      * @param int $currentCategoryId
134:      *         the current category ID
135:      *
136:      * @return array
137:      *         category tree
138:      * 
139:      * @throws cDbException
140:      * @throws cException
141:      * @throws cInvalidArgumentException
142:      * @throws cUnexpectedValueException
143:      */
144:     public function renderNavigation($baseCategoryId, $depth, $currentCategoryId) {
145:         cDeprecated("The cFrontendHelper renderNavigation method are no longer supported.");
146: 
147:         $tree = $this->_fetchCategoryTree($baseCategoryId, $depth, $currentCategoryId);
148: 
149:         return $tree;
150:     }
151: 
152:     /**
153:      * Helper function to render the sitemap.
154:      *
155:      * @deprecated [2015-05-21]
156:      *         This method is no longer supported (no replacement)
157:      *
158:      * @param int       $baseCategoryId
159:      *         root category ID
160:      * @param int       $depth
161:      *         maximum depth
162:      * @param cTemplate $tpl
163:      *         template reference
164:      *
165:      * @throws cDbException
166:      * @throws cException
167:      * @throws cInvalidArgumentException
168:      * @throws cUnexpectedValueException
169:      */
170:     public function renderSitemap($baseCategoryId, $depth, cTemplate &$tpl) {
171:         cDeprecated("The cFrontendHelper renderSitemap method are no longer supported.");
172: 
173:         $tree = $this->_fetchCategoryTree($baseCategoryId, $depth, 0);
174: 
175:         foreach ($tree as $treeItem) {
176:             $treeData = $treeItem['tree_data'];
177:             $catId = $treeData['idcat'];
178: 
179:             $firstChildId = $treeItem['first_child_id'];
180: 
181:             $tpl->set('d', 'name', $treeData['item']->getField('name'));
182:             $tpl->set('d', 'css_level', $treeData['level']);
183:             $tpl->set('d', 'url', $treeData['item']->getLink());
184:             $tpl->next();
185: 
186:             if ($firstChildId != 0) {
187:                 $this->renderSitemap($catId, $depth, $tpl);
188:             }
189:         }
190:     }
191: }
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0