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

Functions

  • addArticlesToTree
  • getArticlesFromCategory
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * @package Module
  6:  * @subpackage ContentSitemapHtml
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @version SVN Revision $Rev:$
 10:  * @author marcus.gnass@4fb.de
 11:  * @author alexander.scheider@4fb.de
 12:  * @copyright four for business AG
 13:  * @link http://www.4fb.de
 14:  */
 15: 
 16: // get globals
 17: $client = cRegistry::getClientId();
 18: $lang = cRegistry::getLanguageId();
 19: $idart = cRegistry::getArticleId();
 20: 
 21: // get content of current article
 22: $art = new cApiArticleLanguage();
 23: $art->loadByArticleAndLanguageId($idart, $lang);
 24: $content = $art->getContent('CMS_TEXT', 1);
 25: $level = $art->getContent('CMS_TEXT', 2);
 26: $article = $art->getContent('CMS_TEXT', 3);
 27: 
 28: // get smarty template instance
 29: $tpl = cSmartyFrontend::getInstance();
 30: $tpl->assign('isBackendEditMode', cRegistry::isBackendEditMode());
 31: 
 32: // assign module translations
 33: $tpl->assign('trans', array(
 34:     'headline' => mi18n("HEADLINE"),
 35:     'categoryLabel' => mi18n("CATEGORY_LABEL"),
 36:     'levelLabel' => mi18n("LEVEL_LABEL"),
 37:     'articleLabel' => mi18n("ARTICLE_LABEL"),
 38:     'articleHintLabel' => mi18n("ARTICLE_HINT_LABEL"),
 39:     'categoryHintLabel' => mi18n("GATEGORY_HINT_LABEL"),
 40:     'levelHintLabel' => mi18n("LEVEL_HINT_LABEL")
 41: ));
 42: 
 43: // assign CMS input fields
 44: $tpl->assign('category', "CMS_TEXT[1]");
 45: $tpl->assign('level', "CMS_TEXT[2]");
 46: $tpl->assign('article', "CMS_TEXT[3]");
 47: $tpl->assign('first', false);
 48: 
 49: // check if content is numeric
 50: if (false === is_numeric($content) || false === is_numeric($level)) {
 51:     $tpl->assign('error', mi18n("NOT_NUMERIC_VALUE"));
 52: } else if ($article != 0 && $article != 1) {
 53:     $tpl->assign('error', mi18n("NOT_ZERO_OR_ONE"));
 54: } else {
 55:     // get category tree
 56:     $categoryHelper = cCategoryHelper::getInstance();
 57:     $categoryHelper->setAuth(cRegistry::getAuth());
 58:     $tree = $categoryHelper->getSubCategories($content, $level);
 59:     if (1 == $article) {
 60:         $tree = addArticlesToTree($tree);
 61:     }
 62:     $tpl->assign('tree', $tree);
 63: }
 64: 
 65: $tpl->display('get.tpl');
 66: 
 67: /**
 68:  * Adds articles to categories in given array $tree as returned by
 69:  * cCategoryHelper->getSubCategories().
 70:  *
 71:  * @param array $tree
 72:  * @return array
 73:  */
 74: function addArticlesToTree(array $tree) {
 75: 
 76:     foreach ($tree as $key => $wrapper) {
 77:         $tree[$key]['articles'] = getArticlesFromCategory($wrapper['idcat']);
 78:         $tree[$key]['subcats'] = addArticlesToTree($tree[$key]['subcats']);
 79:     }
 80: 
 81:     return $tree;
 82: 
 83: }
 84: 
 85: /**
 86:  * Add all online and searchable articles of theses categories to the sitemap.
 87:  *
 88:  * @param int $categoryId
 89:  */
 90: function getArticlesFromCategory($categoryId) {
 91: 
 92:     $cfg = cRegistry::getConfig();
 93:     $db = cRegistry::getDb();
 94: 
 95:     // get articles from DB
 96:     // needed fields: idart, lastmodified, sitemapprio, changefreq
 97:     $sql = '-- getArticlesFromCategory()
 98:         SELECT
 99:             al.idart
100:             , UNIX_TIMESTAMP(al.lastmodified) AS lastmod
101:             , al.changefreq
102:             , al.sitemapprio
103:             , al.title
104:         FROM
105:             `' . $cfg['tab']['art_lang'] . '` AS al
106:             , `' . $cfg['tab']['cat_art'] . '` AS ca
107:         WHERE
108:             al.idart = ca.idart
109:             AND al.idlang = ' . cSecurity::toInteger(cRegistry::getLanguageId()) . '
110:             AND ca.idcat IN (' . $categoryId . ')
111:             AND al.online = 1
112:             AND al.searchable = 1
113:         ;';
114: 
115:     $ret = $db->query($sql);
116: 
117:     $array = array();
118:     if (false !== $ret) {
119:         while ($db->next_record()) {
120:             $article = new cApiArticleLanguage();
121:             $article->loadByPrimaryKey($db->f('idart'));
122:             $array[] = $article;
123:         }
124:     }
125: 
126:     return $array;
127: 
128: }
129: 
130: ?>
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0