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

Functions

  • addArticlesToTree
  • getArticlesFromCategory
  • getStartIdArtLang
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * @package Module
  6:  * @subpackage ContentSitemapHtml
  7:  * @author marcus.gnass@4fb.de
  8:  * @author alexander.scheider@4fb.de
  9:  * @copyright four for business AG
 10:  * @link http://www.4fb.de
 11:  */
 12: 
 13: // get globals
 14: $client = cRegistry::getClientId();
 15: $lang = cRegistry::getLanguageId();
 16: $idart = cRegistry::getArticleId();
 17: 
 18: // get content of current article
 19: $artLang = new cApiArticleLanguage();
 20: $artLang->loadByArticleAndLanguageId($idart, $lang);
 21: 
 22: $content = $artLang->getContent('CMS_TEXT', 1);
 23: $level = $artLang->getContent('CMS_TEXT', 2);
 24: $article = $artLang->getContent('CMS_TEXT', 3);
 25: 
 26: // get smarty template instance
 27: $tpl = cSmartyFrontend::getInstance();
 28: $tpl->assign('isBackendEditMode', cRegistry::isBackendEditMode());
 29: 
 30: // assign module translations
 31: $tpl->assign('trans', array(
 32:     'headline' => mi18n("HEADLINE"),
 33:     'categoryLabel' => mi18n("CATEGORY_LABEL"),
 34:     'levelLabel' => mi18n("LEVEL_LABEL"),
 35:     'articleLabel' => mi18n("ARTICLE_LABEL"),
 36:     'articleHintLabel' => mi18n("ARTICLE_HINT_LABEL"),
 37:     'categoryHintLabel' => mi18n("GATEGORY_HINT_LABEL"),
 38:     'levelHintLabel' => mi18n("LEVEL_HINT_LABEL")
 39: ));
 40: 
 41: // assign CMS input fields
 42: $tpl->assign('category', "CMS_TEXT[1]");
 43: $tpl->assign('level', "CMS_TEXT[2]");
 44: $tpl->assign('article', "CMS_TEXT[3]");
 45: $tpl->assign('first', false);
 46: 
 47: // check if content is numeric
 48: if (false === is_numeric($content) || false === is_numeric($level)) {
 49:     $tpl->assign('error', mi18n("NOT_NUMERIC_VALUE"));
 50: } else if ($article != 0 && $article != 1) {
 51:     $tpl->assign('error', mi18n("NOT_ZERO_OR_ONE"));
 52: } else {
 53:     // get category tree
 54:     $categoryHelper = cCategoryHelper::getInstance();
 55:     $categoryHelper->setAuth(cRegistry::getAuth());
 56:     $tree = $categoryHelper->getSubCategories($content, $level);
 57:     if (1 == $article) {
 58:         $tree = addArticlesToTree($tree);
 59:     }
 60:     $tpl->assign('tree', $tree);
 61: }
 62: 
 63: $tpl->display('get.tpl');
 64: 
 65: /**
 66:  * Adds articles to categories in given array $tree as returned by
 67:  * cCategoryHelper->getSubCategories().
 68:  *
 69:  * @param array $tree
 70:  * @return array
 71:  */
 72: function addArticlesToTree(array $tree) {
 73: 
 74:     $startidartlang = getStartIdArtLang();
 75: 
 76:     foreach ($tree as $key => $wrapper) {
 77:         $tree[$key]['articles'] = getArticlesFromCategory($wrapper['idcat'], $startidartlang);
 78:         $tree[$key]['subcats'] = addArticlesToTree($tree[$key]['subcats']);
 79:     }
 80: 
 81:     return $tree;
 82: 
 83: }
 84: 
 85: /**
 86:  * Read the IDs of all article languages that are used as start article
 87:  * of their respective category.
 88:  *
 89:  * @return array
 90:  *         of article language IDs
 91:  */
 92: function getStartIdArtLang() {
 93: 
 94:     $cfg = cRegistry::getConfig();
 95:     $db = cRegistry::getDb();
 96: 
 97:     // get all startidartlangs
 98: 
 99:     $ret = $db->query('-- getStartIdArtLang()
100:         SELECT
101:             startidartlang
102:         FROM
103:             `' . $cfg['tab']['cat_lang'] . '`
104:         WHERE
105:             visible = 1
106:             AND public = 1
107:         ;');
108: 
109:     $result = array();
110:     while ($db->nextRecord()) {
111:         $result[] = $db->f('startidartlang');
112:     }
113: 
114:     return $result;
115: 
116: }
117: 
118: /**
119:  * Read article languages of given category and the current language.
120:  * Only online articles that are searchable are considered.
121:  * Optionally an array of article language IDs to exclude can be given.
122:  * If no article languages were found an empty array will be returned.
123:  *
124:  * @param int $idcat
125:  *         ID of category to search in
126:  * @param array $excludedIdartlangs [optional]
127:  *         ID of article languages to exclude
128:  * @return array
129:  *         of article languages
130:  */
131: function getArticlesFromCategory($idcat, array $excludedIdartlangs = array()) {
132: 
133:     $cfg = cRegistry::getConfig();
134:     $db = cRegistry::getDb();
135:     $idlang = cRegistry::getLanguageId();
136: 
137:     $ret = $db->query('-- getArticlesFromCategory()
138:         SELECT
139:             art_lang.idartlang
140:         FROM
141:             `' . $cfg['tab']['art_lang'] . '` AS art_lang
142:             , `' . $cfg['tab']['cat_art'] . '` AS ca
143:         WHERE
144:             art_lang.idart = cat_art.idart
145:             AND art_lang.idlang = ' . cSecurity::toInteger($idlang) . '
146:             AND art_lang.online = 1
147:             AND art_lang.searchable = 1
148:             AND cat_art.idcat = ' . cSecurity::toInteger($idcat) . '
149:         ;');
150: 
151:     if (false === $ret) {
152:         return array();
153:     }
154: 
155:     $result = array();
156:     while ($db->nextRecord()) {
157: 
158:         // skip article languages to exclude
159:         if (in_array($db->f('idartlang'), $excludedIdartlangs)) {
160:             continue;
161:         }
162: 
163:         // add article languages to result
164:         $result[] = new cApiArticleLanguage($db->f('idartlang'));
165: 
166:     }
167: 
168:     return $result;
169: 
170: }
171: 
172: ?>
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0