Commit 782302f8 by pupi1985

Themes are now sorted by theme name fetched from metadata rather than directory name

parent 612a817f
...@@ -137,26 +137,25 @@ ...@@ -137,26 +137,25 @@
} }
function qa_admin_theme_options() /**
/* * Return a sorted array of available themes, [theme name] => [theme name]
Return a sorted array of available themes, [theme name] => [theme name] */
*/ function qa_admin_theme_options() {
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$options=array(); $metadataUtil = new Q2A_Util_Metadata();
foreach (glob(QA_THEME_DIR . '*', GLOB_NOSORT | GLOB_MARK) as $directory) {
$directory=@opendir(QA_THEME_DIR); $theme = basename($directory);
if (is_resource($directory)) { $metadata = $metadataUtil->fetchFromAddonPath($directory);
while (($theme=readdir($directory))!==false) if (empty($metadata)) {
if ( (substr($theme, 0, 1)!='.') && file_exists(QA_THEME_DIR.$theme.'/qa-styles.css') ) // limit theme parsing to first 8kB
$options[$theme]=$theme; $contents = file_get_contents($directory . '/qa-styles.css', false, NULL, -1, 8192);
$metadata = qa_addon_metadata($contents, 'Theme');
closedir($directory); }
$options[$theme] = isset($metadata['name']) ? $metadata['name'] : $theme;
} }
asort($options, SORT_STRING); asort($options, SORT_STRING);
return $options; return $options;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment