* @license http://www.contenido.org/license/LIZENZ.txt * @link http://www.4fb.de * @link http://www.contenido.org * @since file available since contenido release <= 4.6 * * {@internal * created 2002-03-02 * modified 2007-04-24, Holger Librenz * modified 2008-02-13, Andreas Lindner * modified 2008-06-27, Frederic Schneider, add security fix * modified 2008-09-08, Ingo van Peeren, optimized HTML, added AJAX an javascript to prevent * reloading of navigation tree, small sql performance * improvement * modified 2009-12-18, Murat Purc, fixed usage of wrong db instance, see [#CON-282] * modified 2010-01-30, Ingo van Peeren, optimized amount of db queries, removed unused variables * * $Id$: * }} * */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } cInclude("includes", "functions.str.php"); cInclude("includes", "functions.tpl.php"); cInclude('includes', 'functions.lang.php'); function showTree($iIdcat, &$aWholelist) { global $check_global_rights, $sess, $cfg, $perm, $db, $db2, $db3, $area, $client, $lang, $navigationTree; $tpl = new Template; $tpl->reset(); $iIdcat = (int) $iIdcat; foreach ($navigationTree[$iIdcat] as $sKey => $aValue) { $cfgdata = ''; $aCssClasses = array(); #Check rights per cat if (!$check_global_rights) { $check_rights = false; } else { $check_rights = true; } if (!$check_rights) { $check_rights = ($aValue['forcedisplay'] == 1) ? true : false; } $idcat = (int) $aValue['idcat']; $level = $aValue['level'] - 1; $name = $aValue['name']; if ($check_rights) { $idtpl = ( $aValue['idtpl'] != '' ) ? $aValue['idtpl'] : 0; if (($aValue["idlang"] != $lang) || ($aValue['articles'] == true)) { #$aCssClasses[] = 'con_sync'; } $check_rights = $perm->have_perm_area_action_item("con", "con_changetemplate", $aValue['idcat']); if (!$check_rights) { $check_rights = $perm->have_perm_area_action("con", "con_changetemplate"); } if ($check_rights) { $changetemplate = 1; } else { $changetemplate = 0; } $check_rights = $perm->have_perm_area_action_item("con", "con_makecatonline", $aValue['idcat']); if (!$check_rights) { $check_rights = $perm->have_perm_area_action("con", "con_makecatonline"); } if ($check_rights) { $onoffline = 1; } else { $onoffline = 0; } $check_rights = $perm->have_perm_area_action_item("con", "con_makepublic", $aValue['idcat']); if (!$check_rights) { $check_rights = $perm->have_perm_area_action("con", "con_makepublic"); } if ($check_rights) { $makepublic = 1; } else { $makepublic = 0; } $check_rights = $perm->have_perm_area_action_item("con", "con_tplcfg_edit", $aValue['idcat']); if (!$check_rights) { $check_rights = $perm->have_perm_area_action("con", "con_tplcfg_edit"); } if ($check_rights) { $templateconfig = 1; } else { $templateconfig = 0; } if ($aValue["idlang"] == $lang) { # Build cfgdata string $cfgdata = $idcat . "-" . $idtpl . "-" . $aValue['online'] . "-" . $aValue['public'] . "-" . $changetemplate . "-" . $onoffline . "-" . $makepublic . "-" . $templateconfig; } else { $cfgdata = ""; } # Select the appropriate folder- # image depending on the structure # properties if ($aValue['online'] == 1) { # Category is online if ($aValue['public'] == 0) { # Category is locked if ($aValue['no_start'] || $aValue['no_online']) { # Error found $aAnchorClass = 'on_error_locked'; } else { # No error found $aAnchorClass = 'on_locked'; } } else { # Category is public if ($aValue['no_start'] || $aValue['no_online']) { # Error found $aAnchorClass = 'on_error'; } else { # No error found $aAnchorClass = 'on'; } } } else { # Category is offline if ($aValue['public'] == 0) { # Category is locked if ($aValue['no_start'] || $aValue['no_online']) { # Error found $aAnchorClass = 'off_error_locked'; } else { # No error found $aAnchorClass = 'off_locked'; } } else { # Category is public if ($aValue['no_start'] || $aValue['no_online']) { # Error found $aAnchorClass = 'off_error'; } else { # No error found $aAnchorClass = 'off'; } } } if ($aValue['islast'] == 1) { $aCssClasses[] = 'last'; } if ($aValue['collapsed'] == 1 && isset($navigationTree[$idcat]) && is_array($navigationTree[$idcat])) { $aCssClasses[] = 'collapsed'; } if ($aValue['active']) { $aCssClasses[] = 'active'; } $bIsSyncable = false; if ($aValue["idlang"] != $lang) { # Fetch parent id and check if it is syncronized $sql = "SELECT parentid FROM %s WHERE idcat = '%s'"; $db->query(sprintf($sql, $cfg["tab"]["cat"], $idcat)); if ($db->next_record()) { if ($db->f("parentid") != 0) { $parentid = $db->f("parentid"); $sql = "SELECT idcatlang FROM %s WHERE idcat = '%s' AND idlang = '%s'"; $db->query(sprintf($sql, $cfg["tab"]["cat_lang"], Contenido_Security::toInteger($parentid), Contenido_Security::toInteger($lang))); if ($db->next_record()) { $aCssClasses[] = 'con_sync'; $bIsSyncable = true; } } else { $aCssClasses[] = 'con_sync'; $bIsSyncable = true; } } } //Last param defines if cat is syncable or not, all other rights are disabled at this point if ($bIsSyncable) { if ($cfgdata != '') { $cfgdata .= '-1'; } else { $cfgdata = $idcat . "-" . $idtpl . "-" . $aValue['online'] . "-" . $aValue['public'] . "-0-0-0-0-1"; } } else { if ($cfgdata != '') { $cfgdata .= '-0'; } else { $cfgdata = $idcat . "-" . $idtpl . "-" . $aValue['online'] . "-" . $aValue['public'] . "-0-0-0-0-0"; } } if(isset($aValue['lang_fallback_name']) && !empty($aValue['lang_fallback_name'])) { $titel = $aValue['lang_fallback_name']."\nidcat".': '. $idcat; } else { $title = "idcat".': '. $idcat; } $mstr = '' . $name . ''; # Build Tree $tpl->set('d', 'CFGDATA', $cfgdata); if (isset($navigationTree[$idcat]) && is_array($navigationTree[$idcat])) { $tpl->set('d', 'SUBCATS', showTree($idcat, $aWholelist)); $tpl->set('d', 'COLLAPSE', ' '); $aWholelist[] = $idcat; } else { $tpl->set('d', 'SUBCATS', ''); $tpl->set('d', 'COLLAPSE', ' '); } $tpl->set('d', 'CAT', $mstr); $tpl->set('d', 'CSS_CLASS', ' class="' . implode(' ', $aCssClasses) . '"'); $tpl->next(); } // end if have_perm else { if (is_array($navigationTree[(int) $aValue['idcat']])) { $sTpl = showTree((int) $aValue['idcat'], $aWholelist); if (!preg_match('/^