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

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _processCmsTags
  • addArtspec
  • addslashes_deep
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • endsWith
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAktuellType
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • modTestModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setHelpContext
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • stripslashes_deep
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • xmlFileToArray
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: /**
   3:  * Defines the general CONTENIDO functions
   4:  *
   5:  * @package Core
   6:  * @subpackage Backend
   7:  * @version SVN Revision $Rev:$
   8:  *
   9:  * @author Jan Lengowski
  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: cInclude('includes', 'functions.file.php');
  19: 
  20: /**
  21:  * Extracts the available content-types from the database
  22:  *
  23:  * Creates an array $a_content[type][number] = content string
  24:  * f.e. $a_content['CMS_HTML'][1] = content string
  25:  * Same for array $a_description
  26:  *
  27:  * @param int $idartlang Language specific ID of the arcticle
  28:  */
  29: function getAvailableContentTypes($idartlang) {
  30:     global $db, $cfg, $a_content, $a_description;
  31: 
  32:     $sql = "SELECT
  33:                 *
  34:             FROM
  35:                 " . $cfg["tab"]["content"] . " AS a,
  36:                 " . $cfg["tab"]["art_lang"] . " AS b,
  37:                 " . $cfg["tab"]["type"] . " AS c
  38:             WHERE
  39:                 a.idtype    = c.idtype AND
  40:                 a.idartlang = b.idartlang AND
  41:                 b.idartlang = " . (int) $idartlang;
  42: 
  43:     $db->query($sql);
  44: 
  45:     while ($db->nextRecord()) {
  46:         $a_content[$db->f('type')][$db->f('typeid')] = $db->f('value');
  47:         $a_description[$db->f('type')][$db->f('typeid')] = i18n($db->f('description'));
  48:     }
  49: }
  50: 
  51: /**
  52:  * Checks if an article is assigned to multiple categories
  53:  *
  54:  * @param int $idart Article-Id
  55:  * @return bool Article assigned to multiple categories
  56:  */
  57: function isArtInMultipleUse($idart) {
  58:     global $cfg;
  59: 
  60:     $db = cRegistry::getDb();
  61:     $sql = "SELECT idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = " . (int) $idart;
  62:     $db->query($sql);
  63: 
  64:     return ($db->affectedRows() > 1);
  65: }
  66: 
  67: /**
  68:  * Checks if a value is alphanumeric
  69:  *
  70:  * @param mixed $test Value to test
  71:  * @param bool $umlauts [Use german Umlaute] Optional
  72:  * @return bool Value is alphanumeric
  73:  */
  74: function isAlphanumeric($test, $umlauts = true) {
  75:     if ($umlauts == true) {
  76:         $match = "/^[a-z0-9ÄäÖöÜüß ]+$/i";
  77:     } else {
  78:         $match = "/^[a-z0-9 ]+$/i";
  79:     }
  80: 
  81:     return (preg_match($match, $test));
  82: }
  83: 
  84: /**
  85:  * Returns whether a string is UTF-8 encoded or not
  86:  *
  87:  * @param string $input
  88:  * @return bool
  89:  */
  90: function isUtf8($input) {
  91:     $len = strlen($input);
  92: 
  93:     for ($i = 0; $i < $len; $i++) {
  94:         $char = ord($input[$i]);
  95:         $n = 0;
  96: 
  97:         if ($char < 0x80) { // ASCII char
  98:             continue;
  99:         } else if (($char & 0xE0) === 0xC0 && $char > 0xC1) { // 2 byte long
 100:             // char
 101:             $n = 1;
 102:         } else if (($char & 0xF0) === 0xE0) { // 3 byte long char
 103:             $n = 2;
 104:         } else if (($char & 0xF8) === 0xF0 && $char < 0xF5) { // 4 byte long
 105:             // char
 106:             $n = 3;
 107:         } else {
 108:             return false;
 109:         }
 110: 
 111:         for ($j = 0; $j < $n; $j++) {
 112:             $i++;
 113: 
 114:             if ($i == $len || (ord($input[$i]) & 0xC0) !== 0x80) {
 115:                 return false;
 116:             }
 117:         }
 118:     }
 119:     return true;
 120: }
 121: 
 122: /**
 123:  * Returns multi-language month name (canonical) by its numeric value
 124:  *
 125:  * @param int $month
 126:  * @return string
 127:  */
 128: function getCanonicalMonth($month) {
 129:     switch ($month) {
 130:         case 1:
 131:             return (i18n("January"));
 132:             break;
 133:         case 2:
 134:             return (i18n("February"));
 135:             break;
 136:         case 3:
 137:             return (i18n("March"));
 138:             break;
 139:         case 4:
 140:             return (i18n("April"));
 141:             break;
 142:         case 5:
 143:             return (i18n("May"));
 144:             break;
 145:         case 6:
 146:             return (i18n("June"));
 147:             break;
 148:         case 7:
 149:             return (i18n("July"));
 150:             break;
 151:         case 8:
 152:             return (i18n("August"));
 153:             break;
 154:         case 9:
 155:             return (i18n("September"));
 156:             break;
 157:         case 10:
 158:             return (i18n("October"));
 159:             break;
 160:         case 11:
 161:             return (i18n("November"));
 162:             break;
 163:         case 12:
 164:             return (i18n("December"));
 165:             break;
 166:     }
 167: }
 168: 
 169: /**
 170:  * Get multi-language day
 171:  *
 172:  * @param int $iDay The day number of date(w)
 173:  * @return string Dayname of current language
 174:  */
 175: function getCanonicalDay($iDay) {
 176:     switch ($iDay) {
 177:         case 1:
 178:             return (i18n("Monday"));
 179:             break;
 180:         case 2:
 181:             return (i18n("Tuesday"));
 182:             break;
 183:         case 3:
 184:             return (i18n("Wednesday"));
 185:             break;
 186:         case 4:
 187:             return (i18n("Thursday"));
 188:             break;
 189:         case 5:
 190:             return (i18n("Friday"));
 191:             break;
 192:         case 6:
 193:             return (i18n("Saturday"));
 194:             break;
 195:         case 0:
 196:             return (i18n("Sunday"));
 197:             break;
 198:         default:
 199:             break;
 200:     }
 201: }
 202: 
 203: /**
 204:  * Returns a formatted date and/or timestring according to the current settings
 205:  *
 206:  * @param mixed $timestamp a timestamp. If no value is given the current time
 207:  *        will be used.
 208:  * @param bool $date if true the date will be included in the string
 209:  * @param bool $time if true the time will be included in the string
 210:  * @return string the formatted time string.
 211:  */
 212: function displayDatetime($timestamp = "", $date = false, $time = false) {
 213:     if ($timestamp == "") {
 214:         $timestamp = time();
 215:     } else {
 216:         $timestamp = strtotime($timestamp);
 217:     }
 218: 
 219:     $ret = "";
 220: 
 221:     if ($date && !$time) {
 222:         $ret = date(getEffectiveSetting("dateformat", "date", "Y-m-d"), $timestamp);
 223:     } else if ($time && !$date) {
 224:         $ret = date(getEffectiveSetting("dateformat", "time", "H:i:s"), $timestamp);
 225:     } else {
 226:         $ret = date(getEffectiveSetting("dateformat", "full", "Y-m-d H:i:s"), $timestamp);
 227:     }
 228:     return $ret;
 229: }
 230: 
 231: /**
 232:  * Returns the id of passed area
 233:  *
 234:  * @param int|string $area Area name or id
 235:  * @return int string
 236:  */
 237: function getIDForArea($area) {
 238:     if (!is_numeric($area)) {
 239:         $oArea = new cApiArea();
 240:         if ($oArea->loadBy('name', $area)) {
 241:             $area = $oArea->get('idarea');
 242:         }
 243:     }
 244: 
 245:     return $area;
 246: }
 247: 
 248: /**
 249:  * Returns the parent id of passed area
 250:  *
 251:  * @param mixed $area
 252:  * @return int
 253:  */
 254: function getParentAreaId($area) {
 255:     $oAreaColl = new cApiAreaCollection();
 256:     return $oAreaColl->getParentAreaID($area);
 257: }
 258: 
 259: /**
 260:  * Write JavaScript to mark
 261:  *
 262:  * @param int $menuitem Which menuitem to mark
 263:  * @param bool $return Return or echo script
 264:  */
 265: function markSubMenuItem($menuitem, $return = false) {
 266:     $str = '
 267:     <script type="text/javascript">
 268:     // @todo  Use conMarkSubmenuItem(id) in general.js, but we have to ensure to load the file!
 269:     (function(id) {
 270:         var menuItem;
 271: 
 272:         try {
 273:             // Check if we are in a dual-frame or a quad-frame
 274:             if (parent.parent.frames[0].name == "header") {
 275:                 if (parent.frames["right_top"].document.getElementById(id)) {
 276:                     menuItem = parent.frames["right_top"].document.getElementById(id).getElementsByTagName("a")[0];
 277:                     parent.frames["right_top"].sub.clicked(menuItem);
 278:                 }
 279:             } else {
 280:                 // Check if submenuItem is existing and mark it
 281:                 if (parent.parent.frames["right"].frames["right_top"].document.getElementById(id)) {
 282:                     menuItem = parent.parent.frames["right"].frames["right_top"].document.getElementById(id).getElementsByTagName("a")[0];
 283:                     parent.parent.frames["right"].frames["right_top"].sub.clicked(menuItem);
 284:                 }
 285:             }
 286:         } catch (e) {}
 287:     })("c_' . $menuitem . '");
 288:     </script>';
 289: 
 290:     if ($return) {
 291:         return $str;
 292:     } else {
 293:         echo $str;
 294:     }
 295: }
 296: 
 297: /**
 298:  * Redirect to main area
 299:  *
 300:  * @param bool $send Redirect Yes/No
 301:  */
 302: function backToMainArea($send) {
 303:     if ($send) {
 304:         // Global vars
 305:         global $area, $sess, $idart, $idcat, $idartlang, $idcatart, $frame;
 306: 
 307:         // Get main area
 308:         $oAreaColl = new cApiAreaCollection();
 309:         $parent = $oAreaColl->getParentAreaID($area);
 310: 
 311:         // Create url string
 312:         $url_str = 'main.php?' . 'area=' . $parent . '&' . 'idcat=' . $idcat . '&' . 'idart=' . $idart . '&' . 'idartlang=' . $idartlang . '&' . 'idcatart=' . $idcatart . '&' . 'force=1&' . 'frame=' . $frame;
 313:         $url = $sess->url($url_str);
 314: 
 315:         // Redirect
 316:         header("location: $url");
 317:     }
 318: }
 319: 
 320: /**
 321:  * Returns list of languages (language ids) by passed client.
 322:  *
 323:  * @param int $client
 324:  * @return array
 325:  */
 326: function getLanguagesByClient($client) {
 327:     $oClientLangColl = new cApiClientLanguageCollection();
 328:     return $oClientLangColl->getLanguagesByClient($client);
 329: }
 330: 
 331: /**
 332:  * Returns all languages (language ids and names) of an client
 333:  *
 334:  * @param int $client
 335:  * @return array List of languages where the key is the language id and value
 336:  *         the language name
 337:  */
 338: function getLanguageNamesByClient($client) {
 339:     $oClientLangColl = new cApiClientLanguageCollection();
 340:     return $oClientLangColl->getLanguageNamesByClient($client);
 341: }
 342: 
 343: /**
 344:  * Adds slashes to passed string if PHP setting for magic quotes is disabled
 345:  *
 346:  * @param string $code String by reference
 347:  */
 348: function set_magic_quotes_gpc(&$code) {
 349:     global $cfg;
 350:     if (!$cfg['simulate_magic_quotes']) {
 351:         if (get_magic_quotes_gpc() == 0) {
 352:             $code = addslashes($code);
 353:         }
 354:     }
 355: }
 356: 
 357: /**
 358:  * Returns a list with all clients and languages.
 359:  *
 360:  * @return array Indexed array where the value is an assoziative array as
 361:  *         follows:
 362:  *         <pre>
 363:  *         - $arr[0]['idlang']
 364:  *         - $arr[0]['langname']
 365:  *         - $arr[0]['idclient']
 366:  *         - $arr[0]['clientname']
 367:  *         </pre>
 368:  */
 369: function getAllClientsAndLanguages() {
 370:     global $db, $cfg;
 371: 
 372:     $sql = "SELECT
 373:                 a.idlang as idlang,
 374:                 a.name as langname,
 375:                 b.name as clientname,
 376:                 b.idclient as idclient
 377:              FROM
 378:                 " . $cfg["tab"]["lang"] . " as a,
 379:                 " . $cfg["tab"]["clients_lang"] . " as c,
 380:                 " . $cfg["tab"]["clients"] . " as b
 381:              WHERE
 382:                 a.idlang = c.idlang AND
 383:                 c.idclient = b.idclient";
 384:     $db->query($sql);
 385: 
 386:     $aRs = array();
 387:     while ($db->nextRecord()) {
 388:         $aRs[] = array(
 389:             'idlang' => $db->f('idlang'),
 390:             'langname' => $db->f('langname'),
 391:             'idclient' => $db->f('idclient'),
 392:             'clientname' => $db->f('clientname')
 393:         );
 394:     }
 395:     return $aRs;
 396: }
 397: 
 398: function getmicrotime() {
 399:     list($usec, $sec) = explode(' ', microtime());
 400:     return ((float) $usec + (float) $sec);
 401: }
 402: 
 403: function isGroup($uid) {
 404:     $user = new cApiUser();
 405:     if ($user->loadByPrimaryKey($uid) === false) {
 406:         return true;
 407:     } else {
 408:         return false;
 409:     }
 410: }
 411: 
 412: function getGroupOrUserName($uid) {
 413:     $user = new cApiUser();
 414:     if ($user->loadByPrimaryKey($uid) === false) {
 415:         $group = new cApiGroup();
 416:         // Yes, it's a group. Let's try to load the group members!
 417:         if ($group->loadByPrimaryKey($uid) === false) {
 418:             return false;
 419:         } else {
 420:             return $group->getGroupName(true);
 421:         }
 422:     } else {
 423:         return $user->getField('realname');
 424:     }
 425: }
 426: 
 427: /**
 428:  * Checks if passed email address is valid or not
 429:  *
 430:  * @param string $email
 431:  * @param bool $strict No more used!
 432:  */
 433: function isValidMail($email, $strict = false) {
 434:     $validator = cValidatorFactory::getInstance('email');
 435:     return $validator->isValid($email);
 436: }
 437: 
 438: function htmldecode($string) {
 439:     $trans_tbl = conGetHtmlTranslationTable(HTML_ENTITIES);
 440:     $trans_tbl = array_flip($trans_tbl);
 441:     $ret = strtr($string, $trans_tbl);
 442:     return $ret;
 443: }
 444: 
 445: /**
 446:  * Loads the client information from the database and stores it in
 447:  * config.client.php.
 448:  * Reinitializes the $cfgClient array and fills it wih updated information if
 449:  * provided.
 450:  *
 451:  * @param number $idclient client id which will be updated
 452:  * @param string $htmlpath new HTML path. Starting with "http://"
 453:  * @param string $frontendpath path the to the frontend
 454:  */
 455: function updateClientCache($idclient = 0, $htmlpath = '', $frontendpath = '') {
 456:     global $cfg, $cfgClient, $errsite_idcat, $errsite_idart, $db;
 457: 
 458:     if (!is_array($cfgClient)) {
 459:         $cfgClient = array();
 460:     }
 461: 
 462:     if (!is_object($db)) {
 463:         $db = cRegistry::getDb();
 464:     }
 465: 
 466:     if ($idclient != 0 && $htmlpath != '' && $frontendpath != '') {
 467:         $cfgClient[$idclient]['path']['frontend'] = cSecurity::escapeString($frontendpath);
 468:         $cfgClient[$idclient]['path']['htmlpath'] = cSecurity::escapeString($htmlpath);
 469:     }
 470: 
 471:     $sql = 'SELECT idclient, name, errsite_cat, errsite_art FROM ' . $cfg['tab']['clients'];
 472:     $db->query($sql);
 473: 
 474:     $htmlpaths = array();
 475:     $frontendpaths = array();
 476:     foreach ($cfgClient as $id => $aclient) {
 477:         if (is_array($aclient)) {
 478:             $htmlpaths[$id] = $aclient["path"]["htmlpath"];
 479:             $frontendpaths[$id] = $aclient["path"]["frontend"];
 480:         }
 481:     }
 482:     unset($cfgClient);
 483:     $cfgClient = array();
 484: 
 485:     foreach ($htmlpaths as $id => $path) {
 486:         $cfgClient[$id]["path"]["htmlpath"] = $htmlpaths[$id];
 487:         $cfgClient[$id]["path"]["frontend"] = $frontendpaths[$id];
 488:     }
 489: 
 490:     while ($db->nextRecord()) {
 491:         $iClient = $db->f('idclient');
 492:         $cfgClient['set'] = 'set';
 493: 
 494:         $cfgClient[$iClient]['name'] = conHtmlSpecialChars(str_replace(array(
 495:             '*/',
 496:             '/*',
 497:             '//'
 498:                         ), '', $db->f('name')));
 499: 
 500:         $errsite_idcat[$iClient] = $db->f('errsite_cat');
 501:         $errsite_idart[$iClient] = $db->f('errsite_art');
 502:         $cfgClient[$iClient]["errsite"]["idcat"] = $errsite_idcat[$iClient];
 503:         $cfgClient[$iClient]["errsite"]["idart"] = $errsite_idart[$iClient];
 504: 
 505:         $cfgClient[$iClient]['images'] = $cfgClient[$iClient]['path']['htmlpath'] . 'images/';
 506:         $cfgClient[$iClient]['upload'] = 'upload/';
 507: 
 508:         $cfgClient[$iClient]['htmlpath']['frontend'] = $cfgClient[$iClient]['path']['htmlpath'];
 509: 
 510:         $cfgClient[$iClient]['upl']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'upload/';
 511:         $cfgClient[$iClient]['upl']['htmlpath'] = $cfgClient[$iClient]['htmlpath']['frontend'] . 'upload/';
 512:         $cfgClient[$iClient]['upl']['frontendpath'] = 'upload/';
 513: 
 514:         $cfgClient[$iClient]['css']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'css/';
 515: 
 516:         $cfgClient[$iClient]['js']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'js/';
 517: 
 518:         $cfgClient[$iClient]['tpl']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'templates/';
 519: 
 520:         $cfgClient[$iClient]['cache']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'cache/';
 521:         $cfgClient[$iClient]['cache']['frontendpath'] = 'cache/';
 522: 
 523:         $cfgClient[$iClient]['code']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'cache/code/';
 524:         $cfgClient[$iClient]['code']['frontendpath'] = 'cache/code/';
 525: 
 526:         $cfgClient[$iClient]['xml']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'xml/';
 527:         $cfgClient[$iClient]['xml']['frontendpath'] = 'xml/';
 528: 
 529:         $cfgClient[$iClient]['template']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'templates/';
 530:         $cfgClient[$iClient]['template']['frontendpath'] = 'templates/';
 531: 
 532:         $cfgClient[$iClient]['data']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/';
 533: 
 534:         $cfgClient[$iClient]['module']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/modules/';
 535:         $cfgClient[$iClient]['module']['frontendpath'] = 'data/modules/';
 536: 
 537:         $cfgClient[$iClient]['config']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/config/' . CON_ENVIRONMENT . '/';
 538:         $cfgClient[$iClient]['config']['frontendpath'] = 'data/config/';
 539: 
 540:         $cfgClient[$iClient]['layout']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/layouts/';
 541:         $cfgClient[$iClient]['layout']['frontendpath'] = 'data/layouts/';
 542: 
 543:         $cfgClient[$iClient]['log']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/logs/';
 544:         $cfgClient[$iClient]['log']['frontendpath'] = 'data/logs/';
 545: 
 546:         $cfgClient[$iClient]['version']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/version/';
 547:         $cfgClient[$iClient]['version']['frontendpath'] = 'data/version/';
 548:     }
 549: 
 550:     $aConfigFileContent = array();
 551:     $aConfigFileContent[] = '<?php';
 552:     $aConfigFileContent[] = 'global $cfgClient;';
 553:     $aConfigFileContent[] = '';
 554: 
 555:     foreach ($cfgClient as $iIdClient => $aClient) {
 556:         if ((int) $iIdClient > 0 && is_array($aClient)) {
 557: 
 558:             $aConfigFileContent[] = '/* ' . $aClient['name'] . ' */';
 559:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["name"] = "' . $aClient['name'] . '";';
 560:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["errsite"]["idcat"] = "' . $aClient["errsite"]["idcat"] . '";';
 561:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["errsite"]["idart"] = "' . $aClient["errsite"]["idart"] . '";';
 562:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["images"] = "' . $aClient["path"]["htmlpath"] . 'images/";';
 563:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upload"] = "upload/";';
 564: 
 565:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["path"]["frontend"] = "' . $aClient["path"]["frontend"] . '";';
 566: 
 567:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["htmlpath"]["frontend"] = "' . $aClient["path"]["htmlpath"] . '";';
 568: 
 569:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "upload/";';
 570:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["htmlpath"] = "' . $aClient["htmlpath"]["frontend"] . 'upload/";';
 571:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["frontendpath"] = "upload/";';
 572: 
 573:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["css"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "css/";';
 574: 
 575:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["js"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "js/";';
 576: 
 577:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["tpl"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "templates/";';
 578: 
 579:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["cache"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "cache/";';
 580:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["cache"]["frontendpath"] = "cache/";';
 581: 
 582:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["code"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "cache/code/";';
 583:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["code"]["frontendpath"] = "cache/code/";';
 584: 
 585:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["xml"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "xml/";';
 586:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["xml"]["frontendpath"] = "xml/";';
 587: 
 588:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["template"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "templates/";';
 589:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["template"]["frontendpath"] = "templates/";';
 590: 
 591:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["data"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/";';
 592: 
 593:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["module"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/modules/";';
 594:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["module"]["frontendpath"] = "data/modules/";';
 595: 
 596:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["config"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/config/' . CON_ENVIRONMENT . '/";';
 597:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["config"]["frontendpath"] = "data/config/";';
 598: 
 599:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["layout"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/layouts/";';
 600:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["layout"]["frontendpath"] = "data/layouts/";';
 601: 
 602:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["log"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/logs/";';
 603:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["log"]["frontendpath"] = "data/logs/";';
 604: 
 605:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["version"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/version/";';
 606:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["version"]["frontendpath"] = "data/version/";';
 607:             $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["path"]["htmlpath"] = "' . $aClient['path']['htmlpath'] . '";';
 608:             $aConfigFileContent[] = '';
 609:         }
 610:     }
 611:     $aConfigFileContent[] = '$cfgClient["set"] = "set";';
 612:     $aConfigFileContent[] = '?>';
 613: 
 614:     cFileHandler::write($cfg['path']['contenido_config'] . 'config.clients.php', implode(PHP_EOL, $aConfigFileContent));
 615: 
 616:     return $cfgClient;
 617: }
 618: 
 619: /**
 620:  * Sets a system property entry
 621:  *
 622:  * @modified Timo Trautmann 22.02.2008 Support for editing name and type
 623:  *
 624:  * @param string $type The type of the item
 625:  * @param string $name The name of the item
 626:  * @param string $value The value of the item
 627:  * @param int $idsystemprop The sysprop id, use optional. If set it allows to
 628:  *        modify type name and value
 629:  */
 630: function setSystemProperty($type, $name, $value, $idsystemprop = 0) {
 631:     if ($type == '' || $name == '') {
 632:         return false;
 633:     }
 634: 
 635:     $idsystemprop = (int) $idsystemprop;
 636: 
 637:     $systemPropColl = new cApiSystemPropertyCollection();
 638: 
 639:     if ($idsystemprop == 0) {
 640:         $prop = $systemPropColl->setValueByTypeName($type, $name, $value);
 641:     } else {
 642:         $prop = $systemPropColl->setTypeNameValueById($type, $name, $value, $idsystemprop);
 643:     }
 644: }
 645: 
 646: /**
 647:  * Remove a system property entry
 648:  *
 649:  * @param string $type The type of the item
 650:  * @param string $name The name of the item
 651:  * @return bool
 652:  */
 653: function deleteSystemProperty($type, $name) {
 654:     $systemPropColl = new cApiSystemPropertyCollection();
 655:     $systemPropColl->deleteByTypeName($type, $name);
 656: }
 657: 
 658: /**
 659:  * Retrieves all available system properties.
 660:  * Array format:
 661:  *
 662:  * $array[$type][$name] = $value;
 663:  *
 664:  * @modified Timo Trautmann 22.02.2008 Support for editing name and type editing
 665:  * by primaray key idsystemprop
 666:  * if bGetPropId is set:
 667:  * $array[$type][$name][value] = $value;
 668:  * $array[$type][$name][idsystemprop] = $idsystemprop;
 669:  *
 670:  * @param bool $bGetPropId If true special mode is activated which generates for
 671:  *        each property a third array, which also contains idsystemprop value
 672:  * @return array
 673:  */
 674: function getSystemProperties($bGetPropId = false) {
 675:     $return = array();
 676: 
 677:     $systemPropColl = new cApiSystemPropertyCollection();
 678:     $props = $systemPropColl->fetchAll('type ASC, name ASC, value ASC');
 679:     foreach ($props as $prop) {
 680:         $item = $prop->toArray();
 681: 
 682:         if ($bGetPropId) {
 683:             $return[$item['type']][$item['name']]['value'] = $item['value'];
 684:             $return[$item['type']][$item['name']]['idsystemprop'] = $item['idsystemprop'];
 685:         } else {
 686:             $return[$item['type']][$item['name']] = $item['value'];
 687:         }
 688:     }
 689: 
 690:     return $return;
 691: }
 692: 
 693: /**
 694:  * Gets a system property entry
 695:  *
 696:  * @param string $type The type of the item
 697:  * @param string $name The name of the item
 698:  * @return string bool property value or false if nothing was found
 699:  */
 700: function getSystemProperty($type, $name) {
 701:     $systemPropColl = new cApiSystemPropertyCollection();
 702:     $prop = $systemPropColl->fetchByTypeName($type, $name);
 703:     return ($prop) ? $prop->get('value') : false;
 704: }
 705: 
 706: /**
 707:  * Gets system property entries
 708:  *
 709:  * @param string $type The type of the properties
 710:  * @return array Assoziative array like $arr[name] = value
 711:  */
 712: function getSystemPropertiesByType($type) {
 713:     $return = array();
 714: 
 715:     $systemPropColl = new cApiSystemPropertyCollection();
 716:     $props = $systemPropColl->fetchByType($type);
 717:     foreach ($props as $prop) {
 718:         $return[$prop->get('name')] = $prop->get('value');
 719:     }
 720:     if (count($return) > 1) {
 721:         ksort($return);
 722:     }
 723:     return $return;
 724: }
 725: 
 726: /**
 727:  * Returns the current effective setting for a property.
 728:  *
 729:  * The order is:
 730:  * System => Client => Group => User
 731:  *
 732:  * System properties can be overridden by the group, and group
 733:  * properties can be overridden by the user.
 734:  *
 735:  * @param string $type The type of the item
 736:  * @param string $name The name of the item
 737:  * @param string $default Optional default value
 738:  * @return mixed boolean false if nothing was found
 739:  */
 740: function getEffectiveSetting($type, $name, $default = '') {
 741:     return cEffectiveSetting::get($type, $name, $default);
 742: }
 743: 
 744: /**
 745:  * Returns the current effective settings for a type of properties.
 746:  *
 747:  * The order is:
 748:  * System => Client => Group => User
 749:  *
 750:  * System properties can be overridden by the group, and group
 751:  * properties can be overridden by the user.
 752:  *
 753:  * @param string $type The type of the item
 754:  * @return array Value
 755:  */
 756: function getEffectiveSettingsByType($type) {
 757:     return cEffectiveSetting::getByType($type);
 758: }
 759: 
 760: /**
 761:  * Retrieve list of article specifications for current client and language
 762:  *
 763:  * @return array list of article specifications
 764:  */
 765: function getArtspec() {
 766:     global $db, $cfg, $lang, $client;
 767:     $sql = "SELECT artspec, idartspec, online, artspecdefault FROM " . $cfg['tab']['art_spec'] . "
 768:             WHERE client = " . (int) $client . " AND lang = " . (int) $lang . " ORDER BY artspec ASC";
 769:     $db->query($sql);
 770: 
 771:     $artspec = array();
 772: 
 773:     while ($db->nextRecord()) {
 774:         $artspec[$db->f("idartspec")]['artspec'] = $db->f("artspec");
 775:         $artspec[$db->f("idartspec")]['online'] = $db->f("online");
 776:         $artspec[$db->f("idartspec")]['default'] = $db->f("artspecdefault");
 777:     }
 778:     return $artspec;
 779: }
 780: 
 781: /**
 782:  * Add new article specification
 783:  *
 784:  * @param string $artspectext specification text
 785:  * @param int $online Online status (1 or 0)
 786:  * @return void
 787:  */
 788: function addArtspec($artspectext, $online) {
 789:     global $db, $cfg, $lang, $client;
 790: 
 791:     if (isset($_POST['idartspec'])) { // update
 792:         $fields = array(
 793:             'artspec' => $artspectext,
 794:             'online' => (int) $online
 795:         );
 796:         $where = array(
 797:             'idartspec' => (int) $_POST['idartspec']
 798:         );
 799:         $sql = $db->buildUpdate($cfg['tab']['art_spec'], $fields, $where);
 800:     } else {
 801:         $fields = array(
 802:             'client' => (int) $client,
 803:             'lang' => (int) $lang,
 804:             'artspec' => $artspectext,
 805:             'online' => 0,
 806:             'artspecdefault' => 0
 807:         );
 808:         $sql = $db->buildInsert($cfg['tab']['art_spec'], $fields);
 809:     }
 810:     $db->query($sql);
 811: }
 812: 
 813: /**
 814:  * Delete specified article specification
 815:  *
 816:  * @param int $idartspec article specification id
 817:  */
 818: function deleteArtspec($idartspec) {
 819:     global $db, $cfg;
 820:     $sql = "DELETE FROM " . $cfg['tab']['art_spec'] . " WHERE idartspec = " . (int) $idartspec;
 821:     $db->query($sql);
 822: 
 823:     $sql = "UPDATE " . $cfg["tab"]["art_lang"] . " SET artspec = 0 WHERE artspec = " . (int) $idartspec;
 824:     $db->query($sql);
 825: }
 826: 
 827: /**
 828:  * Set article specifications online
 829:  *
 830:  * Flag to switch if an article specification should be shown the frontend or
 831:  * not
 832:  *
 833:  * @param int $idartspec article specification id
 834:  * @param int $online 0/1 switch the status between on an offline
 835:  */
 836: function setArtspecOnline($idartspec, $online) {
 837:     global $db, $cfg;
 838:     $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET online = " . (int) $online . " WHERE idartspec = " . (int) $idartspec;
 839:     $db->query($sql);
 840: }
 841: 
 842: /**
 843:  * Set a default article specification
 844:  *
 845:  * While creating a new article this defined article specification will be
 846:  * default setting
 847:  *
 848:  * @param int $idartspec Article specification id
 849:  */
 850: function setArtspecDefault($idartspec) {
 851:     global $db, $cfg, $lang, $client;
 852:     $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault=0 WHERE client = " . (int) $client . " AND lang = " . (int) $lang;
 853:     $db->query($sql);
 854: 
 855:     $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault = 1 WHERE idartspec = " . (int) $idartspec;
 856:     $db->query($sql);
 857: }
 858: 
 859: /**
 860:  * Build a Article select Box
 861:  *
 862:  * @param string $sName Name of the SelectBox
 863:  * @param string $iIdCat category id
 864:  * @param string $sValue Value of the SelectBox
 865:  * @return string HTML
 866:  */
 867: function buildArticleSelect($sName, $iIdCat, $sValue) {
 868:     global $cfg, $lang;
 869: 
 870:     $db = cRegistry::getDb();
 871: 
 872:     $selectElem = new cHTMLSelectElement($sName, "", $sName);
 873:     $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
 874: 
 875:     $sql = "SELECT b.title, b.idart FROM
 876:                " . $cfg["tab"]["art"] . " AS a, " . $cfg["tab"]["art_lang"] . " AS b, " . $cfg["tab"]["cat_art"] . " AS c
 877:                WHERE c.idcat = " . (int) $iIdCat . "
 878:                AND b.idlang = " . (int) $lang . " AND b.idart = a.idart and b.idart = c.idart
 879:                ORDER BY b.title";
 880: 
 881:     $db->query($sql);
 882: 
 883:     while ($db->nextRecord()) {
 884:         if ($sValue != $db->f('idart')) {
 885:             $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart')));
 886:         } else {
 887:             $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart'), true));
 888:         }
 889:     }
 890: 
 891:     return $selectElem->toHTML();
 892: }
 893: 
 894: /**
 895:  * Build a Category / Article select Box
 896:  *
 897:  * @param string Name of the SelectBox
 898:  * @param string Value of the SelectBox
 899:  * @param int Value of highest level that should be shown
 900:  * @param string Optional css class for select
 901:  * @return string HTML
 902:  */
 903: function buildCategorySelect($sName, $sValue, $sLevel = 0, $sClass = '') {
 904:     global $cfg, $client, $lang;
 905: 
 906:     $db = cRegistry::getDb();
 907:     $db2 = cRegistry::getDb();
 908: 
 909:     $selectElem = new cHTMLSelectElement($sName, "", $sName);
 910:     $selectElem->setClass($sClass);
 911:     $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
 912: 
 913:     if ($sLevel > 0) {
 914:         $addString = "AND c.level < " . (int) $sLevel;
 915:     }
 916: 
 917:     $sql = "SELECT a.idcat AS idcat, b.name AS name, c.level FROM
 918:            " . $cfg["tab"]["cat"] . " AS a, " . $cfg["tab"]["cat_lang"] . " AS b,
 919:            " . $cfg["tab"]["cat_tree"] . " AS c WHERE a.idclient = " . (int) $client . "
 920:            AND b.idlang = " . (int) $lang . " AND b.idcat = a.idcat AND c.idcat = a.idcat " . $addString . "
 921:            ORDER BY c.idtree";
 922: 
 923:     $db->query($sql);
 924: 
 925:     $categories = array();
 926: 
 927:     while ($db->nextRecord()) {
 928:         $categories[$db->f("idcat")]["name"] = $db->f("name");
 929: 
 930:         $sql2 = "SELECT level FROM " . $cfg["tab"]["cat_tree"] . " WHERE idcat = " . (int) $db->f("idcat");
 931:         $db2->query($sql2);
 932: 
 933:         if ($db2->nextRecord()) {
 934:             $categories[$db->f("idcat")]["level"] = $db2->f("level");
 935:         }
 936: 
 937:         $sql2 = "SELECT a.title AS title, b.idcatart AS idcatart FROM
 938:                 " . $cfg["tab"]["art_lang"] . " AS a,  " . $cfg["tab"]["cat_art"] . " AS b
 939:                 WHERE b.idcat = '" . $db->f("idcat") . "' AND a.idart = b.idart AND
 940:                 a.idlang = " . (int) $lang;
 941: 
 942:         $db2->query($sql2);
 943: 
 944:         while ($db2->nextRecord()) {
 945:             $categories[$db->f("idcat")]["articles"][$db2->f("idcatart")] = $db2->f("title");
 946:         }
 947:     }
 948: 
 949:     foreach ($categories as $tmpidcat => $props) {
 950:         $spaces = "&nbsp;&nbsp;";
 951: 
 952:         for ($i = 0; $i < $props["level"]; $i++) {
 953:             $spaces .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 954:         }
 955: 
 956:         $tmp_val = $tmpidcat;
 957: 
 958:         if ($sValue != $tmp_val) {
 959:             $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val));
 960:         } else {
 961:             $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val, true));
 962:         }
 963:     }
 964: 
 965:     return $selectElem->toHTML();
 966: }
 967: 
 968: /**
 969:  * Converts a size in bytes in a human readable form
 970:  *
 971:  * @param int $number Some number of bytes
 972:  * @return string
 973:  */
 974: function humanReadableSize($number) {
 975:     $base = 1024;
 976:     $suffixes = array(
 977:         'Bytes',
 978:         'KiB',
 979:         'MiB',
 980:         'GiB',
 981:         'TiB',
 982:         'PiB',
 983:         'EiB'
 984:     );
 985: 
 986:     $usesuf = 0;
 987:     $n = (float) $number; // Appears to be necessary to avoid rounding
 988:     while ($n >= $base) {
 989:         $n /= (float) $base;
 990:         $usesuf++;
 991:     }
 992: 
 993:     $places = 2 - floor(log10($n));
 994:     $places = max($places, 0);
 995:     $retval = number_format($n, $places, '.', '') . ' ' . $suffixes[$usesuf];
 996:     return $retval;
 997: }
 998: 
 999: /**
1000:  * Converts a byte size like "8M" to the absolute number of bytes
1001:  *
1002:  * @param string $sizeString contains the size acquired from ini_get for example
1003:  * @return number
1004:  */
1005: function machineReadableSize($sizeString) {
1006:     $val = trim($sizeString);
1007:     $last = strtolower($val[strlen($val) - 1]);
1008:     $val = (float) substr($val, 0, strlen($val) - 1);
1009:     switch ($last) {
1010:         case 'g':
1011:             $val *= 1024;
1012:         case 'm':
1013:             $val *= 1024;
1014:         case 'k':
1015:             $val *= 1024;
1016:     }
1017: 
1018:     return $val;
1019: }
1020: 
1021: /**
1022:  * Checks if the script is being runned from the web
1023:  *
1024:  * @return bool True if the script is running from the web
1025:  */
1026: function isRunningFromWeb() {
1027:     if ($_SERVER['PHP_SELF'] == '' || php_sapi_name() == 'cgi' || php_sapi_name() == 'cli') {
1028:         return false;
1029:     }
1030: 
1031:     return true;
1032: }
1033: 
1034: /**
1035:  * Scans a given plugin directory and places the found plugins into the array
1036:  * $cfg['plugins'].
1037:  *
1038:  * Result:
1039:  * $cfg['plugins']['frontendusers'] => array with all found plugins
1040:  *
1041:  * Note: Plugins are only "found" if the following directory structure if found:
1042:  *
1043:  * entity/
1044:  * plugin1/plugin1.php
1045:  * plugin2/plugin2.php
1046:  *
1047:  * The plugin's directory and file name have to be the same, otherwise the
1048:  * function
1049:  * won't find them!
1050:  *
1051:  * @param string $entity Name of the directory to scan
1052:  * @return void
1053:  */
1054: function scanPlugins($entity) {
1055:     global $cfg;
1056: 
1057:     $basedir = cRegistry::getBackendPath() . $cfg['path']['plugins'] . $entity . '/';
1058:     if (is_dir($basedir) === false) {
1059:         return;
1060:     }
1061: 
1062:     $pluginorder = getSystemProperty('plugin', $entity . '-pluginorder');
1063:     $lastscantime = getSystemProperty('plugin', $entity . '-lastscantime');
1064: 
1065:     $plugins = array();
1066: 
1067:     // Fetch and trim the plugin order
1068:     if ($pluginorder != '') {
1069:         $plugins = explode(',', $pluginorder);
1070:         foreach ($plugins as $key => $plugin) {
1071:             $plugins[$key] = trim($plugin);
1072:         }
1073:     }
1074: 
1075:     // Don't scan all the time, but each 5 minutes
1076:     if ($lastscantime + 300 < time()) {
1077:         setSystemProperty('plugin', $entity . '-lastscantime', time());
1078:         if (is_dir($basedir)) {
1079:             if (false !== $dh = opendir($basedir)) {
1080:                 while (($file = readdir($dh)) !== false) {
1081:                     if (is_dir($basedir . $file) && $file != 'includes' && $file != '.' && $file != '..') {
1082:                         if (!in_array($file, $plugins)) {
1083:                             if (cFileHandler::exists($basedir . $file . '/' . $file . '.php')) {
1084:                                 $plugins[] = $file;
1085:                             }
1086:                         }
1087:                     }
1088:                 }
1089:                 closedir($dh);
1090:             }
1091:         }
1092: 
1093:         foreach ($plugins as $key => $value) {
1094:             if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1095:                 unset($plugins[$key]);
1096:             }
1097:         }
1098: 
1099:         sort($plugins);
1100: 
1101:         $pluginorder = implode(',', $plugins);
1102:         setSystemProperty('plugin', $entity . '-pluginorder', $pluginorder);
1103:     }
1104: 
1105:     foreach ($plugins as $key => $value) {
1106:         if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1107:             unset($plugins[$key]);
1108:         } else {
1109:             i18nRegisterDomain($entity . '_' . $value, $basedir . $value . '/locale/');
1110:         }
1111:     }
1112: 
1113:     $cfg['plugins'][$entity] = $plugins;
1114: }
1115: 
1116: /**
1117:  * Includes plugins for a given entity.
1118:  *
1119:  * @param $entity Name of the directory to scan
1120:  */
1121: function includePlugins($entity) {
1122:     global $cfg;
1123: 
1124:     if (is_array($cfg['plugins'][$entity])) {
1125:         foreach ($cfg['plugins'][$entity] as $plugin) {
1126:             plugin_include($entity, $plugin . '/' . $plugin . '.php');
1127:         }
1128:     }
1129: }
1130: 
1131: /**
1132:  * Calls the plugin's store methods.
1133:  *
1134:  * @param string $entity Name of the directory to scan
1135:  */
1136: function callPluginStore($entity) {
1137:     global $cfg;
1138: 
1139:     // Check out if there are any plugins
1140:     if (is_array($cfg['plugins'][$entity])) {
1141:         foreach ($cfg['plugins'][$entity] as $plugin) {
1142:             if (function_exists($entity . '_' . $plugin . '_wantedVariables') && function_exists($entity . '_' . $plugin . '_store')) {
1143:                 $wantVariables = call_user_func($entity . '_' . $plugin . '_wantedVariables');
1144: 
1145:                 if (is_array($wantVariables)) {
1146:                     $varArray = array();
1147:                     foreach ($wantVariables as $value) {
1148:                         $varArray[$value] = stripslashes($GLOBALS[$value]);
1149:                     }
1150:                 }
1151:                 $store = call_user_func($entity . '_' . $plugin . '_store', $varArray);
1152:             }
1153:         }
1154:     }
1155: }
1156: 
1157: /**
1158:  * Creates a random name (example: Passwords).
1159:  *
1160:  * @param int $nameLength Length of the generated string
1161:  * @return string Random name
1162:  */
1163: function createRandomName($nameLength) {
1164:     $NameChars = 'abcdefghijklmnopqrstuvwxyz';
1165:     $Vouel = 'aeiou';
1166:     $Name = '';
1167: 
1168:     for ($index = 1; $index <= $nameLength; $index++) {
1169:         if ($index % 3 == 0) {
1170:             $randomNumber = rand(1, strlen($Vouel));
1171:             $Name .= substr($Vouel, $randomNumber - 1, 1);
1172:         } else {
1173:             $randomNumber = rand(1, strlen($NameChars));
1174:             $Name .= substr($NameChars, $randomNumber - 1, 1);
1175:         }
1176:     }
1177: 
1178:     return $Name;
1179: }
1180: 
1181: /**
1182:  * @deprecated [2013-10-02]  Use getJsHelpContext() instead
1183:  */
1184: function setHelpContext($area) {
1185:     cDeprecated("The function setHelpContext() is deprecated. Use getJsHelpContext() instead.");
1186:     return getJsHelpContext($area);
1187: }
1188: 
1189: /**
1190:  * Returns the JavaScript help context code, if help confuguration is enabled
1191:  * @param string $area  The area name
1192:  * @return The context context JS code
1193:  */
1194: function getJsHelpContext($area) {
1195:     global $cfg;
1196: 
1197:     if ($cfg['help'] == true) {
1198:         $hc = "parent.parent.parent.frames[0].document.getElementById('help').setAttribute('data', '$area');";
1199:     } else {
1200:         $hc = '';
1201:     }
1202: 
1203:     return $hc;
1204: }
1205: 
1206: /**
1207:  * Defines a constant if not defined before.
1208:  *
1209:  * @param string $constant Name of constant to define
1210:  * @param mixed $value It's value
1211:  */
1212: function defineIfNotDefined($constant, $value) {
1213:     if (!defined($constant)) {
1214:         define($constant, $value);
1215:     }
1216: }
1217: 
1218: /**
1219:  * CONTENIDO die-alternative.
1220:  * Logs the message and calls die().
1221:  *
1222:  * @param string $file File name (use __FILE__)
1223:  * @param int $line Line number (use __LINE__)
1224:  * @param string $message Message to display
1225:  */
1226: function cDie($file, $line, $message) {
1227:     cError($file, $line, $message);
1228:     die("$file $line: $message");
1229: }
1230: 
1231: /**
1232:  * Returns a formatted string with a stack trace ready for output.
1233:  * "\tfunction1() called in file $filename($line)"
1234:  * "\tfunction2() called in file $filename($line)"
1235:  * ...
1236:  *
1237:  * @param int $startlevel The startlevel. Note that 0 is always buildStackString
1238:  *        and 1 is the function called buildStackString (e.g. cWarning)
1239:  * @return string
1240:  */
1241: function buildStackString($startlevel = 2) {
1242:     $e = new Exception();
1243:     $stack = $e->getTrace();
1244: 
1245:     $msg = '';
1246: 
1247:     for ($i = $startlevel; $i < count($stack); $i++) {
1248:         $filename = basename($stack[$i]['file']);
1249: 
1250:         $msg .= "\t" . $stack[$i]['function'] . "() called in file " . $filename . "(" . $stack[$i]['line'] . ")\n";
1251:     }
1252: 
1253:     return $msg;
1254: }
1255: 
1256: /**
1257:  * CONTENIDO warning
1258:  *
1259:  * Examples:
1260:  * <pre>
1261:  * // New version
1262:  * cWarning('Some warning message');
1263:  * // Old version
1264:  * cWarning(__FILE__, __LINE__, 'Some warning message');
1265:  * </pre>
1266:  *
1267:  * @param Multiple parameters
1268:  */
1269: function cWarning() {
1270:     global $cfg;
1271: 
1272:     $args = func_get_args();
1273:     if (count($args) == 3) {
1274:         // Old version
1275:         $file = $args[0];
1276:         $line = $args[1];
1277:         $message = $args[2];
1278:     } else {
1279:         // New version
1280:         $file = '';
1281:         $line = '';
1282:         $message = $args[0];
1283:     }
1284: 
1285:     $msg = "[" . date("Y-m-d H:i:s") . "] ";
1286:     $msg .= "Warning: \"" . $message . "\" at ";
1287: 
1288:     $e = new Exception();
1289:     $stack = $e->getTrace();
1290:     $function_name = $stack[1]['function'];
1291: 
1292:     $msg .= $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]\n";
1293: 
1294:     if ($cfg['debug']['log_stacktraces'] == true) {
1295:         $msg .= buildStackString();
1296:         $msg .= "\n";
1297:     }
1298: 
1299:     cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1300: 
1301:     trigger_error($message, E_USER_WARNING);
1302: }
1303: 
1304: /**
1305:  * CONTENIDO error
1306:  *
1307:  * Examples:
1308:  * <pre>
1309:  * // New version
1310:  * cWarning('Some error message');
1311:  * // Old version
1312:  * cWarning(__FILE__, __LINE__, 'Some error message');
1313:  * </pre>
1314:  *
1315:  * @param Multiple parameters
1316:  */
1317: function cError($message) {
1318:     global $cfg;
1319: 
1320:     $args = func_get_args();
1321:     if (count($args) == 3) {
1322:         // Old version
1323:         $file = $args[0];
1324:         $line = $args[1];
1325:         $message = $args[2];
1326:     } else {
1327:         // New version
1328:         $file = '';
1329:         $line = '';
1330:         $message = $args[0];
1331:     }
1332: 
1333:     $msg = "[" . date("Y-m-d H:i:s") . "] ";
1334:     $msg .= "Error: \"" . $message . "\" at ";
1335: 
1336:     $e = new Exception();
1337:     $stack = $e->getTrace();
1338:     $function_name = $stack[1]['function'];
1339: 
1340:     $msg .= $function_name . "() called in " . basename($stack[1]['file']) . "(" . $stack[1]['line'] . ")\n";
1341: 
1342:     if ($cfg['debug']['log_stacktraces'] == true) {
1343:         $msg .= buildStackString();
1344:         $msg .= "\n";
1345:     }
1346: 
1347:     cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1348: 
1349:     trigger_error($message, E_USER_ERROR);
1350: }
1351: 
1352: /**
1353:  * Writes a note to deprecatedlog.txt
1354:  *
1355:  * @param string $amsg Optional message (e.g. "Use function XYZ instead")
1356:  */
1357: function cDeprecated($message = '') {
1358:     global $cfg;
1359: 
1360:     if (isset($cfg['debug']['log_deprecations']) && $cfg['debug']['log_deprecations'] == false) {
1361:         return;
1362:     }
1363: 
1364:     $e = new Exception();
1365:     $stack = $e->getTrace();
1366:     $function_name = $stack[1]['function'];
1367: 
1368:     $msg = "Deprecated call: " . $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]: ";
1369:     if ($message != '') {
1370:         $msg .= "\"" . $message . "\"" . "\n";
1371:     } else {
1372:         $msg .= "\n";
1373:     }
1374: 
1375:     if ($cfg['debug']['log_stacktraces'] == true) {
1376:         $msg .= buildStackString(2);
1377:         $msg .= "\n";
1378:     }
1379: 
1380:     cFileHandler::write($cfg['path']['contenido_logs'] . 'deprecatedlog.txt', $msg, true);
1381: }
1382: 
1383: /**
1384:  * Returns the name of the numeric frame given
1385:  *
1386:  * @param int $frame Frame number
1387:  * @return string Canonical name of the frame
1388:  */
1389: function getNamedFrame($frame) {
1390:     switch ($frame) {
1391:         case 1:
1392:             return 'left_top';
1393:             break;
1394:         case 2:
1395:             return 'left_bottom';
1396:             break;
1397:         case 3:
1398:             return 'right_top';
1399:             break;
1400:         case 4:
1401:             return 'right_bottom';
1402:             break;
1403:         default:
1404:             return '';
1405:             break;
1406:     }
1407: }
1408: 
1409: /**
1410:  * Starts the timing for a specific function
1411:  *
1412:  * @param string $function Name of the function
1413:  * @param array $parameters All parameters for the function to measure
1414:  * @return int uuid for this measure process
1415:  */
1416: function startTiming($function, $parameters = array()) {
1417:     global $_timings, $cfg;
1418: 
1419:     if ($cfg['debug']['functiontiming'] == false) {
1420:         return;
1421:     }
1422: 
1423:     // Create (almost) unique ID
1424:     $uuid = md5(uniqid(rand(), true));
1425: 
1426:     if (!is_array($parameters)) {
1427:         cWarning(__FILE__, __LINE__, "Warning: startTiming's parameters parameter expects an array");
1428:         $parameters = array();
1429:     }
1430: 
1431:     $_timings[$uuid]['parameters'] = $parameters;
1432:     $_timings[$uuid]['function'] = $function;
1433: 
1434:     $_timings[$uuid]['start'] = getmicrotime();
1435: 
1436:     return $uuid;
1437: }
1438: 
1439: /**
1440:  * Ends the timing process and logs it to the timings file
1441:  *
1442:  * @param $uuid int UUID which has been used for timing
1443:  */
1444: function endAndLogTiming($uuid) {
1445:     global $_timings, $cfg;
1446: 
1447:     if ($cfg['debug']['functiontiming'] == false) {
1448:         return;
1449:     }
1450: 
1451:     $_timings[$uuid]['end'] = getmicrotime();
1452: 
1453:     $timeSpent = $_timings[$uuid]['end'] - $_timings[$uuid]['start'];
1454: 
1455:     $myparams = array();
1456: 
1457:     // Build nice representation of the function
1458:     foreach ($_timings[$uuid]['parameters'] as $parameter) {
1459:         switch (gettype($parameter)) {
1460:             case 'string':
1461:                 $myparams[] = '"' . $parameter . '"';
1462:                 break;
1463:             case 'boolean':
1464:                 if ($parameter == true) {
1465:                     $myparams[] = 'true';
1466:                 } else {
1467:                     $myparams[] = 'false';
1468:                 }
1469:                 break;
1470:             default:
1471:                 if ($parameter == '') {
1472:                     $myparams[] = '"' . $parameter . '"';
1473:                 } else {
1474:                     $myparams[] = $parameter;
1475:                 }
1476:         }
1477:     }
1478: 
1479:     $parameterString = implode(', ', $myparams);
1480: 
1481:     cDebug::out('calling function ' . $_timings[$uuid]['function'] . '(' . $parameterString . ') took ' . $timeSpent . ' seconds');
1482: }
1483: 
1484: /**
1485:  * Function checks current language and client settings by HTTP-Params and DB
1486:  * settings.
1487:  * Based on this informations it will send an HTTP header for right encoding.
1488:  *
1489:  * @param cDb $db NO MORE NEEDED
1490:  * @param array $cfg Global cfg-array
1491:  * @param int $lang Global language id
1492:  * @param string $contentType Mime type
1493:  */
1494: function sendEncodingHeader($db, $cfg, $lang, $contentType = 'text/html') {
1495:     if (isset($_GET['use_encoding'])) {
1496:         $use_encoding = trim(strip_tags($_GET['use_encoding']));
1497:     } elseif (isset($_POST['use_encoding'])) {
1498:         $use_encoding = trim(strip_tags($_POST['use_encoding']));
1499:     } else {
1500:         $use_encoding = true;
1501:     }
1502: 
1503:     if (is_string($use_encoding)) {
1504:         $use_encoding = ($use_encoding == 'false') ? false : true;
1505:     }
1506: 
1507:     if ($use_encoding != false) {
1508:         $aLanguageEncodings = array();
1509: 
1510:         $oLangColl = new cApiLanguageCollection();
1511:         $oLangColl->select();
1512:         while (($oItem = $oLangColl->next()) !== false) {
1513:             $aLanguageEncodings[$oItem->get('idlang')] = $oItem->get('encoding');
1514:         }
1515: 
1516:         $charset = 'ISO-8859-1';
1517:         if (isset($aLanguageEncodings[$lang])) {
1518:             if (in_array($aLanguageEncodings[$lang], $cfg['AvailableCharsets'])) {
1519:                 $charset = $aLanguageEncodings[$lang];
1520:             }
1521:         }
1522:         header('Content-Type: ' . $contentType . '; charset=' . $charset);
1523:     }
1524: }
1525: 
1526: /**
1527:  * IP match
1528:  *
1529:  * @param string $network
1530:  * @param string $mask
1531:  * @param string $ip
1532:  * @return boolean
1533:  */
1534: function ipMatch($network, $mask, $ip) {
1535:     bcscale(3);
1536:     $ip_long = ip2long($ip);
1537:     $mask_long = ip2long($network);
1538: 
1539:     // Convert mask to divider
1540:     if (preg_match('/^[0-9]+$/', $mask)) {
1541:         // / 212.50.13.0/27 style mask (Cisco style)
1542:         $divider = bcpow(2, (32 - $mask));
1543:     } else {
1544:         // / 212.50.13.0/255.255.255.0 style mask
1545:         $xmask = ip2long($mask);
1546:         if ($xmask < 0) {
1547:             $xmask = bcadd(bcpow(2, 32), $xmask);
1548:         }
1549:         $divider = bcsub(bcpow(2, 32), $xmask);
1550:     }
1551:     // Test is IP within specified mask
1552:     if (floor(bcdiv($ip_long, $divider)) == floor(bcdiv($mask_long, $divider))) {
1553:         // match - this IP is within specified mask
1554:         return true;
1555:     } else {
1556:         // fail - this IP is NOT within specified mask
1557:         return false;
1558:     }
1559: }
1560: 
1561: /**
1562:  * @deprecated [2013-08-14]  Use cString::endsWith() instead
1563:  */
1564: function endsWith($haystack, $needle) {
1565:     cDeprecated("The function endsWith is deprecated. Use cString::endsWith() instead.");
1566:     return cString::endsWith($haystack, $needle);
1567: }
1568: 
1569: /**
1570:  * Checks, if a function is disabled or not ('disable_functions' setting in php.ini)
1571:  * @param  string  $functionName  Name of the function to check
1572:  * @return bool
1573:  */
1574: function isFunctionDisabled($functionName) {
1575:     static $disabledFunctions;
1576: 
1577:     if (empty($functionName)) {
1578:         return true;
1579:     }
1580: 
1581:     if (!isset($disabledFunctions)) {
1582:         $disabledFunctions = array_map('trim', explode(',', ini_get('disable_functions')));
1583:     }
1584: 
1585:     return (in_array($functionName, $disabledFunctions));
1586: }
1587: 
1588: /**
1589:  * Generates category article breadcrumb for backend
1590:  *
1591:  * @param string $syncoptions syncstate of backend
1592:  * @param string $showArticle show also current article or categories only (optional)
1593:  * @return NULL
1594:  */
1595: function renderBackendBreadcrumb($syncoptions, $showArticle = true, $return = false) {
1596:     $tplBread = new cTemplate();
1597:     $tplBread->set('s', 'LABEL', i18n("You are here"));
1598:     $syncoptions = (int) $syncoptions;
1599: 
1600:     $helper = cCategoryHelper::getInstance();
1601:     $categories = $helper->getCategoryPath(cRegistry::getCategoryId(), 1);
1602:     $catCount = count($categories);
1603:     $tplCfg = new cApiTemplateConfiguration();
1604:     $sess = cRegistry::getSession();
1605:     $cfg = cRegistry::getConfig();
1606:     $lang = cRegistry::getLanguageId();
1607:     $idart = cRegistry::getArticleId();
1608: 
1609: 
1610:     for ($i = 0; $i < $catCount; $i++) {
1611:         $idcat_tpl = 0;
1612:         $idcat_bread = $categories[$i]->getField('idcat');
1613:         $idcat_name = $categories[$i]->getField('name');
1614:         $idcat_tplcfg = $categories[$i]->getField('idtplcfg');
1615:         if ((int) $idcat_tplcfg > 0) {
1616:             $tplCfg->loadByPrimaryKey($idcat_tplcfg);
1617:             if ($tplCfg->isLoaded()) {
1618:                 $idcat_tpl = $tplCfg->getField('idtpl');
1619:             }
1620:         }
1621: 
1622:         $linkUrl = $sess->url(cRegistry::getBackendUrl() . "main.php?area=con&frame=4&idcat=$idcat_bread&idtpl=$idcat_tpl&syncoptions=$syncoptions&contenido=1");
1623:         $tplBread->set('d', 'LINK', $linkUrl);
1624:         $tplBread->set('d', 'NAME', $idcat_name);
1625: 
1626:         $sepArrow = '';
1627:         if ($i < $catCount - 1) {
1628:             $sepArrow = ' > ';
1629:         } else {
1630:             if ((int) $idart > 0 && $showArticle === true) {
1631:                 $art = new cApiArticleLanguage();
1632:                 $art->loadByArticleAndLanguageId($idart, $lang);
1633:                 if ($art->isLoaded()) {
1634:                     $name = $art->getField('title');
1635:                     $sepArrow = ' > ' . $name;
1636:                 }
1637:             }
1638:         }
1639:         $tplBread->set('d', 'SEP_ARROW', $sepArrow);
1640: 
1641:         $tplBread->next();
1642:     }
1643: 
1644:     return $tplBread->generate($cfg['path']['templates'] . $cfg['templates']['breadcrumb'], $return);
1645: }
1646: 
1647: ?>
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0