mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 09:49:30 +02:00
Add UI::find_template method and its allow_php_themes argument
This commit is contained in:
parent
d48575fcf6
commit
35477d0a5e
2 changed files with 32 additions and 6 deletions
|
@ -972,3 +972,10 @@ encode_ss_duration = "-t %DURATION%"
|
||||||
; so that the ordering is sane.
|
; so that the ordering is sane.
|
||||||
; DEFAULT: auto
|
; DEFAULT: auto
|
||||||
;mb_detect_order = "ASCII,UTF-8,EUC-JP,ISO-2022-JP,SJIS,JIS"
|
;mb_detect_order = "ASCII,UTF-8,EUC-JP,ISO-2022-JP,SJIS,JIS"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; This setting allows themes to overwrite PHP template files. This can be really
|
||||||
|
; dangerous. Do this only if you trust every theme in your themes/ directory.
|
||||||
|
; DEFAULT: false
|
||||||
|
;allow_php_themes = "false"
|
||||||
|
|
|
@ -34,6 +34,25 @@ class UI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find_template
|
||||||
|
*
|
||||||
|
* Return the path to the template file wanted. The file can be overwriten
|
||||||
|
* by the theme if it's not a php file, or if it is and if option
|
||||||
|
* allow_php_themes is set to true.
|
||||||
|
*/
|
||||||
|
public static function find_template($template)
|
||||||
|
{
|
||||||
|
$path = AmpConfig::get('theme_path') . '/templates/' . $template;
|
||||||
|
$realpath = AmpConfig::get('prefix') . $path;
|
||||||
|
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
if(($extension != 'php' || AmpConfig::get('allow_php_themes'))
|
||||||
|
&& file_exists($realpath) && is_file($realpath))
|
||||||
|
return $path;
|
||||||
|
else
|
||||||
|
return '/templates/' . $template;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* access_denied
|
* access_denied
|
||||||
*
|
*
|
||||||
|
@ -44,7 +63,7 @@ class UI
|
||||||
// Clear any buffered crap
|
// Clear any buffered crap
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
header("HTTP/1.1 403 $error");
|
header("HTTP/1.1 403 $error");
|
||||||
require_once AmpConfig::get('prefix') . '/templates/show_denied.inc.php';
|
require_once AmpConfig::get('prefix') . UI::find_template('show_denied.inc.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +76,7 @@ class UI
|
||||||
public static function ajax_include($template)
|
public static function ajax_include($template)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
require AmpConfig::get('prefix') . '/templates/' . $template;
|
require AmpConfig::get('prefix') . UI::find_template('') . $template;
|
||||||
$output = ob_get_contents();
|
$output = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
|
@ -274,7 +293,7 @@ END;
|
||||||
*/
|
*/
|
||||||
public static function show_header()
|
public static function show_header()
|
||||||
{
|
{
|
||||||
require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
|
require_once AmpConfig::get('prefix') . UI::find_template('header.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,7 +315,7 @@ END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once AmpConfig::get('prefix') . '/templates/footer.inc.php';
|
require_once AmpConfig::get('prefix') . UI::find_template('footer.inc.php');
|
||||||
if (isset($_REQUEST['profiling'])) {
|
if (isset($_REQUEST['profiling'])) {
|
||||||
Dba::show_profile();
|
Dba::show_profile();
|
||||||
}
|
}
|
||||||
|
@ -309,7 +328,7 @@ END;
|
||||||
*/
|
*/
|
||||||
public static function show_box_top($title = '', $class = '')
|
public static function show_box_top($title = '', $class = '')
|
||||||
{
|
{
|
||||||
require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
|
require AmpConfig::get('prefix') . UI::find_template('show_box_top.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -319,7 +338,7 @@ END;
|
||||||
*/
|
*/
|
||||||
public static function show_box_bottom()
|
public static function show_box_bottom()
|
||||||
{
|
{
|
||||||
require AmpConfig::get('prefix') . '/templates/show_box_bottom.inc.php';
|
require AmpConfig::get('prefix') . UI::find_template('show_box_bottom.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function show_custom_style()
|
public static function show_custom_style()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue