Merge pull request #2672 from rabuzarus/1007-page_template
add possibility to load custom page templates + none.php pagetemplate…
This commit is contained in:
commit
2a088d27d0
|
@ -399,7 +399,7 @@ function acl_lookup(&$a, $out_type = 'json') {
|
||||||
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
|
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
|
||||||
$search = (x($_REQUEST,'search') ? $_REQUEST['search'] : "");
|
$search = (x($_REQUEST,'search') ? $_REQUEST['search'] : "");
|
||||||
$type = (x($_REQUEST,'type') ? $_REQUEST['type'] : "");
|
$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);
|
$conv_id = (x($_REQUEST,'conversation') ? $_REQUEST['conversation'] : null);
|
||||||
|
|
||||||
// For use with jquery.textcomplete for private mail completion
|
// For use with jquery.textcomplete for private mail completion
|
||||||
|
@ -690,7 +690,7 @@ function navbar_complete(&$a) {
|
||||||
$localsearch = get_config('system','poco_local_search');
|
$localsearch = get_config('system','poco_local_search');
|
||||||
|
|
||||||
$search = $prefix.notags(trim($_REQUEST['search']));
|
$search = $prefix.notags(trim($_REQUEST['search']));
|
||||||
$mode = $_REQUEST['mode'];
|
$mode = $_REQUEST['smode'];
|
||||||
|
|
||||||
// don't search if search term has less than 2 characters
|
// don't search if search term has less than 2 characters
|
||||||
if(! $search || mb_strlen($search) < 2)
|
if(! $search || mb_strlen($search) < 2)
|
||||||
|
|
|
@ -534,3 +534,41 @@ function upgrade_bool_message($bbcode = false) {
|
||||||
$x = upgrade_link($bbcode);
|
$x = upgrade_link($bbcode);
|
||||||
return t('This action is not available under your subscription plan.') . (($x) ? ' ' . $x : '') ;
|
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 '';
|
||||||
|
}
|
26
index.php
26
index.php
|
@ -500,21 +500,19 @@ $profile = $a->profile;
|
||||||
header("X-Friendica-Version: ".FRIENDICA_VERSION);
|
header("X-Friendica-Version: ".FRIENDICA_VERSION);
|
||||||
header("Content-type: text/html; charset=utf-8");
|
header("Content-type: text/html; charset=utf-8");
|
||||||
|
|
||||||
|
// We use $_GET["mode"] for special page templates. So we will check if we have
|
||||||
if (isset($_GET["mode"]) AND ($_GET["mode"] == "minimal")) {
|
// to load another page template than the default one
|
||||||
//$page['content'] = substr($target->saveHTML(), 6, -8)."\n\n".
|
// The page templates are located in /view/php/ or in the theme directory
|
||||||
// '<div id="conversation-end"></div>'."\n\n";
|
if (isset($_GET["mode"])) {
|
||||||
|
$template = theme_include($_GET["mode"].'.php');
|
||||||
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();
|
session_write_close();
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -41,7 +41,7 @@ function contact_search(term, callback, backend_url, type, mode) {
|
||||||
postdata['conversation'] = conv_id[0];
|
postdata['conversation'] = conv_id[0];
|
||||||
|
|
||||||
if(mode !== null)
|
if(mode !== null)
|
||||||
postdata['mode'] = mode;
|
postdata['smode'] = mode;
|
||||||
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file view/theme/frio/default.php
|
|
||||||
*
|
|
||||||
* @brief load site template in dependence of the mode
|
|
||||||
* You will find the site templates under:
|
|
||||||
* {{?themepath}}/php/modes/
|
|
||||||
*/
|
|
||||||
require_once('view/theme/frio/php/frio_boot.php');
|
|
||||||
|
|
||||||
|
|
||||||
// Check if page is defined as model and set it as modal
|
|
||||||
// This is a workaround, where we can't change the page the
|
|
||||||
// page mode in the template with javascript
|
|
||||||
$page_type = get_page_type($a->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";
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user