1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: cInclude('includes', 'functions.file.php');
19:
20: 21: 22: 23: 24: 25: 26: 27: 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: 53: 54: 55: 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: 69: 70: 71: 72: 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: 86: 87: 88: 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) {
98: continue;
99: } else if (($char & 0xE0) === 0xC0 && $char > 0xC1) {
100:
101: $n = 1;
102: } else if (($char & 0xF0) === 0xE0) {
103: $n = 2;
104: } else if (($char & 0xF8) === 0xF0 && $char < 0xF5) {
105:
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: 124: 125: 126: 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: 171: 172: 173: 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: 205: 206: 207: 208: 209: 210: 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: 233: 234: 235: 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: 250: 251: 252: 253:
254: function getParentAreaId($area) {
255: $oAreaColl = new cApiAreaCollection();
256: return $oAreaColl->getParentAreaID($area);
257: }
258:
259: 260: 261: 262: 263: 264:
265: function ($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: 299: 300: 301:
302: function backToMainArea($send) {
303: if ($send) {
304:
305: global $area, $sess, $idart, $idcat, $idartlang, $idcatart, $frame;
306:
307:
308: $oAreaColl = new cApiAreaCollection();
309: $parent = $oAreaColl->getParentAreaID($area);
310:
311:
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:
316: header("location: $url");
317: }
318: }
319:
320: 321: 322: 323: 324: 325:
326: function getLanguagesByClient($client) {
327: $oClientLangColl = new cApiClientLanguageCollection();
328: return $oClientLangColl->getLanguagesByClient($client);
329: }
330:
331: 332: 333: 334: 335: 336: 337:
338: function getLanguageNamesByClient($client) {
339: $oClientLangColl = new cApiClientLanguageCollection();
340: return $oClientLangColl->getLanguageNamesByClient($client);
341: }
342:
343: 344: 345: 346: 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: 359: 360: 361: 362: 363: 364: 365: 366: 367: 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:
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: 429: 430: 431: 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: 447: 448: 449: 450: 451: 452: 453: 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: 621: 622: 623: 624: 625: 626: 627: 628: 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: 648: 649: 650: 651: 652:
653: function deleteSystemProperty($type, $name) {
654: $systemPropColl = new cApiSystemPropertyCollection();
655: $systemPropColl->deleteByTypeName($type, $name);
656: }
657:
658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 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: 695: 696: 697: 698: 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: 708: 709: 710: 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: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741:
742: function getEffectiveSetting($type, $name, $default = '') {
743: return cEffectiveSetting::get($type, $name, $default);
744: }
745:
746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757:
758: function getEffectiveSettingsByType($type) {
759: return cEffectiveSetting::getByType($type);
760: }
761:
762: 763: 764: 765: 766:
767: function getArtspec() {
768: global $db, $cfg, $lang, $client;
769: $sql = "SELECT artspec, idartspec, online, artspecdefault FROM " . $cfg['tab']['art_spec'] . "
770: WHERE client = " . (int) $client . " AND lang = " . (int) $lang . " ORDER BY artspec ASC";
771: $db->query($sql);
772:
773: $artspec = array();
774:
775: while ($db->nextRecord()) {
776: $artspec[$db->f("idartspec")]['artspec'] = $db->f("artspec");
777: $artspec[$db->f("idartspec")]['online'] = $db->f("online");
778: $artspec[$db->f("idartspec")]['default'] = $db->f("artspecdefault");
779: }
780: return $artspec;
781: }
782:
783: 784: 785: 786: 787: 788: 789:
790: function addArtspec($artspectext, $online) {
791: global $db, $cfg, $lang, $client;
792:
793: if (isset($_POST['idartspec'])) {
794: $fields = array(
795: 'artspec' => $artspectext,
796: 'online' => (int) $online
797: );
798: $where = array(
799: 'idartspec' => (int) $_POST['idartspec']
800: );
801: $sql = $db->buildUpdate($cfg['tab']['art_spec'], $fields, $where);
802: } else {
803: $fields = array(
804: 'client' => (int) $client,
805: 'lang' => (int) $lang,
806: 'artspec' => $artspectext,
807: 'online' => 0,
808: 'artspecdefault' => 0
809: );
810: $sql = $db->buildInsert($cfg['tab']['art_spec'], $fields);
811: }
812: $db->query($sql);
813: }
814:
815: 816: 817: 818: 819:
820: function deleteArtspec($idartspec) {
821: global $db, $cfg;
822: $sql = "DELETE FROM " . $cfg['tab']['art_spec'] . " WHERE idartspec = " . (int) $idartspec;
823: $db->query($sql);
824:
825: $sql = "UPDATE " . $cfg["tab"]["art_lang"] . " SET artspec = 0 WHERE artspec = " . (int) $idartspec;
826: $db->query($sql);
827: }
828:
829: 830: 831: 832: 833: 834: 835: 836: 837:
838: function setArtspecOnline($idartspec, $online) {
839: global $db, $cfg;
840: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET online = " . (int) $online . " WHERE idartspec = " . (int) $idartspec;
841: $db->query($sql);
842: }
843:
844: 845: 846: 847: 848: 849: 850: 851:
852: function setArtspecDefault($idartspec) {
853: global $db, $cfg, $lang, $client;
854: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault=0 WHERE client = " . (int) $client . " AND lang = " . (int) $lang;
855: $db->query($sql);
856:
857: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault = 1 WHERE idartspec = " . (int) $idartspec;
858: $db->query($sql);
859: }
860:
861: 862: 863: 864: 865: 866: 867: 868:
869: function buildArticleSelect($sName, $iIdCat, $sValue) {
870: global $cfg, $lang;
871:
872: $db = cRegistry::getDb();
873:
874: $selectElem = new cHTMLSelectElement($sName, "", $sName);
875: $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
876:
877: $sql = "SELECT b.title, b.idart FROM
878: " . $cfg["tab"]["art"] . " AS a, " . $cfg["tab"]["art_lang"] . " AS b, " . $cfg["tab"]["cat_art"] . " AS c
879: WHERE c.idcat = " . (int) $iIdCat . "
880: AND b.idlang = " . (int) $lang . " AND b.idart = a.idart and b.idart = c.idart
881: ORDER BY b.title";
882:
883: $db->query($sql);
884:
885: while ($db->nextRecord()) {
886: if ($sValue != $db->f('idart')) {
887: $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart')));
888: } else {
889: $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart'), true));
890: }
891: }
892:
893: return $selectElem->toHTML();
894: }
895:
896: 897: 898: 899: 900: 901: 902: 903: 904:
905: function buildCategorySelect($sName, $sValue, $sLevel = 0, $sClass = '') {
906: global $cfg, $client, $lang;
907:
908: $db = cRegistry::getDb();
909: $db2 = cRegistry::getDb();
910:
911: $selectElem = new cHTMLSelectElement($sName, "", $sName);
912: $selectElem->setClass($sClass);
913: $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
914:
915: if ($sLevel > 0) {
916: $addString = "AND c.level < " . (int) $sLevel;
917: }
918:
919: $sql = "SELECT a.idcat AS idcat, b.name AS name, c.level FROM
920: " . $cfg["tab"]["cat"] . " AS a, " . $cfg["tab"]["cat_lang"] . " AS b,
921: " . $cfg["tab"]["cat_tree"] . " AS c WHERE a.idclient = " . (int) $client . "
922: AND b.idlang = " . (int) $lang . " AND b.idcat = a.idcat AND c.idcat = a.idcat " . $addString . "
923: ORDER BY c.idtree";
924:
925: $db->query($sql);
926:
927: $categories = array();
928:
929: while ($db->nextRecord()) {
930: $categories[$db->f("idcat")]["name"] = $db->f("name");
931:
932: $sql2 = "SELECT level FROM " . $cfg["tab"]["cat_tree"] . " WHERE idcat = " . (int) $db->f("idcat");
933: $db2->query($sql2);
934:
935: if ($db2->nextRecord()) {
936: $categories[$db->f("idcat")]["level"] = $db2->f("level");
937: }
938:
939: $sql2 = "SELECT a.title AS title, b.idcatart AS idcatart FROM
940: " . $cfg["tab"]["art_lang"] . " AS a, " . $cfg["tab"]["cat_art"] . " AS b
941: WHERE b.idcat = '" . $db->f("idcat") . "' AND a.idart = b.idart AND
942: a.idlang = " . (int) $lang;
943:
944: $db2->query($sql2);
945:
946: while ($db2->nextRecord()) {
947: $categories[$db->f("idcat")]["articles"][$db2->f("idcatart")] = $db2->f("title");
948: }
949: }
950:
951: foreach ($categories as $tmpidcat => $props) {
952: $spaces = " ";
953:
954: for ($i = 0; $i < $props["level"]; $i++) {
955: $spaces .= " ";
956: }
957:
958: $tmp_val = $tmpidcat;
959:
960: if ($sValue != $tmp_val) {
961: $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val));
962: } else {
963: $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val, true));
964: }
965: }
966:
967: return $selectElem->toHTML();
968: }
969:
970: 971: 972: 973: 974: 975:
976: function humanReadableSize($number) {
977: $base = 1024;
978: $suffixes = array(
979: 'Bytes',
980: 'KiB',
981: 'MiB',
982: 'GiB',
983: 'TiB',
984: 'PiB',
985: 'EiB'
986: );
987:
988: $usesuf = 0;
989: $n = (float) $number;
990: while ($n >= $base) {
991: $n /= (float) $base;
992: $usesuf++;
993: }
994:
995: $places = 2 - floor(log10($n));
996: $places = max($places, 0);
997: $retval = number_format($n, $places, '.', '') . ' ' . $suffixes[$usesuf];
998: return $retval;
999: }
1000:
1001: 1002: 1003: 1004: 1005: 1006:
1007: function machineReadableSize($sizeString) {
1008: $val = trim($sizeString);
1009: $last = strtolower($val[strlen($val) - 1]);
1010: $val = (float) substr($val, 0, strlen($val) - 1);
1011: switch ($last) {
1012: case 'g':
1013: $val *= 1024;
1014: case 'm':
1015: $val *= 1024;
1016: case 'k':
1017: $val *= 1024;
1018: }
1019:
1020: return $val;
1021: }
1022:
1023: 1024: 1025: 1026: 1027:
1028: function isRunningFromWeb() {
1029: if ($_SERVER['PHP_SELF'] == '' || php_sapi_name() == 'cgi' || php_sapi_name() == 'cli') {
1030: return false;
1031: }
1032:
1033: return true;
1034: }
1035:
1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055:
1056: function scanPlugins($entity) {
1057: global $cfg;
1058:
1059: $basedir = cRegistry::getBackendPath() . $cfg['path']['plugins'] . $entity . '/';
1060: if (is_dir($basedir) === false) {
1061: return;
1062: }
1063:
1064: $pluginorder = getSystemProperty('plugin', $entity . '-pluginorder');
1065: $lastscantime = getSystemProperty('plugin', $entity . '-lastscantime');
1066:
1067: $plugins = array();
1068:
1069:
1070: if ($pluginorder != '') {
1071: $plugins = explode(',', $pluginorder);
1072: foreach ($plugins as $key => $plugin) {
1073: $plugins[$key] = trim($plugin);
1074: }
1075: }
1076:
1077:
1078: if ($lastscantime + 300 < time()) {
1079: setSystemProperty('plugin', $entity . '-lastscantime', time());
1080: if (is_dir($basedir)) {
1081: if (false !== $dh = opendir($basedir)) {
1082: while (($file = readdir($dh)) !== false) {
1083: if (is_dir($basedir . $file) && $file != 'includes' && $file != '.' && $file != '..') {
1084: if (!in_array($file, $plugins)) {
1085: if (cFileHandler::exists($basedir . $file . '/' . $file . '.php')) {
1086: $plugins[] = $file;
1087: }
1088: }
1089: }
1090: }
1091: closedir($dh);
1092: }
1093: }
1094:
1095: foreach ($plugins as $key => $value) {
1096: if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1097: unset($plugins[$key]);
1098: }
1099: }
1100:
1101: sort($plugins);
1102:
1103: $pluginorder = implode(',', $plugins);
1104: setSystemProperty('plugin', $entity . '-pluginorder', $pluginorder);
1105: }
1106:
1107: foreach ($plugins as $key => $value) {
1108: if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1109: unset($plugins[$key]);
1110: } else {
1111: i18nRegisterDomain($entity . '_' . $value, $basedir . $value . '/locale/');
1112: }
1113: }
1114:
1115: $cfg['plugins'][$entity] = $plugins;
1116: }
1117:
1118: 1119: 1120: 1121: 1122:
1123: function includePlugins($entity) {
1124: global $cfg;
1125:
1126: if (is_array($cfg['plugins'][$entity])) {
1127: foreach ($cfg['plugins'][$entity] as $plugin) {
1128: plugin_include($entity, $plugin . '/' . $plugin . '.php');
1129: }
1130: }
1131: }
1132:
1133: 1134: 1135: 1136: 1137:
1138: function callPluginStore($entity) {
1139: global $cfg;
1140:
1141:
1142: if (is_array($cfg['plugins'][$entity])) {
1143: foreach ($cfg['plugins'][$entity] as $plugin) {
1144: if (function_exists($entity . '_' . $plugin . '_wantedVariables') && function_exists($entity . '_' . $plugin . '_store')) {
1145: $wantVariables = call_user_func($entity . '_' . $plugin . '_wantedVariables');
1146:
1147: if (is_array($wantVariables)) {
1148: $varArray = array();
1149: foreach ($wantVariables as $value) {
1150: $varArray[$value] = stripslashes($GLOBALS[$value]);
1151: }
1152: }
1153: $store = call_user_func($entity . '_' . $plugin . '_store', $varArray);
1154: }
1155: }
1156: }
1157: }
1158:
1159: 1160: 1161: 1162: 1163: 1164:
1165: function createRandomName($nameLength) {
1166: $NameChars = 'abcdefghijklmnopqrstuvwxyz';
1167: $Vouel = 'aeiou';
1168: $Name = '';
1169:
1170: for ($index = 1; $index <= $nameLength; $index++) {
1171: if ($index % 3 == 0) {
1172: $randomNumber = rand(1, strlen($Vouel));
1173: $Name .= substr($Vouel, $randomNumber - 1, 1);
1174: } else {
1175: $randomNumber = rand(1, strlen($NameChars));
1176: $Name .= substr($NameChars, $randomNumber - 1, 1);
1177: }
1178: }
1179:
1180: return $Name;
1181: }
1182:
1183: 1184: 1185:
1186: function setHelpContext($area) {
1187: cDeprecated("The function setHelpContext() is deprecated. Use getJsHelpContext() instead.");
1188: return getJsHelpContext($area);
1189: }
1190:
1191: 1192: 1193: 1194: 1195:
1196: function getJsHelpContext($area) {
1197: global $cfg;
1198:
1199: if ($cfg['help'] == true) {
1200: $hc = "parent.parent.parent.frames[0].document.getElementById('help').setAttribute('data', '$area');";
1201: } else {
1202: $hc = '';
1203: }
1204:
1205: return $hc;
1206: }
1207:
1208: 1209: 1210: 1211: 1212: 1213:
1214: function defineIfNotDefined($constant, $value) {
1215: if (!defined($constant)) {
1216: define($constant, $value);
1217: }
1218: }
1219:
1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227:
1228: function cDie($file, $line, $message) {
1229: cError($file, $line, $message);
1230: die("$file $line: $message");
1231: }
1232:
1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242:
1243: function buildStackString($startlevel = 2) {
1244: $e = new Exception();
1245: $stack = $e->getTrace();
1246:
1247: $msg = '';
1248:
1249: for ($i = $startlevel; $i < count($stack); $i++) {
1250: $filename = basename($stack[$i]['file']);
1251:
1252: $msg .= "\t" . $stack[$i]['function'] . "() called in file " . $filename . "(" . $stack[$i]['line'] . ")\n";
1253: }
1254:
1255: return $msg;
1256: }
1257:
1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270:
1271: function cWarning() {
1272: global $cfg;
1273:
1274: $args = func_get_args();
1275: if (count($args) == 3) {
1276:
1277: $file = $args[0];
1278: $line = $args[1];
1279: $message = $args[2];
1280: } else {
1281:
1282: $file = '';
1283: $line = '';
1284: $message = $args[0];
1285: }
1286:
1287: $msg = "[" . date("Y-m-d H:i:s") . "] ";
1288: $msg .= "Warning: \"" . $message . "\" at ";
1289:
1290: $e = new Exception();
1291: $stack = $e->getTrace();
1292: $function_name = $stack[1]['function'];
1293:
1294: $msg .= $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]\n";
1295:
1296: if ($cfg['debug']['log_stacktraces'] == true) {
1297: $msg .= buildStackString();
1298: $msg .= "\n";
1299: }
1300:
1301: cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1302:
1303: trigger_error($message, E_USER_WARNING);
1304: }
1305:
1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318:
1319: function cError($message) {
1320: global $cfg;
1321:
1322: $args = func_get_args();
1323: if (count($args) == 3) {
1324:
1325: $file = $args[0];
1326: $line = $args[1];
1327: $message = $args[2];
1328: } else {
1329:
1330: $file = '';
1331: $line = '';
1332: $message = $args[0];
1333: }
1334:
1335: $msg = "[" . date("Y-m-d H:i:s") . "] ";
1336: $msg .= "Error: \"" . $message . "\" at ";
1337:
1338: $e = new Exception();
1339: $stack = $e->getTrace();
1340: $function_name = $stack[1]['function'];
1341:
1342: $msg .= $function_name . "() called in " . basename($stack[1]['file']) . "(" . $stack[1]['line'] . ")\n";
1343:
1344: if ($cfg['debug']['log_stacktraces'] == true) {
1345: $msg .= buildStackString();
1346: $msg .= "\n";
1347: }
1348:
1349: cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1350:
1351: trigger_error($message, E_USER_ERROR);
1352: }
1353:
1354: 1355: 1356: 1357: 1358:
1359: function cDeprecated($message = '') {
1360: global $cfg;
1361:
1362: if (isset($cfg['debug']['log_deprecations']) && $cfg['debug']['log_deprecations'] == false) {
1363: return;
1364: }
1365:
1366: $e = new Exception();
1367: $stack = $e->getTrace();
1368: $function_name = $stack[1]['function'];
1369:
1370: $msg = "Deprecated call: " . $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]: ";
1371: if ($message != '') {
1372: $msg .= "\"" . $message . "\"" . "\n";
1373: } else {
1374: $msg .= "\n";
1375: }
1376:
1377: if ($cfg['debug']['log_stacktraces'] == true) {
1378: $msg .= buildStackString(2);
1379: $msg .= "\n";
1380: }
1381:
1382: cFileHandler::write($cfg['path']['contenido_logs'] . 'deprecatedlog.txt', $msg, true);
1383: }
1384:
1385: 1386: 1387: 1388: 1389: 1390:
1391: function getNamedFrame($frame) {
1392: switch ($frame) {
1393: case 1:
1394: return 'left_top';
1395: break;
1396: case 2:
1397: return 'left_bottom';
1398: break;
1399: case 3:
1400: return 'right_top';
1401: break;
1402: case 4:
1403: return 'right_bottom';
1404: break;
1405: default:
1406: return '';
1407: break;
1408: }
1409: }
1410:
1411: 1412: 1413: 1414: 1415: 1416: 1417:
1418: function startTiming($function, $parameters = array()) {
1419: global $_timings, $cfg;
1420:
1421: if ($cfg['debug']['functiontiming'] == false) {
1422: return;
1423: }
1424:
1425:
1426: $uuid = md5(uniqid(rand(), true));
1427:
1428: if (!is_array($parameters)) {
1429: cWarning(__FILE__, __LINE__, "Warning: startTiming's parameters parameter expects an array");
1430: $parameters = array();
1431: }
1432:
1433: $_timings[$uuid]['parameters'] = $parameters;
1434: $_timings[$uuid]['function'] = $function;
1435:
1436: $_timings[$uuid]['start'] = getmicrotime();
1437:
1438: return $uuid;
1439: }
1440:
1441: 1442: 1443: 1444: 1445:
1446: function endAndLogTiming($uuid) {
1447: global $_timings, $cfg;
1448:
1449: if ($cfg['debug']['functiontiming'] == false) {
1450: return;
1451: }
1452:
1453: $_timings[$uuid]['end'] = getmicrotime();
1454:
1455: $timeSpent = $_timings[$uuid]['end'] - $_timings[$uuid]['start'];
1456:
1457: $myparams = array();
1458:
1459:
1460: foreach ($_timings[$uuid]['parameters'] as $parameter) {
1461: switch (gettype($parameter)) {
1462: case 'string':
1463: $myparams[] = '"' . $parameter . '"';
1464: break;
1465: case 'boolean':
1466: if ($parameter == true) {
1467: $myparams[] = 'true';
1468: } else {
1469: $myparams[] = 'false';
1470: }
1471: break;
1472: default:
1473: if ($parameter == '') {
1474: $myparams[] = '"' . $parameter . '"';
1475: } else {
1476: $myparams[] = $parameter;
1477: }
1478: }
1479: }
1480:
1481: $parameterString = implode(', ', $myparams);
1482:
1483: cDebug::out('calling function ' . $_timings[$uuid]['function'] . '(' . $parameterString . ') took ' . $timeSpent . ' seconds');
1484: }
1485:
1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495:
1496: function ($db, $cfg, $lang, $contentType = 'text/html') {
1497: if (isset($_GET['use_encoding'])) {
1498: $use_encoding = trim(strip_tags($_GET['use_encoding']));
1499: } elseif (isset($_POST['use_encoding'])) {
1500: $use_encoding = trim(strip_tags($_POST['use_encoding']));
1501: } else {
1502: $use_encoding = true;
1503: }
1504:
1505: if (is_string($use_encoding)) {
1506: $use_encoding = ($use_encoding == 'false') ? false : true;
1507: }
1508:
1509: if ($use_encoding != false) {
1510: $aLanguageEncodings = array();
1511:
1512: $oLangColl = new cApiLanguageCollection();
1513: $oLangColl->select();
1514: while (($oItem = $oLangColl->next()) !== false) {
1515: $aLanguageEncodings[$oItem->get('idlang')] = $oItem->get('encoding');
1516: }
1517:
1518: $charset = 'ISO-8859-1';
1519: if (isset($aLanguageEncodings[$lang])) {
1520: if (in_array($aLanguageEncodings[$lang], $cfg['AvailableCharsets'])) {
1521: $charset = $aLanguageEncodings[$lang];
1522: }
1523: }
1524: header('Content-Type: ' . $contentType . '; charset=' . $charset);
1525: }
1526: }
1527:
1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535:
1536: function ipMatch($network, $mask, $ip) {
1537: bcscale(3);
1538: $ip_long = ip2long($ip);
1539: $mask_long = ip2long($network);
1540:
1541:
1542: if (preg_match('/^[0-9]+$/', $mask)) {
1543:
1544: $divider = bcpow(2, (32 - $mask));
1545: } else {
1546:
1547: $xmask = ip2long($mask);
1548: if ($xmask < 0) {
1549: $xmask = bcadd(bcpow(2, 32), $xmask);
1550: }
1551: $divider = bcsub(bcpow(2, 32), $xmask);
1552: }
1553:
1554: if (floor(bcdiv($ip_long, $divider)) == floor(bcdiv($mask_long, $divider))) {
1555:
1556: return true;
1557: } else {
1558:
1559: return false;
1560: }
1561: }
1562:
1563: 1564: 1565:
1566: function endsWith($haystack, $needle) {
1567: cDeprecated("The function endsWith is deprecated. Use cString::endsWith() instead.");
1568: return cString::endsWith($haystack, $needle);
1569: }
1570:
1571: 1572: 1573: 1574: 1575:
1576: function isFunctionDisabled($functionName) {
1577: static $disabledFunctions;
1578:
1579: if (empty($functionName)) {
1580: return true;
1581: }
1582:
1583: if (!isset($disabledFunctions)) {
1584: $disabledFunctions = array_map('trim', explode(',', ini_get('disable_functions')));
1585: }
1586:
1587: return (in_array($functionName, $disabledFunctions));
1588: }
1589:
1590: 1591: 1592: 1593: 1594: 1595: 1596:
1597: function renderBackendBreadcrumb($syncoptions, $showArticle = true, $return = false) {
1598: $tplBread = new cTemplate();
1599: $tplBread->set('s', 'LABEL', i18n("You are here"));
1600: $syncoptions = (int) $syncoptions;
1601:
1602: $helper = cCategoryHelper::getInstance();
1603: $categories = $helper->getCategoryPath(cRegistry::getCategoryId(), 1);
1604: $catCount = count($categories);
1605: $tplCfg = new cApiTemplateConfiguration();
1606: $sess = cRegistry::getSession();
1607: $cfg = cRegistry::getConfig();
1608: $lang = cRegistry::getLanguageId();
1609: $idart = cRegistry::getArticleId();
1610:
1611:
1612: for ($i = 0; $i < $catCount; $i++) {
1613: $idcat_tpl = 0;
1614: $idcat_bread = $categories[$i]->getField('idcat');
1615: $idcat_name = $categories[$i]->getField('name');
1616: $idcat_tplcfg = $categories[$i]->getField('idtplcfg');
1617: if ((int) $idcat_tplcfg > 0) {
1618: $tplCfg->loadByPrimaryKey($idcat_tplcfg);
1619: if ($tplCfg->isLoaded()) {
1620: $idcat_tpl = $tplCfg->getField('idtpl');
1621: }
1622: }
1623:
1624: $linkUrl = $sess->url(cRegistry::getBackendUrl() . "main.php?area=con&frame=4&idcat=$idcat_bread&idtpl=$idcat_tpl&syncoptions=$syncoptions&contenido=1");
1625: $tplBread->set('d', 'LINK', $linkUrl);
1626: $tplBread->set('d', 'NAME', $idcat_name);
1627:
1628: $sepArrow = '';
1629: if ($i < $catCount - 1) {
1630: $sepArrow = ' > ';
1631: } else {
1632: if ((int) $idart > 0 && $showArticle === true) {
1633: $art = new cApiArticleLanguage();
1634: $art->loadByArticleAndLanguageId($idart, $lang);
1635: if ($art->isLoaded()) {
1636: $name = $art->getField('title');
1637: $sepArrow = ' > ' . $name;
1638: }
1639: }
1640: }
1641: $tplBread->set('d', 'SEP_ARROW', $sepArrow);
1642:
1643: $tplBread->next();
1644: }
1645:
1646: return $tplBread->generate($cfg['path']['templates'] . $cfg['templates']['breadcrumb'], $return);
1647: }
1648:
1649: ?>