1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: cInclude('includes', 'functions.file.php');
20:
21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
31: function getAvailableContentTypes($idartlang) {
32: global $db, $cfg, $a_content, $a_description;
33:
34: $sql = "SELECT
35: *
36: FROM
37: " . $cfg["tab"]["content"] . " AS a,
38: " . $cfg["tab"]["art_lang"] . " AS b,
39: " . $cfg["tab"]["type"] . " AS c
40: WHERE
41: a.idtype = c.idtype AND
42: a.idartlang = b.idartlang AND
43: b.idartlang = " . (int) $idartlang;
44:
45: $db->query($sql);
46:
47: while ($db->nextRecord()) {
48: $a_content[$db->f('type')][$db->f('typeid')] = $db->f('value');
49: $a_description[$db->f('type')][$db->f('typeid')] = i18n($db->f('description'));
50: }
51: }
52:
53: 54: 55: 56: 57: 58: 59: 60:
61: function isArtInMultipleUse($idart) {
62: global $cfg;
63:
64: $db = cRegistry::getDb();
65: $sql = "SELECT idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = " . (int) $idart;
66: $db->query($sql);
67:
68: return ($db->affectedRows() > 1);
69: }
70:
71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82:
83: function isAlphanumeric($test, $umlauts = true) {
84: return cString::isAlphanumeric($test, $umlauts);
85: }
86:
87: 88: 89: 90: 91: 92: 93: 94:
95: function isUtf8($input) {
96: return cString::isUtf8($input);
97: }
98:
99: 100: 101: 102: 103: 104:
105: function getCanonicalMonth($month) {
106: switch ($month) {
107: case 1:
108: return (i18n("January"));
109: break;
110: case 2:
111: return (i18n("February"));
112: break;
113: case 3:
114: return (i18n("March"));
115: break;
116: case 4:
117: return (i18n("April"));
118: break;
119: case 5:
120: return (i18n("May"));
121: break;
122: case 6:
123: return (i18n("June"));
124: break;
125: case 7:
126: return (i18n("July"));
127: break;
128: case 8:
129: return (i18n("August"));
130: break;
131: case 9:
132: return (i18n("September"));
133: break;
134: case 10:
135: return (i18n("October"));
136: break;
137: case 11:
138: return (i18n("November"));
139: break;
140: case 12:
141: return (i18n("December"));
142: break;
143: }
144: }
145:
146: 147: 148: 149: 150: 151: 152: 153:
154: function getCanonicalDay($iDay) {
155: switch ($iDay) {
156: case 1:
157: return (i18n("Monday"));
158: break;
159: case 2:
160: return (i18n("Tuesday"));
161: break;
162: case 3:
163: return (i18n("Wednesday"));
164: break;
165: case 4:
166: return (i18n("Thursday"));
167: break;
168: case 5:
169: return (i18n("Friday"));
170: break;
171: case 6:
172: return (i18n("Saturday"));
173: break;
174: case 0:
175: return (i18n("Sunday"));
176: break;
177: default:
178: break;
179: }
180: }
181:
182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193:
194: function displayDatetime($timestamp = "", $date = false, $time = false) {
195: if ($timestamp == "") {
196: $timestamp = time();
197: } else {
198: $timestamp = strtotime($timestamp);
199: }
200:
201: $ret = "";
202:
203: if ($date && !$time) {
204: $ret = date(getEffectiveSetting("dateformat", "date", "Y-m-d"), $timestamp);
205: } else if ($time && !$date) {
206: $ret = date(getEffectiveSetting("dateformat", "time", "H:i:s"), $timestamp);
207: } else {
208: $ret = date(getEffectiveSetting("dateformat", "full", "Y-m-d H:i:s"), $timestamp);
209: }
210: return $ret;
211: }
212:
213: 214: 215: 216: 217: 218: 219:
220: function getIDForArea($area) {
221: if (!is_numeric($area)) {
222: $oArea = new cApiArea();
223: if ($oArea->loadBy('name', $area)) {
224: $area = $oArea->get('idarea');
225: }
226: }
227:
228: return $area;
229: }
230:
231: 232: 233: 234: 235: 236:
237: function getParentAreaId($area) {
238: $oAreaColl = new cApiAreaCollection();
239: return $oAreaColl->getParentAreaID($area);
240: }
241:
242: 243: 244: 245: 246: 247: 248: 249: 250:
251: function ($menuitem, $return = false) {
252: global $changeview;
253:
254: if (!isset($changeview) || 'prev' !== $changeview) {
255:
256: $str = <<<JS
257: <script type="text/javascript">
258: var id = 'c_{$menuitem}';
259: if ('undefined' !== typeof(Con)) {
260: Con.markSubmenuItem(id);
261: } else {
262: // Contenido backend but with frozen article
263: // Check if submenuItem is existing and mark it
264: if (parent.parent.frames.right.frames.right_top.document.getElementById(id)) {
265: menuItem = parent.parent.frames.right.frames.right_top.document.getElementById(id).getElementsByTagName('a')[0];
266: // load the new tab now
267: parent.parent.frames.right.frames.right_top.Con.Subnav.clicked(menuItem, true);
268: }
269: }
270: </script>
271: JS;
272: } else {
273:
274: $str = <<<JS
275: <script type="text/javascript">
276: (function(id) {
277: var menuItem;
278: try {
279: // Check if we are in a dual-frame or a quad-frame
280: if (parent.parent.frames[0].name == 'header') {
281: if (parent.frames.right_top.document.getElementById(id)) {
282: menuItem = parent.frames.right_top.document.getElementById(id).getElementsByTagName('a')[0];
283: parent.frames.right_top.Con.Subnav.clicked(menuItem);
284: }
285: } else {
286: // Check if submenuItem is existing and mark it
287: if (parent.parent.frames.right.frames.right_top.document.getElementById(id)) {
288: menuItem = parent.parent.frames.right.frames.right_top.document.getElementById(id).getElementsByTagName('a')[0];
289: parent.parent.frames.right.frames.right_top.Con.Subnav.clicked(menuItem);
290: }
291: }
292: } catch (e) {}
293: })('c_{$menuitem}');
294: </script>
295: JS;
296: }
297:
298: if ($return) {
299: return $str;
300: } else {
301: echo $str;
302: }
303: }
304:
305: 306: 307: 308: 309: 310: 311:
312: function conMakeInlineScript($content) {
313: $script = <<<JS
314: <script type="text/javascript">
315: (function(Con, $) {
316: {$content}
317: })(Con, Con.$);
318: </script>
319: JS;
320: return $script;
321: }
322:
323: 324: 325: 326: 327: 328:
329: function backToMainArea($send) {
330: if ($send) {
331:
332: global $area, $sess, $idart, $idcat, $idartlang, $idcatart, $frame;
333:
334:
335: $oAreaColl = new cApiAreaCollection();
336: $parent = $oAreaColl->getParentAreaID($area);
337:
338:
339: $url_str = 'main.php?' . 'area=' . $parent . '&' . 'idcat=' . $idcat . '&' . 'idart=' . $idart . '&' . 'idartlang=' . $idartlang . '&' . 'idcatart=' . $idcatart . '&' . 'force=1&' . 'frame=' . $frame;
340: $url = $sess->url($url_str);
341:
342:
343: header("location: $url");
344: }
345: }
346:
347: 348: 349: 350: 351: 352:
353: function getLanguagesByClient($client) {
354: $oClientLangColl = new cApiClientLanguageCollection();
355: return $oClientLangColl->getLanguagesByClient($client);
356: }
357:
358: 359: 360: 361: 362: 363: 364: 365:
366: function getLanguageNamesByClient($client) {
367: $oClientLangColl = new cApiClientLanguageCollection();
368: return $oClientLangColl->getLanguageNamesByClient($client);
369: }
370:
371: 372: 373: 374: 375: 376: 377: 378:
379: function set_magic_quotes_gpc(&$code) {
380: cDeprecated('This method is deprecated and is not needed any longer');
381:
382: global $cfg;
383: if (!$cfg['simulate_magic_quotes']) {
384: if (get_magic_quotes_gpc() == 0) {
385: $code = addslashes($code);
386: }
387: }
388: }
389:
390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401:
402: function getAllClientsAndLanguages() {
403: global $db, $cfg;
404:
405: $sql = "SELECT
406: a.idlang as idlang,
407: a.name as langname,
408: b.name as clientname,
409: b.idclient as idclient
410: FROM
411: " . $cfg["tab"]["lang"] . " as a,
412: " . $cfg["tab"]["clients_lang"] . " as c,
413: " . $cfg["tab"]["clients"] . " as b
414: WHERE
415: a.idlang = c.idlang AND
416: c.idclient = b.idclient";
417: $db->query($sql);
418:
419: $aRs = array();
420: while ($db->nextRecord()) {
421: $aRs[] = array(
422: 'idlang' => $db->f('idlang'),
423: 'langname' => $db->f('langname'),
424: 'idclient' => $db->f('idclient'),
425: 'clientname' => $db->f('clientname')
426: );
427: }
428: return $aRs;
429: }
430:
431: 432: 433: 434:
435: function getmicrotime() {
436: list($usec, $sec) = explode(' ', microtime());
437: return ((float) $usec + (float) $sec);
438: }
439:
440: 441: 442: 443: 444:
445: function isGroup($uid) {
446: $user = new cApiUser();
447: if ($user->loadByPrimaryKey($uid) === false) {
448: return true;
449: } else {
450: return false;
451: }
452: }
453:
454: 455: 456: 457: 458:
459: function getGroupOrUserName($uid) {
460: $user = new cApiUser();
461: if ($user->loadByPrimaryKey($uid) === false) {
462: $group = new cApiGroup();
463:
464: if ($group->loadByPrimaryKey($uid) === false) {
465: return false;
466: } else {
467: return $group->getGroupName(true);
468: }
469: } else {
470: return $user->getField('realname');
471: }
472: }
473:
474: 475: 476: 477: 478: 479: 480: 481:
482: function isValidMail($email, $strict = false) {
483: $validator = cValidatorFactory::getInstance('email');
484: return $validator->isValid($email);
485: }
486:
487: 488: 489: 490: 491:
492: function htmldecode($string) {
493: $trans_tbl = conGetHtmlTranslationTable(HTML_ENTITIES);
494: $trans_tbl = array_flip($trans_tbl);
495: $ret = strtr($string, $trans_tbl);
496: return $ret;
497: }
498:
499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513:
514: function updateClientCache($idclient = 0, $htmlpath = '', $frontendpath = '') {
515:
516: global $cfg, $cfgClient, $errsite_idcat, $errsite_idart;
517:
518: if (!is_array($cfgClient)) {
519: $cfgClient = array();
520: }
521:
522: if ($idclient != 0 && $htmlpath != '' && $frontendpath != '') {
523: $cfgClient[$idclient]['path']['frontend'] = cSecurity::escapeString($frontendpath);
524: $cfgClient[$idclient]['path']['htmlpath'] = cSecurity::escapeString($htmlpath);
525: }
526:
527:
528: $htmlpaths = array();
529: $frontendpaths = array();
530: foreach ($cfgClient as $id => $aclient) {
531: if (is_array($aclient)) {
532: $htmlpaths[$id] = $aclient["path"]["htmlpath"];
533: $frontendpaths[$id] = $aclient["path"]["frontend"];
534: }
535: }
536: unset($cfgClient);
537: $cfgClient = array();
538:
539:
540:
541:
542:
543:
544:
545:
546:
547: $db = cRegistry::getDb();
548: $db->query('
549: SELECT idclient
550: , name
551: , errsite_cat
552: , errsite_art
553: FROM ' . $cfg['tab']['clients']);
554:
555: while ($db->nextRecord()) {
556: $iClient = $db->f('idclient');
557: $cfgClient['set'] = 'set';
558:
559:
560: if (isset($htmlpaths[$iClient])) {
561: $cfgClient[$iClient]["path"]["htmlpath"] = $htmlpaths[$iClient];
562: }
563: if (isset($frontendpaths[$iClient])) {
564: $cfgClient[$iClient]["path"]["frontend"] = $frontendpaths[$iClient];
565: }
566:
567: $cfgClient[$iClient]['name'] = conHtmlSpecialChars(str_replace(array(
568: '*/',
569: '/*',
570: '//'
571: ), '', $db->f('name')));
572:
573: $errsite_idcat[$iClient] = $db->f('errsite_cat');
574: $errsite_idart[$iClient] = $db->f('errsite_art');
575: $cfgClient[$iClient]["errsite"]["idcat"] = $errsite_idcat[$iClient];
576: $cfgClient[$iClient]["errsite"]["idart"] = $errsite_idart[$iClient];
577:
578: $cfgClient[$iClient]['images'] = $cfgClient[$iClient]['path']['htmlpath'] . 'images/';
579: $cfgClient[$iClient]['upload'] = 'upload/';
580:
581: $cfgClient[$iClient]['htmlpath']['frontend'] = $cfgClient[$iClient]['path']['htmlpath'];
582:
583: $cfgClient[$iClient]['upl']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'upload/';
584: $cfgClient[$iClient]['upl']['htmlpath'] = $cfgClient[$iClient]['htmlpath']['frontend'] . 'upload/';
585: $cfgClient[$iClient]['upl']['frontendpath'] = 'upload/';
586:
587: $cfgClient[$iClient]['css']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'css/';
588:
589: $cfgClient[$iClient]['js']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'js/';
590:
591: $cfgClient[$iClient]['tpl']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'templates/';
592:
593: $cfgClient[$iClient]['cache']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'cache/';
594: $cfgClient[$iClient]['cache']['frontendpath'] = 'cache/';
595:
596: $cfgClient[$iClient]['code']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'cache/code/';
597: $cfgClient[$iClient]['code']['frontendpath'] = 'cache/code/';
598:
599: $cfgClient[$iClient]['xml']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'xml/';
600: $cfgClient[$iClient]['xml']['frontendpath'] = 'xml/';
601:
602: $cfgClient[$iClient]['template']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'templates/';
603: $cfgClient[$iClient]['template']['frontendpath'] = 'templates/';
604:
605: $cfgClient[$iClient]['data']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/';
606:
607: $cfgClient[$iClient]['module']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/modules/';
608: $cfgClient[$iClient]['module']['frontendpath'] = 'data/modules/';
609:
610: $cfgClient[$iClient]['config']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/config/' . CON_ENVIRONMENT . '/';
611: $cfgClient[$iClient]['config']['frontendpath'] = 'data/config/';
612:
613: $cfgClient[$iClient]['layout']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/layouts/';
614: $cfgClient[$iClient]['layout']['frontendpath'] = 'data/layouts/';
615:
616: $cfgClient[$iClient]['log']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/logs/';
617: $cfgClient[$iClient]['log']['frontendpath'] = 'data/logs/';
618:
619: $cfgClient[$iClient]['version']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/version/';
620: $cfgClient[$iClient]['version']['frontendpath'] = 'data/version/';
621: }
622:
623: $aConfigFileContent = array();
624: $aConfigFileContent[] = '<?php';
625: $aConfigFileContent[] = 'global $cfgClient;';
626: $aConfigFileContent[] = '';
627:
628: foreach ($cfgClient as $iIdClient => $aClient) {
629: if ((int) $iIdClient > 0 && is_array($aClient)) {
630:
631: $aConfigFileContent[] = '/* ' . $aClient['name'] . ' */';
632: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["name"] = "' . $aClient['name'] . '";';
633: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["errsite"]["idcat"] = "' . $aClient["errsite"]["idcat"] . '";';
634: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["errsite"]["idart"] = "' . $aClient["errsite"]["idart"] . '";';
635: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["images"] = "' . $aClient["path"]["htmlpath"] . 'images/";';
636: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upload"] = "upload/";';
637:
638: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["path"]["frontend"] = "' . $aClient["path"]["frontend"] . '";';
639:
640: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["htmlpath"]["frontend"] = "' . $aClient["path"]["htmlpath"] . '";';
641:
642: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "upload/";';
643: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["htmlpath"] = "' . $aClient["htmlpath"]["frontend"] . 'upload/";';
644: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["frontendpath"] = "upload/";';
645:
646: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["css"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "css/";';
647:
648: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["js"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "js/";';
649:
650: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["tpl"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "templates/";';
651:
652: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["cache"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "cache/";';
653: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["cache"]["frontendpath"] = "cache/";';
654:
655: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["code"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "cache/code/";';
656: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["code"]["frontendpath"] = "cache/code/";';
657:
658: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["xml"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "xml/";';
659: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["xml"]["frontendpath"] = "xml/";';
660:
661: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["template"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "templates/";';
662: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["template"]["frontendpath"] = "templates/";';
663:
664: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["data"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/";';
665:
666: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["module"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/modules/";';
667: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["module"]["frontendpath"] = "data/modules/";';
668:
669: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["config"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/config/' . CON_ENVIRONMENT . '/";';
670: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["config"]["frontendpath"] = "data/config/";';
671:
672: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["layout"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/layouts/";';
673: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["layout"]["frontendpath"] = "data/layouts/";';
674:
675: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["log"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/logs/";';
676: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["log"]["frontendpath"] = "data/logs/";';
677:
678: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["version"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/version/";';
679: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["version"]["frontendpath"] = "data/version/";';
680: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["path"]["htmlpath"] = "' . $aClient['path']['htmlpath'] . '";';
681: $aConfigFileContent[] = '';
682: }
683: }
684: $aConfigFileContent[] = '$cfgClient["set"] = "set";';
685: $aConfigFileContent[] = '?>';
686:
687: cFileHandler::write($cfg['path']['contenido_config'] . 'config.clients.php', implode(PHP_EOL, $aConfigFileContent));
688:
689: return $cfgClient;
690: }
691:
692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707:
708: function setSystemProperty($type, $name, $value, $idsystemprop = 0) {
709: if ($type == '' || $name == '') {
710: return false;
711: }
712:
713: $idsystemprop = (int) $idsystemprop;
714:
715: $systemPropColl = new cApiSystemPropertyCollection();
716:
717: if ($idsystemprop == 0) {
718: $prop = $systemPropColl->setValueByTypeName($type, $name, $value);
719: } else {
720: $prop = $systemPropColl->setTypeNameValueById($type, $name, $value, $idsystemprop);
721: }
722: }
723:
724: 725: 726: 727: 728: 729: 730: 731: 732:
733: function deleteSystemProperty($type, $name) {
734: $systemPropColl = new cApiSystemPropertyCollection();
735: $systemPropColl->deleteByTypeName($type, $name);
736: }
737:
738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754:
755: function getSystemProperties($bGetPropId = false) {
756: $return = array();
757:
758: $systemPropColl = new cApiSystemPropertyCollection();
759: $props = $systemPropColl->fetchAll('type ASC, name ASC, value ASC');
760: foreach ($props as $prop) {
761: $item = $prop->toArray();
762:
763: if ($bGetPropId) {
764: $return[$item['type']][$item['name']]['value'] = $item['value'];
765: $return[$item['type']][$item['name']]['idsystemprop'] = $item['idsystemprop'];
766: } else {
767: $return[$item['type']][$item['name']] = $item['value'];
768: }
769: }
770:
771: return $return;
772: }
773:
774: 775: 776: 777: 778: 779: 780: 781: 782: 783:
784: function getSystemProperty($type, $name) {
785: $systemPropColl = new cApiSystemPropertyCollection();
786: $prop = $systemPropColl->fetchByTypeName($type, $name);
787: return ($prop) ? $prop->get('value') : false;
788: }
789:
790: 791: 792: 793: 794: 795: 796: 797: 798:
799: function getSystemPropertiesByType($type) {
800: $return = array();
801:
802: $systemPropColl = new cApiSystemPropertyCollection();
803: $props = $systemPropColl->fetchByType($type);
804: foreach ($props as $prop) {
805: $return[$prop->get('name')] = $prop->get('value');
806: }
807: if (count($return) > 1) {
808: ksort($return);
809: }
810: return $return;
811: }
812:
813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832:
833: function getEffectiveSetting($type, $name, $default = '') {
834: return cEffectiveSetting::get($type, $name, $default);
835: }
836:
837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848:
849: function getEffectiveSettingsByType($type) {
850: return cEffectiveSetting::getByType($type);
851: }
852:
853: 854: 855: 856: 857: 858:
859: function getArtspec() {
860: global $db, $cfg, $lang, $client;
861: $sql = "SELECT artspec, idartspec, online, artspecdefault FROM " . $cfg['tab']['art_spec'] . "
862: WHERE client = " . (int) $client . " AND lang = " . (int) $lang . " ORDER BY artspec ASC";
863: $db->query($sql);
864:
865: $artspec = array();
866:
867: while ($db->nextRecord()) {
868: $artspec[$db->f("idartspec")]['artspec'] = $db->f("artspec");
869: $artspec[$db->f("idartspec")]['online'] = $db->f("online");
870: $artspec[$db->f("idartspec")]['default'] = $db->f("artspecdefault");
871: }
872: return $artspec;
873: }
874:
875: 876: 877: 878: 879: 880: 881: 882:
883: function addArtspec($artspectext, $online) {
884: global $db, $cfg, $lang, $client;
885:
886: if (isset($_POST['idartspec'])) {
887: $fields = array(
888: 'artspec' => $artspectext,
889: 'online' => (int) $online
890: );
891: $where = array(
892: 'idartspec' => (int) $_POST['idartspec']
893: );
894: $sql = $db->buildUpdate($cfg['tab']['art_spec'], $fields, $where);
895: } else {
896: $fields = array(
897: 'client' => (int) $client,
898: 'lang' => (int) $lang,
899: 'artspec' => $artspectext,
900: 'online' => 0,
901: 'artspecdefault' => 0
902: );
903: $sql = $db->buildInsert($cfg['tab']['art_spec'], $fields);
904: }
905: $db->query($sql);
906: }
907:
908: 909: 910: 911: 912: 913:
914: function deleteArtspec($idartspec) {
915: global $db, $cfg;
916: $sql = "DELETE FROM " . $cfg['tab']['art_spec'] . " WHERE idartspec = " . (int) $idartspec;
917: $db->query($sql);
918:
919: $sql = "UPDATE " . $cfg["tab"]["art_lang"] . " SET artspec = 0 WHERE artspec = " . (int) $idartspec;
920: $db->query($sql);
921: }
922:
923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933:
934: function setArtspecOnline($idartspec, $online) {
935: global $db, $cfg;
936: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET online = " . (int) $online . " WHERE idartspec = " . (int) $idartspec;
937: $db->query($sql);
938: }
939:
940: 941: 942: 943: 944: 945: 946: 947: 948:
949: function setArtspecDefault($idartspec) {
950: global $db, $cfg, $lang, $client;
951: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault=0 WHERE client = " . (int) $client . " AND lang = " . (int) $lang;
952: $db->query($sql);
953:
954: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault = 1 WHERE idartspec = " . (int) $idartspec;
955: $db->query($sql);
956: }
957:
958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969:
970: function buildArticleSelect($sName, $iIdCat, $sValue) {
971: global $cfg, $lang;
972:
973: $db = cRegistry::getDb();
974:
975: $selectElem = new cHTMLSelectElement($sName, "", $sName);
976: $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
977:
978: $sql = "SELECT b.title, b.idart FROM
979: " . $cfg["tab"]["art"] . " AS a, " . $cfg["tab"]["art_lang"] . " AS b, " . $cfg["tab"]["cat_art"] . " AS c
980: WHERE c.idcat = " . (int) $iIdCat . "
981: AND b.idlang = " . (int) $lang . " AND b.idart = a.idart and b.idart = c.idart
982: ORDER BY b.title";
983:
984: $db->query($sql);
985:
986: while ($db->nextRecord()) {
987: if ($sValue != $db->f('idart')) {
988: $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart')));
989: } else {
990: $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart'), true));
991: }
992: }
993:
994: return $selectElem->toHTML();
995: }
996:
997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010:
1011: function buildCategorySelect($sName, $sValue, $sLevel = 0, $sClass = '') {
1012: global $cfg, $client, $lang;
1013:
1014: $db = cRegistry::getDb();
1015: $db2 = cRegistry::getDb();
1016:
1017: $selectElem = new cHTMLSelectElement($sName, "", $sName);
1018: $selectElem->setClass($sClass);
1019: $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
1020:
1021: if ($sLevel > 0) {
1022: $addString = "AND c.level < " . (int) $sLevel;
1023: }
1024:
1025: $sql = "SELECT a.idcat AS idcat, b.name AS name, c.level FROM
1026: " . $cfg["tab"]["cat"] . " AS a, " . $cfg["tab"]["cat_lang"] . " AS b,
1027: " . $cfg["tab"]["cat_tree"] . " AS c WHERE a.idclient = " . (int) $client . "
1028: AND b.idlang = " . (int) $lang . " AND b.idcat = a.idcat AND c.idcat = a.idcat " . $addString . "
1029: ORDER BY c.idtree";
1030:
1031: $db->query($sql);
1032:
1033: $categories = array();
1034:
1035: while ($db->nextRecord()) {
1036: $categories[$db->f("idcat")]["name"] = $db->f("name");
1037:
1038: $sql2 = "SELECT level FROM " . $cfg["tab"]["cat_tree"] . " WHERE idcat = " . (int) $db->f("idcat");
1039: $db2->query($sql2);
1040:
1041: if ($db2->nextRecord()) {
1042: $categories[$db->f("idcat")]["level"] = $db2->f("level");
1043: }
1044:
1045: $sql2 = "SELECT a.title AS title, b.idcatart AS idcatart FROM
1046: " . $cfg["tab"]["art_lang"] . " AS a, " . $cfg["tab"]["cat_art"] . " AS b
1047: WHERE b.idcat = '" . $db->f("idcat") . "' AND a.idart = b.idart AND
1048: a.idlang = " . (int) $lang;
1049:
1050: $db2->query($sql2);
1051:
1052: while ($db2->nextRecord()) {
1053: $categories[$db->f("idcat")]["articles"][$db2->f("idcatart")] = $db2->f("title");
1054: }
1055: }
1056:
1057: foreach ($categories as $tmpidcat => $props) {
1058: $spaces = " ";
1059:
1060: for ($i = 0; $i < $props["level"]; $i++) {
1061: $spaces .= " ";
1062: }
1063:
1064: $tmp_val = $tmpidcat;
1065:
1066: if ($sValue != $tmp_val) {
1067: $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val));
1068: } else {
1069: $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val, true));
1070: }
1071: }
1072:
1073: return $selectElem->toHTML();
1074: }
1075:
1076: 1077: 1078: 1079: 1080: 1081: 1082:
1083: function humanReadableSize($number) {
1084: $base = 1024;
1085: $suffixes = array(
1086: 'Bytes',
1087: 'KiB',
1088: 'MiB',
1089: 'GiB',
1090: 'TiB',
1091: 'PiB',
1092: 'EiB'
1093: );
1094:
1095: $usesuf = 0;
1096: $n = (float) $number;
1097: while ($n >= $base) {
1098: $n /= (float) $base;
1099: $usesuf++;
1100: }
1101:
1102: $places = 2 - floor(log10($n));
1103: $places = max($places, 0);
1104: $retval = number_format($n, $places, '.', '') . ' ' . $suffixes[$usesuf];
1105: return $retval;
1106: }
1107:
1108: 1109: 1110: 1111: 1112: 1113: 1114:
1115: function machineReadableSize($sizeString) {
1116:
1117:
1118: if (cSecurity::isInteger($sizeString)) {
1119: return $sizeString;
1120: }
1121:
1122: $val = trim($sizeString);
1123: $last = strtolower($val[strlen($val) - 1]);
1124: $val = (float) substr($val, 0, strlen($val) - 1);
1125: switch ($last) {
1126: case 'g':
1127: $val *= 1024;
1128: case 'm':
1129: $val *= 1024;
1130: case 'k':
1131: $val *= 1024;
1132: }
1133:
1134: return $val;
1135: }
1136:
1137: 1138: 1139: 1140: 1141: 1142:
1143: function isRunningFromWeb() {
1144: if ($_SERVER['PHP_SELF'] == '' || php_sapi_name() == 'cgi' || php_sapi_name() == 'cli') {
1145: return false;
1146: }
1147:
1148: return true;
1149: }
1150:
1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170:
1171: function scanPlugins($entity) {
1172: global $cfg;
1173:
1174: $basedir = cRegistry::getBackendPath() . $cfg['path']['plugins'] . $entity . '/';
1175: if (is_dir($basedir) === false) {
1176: return;
1177: }
1178:
1179: $pluginorder = getSystemProperty('plugin', $entity . '-pluginorder');
1180: $lastscantime = (int) getSystemProperty('plugin', $entity . '-lastscantime');
1181:
1182: $plugins = array();
1183:
1184:
1185: if ($pluginorder != '') {
1186: $plugins = explode(',', $pluginorder);
1187: foreach ($plugins as $key => $plugin) {
1188: $plugins[$key] = trim($plugin);
1189: }
1190: }
1191:
1192:
1193: if ($lastscantime + 300 < time()) {
1194: setSystemProperty('plugin', $entity . '-lastscantime', time());
1195: if (is_dir($basedir)) {
1196: if (false !== ($handle = cDirHandler::read($basedir))) {
1197: foreach ($handle as $file) {
1198: if (is_dir($basedir . $file) && $file != 'includes' && cFileHandler::fileNameIsDot($file) === false) {
1199: if (!in_array($file, $plugins)) {
1200: if (cFileHandler::exists($basedir . $file . '/' . $file . '.php')) {
1201: $plugins[] = $file;
1202: }
1203: }
1204: }
1205: }
1206: }
1207: }
1208:
1209: foreach ($plugins as $key => $value) {
1210: if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1211: unset($plugins[$key]);
1212: }
1213: }
1214:
1215: sort($plugins);
1216:
1217: $pluginorder = implode(',', $plugins);
1218: setSystemProperty('plugin', $entity . '-pluginorder', $pluginorder);
1219: }
1220:
1221: foreach ($plugins as $key => $value) {
1222: if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1223: unset($plugins[$key]);
1224: } else {
1225: i18nRegisterDomain($entity . '_' . $value, $basedir . $value . '/locale/');
1226: }
1227: }
1228:
1229: $cfg['plugins'][$entity] = $plugins;
1230: }
1231:
1232: 1233: 1234: 1235: 1236: 1237:
1238: function includePlugins($entity) {
1239: global $cfg;
1240:
1241: if (is_array($cfg['plugins'][$entity])) {
1242: foreach ($cfg['plugins'][$entity] as $plugin) {
1243: plugin_include($entity, $plugin . '/' . $plugin . '.php');
1244: }
1245: }
1246: }
1247:
1248: 1249: 1250: 1251: 1252: 1253:
1254: function callPluginStore($entity) {
1255: global $cfg;
1256:
1257:
1258: if (is_array($cfg['plugins'][$entity])) {
1259: foreach ($cfg['plugins'][$entity] as $plugin) {
1260: if (function_exists($entity . '_' . $plugin . '_wantedVariables') && function_exists($entity . '_' . $plugin . '_store')) {
1261: $wantVariables = call_user_func($entity . '_' . $plugin . '_wantedVariables');
1262:
1263: if (is_array($wantVariables)) {
1264: $varArray = array();
1265: foreach ($wantVariables as $value) {
1266: $varArray[$value] = stripslashes($GLOBALS[$value]);
1267: }
1268: }
1269: $store = call_user_func($entity . '_' . $plugin . '_store', $varArray);
1270: }
1271: }
1272: }
1273: }
1274:
1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282:
1283: function createRandomName($nameLength) {
1284: $NameChars = 'abcdefghijklmnopqrstuvwxyz';
1285: $Vouel = 'aeiou';
1286: $Name = '';
1287:
1288: for ($index = 1; $index <= $nameLength; $index++) {
1289: if ($index % 3 == 0) {
1290: $randomNumber = rand(1, strlen($Vouel));
1291: $Name .= substr($Vouel, $randomNumber - 1, 1);
1292: } else {
1293: $randomNumber = rand(1, strlen($NameChars));
1294: $Name .= substr($NameChars, $randomNumber - 1, 1);
1295: }
1296: }
1297:
1298: return $Name;
1299: }
1300:
1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308:
1309: function getJsHelpContext($area) {
1310: global $cfg;
1311:
1312: if ($cfg['help'] == true) {
1313: $hc = "parent.parent.parent.frames[0].document.getElementById('help').setAttribute('data', '$area');";
1314: } else {
1315: $hc = '';
1316: }
1317:
1318: return $hc;
1319: }
1320:
1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328:
1329: function defineIfNotDefined($constant, $value) {
1330: if (!defined($constant)) {
1331: define($constant, $value);
1332: }
1333: }
1334:
1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345:
1346: function cDie($file, $line, $message) {
1347: cError($file, $line, $message);
1348: die("$file $line: $message");
1349: }
1350:
1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361:
1362: function buildStackString($startlevel = 2) {
1363: $e = new Exception();
1364: $stack = $e->getTrace();
1365:
1366: $msg = '';
1367:
1368: for ($i = $startlevel; $i < count($stack); $i++) {
1369: $filename = basename($stack[$i]['file']);
1370:
1371: $msg .= "\t" . $stack[$i]['function'] . "() called in file " . $filename . "(" . $stack[$i]['line'] . ")\n";
1372: }
1373:
1374: return $msg;
1375: }
1376:
1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390:
1391: function cWarning() {
1392: global $cfg;
1393:
1394: $args = func_get_args();
1395: if (count($args) == 3) {
1396:
1397: $file = $args[0];
1398: $line = $args[1];
1399: $message = $args[2];
1400: } else {
1401:
1402: $file = '';
1403: $line = '';
1404: $message = $args[0];
1405: }
1406:
1407: $msg = "[" . date("Y-m-d H:i:s") . "] ";
1408: $msg .= "Warning: \"" . $message . "\" at ";
1409:
1410: $e = new Exception();
1411: $stack = $e->getTrace();
1412: $function_name = $stack[1]['function'];
1413:
1414: $msg .= $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]\n";
1415:
1416: if ($cfg['debug']['log_stacktraces'] == true) {
1417: $msg .= buildStackString();
1418: $msg .= "\n";
1419: }
1420:
1421: cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1422:
1423: trigger_error($message, E_USER_WARNING);
1424: }
1425:
1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439:
1440: function cError($message) {
1441: global $cfg;
1442:
1443: $args = func_get_args();
1444: if (count($args) == 3) {
1445:
1446: $file = $args[0];
1447: $line = $args[1];
1448: $message = $args[2];
1449: } else {
1450:
1451: $file = '';
1452: $line = '';
1453: $message = $args[0];
1454: }
1455:
1456: $msg = "[" . date("Y-m-d H:i:s") . "] ";
1457: $msg .= "Error: \"" . $message . "\" at ";
1458:
1459: $e = new Exception();
1460: $stack = $e->getTrace();
1461: $function_name = $stack[1]['function'];
1462:
1463: $msg .= $function_name . "() called in " . basename($stack[1]['file']) . "(" . $stack[1]['line'] . ")\n";
1464:
1465: if ($cfg['debug']['log_stacktraces'] == true) {
1466: $msg .= buildStackString();
1467: $msg .= "\n";
1468: }
1469:
1470: cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1471:
1472: trigger_error($message, E_USER_ERROR);
1473: }
1474:
1475: 1476: 1477: 1478: 1479: 1480:
1481: function cDeprecated($message = '') {
1482: global $cfg;
1483:
1484: if (isset($cfg['debug']['log_deprecations']) && $cfg['debug']['log_deprecations'] == false) {
1485: return;
1486: }
1487:
1488: $e = new Exception();
1489: $stack = $e->getTrace();
1490: $function_name = $stack[1]['function'];
1491:
1492: $msg = "Deprecated call: " . $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]: ";
1493: if ($message != '') {
1494: $msg .= "\"" . $message . "\"" . "\n";
1495: } else {
1496: $msg .= "\n";
1497: }
1498:
1499: if ($cfg['debug']['log_stacktraces'] == true) {
1500: $msg .= buildStackString(2);
1501: $msg .= "\n";
1502: }
1503:
1504: cFileHandler::write($cfg['path']['contenido_logs'] . 'deprecatedlog.txt', $msg, true);
1505: }
1506:
1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516:
1517: function getNamedFrame($frame) {
1518: switch ($frame) {
1519: case 1:
1520: return 'left_top';
1521: break;
1522: case 2:
1523: return 'left_bottom';
1524: break;
1525: case 3:
1526: return 'right_top';
1527: break;
1528: case 4:
1529: return 'right_bottom';
1530: break;
1531: default:
1532: return '';
1533: break;
1534: }
1535: }
1536:
1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546:
1547: function startTiming($function, $parameters = array()) {
1548: global $_timings, $cfg;
1549:
1550: if ($cfg['debug']['functiontiming'] == false) {
1551: return;
1552: }
1553:
1554:
1555: $uuid = md5(uniqid(rand(), true));
1556:
1557: if (!is_array($parameters)) {
1558: cWarning(__FILE__, __LINE__, "Warning: startTiming's parameters parameter expects an array");
1559: $parameters = array();
1560: }
1561:
1562: $_timings[$uuid]['parameters'] = $parameters;
1563: $_timings[$uuid]['function'] = $function;
1564:
1565: $_timings[$uuid]['start'] = getmicrotime();
1566:
1567: return $uuid;
1568: }
1569:
1570: 1571: 1572: 1573: 1574: 1575:
1576: function endAndLogTiming($uuid) {
1577: global $_timings, $cfg;
1578:
1579: if ($cfg['debug']['functiontiming'] == false) {
1580: return;
1581: }
1582:
1583: $_timings[$uuid]['end'] = getmicrotime();
1584:
1585: $timeSpent = $_timings[$uuid]['end'] - $_timings[$uuid]['start'];
1586:
1587: $myparams = array();
1588:
1589:
1590: foreach ($_timings[$uuid]['parameters'] as $parameter) {
1591: switch (gettype($parameter)) {
1592: case 'string':
1593: $myparams[] = '"' . $parameter . '"';
1594: break;
1595: case 'boolean':
1596: if ($parameter == true) {
1597: $myparams[] = 'true';
1598: } else {
1599: $myparams[] = 'false';
1600: }
1601: break;
1602: default:
1603: if ($parameter == '') {
1604: $myparams[] = '"' . $parameter . '"';
1605: } else {
1606: $myparams[] = $parameter;
1607: }
1608: }
1609: }
1610:
1611: $parameterString = implode(', ', $myparams);
1612:
1613: cDebug::out('calling function ' . $_timings[$uuid]['function'] . '(' . $parameterString . ') took ' . $timeSpent . ' seconds');
1614: }
1615:
1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629:
1630: function ($db, $cfg, $lang, $contentType = 'text/html') {
1631: if (isset($_GET['use_encoding'])) {
1632: $use_encoding = trim(strip_tags($_GET['use_encoding']));
1633: } elseif (isset($_POST['use_encoding'])) {
1634: $use_encoding = trim(strip_tags($_POST['use_encoding']));
1635: } else {
1636: $use_encoding = true;
1637: }
1638:
1639: if (is_string($use_encoding)) {
1640: $use_encoding = ($use_encoding == 'false') ? false : true;
1641: }
1642:
1643: if ($use_encoding != false) {
1644: $aLanguageEncodings = array();
1645:
1646: $oLangColl = new cApiLanguageCollection();
1647: $oLangColl->select();
1648: while (($oItem = $oLangColl->next()) !== false) {
1649: $aLanguageEncodings[$oItem->get('idlang')] = $oItem->get('encoding');
1650: }
1651:
1652: $charset = 'utf-8';
1653: if (isset($aLanguageEncodings[$lang])) {
1654: if (in_array($aLanguageEncodings[$lang], $cfg['AvailableCharsets'])) {
1655: $charset = $aLanguageEncodings[$lang];
1656: }
1657: }
1658: header('Content-Type: ' . $contentType . '; charset=' . $charset);
1659: }
1660: }
1661:
1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669:
1670: function ipMatch($network, $mask, $ip) {
1671: bcscale(3);
1672: $ip_long = ip2long($ip);
1673: $mask_long = ip2long($network);
1674:
1675:
1676: if (preg_match('/^[0-9]+$/', $mask)) {
1677:
1678: $divider = bcpow(2, (32 - $mask));
1679: } else {
1680:
1681: $xmask = ip2long($mask);
1682: if ($xmask < 0) {
1683: $xmask = bcadd(bcpow(2, 32), $xmask);
1684: }
1685: $divider = bcsub(bcpow(2, 32), $xmask);
1686: }
1687:
1688: if (floor(bcdiv($ip_long, $divider)) == floor(bcdiv($mask_long, $divider))) {
1689:
1690: return true;
1691: } else {
1692:
1693: return false;
1694: }
1695: }
1696:
1697: 1698: 1699: 1700: 1701: 1702: 1703:
1704: function isFunctionDisabled($functionName) {
1705: static $disabledFunctions;
1706:
1707: if (empty($functionName)) {
1708: return true;
1709: }
1710:
1711: if (!isset($disabledFunctions)) {
1712: $disabledFunctions = array_map('trim', explode(',', ini_get('disable_functions')));
1713: }
1714:
1715: return (in_array($functionName, $disabledFunctions));
1716: }
1717:
1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729:
1730: function renderBackendBreadcrumb($syncoptions, $showArticle = true, $return = false) {
1731: $tplBread = new cTemplate();
1732: $tplBread->set('s', 'LABEL', i18n("You are here"));
1733: $syncoptions = (int) $syncoptions;
1734:
1735: $helper = cCategoryHelper::getInstance();
1736: $categories = $helper->getCategoryPath(cRegistry::getCategoryId(), 1);
1737: $catIds = array_reverse($helper->getParentCategoryIds(cRegistry::getCategoryId()));
1738: $catIds[] = cRegistry::getCategoryId();
1739: $catCount = count($categories);
1740: $tplCfg = new cApiTemplateConfiguration();
1741: $sess = cRegistry::getSession();
1742: $cfg = cRegistry::getConfig();
1743: $lang = cRegistry::getLanguageId();
1744: $idart = cRegistry::getArticleId();
1745:
1746: for ($i = 0; $i < $catCount; $i++) {
1747: $idcat_tpl = 0;
1748: $idcat_bread = $categories[$i]->getField('idcat');
1749: $idcat_name = $categories[$i]->getField('name');
1750: $idcat_tplcfg = $categories[$i]->getField('idtplcfg');
1751: if ((int) $idcat_tplcfg > 0) {
1752: $tplCfg->loadByPrimaryKey($idcat_tplcfg);
1753: if ($tplCfg->isLoaded()) {
1754: $idcat_tpl = $tplCfg->getField('idtpl');
1755: }
1756: }
1757:
1758: $linkUrl = $sess->url(cRegistry::getBackendUrl() . "main.php?area=con&frame=4&idcat=$idcat_bread&idtpl=$idcat_tpl&syncoptions=$syncoptions&contenido=1");
1759:
1760: $disabled = false;
1761: if(!$categories[$i]->isLoaded() && $syncoptions > 0) {
1762: $idcat_name = sprintf(i18n("Unsynchronized category (%s)"), $catIds[$i]);
1763: $linkUrl = "#";
1764: $disabled = true;
1765: }
1766: $tplBread->set('d', 'LINK', $linkUrl);
1767: $tplBread->set('d', 'NAME', $idcat_name);
1768: $tplBread->set('d', 'DISABLED', $disabled ? 'disabled' : '');
1769:
1770: $sepArrow = '';
1771: if ($i < $catCount - 1) {
1772: $sepArrow = ' > ';
1773: } else {
1774: if ((int) $idart > 0 && $showArticle === true) {
1775: $art = new cApiArticleLanguage();
1776: $art->loadByArticleAndLanguageId($idart, $lang);
1777: if ($art->isLoaded()) {
1778: $name = $art->getField('title');
1779: $sepArrow = ' > ' . $name;
1780: }
1781: }
1782: }
1783: $tplBread->set('d', 'SEP_ARROW', $sepArrow);
1784:
1785: $tplBread->next();
1786: }
1787:
1788: return $tplBread->generate($cfg['path']['templates'] . $cfg['templates']['breadcrumb'], $return);
1789: }
1790: