mirror of
https://github.com/BeitDina/AutoIndex.git
synced 2025-12-27 01:09:42 +01:00
Update TemplateIndexer.php for lowercase language keys
This commit is contained in:
committed by
GitHub
parent
31d20d14b9
commit
55b4c5f2df
@@ -4,7 +4,7 @@
|
||||
*ş
|
||||
* @copyright Copyright (C) 2002-2008 Justin Hagstrom, 2019-2023 Florin C Bodin
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
|
||||
* @version $Id: TemplateIndexer.php, v 2.2.6 2023/11/15 08:08:08 orynider Exp $
|
||||
* @version $Id: TemplateIndexer.php, v 2.2.6 2023/11/27 22:28:28 orynider Exp $
|
||||
* @link http://autoindex.sourceforge.net
|
||||
*/
|
||||
|
||||
@@ -79,7 +79,45 @@ class TemplateIndexer
|
||||
global $config;
|
||||
return $config->__get(strtolower($m[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all files in $path that match the filename format
|
||||
* of themes files.
|
||||
*
|
||||
* There are two valid formats for the filename of a template folder..
|
||||
*
|
||||
* @param string $path The directory to read from
|
||||
* @return array The list of valid theme names (based on directory name)
|
||||
*/
|
||||
public static function get_all_styles($path = PATH_TO_TEMPLATES)
|
||||
{
|
||||
if (($hndl = @opendir($path)) === false)
|
||||
{
|
||||
echo 'Did try to open dir: ' . $path;
|
||||
return false;
|
||||
}
|
||||
$installable_themes = array();
|
||||
while (($sub_dir = readdir($hndl)) !== false)
|
||||
{
|
||||
// get the sub-template path
|
||||
if( !is_file(@realpath($path . $sub_dir)) && !is_link(@realpath($path . $sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" )
|
||||
{
|
||||
if( @file_exists(realpath($path . $sub_dir . "/$sub_dir.css")) || @file_exists(realpath($path . $sub_dir . "/default.css")) )
|
||||
{
|
||||
$installable_themes[] = array('template' => $path . $sub_dir . '/', 'template_name' => $sub_dir);
|
||||
//echo 'Did try to open dir: ' . $path . $sub_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($hndl);
|
||||
|
||||
$last_style = count($installable_themes);
|
||||
for ($style_id = 0; $style_id < $last_style; $style_id++)
|
||||
{
|
||||
//remove the file extention from each language code
|
||||
$installable_themes[] = array($installable_themes['template'][$style_id], $installable_themes['template_name'][$style_id]);
|
||||
}
|
||||
return $installable_themes;
|
||||
}
|
||||
/**
|
||||
* Parses the text in $filename and sets the result to $out. We cannot
|
||||
* use ExceptionDisplay here if there is an error, since it uses the
|
||||
@@ -96,9 +134,13 @@ class TemplateIndexer
|
||||
*/
|
||||
public function __construct($filename)
|
||||
{
|
||||
global $config, $dir, $subdir, $words, $mobile_device_detect;
|
||||
global $config, $request, $dir, $subdir, $words, $mobile_device_detect;
|
||||
|
||||
$full_filename = $config->__get('template') . $filename;
|
||||
$style = $request->is_set('style') ? $request->variable('style', '') : 0;
|
||||
$themes = $this->get_all_styles($config->__get('template_path'));
|
||||
|
||||
$template_path = $request->is_set('style') ? $themes[$style]['template'] : $config->__get('template');
|
||||
$full_filename = $template_path . $filename;
|
||||
|
||||
if (!is_file($full_filename))
|
||||
{
|
||||
@@ -122,10 +164,10 @@ class TemplateIndexer
|
||||
'{info:version}' => VERSION,
|
||||
'{info:page_time}' => round((microtime(true) - START_TIME) * 1000, 1),
|
||||
'{info:statinfo}' => $mobile_device_detect->detect()->getInfo(),
|
||||
'{info:message}' => $words->__get('COOKIE_CONSENT_MSG'),
|
||||
'{info:dismiss}' => $words->__get('COOKIE_CONSENT_OK'),
|
||||
'{info:link}' => $words->__get('COOKIE_CONSENT_INFO'),
|
||||
'{info:href}' => $words->__get('PRIVACY')
|
||||
'{info:message}' => $words->__get('cookie consent msg'),
|
||||
'{info:dismiss}' => $words->__get('cookie consent OK'),
|
||||
'{info:link}' => $words->__get('cookie consent info'),
|
||||
'{info:href}' => $words->__get('privacy')
|
||||
);
|
||||
$contents = preg_replace_callback('/\{\s*words?\s*:\s*(.+)\s*\}/Ui',
|
||||
array('self', 'callback_words'), strtr($contents, $tr));
|
||||
|
||||
Reference in New Issue
Block a user