From: rabuzarus <> Date: Mon, 11 Jul 2016 08:33:39 +0000 (+0200) Subject: add possibility to load custom page templates + none.php pagetemplate is part of... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=15471f383528a17c7373a1ef61ddd7ffb59faf06;p=friendica.git add possibility to load custom page templates + none.php pagetemplate is part of core now --- diff --git a/include/acl_selectors.php b/include/acl_selectors.php index fc3df52327..76f0e0b796 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -399,7 +399,7 @@ function acl_lookup(&$a, $out_type = 'json') { $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100); $search = (x($_REQUEST,'search') ? $_REQUEST['search'] : ""); $type = (x($_REQUEST,'type') ? $_REQUEST['type'] : ""); - $mode = (x($_REQUEST,'mode') ? $_REQUEST['mode'] : ""); + $mode = (x($_REQUEST,'smode') ? $_REQUEST['smode'] : ""); $conv_id = (x($_REQUEST,'conversation') ? $_REQUEST['conversation'] : null); // For use with jquery.textcomplete for private mail completion @@ -690,7 +690,7 @@ function navbar_complete(&$a) { $localsearch = get_config('system','poco_local_search'); $search = $prefix.notags(trim($_REQUEST['search'])); - $mode = $_REQUEST['mode']; + $mode = $_REQUEST['smode']; // don't search if search term has less than 2 characters if(! $search || mb_strlen($search) < 2) diff --git a/include/plugin.php b/include/plugin.php index 2cb94b3504..e2bd23ee2a 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -534,3 +534,41 @@ function upgrade_bool_message($bbcode = false) { $x = upgrade_link($bbcode); return t('This action is not available under your subscription plan.') . (($x) ? ' ' . $x : '') ; } + +/** + * @brief Get the full path to relevant theme files by filename + * + * This function search in the theme directory (and if not present in global theme directory) + * if there is a directory with the file extension and for a file with the given + * filename. + * + * @param string $file Filename + * @param string $root Full root path + * @return string Path to the file or empty string if the file isn't found + */ +function theme_include($file, $root = '') { + // Make sure $root ends with a slash / if it's not blank + if($root !== '' && $root[strlen($root)-1] !== '/') + $root = $root . '/'; + $theme_info = $a->theme_info; + if(array_key_exists('extends',$theme_info)) + $parent = $theme_info['extends']; + else + $parent = 'NOPATH'; + $theme = current_theme(); + $thname = $theme; + $ext = substr($file,strrpos($file,'.')+1); + $paths = array( + "{$root}view/theme/$thname/$ext/$file", + "{$root}view/theme/$parent/$ext/$file", + "{$root}view/$ext/$file", + ); + foreach($paths as $p) { + // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) + if(strpos($p,'NOPATH') !== false) + continue; + if(file_exists($p)) + return $p; + } + return ''; +} \ No newline at end of file diff --git a/index.php b/index.php index 7b41403351..6ce348eac5 100644 --- a/index.php +++ b/index.php @@ -500,21 +500,19 @@ $profile = $a->profile; header("X-Friendica-Version: ".FRIENDICA_VERSION); header("Content-type: text/html; charset=utf-8"); +// We use $_GET["mode"] for special page templates. So we will check if we have +// to load another page template than the default one +// The page templates are located in /view/php/ or in the theme directory +if (isset($_GET["mode"])) { + $template = theme_include($_GET["mode"].'.php'); +} -if (isset($_GET["mode"]) AND ($_GET["mode"] == "minimal")) { - //$page['content'] = substr($target->saveHTML(), 6, -8)."\n\n". - // '
'."\n\n"; - - require "view/minimal.php"; -} else { - $template = 'view/theme/' . current_theme() . '/' - . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php'; - - if(file_exists($template)) - require_once($template); - else - require_once(str_replace('theme/' . current_theme() . '/', '', $template)); +// If there is no page template use the default page template +if(!$template) { + $template = theme_include("default.php"); } +require_once($template); + session_write_close(); exit; diff --git a/js/autocomplete.js b/js/autocomplete.js index 8020478722..d0c770cc4b 100644 --- a/js/autocomplete.js +++ b/js/autocomplete.js @@ -41,7 +41,7 @@ function contact_search(term, callback, backend_url, type, mode) { postdata['conversation'] = conv_id[0]; if(mode !== null) - postdata['mode'] = mode; + postdata['smode'] = mode; $.ajax({ diff --git a/view/default.php b/view/default.php deleted file mode 100644 index df9adbc392..0000000000 --- a/view/default.php +++ /dev/null @@ -1,19 +0,0 @@ - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - - - - -
- -
- -
- - - - diff --git a/view/minimal.php b/view/minimal.php deleted file mode 100644 index a131e3ec5e..0000000000 --- a/view/minimal.php +++ /dev/null @@ -1,14 +0,0 @@ - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - - -
- -
- - - diff --git a/view/php/default.php b/view/php/default.php new file mode 100644 index 0000000000..df9adbc392 --- /dev/null +++ b/view/php/default.php @@ -0,0 +1,19 @@ + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + + + + +
+ +
+ +
+ + + + diff --git a/view/php/minimal.php b/view/php/minimal.php new file mode 100644 index 0000000000..a131e3ec5e --- /dev/null +++ b/view/php/minimal.php @@ -0,0 +1,14 @@ + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + + +
+ +
+ + + diff --git a/view/php/none.php b/view/php/none.php new file mode 100644 index 0000000000..5b96e282e3 --- /dev/null +++ b/view/php/none.php @@ -0,0 +1,11 @@ + - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - -module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> - - - module === 'home' ) { ?> -
-
- -
-
- - module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { - ?> -
-
-
-
- - - -
- -
- module === 'settings' || $a->module === 'message' || $a->module === 'profile') && x($page,'aside')) echo $page['aside']; ?> -
- -
-
- - module === 'contacts') && x($page,'aside')) echo $page['aside']; ?> - - -
- - - - - diff --git a/view/theme/decaf-mobile/php/default.php b/view/theme/decaf-mobile/php/default.php new file mode 100644 index 0000000000..ad464760f7 --- /dev/null +++ b/view/theme/decaf-mobile/php/default.php @@ -0,0 +1,44 @@ + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + +module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> + + + module === 'home' ) { ?> +
+
+ +
+
+ + module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { + ?> +
+
+
+
+ + + +
+ +
+ module === 'settings' || $a->module === 'message' || $a->module === 'profile') && x($page,'aside')) echo $page['aside']; ?> +
+ +
+
+ + module === 'contacts') && x($page,'aside')) echo $page['aside']; ?> + + +
+ + + + + diff --git a/view/theme/dispy/default.php b/view/theme/dispy/default.php deleted file mode 100644 index c3e6c91196..0000000000 --- a/view/theme/dispy/default.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - <?php if(x($page,'title')) echo $page['title']; ?> - - - - -
- -
-
-
- -
- - -
- -
-
-
- - - -
- - - - - diff --git a/view/theme/dispy/php/default.php b/view/theme/dispy/php/default.php new file mode 100644 index 0000000000..c3e6c91196 --- /dev/null +++ b/view/theme/dispy/php/default.php @@ -0,0 +1,44 @@ + + + + <?php if(x($page,'title')) echo $page['title']; ?> + + + + +
+ +
+
+
+ +
+ + +
+ +
+
+
+ + + +
+ + + + + diff --git a/view/theme/frio/default.php b/view/theme/frio/default.php deleted file mode 100644 index 0faa7d97bb..0000000000 --- a/view/theme/frio/default.php +++ /dev/null @@ -1,32 +0,0 @@ -argv[0]); - -// This is uncommented because we don't need it anymore. -// We try to to use links which resulting in $_GET["mode"] = "none" -//if($page_type === "none") { -// $_GET["mode"] = "none"; -//} - -if((isset($_GET["mode"]) AND ($_GET["mode"] == "none"))) { - - require "view/theme/frio/php/modes/none.php"; -} elseif($page_type === "standard_page") { - require "view/theme/frio/php/modes/standard.php"; -} else { - require "view/theme/frio/php/modes/default.php"; -} - diff --git a/view/theme/frio/php/default.php b/view/theme/frio/php/default.php new file mode 100644 index 0000000000..6f9c1a4b06 --- /dev/null +++ b/view/theme/frio/php/default.php @@ -0,0 +1,134 @@ + + + + + + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + + get_baseurl(); ?> + + + + + +"; +} +else +{ + echo""; +} +?> +Skip to main content + +
+ +
+
+
+
+ + "; if(x($page,'aside')) echo $page['aside']; echo" + "; if(x($page,'right_aside')) echo $page['right_aside']; echo" + + + +
+
+
+ "; if(x($page,'aside')) echo $page['aside']; echo" + "; if(x($page,'right_aside')) echo $page['right_aside']; echo" +
+
+
+ +
+
argv[0]; echo "-content-wrapper\">"; + if(x($page,'content')) echo $page['content']; echo" +
+
+
+ "; + } + else + { + echo" +
+ "; if(x($page,'content')) echo $page['content']; echo" +
+ "; + } +?> + +
+
+ +
+
+ + + + diff --git a/view/theme/frio/php/modes/default.php b/view/theme/frio/php/modes/default.php deleted file mode 100644 index 6f9c1a4b06..0000000000 --- a/view/theme/frio/php/modes/default.php +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - - get_baseurl(); ?> - - - - - -"; -} -else -{ - echo""; -} -?> -Skip to main content - -
- -
-
-
-
- - "; if(x($page,'aside')) echo $page['aside']; echo" - "; if(x($page,'right_aside')) echo $page['right_aside']; echo" - - - -
-
-
- "; if(x($page,'aside')) echo $page['aside']; echo" - "; if(x($page,'right_aside')) echo $page['right_aside']; echo" -
-
-
- -
-
argv[0]; echo "-content-wrapper\">"; - if(x($page,'content')) echo $page['content']; echo" -
-
-
- "; - } - else - { - echo" -
- "; if(x($page,'content')) echo $page['content']; echo" -
- "; - } -?> - -
-
- -
-
- - - - diff --git a/view/theme/frio/php/modes/none.php b/view/theme/frio/php/modes/none.php deleted file mode 100644 index 5b96e282e3..0000000000 --- a/view/theme/frio/php/modes/none.php +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - - - get_baseurl(); ?> - - - - - -"; - -Skip to main content - -
- -
-
- - "; if(x($page,'aside')) echo $page['aside']; echo" - "; if(x($page,'right_aside')) echo $page['right_aside']; echo" - "; include('includes/photo_side.php'); echo" - - -
-
-
- "; if(x($page,'aside')) echo $page['aside']; echo" - "; if(x($page,'right_aside')) echo $page['right_aside']; echo" - "; include('includes/photo_side.php'); echo" -
-
-
- -
-
-
argv[0]; echo "-content-wrapper\"> -
"; - if(x($page,'content')) echo $page['content']; echo" -
-
-
-
-
- "; -?> - -
-
- -
-
- - - diff --git a/view/theme/frio/php/standard.php b/view/theme/frio/php/standard.php new file mode 100644 index 0000000000..93007bca5e --- /dev/null +++ b/view/theme/frio/php/standard.php @@ -0,0 +1,142 @@ + + + + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + + + get_baseurl(); ?> + + + + + +"; + +Skip to main content + +
+ +
+
+ + "; if(x($page,'aside')) echo $page['aside']; echo" + "; if(x($page,'right_aside')) echo $page['right_aside']; echo" + "; include('includes/photo_side.php'); echo" + + +
+
+
+ "; if(x($page,'aside')) echo $page['aside']; echo" + "; if(x($page,'right_aside')) echo $page['right_aside']; echo" + "; include('includes/photo_side.php'); echo" +
+
+
+ +
+
+
argv[0]; echo "-content-wrapper\"> +
"; + if(x($page,'content')) echo $page['content']; echo" +
+
+
+
+
+ "; +?> + +
+
+ +
+
+ + + diff --git a/view/theme/frost-mobile/default.php b/view/theme/frost-mobile/default.php deleted file mode 100644 index 332291ca92..0000000000 --- a/view/theme/frost-mobile/default.php +++ /dev/null @@ -1,45 +0,0 @@ - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - -module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> - - - module === 'home' ) { ?> -
-
- -
-
- - module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { - ?> -
-
-
-
- - - -
- -
- module === 'settings' || $a->module === 'message' || $a->module === 'profile') && x($page,'aside')) echo $page['aside']; ?> -
- -
- -
-
- - module === 'contacts') && x($page,'aside')) echo $page['aside']; ?> - - -
- - - - diff --git a/view/theme/frost-mobile/php/default.php b/view/theme/frost-mobile/php/default.php new file mode 100644 index 0000000000..332291ca92 --- /dev/null +++ b/view/theme/frost-mobile/php/default.php @@ -0,0 +1,45 @@ + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + +module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> + + + module === 'home' ) { ?> +
+
+ +
+
+ + module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { + ?> +
+
+
+
+ + + +
+ +
+ module === 'settings' || $a->module === 'message' || $a->module === 'profile') && x($page,'aside')) echo $page['aside']; ?> +
+ +
+ +
+
+ + module === 'contacts') && x($page,'aside')) echo $page['aside']; ?> + + +
+ + + + diff --git a/view/theme/frost/default.php b/view/theme/frost/default.php deleted file mode 100644 index c67bdcf20e..0000000000 --- a/view/theme/frost/default.php +++ /dev/null @@ -1,43 +0,0 @@ - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - -module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> - - - module === 'home' ) { ?> -
-
- -
-
- - module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { - ?> -
-
-
-
- - - -
- -
- -
- -
- -
- - -
-
- - - - diff --git a/view/theme/frost/php/default.php b/view/theme/frost/php/default.php new file mode 100644 index 0000000000..c67bdcf20e --- /dev/null +++ b/view/theme/frost/php/default.php @@ -0,0 +1,43 @@ + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + +module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> + + + module === 'home' ) { ?> +
+
+ +
+
+ + module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { + ?> +
+
+
+
+ + + +
+ +
+ +
+ +
+ +
+ + +
+
+ + + + diff --git a/view/theme/smoothly/default.php b/view/theme/smoothly/default.php deleted file mode 100644 index 405e1cad34..0000000000 --- a/view/theme/smoothly/default.php +++ /dev/null @@ -1,45 +0,0 @@ - - - - <?php if(x($page,'title')) echo $page['title'] ?> - - - - - -
- -
- - - - - -
- -
- -
- - - - - - - - - - - - - diff --git a/view/theme/smoothly/php/default.php b/view/theme/smoothly/php/default.php new file mode 100644 index 0000000000..405e1cad34 --- /dev/null +++ b/view/theme/smoothly/php/default.php @@ -0,0 +1,45 @@ + + + + <?php if(x($page,'title')) echo $page['title'] ?> + + + + + +
+ +
+ + + + + +
+ +
+ +
+ + + + + + + + + + + + +