Commit 89b717fa by pupi1985

Minor fixes and improvements to the new metadata system

parent 13012857
...@@ -44,7 +44,7 @@ class Q2A_Util_Metadata ...@@ -44,7 +44,7 @@ class Q2A_Util_Metadata
*/ */
public function fetchFromAddonPath($path) public function fetchFromAddonPath($path)
{ {
$metadataFile = $path . self::METADATA_FILE_JSON; $metadataFile = $path . '/' . self::METADATA_FILE_JSON;
if (is_file($metadataFile)) { if (is_file($metadataFile)) {
$content = file_get_contents($metadataFile); $content = file_get_contents($metadataFile);
return $this->getArrayFromJson($content); return $this->getArrayFromJson($content);
......
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
// find all language folders // find all language folders
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
foreach (glob(QA_LANG_DIR.'*', GLOB_NOSORT | GLOB_MARK) as $directory) { foreach (glob(QA_LANG_DIR . '*', GLOB_NOSORT | GLOB_ONLYDIR) as $directory) {
$code = basename($directory); $code = basename($directory);
$metadata = $metadataUtil->fetchFromAddonPath($directory); $metadata = $metadataUtil->fetchFromAddonPath($directory);
if (isset($metadata['display_name'])) if (isset($metadata['display_name']))
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
} }
asort($options, SORT_STRING); asort($options, SORT_STRING);
return $options; return $options;
} }
...@@ -144,7 +143,7 @@ ...@@ -144,7 +143,7 @@
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); }
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
foreach (glob(QA_THEME_DIR . '*', GLOB_NOSORT | GLOB_MARK) as $directory) { foreach (glob(QA_THEME_DIR . '*', GLOB_NOSORT | GLOB_ONLYDIR) as $directory) {
$theme = basename($directory); $theme = basename($directory);
$metadata = $metadataUtil->fetchFromAddonPath($directory); $metadata = $metadataUtil->fetchFromAddonPath($directory);
if (empty($metadata)) { if (empty($metadata)) {
......
...@@ -1007,11 +1007,11 @@ ...@@ -1007,11 +1007,11 @@
qa_optionfield_make_select($optionfield, $themeoptions, $value, 'Classic'); qa_optionfield_make_select($optionfield, $themeoptions, $value, 'Classic');
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
$themedirectory = QA_THEME_DIR . $value . '/'; $themedirectory = QA_THEME_DIR . $value;
$metadata = $metadataUtil->fetchFromAddonPath($themedirectory); $metadata = $metadataUtil->fetchFromAddonPath($themedirectory);
if (empty($metadata)) { if (empty($metadata)) {
// limit theme parsing to first 8kB // limit theme parsing to first 8kB
$contents = file_get_contents($themedirectory . 'qa-styles.css', false, NULL, -1, 8192); $contents = file_get_contents($themedirectory . '/qa-styles.css', false, NULL, -1, 8192);
$metadata = qa_addon_metadata($contents, 'Theme'); $metadata = qa_addon_metadata($contents, 'Theme');
} }
......
...@@ -103,8 +103,7 @@ ...@@ -103,8 +103,7 @@
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
$sortedPluginFiles = array(); $sortedPluginFiles = array();
foreach ($pluginfiles as $pluginFile) { foreach ($pluginfiles as $pluginFile) {
$pluginDirectory = dirname($pluginFile) . '/'; $metadata = $metadataUtil->fetchFromAddonPath(dirname($pluginFile));
$metadata = $metadataUtil->fetchFromAddonPath($pluginDirectory);
if (empty($metadata)) { if (empty($metadata)) {
// limit plugin parsing to first 8kB // limit plugin parsing to first 8kB
$contents = file_get_contents($pluginFile, false, NULL, -1, 8192); $contents = file_get_contents($pluginFile, false, NULL, -1, 8192);
...@@ -120,7 +119,7 @@ ...@@ -120,7 +119,7 @@
$pluginIndex = -1; $pluginIndex = -1;
foreach ($sortedPluginFiles as $pluginFile => $metadata) { foreach ($sortedPluginFiles as $pluginFile => $metadata) {
$pluginIndex++; $pluginIndex++;
$plugindirectory = dirname($pluginFile . '/'); $plugindirectory = dirname($pluginFile) . '/';
$hash = qa_admin_plugin_directory_hash($plugindirectory); $hash = qa_admin_plugin_directory_hash($plugindirectory);
$showthisform = $showpluginforms && (qa_get('show') == $hash); $showthisform = $showpluginforms && (qa_get('show') == $hash);
......
...@@ -338,11 +338,9 @@ ...@@ -338,11 +338,9 @@
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
foreach ($pluginfiles as $pluginfile) { foreach ($pluginfiles as $pluginfile) {
// these variables are utilized in the qa_register_plugin_* functions $pluginDirectory = dirname($pluginfile);
$qa_plugin_directory = dirname($pluginfile) . '/';
$qa_plugin_urltoroot = substr($qa_plugin_directory, strlen(QA_BASE_DIR));
$metadata = $metadataUtil->fetchFromAddonPath($qa_plugin_directory); $metadata = $metadataUtil->fetchFromAddonPath($pluginDirectory);
if (empty($metadata)) { if (empty($metadata)) {
// limit plugin parsing to first 8kB // limit plugin parsing to first 8kB
$contents = file_get_contents($pluginfile, false, NULL, -1, 8192); $contents = file_get_contents($pluginfile, false, NULL, -1, 8192);
...@@ -356,6 +354,10 @@ ...@@ -356,6 +354,10 @@
if (isset($metadata['min_php']) && qa_php_version_below($metadata['min_php'])) if (isset($metadata['min_php']) && qa_php_version_below($metadata['min_php']))
continue; continue;
// these variables are utilized in the qa_register_plugin_* functions
$qa_plugin_directory = $pluginDirectory . '/';
$qa_plugin_urltoroot = substr($qa_plugin_directory, strlen(QA_BASE_DIR));
require_once $pluginfile; require_once $pluginfile;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"author": "Question2Answer", "author": "Question2Answer",
"author_uri": "http://www.question2answer.org", "author_uri": "http://www.question2answer.org",
"license": "GPLv2", "license": "GPLv2",
"update": "http://localhost/webs/q2a-dev/qa-plugin/basic-adsense/metadata_1.json", "update": "",
"min_q2a": "1.4", "min_q2a": "1.4",
"min_php": "" "min_php": ""
} }
{ {
"name": "Snow Flat", "name": "SnowFlat",
"uri": "", "uri": "",
"description": "ShowFlat responsive theme with RTL support", "description": "ShowFlat responsive theme with RTL support",
"version": "1.4", "version": "1.4",
......
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