From 07b6c868b3a66efc2737dfc6459b4114fea59ba0 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 17 Aug 2011 18:36:24 +0200 Subject: [PATCH] remove javascript to set selectect nav item. enanche img template prefetch ignoring --- boot.php | 2 ++ include/nav.php | 22 +++++++++++++++++++++- include/template_processor.php | 13 ++++++++----- index.php | 5 ++--- mod/community.php | 2 +- mod/contacts.php | 2 +- mod/directory.php | 2 +- mod/help.php | 3 ++- mod/message.php | 2 +- mod/network.php | 2 +- mod/notifications.php | 2 +- mod/profile.php | 5 +++-- mod/profiles.php | 2 +- mod/search.php | 2 ++ mod/settings.php | 2 +- view/nav.tpl | 19 ++++++++++--------- 16 files changed, 58 insertions(+), 29 deletions(-) diff --git a/boot.php b/boot.php index 39bb6a9da..399e100d0 100644 --- a/boot.php +++ b/boot.php @@ -5,6 +5,7 @@ require_once('include/network.php'); require_once('include/plugin.php'); require_once('include/text.php'); require_once("include/pgettext.php"); +require_once('include/nav.php'); define ( 'FRIENDIKA_VERSION', '2.2.1074' ); @@ -1156,3 +1157,4 @@ function load_contact_links($uid) { $a->contacts = $ret; return; }} + diff --git a/include/nav.php b/include/nav.php index bb1a5b2d8..f9e72bda7 100644 --- a/include/nav.php +++ b/include/nav.php @@ -157,8 +157,28 @@ function nav(&$a) { '$banner' => $banner, '$emptynotifications' => t('Nothing new here'), '$userinfo' => $userinfo, + '$sel' => $a->nav_sel, )); call_hooks('page_header', $a->page['nav']); - +} + +/* + * Set a menu item in navbar as selected + * + */ +function nav_set_selected($item){ + $a = get_app(); + $a->nav_sel = array( + 'community' => null, + 'network' => null, + 'home' => null, + 'profiles' => null, + 'notifications' => null, + 'messages' => null, + 'directyory' => null, + 'settings' => null, + 'contacts' => null, + ); + $a->nav_sel[$item] = 'selected'; } diff --git a/include/template_processor.php b/include/template_processor.php index f1d2eae4e..11769bbd0 100644 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -11,15 +11,18 @@ private function _preg_error(){ switch(preg_last_error()){ - case PREG_INTERNAL_ERROR: die('PREG_INTERNAL_ERROR'); break; - case PREG_BACKTRACK_LIMIT_ERROR: die('PREG_BACKTRACK_LIMIT_ERROR'); break; - case PREG_RECURSION_LIMIT_ERROR: die('PREG_RECURSION_LIMIT_ERROR'); break; - case PREG_BAD_UTF8_ERROR: die('PREG_BAD_UTF8_ERROR'); break; - case PREG_BAD_UTF8_OFFSET_ERROR: die('PREG_BAD_UTF8_OFFSET_ERROR'); break; + case PREG_INTERNAL_ERROR: echo('PREG_INTERNAL_ERROR'); break; + case PREG_BACKTRACK_LIMIT_ERROR: echo('PREG_BACKTRACK_LIMIT_ERROR'); break; + case PREG_RECURSION_LIMIT_ERROR: echo('PREG_RECURSION_LIMIT_ERROR'); break; + case PREG_BAD_UTF8_ERROR: echo('PREG_BAD_UTF8_ERROR'); break; + case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break; default: //die("Unknown preg error."); return; } + echo "
";
+			debug_print_backtrace();
+			die();
 		}
 		
 		private function _build_replace($r, $prefix){
diff --git a/index.php b/index.php
index 80e8ca3b0..51c87cae6 100644
--- a/index.php
+++ b/index.php
@@ -195,8 +195,8 @@ if(strlen($a->module)) {
 
 	if(! $a->module_loaded) {
 
-		// Stupid browser tried to pre-fetch our ACL img template. Don't log the event or return anything - just quietly exit.
-		if((x($_SERVER,'QUERY_STRING')) && strpos($_SERVER['QUERY_STRING'],'{0}') !== false) {
+		// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
+		if((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
 			killme();
 		}
 
@@ -306,7 +306,6 @@ $a->page['content'] .=  '
'; */ if($a->module != 'install') { - require_once('nav.php'); nav($a); } diff --git a/mod/community.php b/mod/community.php index f8bd88d86..cb255029f 100644 --- a/mod/community.php +++ b/mod/community.php @@ -25,7 +25,7 @@ function community_content(&$a, $update = 0) { $o .= '

' . t('Community') . '

'; if(! $update) { - $o .= set_nav_selected('nav-community-link'); + nav_set_selected('community'); $o .= '
' . "\r\n"; $o .= "\r\n"; } diff --git a/mod/contacts.php b/mod/contacts.php index f8b9a743f..eb1de25ad 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -124,7 +124,7 @@ function contacts_content(&$a) { $sort_type = 0; $o = ''; - $o .= set_nav_selected('nav-contacts-link'); + nav_set_selected('contacts'); $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; diff --git a/mod/directory.php b/mod/directory.php index 03b6ab4d1..93abcd5de 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -22,7 +22,7 @@ function directory_content(&$a) { } $o = ''; - $o .= set_nav_selected('nav-directory-link'); + nav_set_selected('directory'); if(x($_SESSION,'theme')) unset($_SESSION['theme']); diff --git a/mod/help.php b/mod/help.php index 495b4ccc2..59e062f6d 100644 --- a/mod/help.php +++ b/mod/help.php @@ -17,6 +17,7 @@ function load_doc_file($s) { function help_content(&$a) { + nav_set_selected('help'); global $lang; @@ -41,4 +42,4 @@ function help_content(&$a) { return Markdown($text); -} \ No newline at end of file +} diff --git a/mod/message.php b/mod/message.php index ff3db06e2..9e8999592 100644 --- a/mod/message.php +++ b/mod/message.php @@ -110,7 +110,7 @@ function message_post(&$a) { function message_content(&$a) { $o = ''; - $o .= set_nav_selected('nav-messages-link'); + nav_set_selected('messages'); if(! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/network.php b/mod/network.php index 7cac7b858..cf4c994f0 100644 --- a/mod/network.php +++ b/mod/network.php @@ -98,7 +98,7 @@ function network_content(&$a, $update = 0) { } } - $o .= set_nav_selected('nav-network-link'); + nav_set_selected('network'); $_SESSION['return_url'] = $a->cmd; diff --git a/mod/notifications.php b/mod/notifications.php index 920d0d82d..0c35d4cd1 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -64,7 +64,7 @@ function notifications_content(&$a) { } $o = ''; - $o .= set_nav_selected("nav-notifications-link"); + nav_set_selected("notifications"); if(($a->argc > 1) && ($a->argv[1] == 'all')) $sql_extra = ''; diff --git a/mod/profile.php b/mod/profile.php index b309ea647..5a66892da 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -69,8 +69,9 @@ function profile_content(&$a, $update = 0) { $a->profile['profile_uid'] = $update; } else { - if($a->profile['profile_uid'] == local_user()) - $o .= set_nav_selected('nav-home-link'); + if($a->profile['profile_uid'] == local_user()) { + nav_set_selected('home'); + } } $contact = null; diff --git a/mod/profiles.php b/mod/profiles.php index 9b0a2970b..5cc9fa38c 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -220,7 +220,7 @@ function profiles_post(&$a) { function profiles_content(&$a) { $o = ''; - $o .= set_nav_selected('nav-profiles-link'); + nav_set_selected('profiles'); if(! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/search.php b/mod/search.php index 88ff9bbb7..f7ce75905 100644 --- a/mod/search.php +++ b/mod/search.php @@ -13,6 +13,8 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } + + nav_set_selected('search'); require_once("include/bbcode.php"); require_once('include/security.php'); diff --git a/mod/settings.php b/mod/settings.php index 0223b1b9c..44ebdd77b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -299,7 +299,7 @@ if(! function_exists('settings_content')) { function settings_content(&$a) { $o = ''; - $o .= set_nav_selected('nav-settings-link'); + nav_set_selected('settings'); if(! local_user()) { notice( t('Permission denied.') . EOL ); diff --git a/view/nav.tpl b/view/nav.tpl index 0444ea75c..434c9f844 100644 --- a/view/nav.tpl +++ b/view/nav.tpl @@ -15,24 +15,25 @@ {{ if $nav.notifications }}
  • $nav.notifications.1
  • {{ endif }} {{ if $nav.messages }}
  • $nav.messages.1
  • {{ endif }} + {{ if $nav.contacts }}
  • $nav.contacts.1{{ endif }}
  • {{ endif }} {{ if $nav.community }} - {{ endif }} {{ if $nav.network }} - {{ endif }} - {{ if $nav.network }} - @@ -67,19 +68,19 @@ - - - {{ if $nav.apps }} - {{ endif }} @@ -122,7 +123,7 @@ {{ if $nav.settings }}$nav.settings.1{{ endif }} {{ if $nav.profiles }}$nav.profiles.1{{ endif }} -{{ if $nav.contacts }}$nav.contacts.1{{ endif }} +