From e0f8b579ee4943b217cbb75a5411c2591b877677 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 14 Dec 2012 21:39:17 -0800 Subject: [PATCH] Very basic 'active' site-link detection. --- e107_core/templates/navigation_template.php | 12 ++++++------ e107_handlers/sitelinks_class.php | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/e107_core/templates/navigation_template.php b/e107_core/templates/navigation_template.php index 457d63e75..ef0e7053b 100644 --- a/e107_core/templates/navigation_template.php +++ b/e107_core/templates/navigation_template.php @@ -31,8 +31,8 @@ $NAVIGATION_TEMPLATE['main']['item_submenu'] = ' '; $NAVIGATION_TEMPLATE['main']['item_submenu_active'] = ' - @@ -91,7 +91,7 @@ $NAVIGATION_TEMPLATE['side']['item'] = '
  • {LINK_NAME} $NAVIGATION_TEMPLATE['side']['item_submenu'] = '
  • {LINK_SUB} '; -$NAVIGATION_TEMPLATE['side']['item_active'] = '
  • {LINK_NAME}
  • +$NAVIGATION_TEMPLATE['side']['item_active'] = '
  • {LINK_NAME}
  • '; $NAVIGATION_TEMPLATE['side']['end'] = ' @@ -102,7 +102,7 @@ $NAVIGATION_TEMPLATE['side']['submenu_start'] = ''; $NAVIGATION_TEMPLATE['side']['submenu_item'] = '
  • {LINK_NAME}
  • '; -$NAVIGATION_TEMPLATE['side']['submenu_item_active'] = '
  • {LINK_NAME}
  • +$NAVIGATION_TEMPLATE['side']['submenu_item_active'] = '
  • {LINK_NAME}
  • '; $NAVIGATION_TEMPLATE['side']['submenu_end'] = ''; diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index da367c61a..7c28a7ed6 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -813,7 +813,7 @@ class e_navigation $eplug_name = $tp->toHTML($eplug_name,FALSE,"defs, emotes_off"); $plugin_icon = $eplug_icon_small ? "" : E_16_PLUGIN; $plugin_icon_32 = $eplug_icon ? "" : E_32_PLUGIN; - $plugin_array['p-'.$plugin_path] = array('link' => e_PLUGIN.$plugin_path."/".$eplug_conffile, 'title' => $eplug_name, 'caption' => $eplug_caption, 'perms' => "P".$plug_id[$plugin_path], 'icon' => $plugin_icon, 'icon_32' => $plugin_icon_32); + $plugin_array['p-'.$plugin_path] = array('link' => e_PLUGIN.$plugin_path."/".$eplug_conffile, 'title' => $eplug_name, 'caption' => $eplug_caption, 'perms' => "P".varset($plug_id[$plugin_path]), 'icon' => $plugin_icon, 'icon_32' => $plugin_icon_32); } } } @@ -1491,11 +1491,23 @@ class e_navigation } /** - * TODO Active Link Detection; + * TODO Extensive Active Link Detection; * */ public function isActive($data='') { + $dbLink = e_HTTP. e107::getParser()->replaceConstants($data['link_url'], TRUE, TRUE);; + + if(E107_DBG_PATH) + { + e107::getMessage()->addDebug("db=".$dbLink); + } + + if(e_REQUEST_HTTP == $dbLink) + { + return true; + } + return false; } @@ -1529,7 +1541,7 @@ class navigation_shortcodes extends e_shortcode function sc_link_image($parm='') { - return e107::getParser()->replaceConstants($this->var['link_image']); + return e107::getParser()->replaceConstants(vartrue($this->var['link_image'])); } @@ -1551,7 +1563,7 @@ class navigation_shortcodes extends e_shortcode { $this->setVars($val); $active = (e107::getNav()->isActive($val)) ? "_active" : ""; - $tmpl = (count($val['link_sub'])>0) ? $this->template['submenu_loweritem'] : $this->template['submenu_item'.$active]; + $tmpl = vartrue($val['link_sub']) ? varset($this->template['submenu_loweritem']) : varset($this->template['submenu_item'.$active]); $text .= e107::getParser()->parseTemplate($tmpl, TRUE); }