cleanRemovedPlugins(); $enabledPlugins = $pluginManager->getEnabledPlugins(); $fileSystemPlugins = $pluginManager->getFilesystemPlugins(); $pluginHashes = $pluginManager->getHashesForPlugins($fileSystemPlugins); $showpluginforms = true; if (qa_is_http_post()) { if (!qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) { $qa_content['error'] = qa_lang_html('misc/form_security_reload'); $showpluginforms = false; } else { if (qa_clicked('dosave')) { $enabledPluginHashes = qa_post_text('enabled_plugins_hashes'); $enabledPluginHashesArray = explode(';', $enabledPluginHashes); $pluginDirectories = array_keys(array_intersect($pluginHashes, $enabledPluginHashesArray)); $pluginManager->setEnabledPlugins($pluginDirectories); qa_redirect('admin/plugins'); } } } // Map modules with options to their containing plugins $pluginoptionmodules = array(); $tables = qa_db_list_tables(); $moduletypes = qa_list_module_types(); foreach ($moduletypes as $type) { $modules = qa_list_modules($type); foreach ($modules as $name) { $module = qa_load_module($type, $name); if (method_exists($module, 'admin_form')) { $info = qa_get_module_info($type, $name); $dir = rtrim($info['directory'], '/'); $pluginoptionmodules[$dir][] = array( 'type' => $type, 'name' => $name, ); } } } foreach ($moduletypes as $type) { $modules = qa_load_modules_with($type, 'init_queries'); foreach ($modules as $name => $module) { $queries = $module->init_queries($tables); if (!empty($queries)) { if (qa_is_http_post()) qa_redirect('install'); else { $qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array( '^1' => qa_html($name), '^2' => qa_html($type), '^3' => '', '^4' => '', )); } } } } if (!empty($fileSystemPlugins)) { $metadataUtil = new Q2A_Util_Metadata(); $sortedPluginFiles = array(); foreach ($fileSystemPlugins as $pluginDirectory) { $pluginDirectoryPath = QA_PLUGIN_DIR . $pluginDirectory; $metadata = $metadataUtil->fetchFromAddonPath($pluginDirectoryPath); if (empty($metadata)) { $pluginFile = $pluginDirectoryPath . '/qa-plugin.php'; // limit plugin parsing to first 8kB $contents = file_get_contents($pluginFile, false, null, 0, 8192); $metadata = qa_addon_metadata($contents, 'Plugin'); } $metadata['name'] = isset($metadata['name']) && !empty($metadata['name']) ? qa_html($metadata['name']) : qa_lang_html('admin/unnamed_plugin'); $sortedPluginFiles[$pluginDirectory] = $metadata; } qa_sort_by($sortedPluginFiles, 'name'); $pluginIndex = -1; foreach ($sortedPluginFiles as $pluginDirectory => $metadata) { $pluginIndex++; $pluginDirectoryPath = QA_PLUGIN_DIR . $pluginDirectory; $hash = $pluginHashes[$pluginDirectory]; $showthisform = $showpluginforms && (qa_get('show') == $hash); $namehtml = $metadata['name']; if (isset($metadata['uri']) && strlen($metadata['uri'])) $namehtml = '' . $namehtml . ''; $namehtml = '' . $namehtml . ''; $metaver = isset($metadata['version']) && strlen($metadata['version']); if ($metaver) $namehtml .= ' v' . qa_html($metadata['version']); if (isset($metadata['author']) && strlen($metadata['author'])) { $authorhtml = qa_html($metadata['author']); if (isset($metadata['author_uri']) && strlen($metadata['author_uri'])) $authorhtml = '' . $authorhtml . ''; $authorhtml = qa_lang_html_sub('main/by_x', $authorhtml); } else $authorhtml = ''; if ($metaver && isset($metadata['update_uri']) && strlen($metadata['update_uri'])) { $elementid = 'version_check_' . md5($pluginDirectory); $updatehtml = '(...)'; $qa_content['script_onloads'][] = array( "qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ", false);" ); } else $updatehtml = ''; if (isset($metadata['description'])) $deschtml = qa_html($metadata['description']); else $deschtml = ''; if (isset($pluginoptionmodules[$pluginDirectoryPath]) && !$showthisform) { $deschtml .= (strlen($deschtml) ? ' - ' : '') . '' . qa_lang_html('admin/options') . ''; } $allowDisable = isset($metadata['load_order']) && $metadata['load_order'] === 'after_db_init'; $beforeDbInit = isset($metadata['load_order']) && $metadata['load_order'] === 'before_db_init'; $enabled = $beforeDbInit || !$allowDisable || in_array($pluginDirectory, $enabledPlugins); $pluginhtml = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml . '
'; $pluginhtml .= $deschtml . (strlen($deschtml) > 0 ? '
' : ''); $pluginhtml .= '' . qa_html($pluginDirectoryPath) . '/'; if (qa_qa_version_below(@$metadata['min_q2a'])) $pluginhtml = ''.$pluginhtml.'
'. qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])).''; elseif (qa_php_version_below(@$metadata['min_php'])) $pluginhtml = ''.$pluginhtml.'
'. qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])).''; $qa_content['form_plugin_'.$pluginIndex] = array( 'tags' => 'id="'.qa_html($hash).'"', 'style' => 'tall', 'fields' => array( array( 'type' => 'checkbox', 'label' => qa_lang_html('admin/enabled'), 'value' => $enabled, 'tags' => sprintf('id="plugin_enabled_%s"%s', $hash, $allowDisable ? '' : ' disabled'), ), array( 'type' => 'custom', 'html' => $pluginhtml, ), ), ); if ($showthisform && isset($pluginoptionmodules[$pluginDirectoryPath])) { foreach ($pluginoptionmodules[$pluginDirectoryPath] as $pluginoptionmodule) { $type = $pluginoptionmodule['type']; $name = $pluginoptionmodule['name']; $module = qa_load_module($type, $name); $form = $module->admin_form($qa_content); if (!isset($form['tags'])) $form['tags'] = 'method="post" action="' . qa_admin_plugin_options_path($pluginDirectory) . '"'; if (!isset($form['style'])) $form['style'] = 'tall'; $form['boxed'] = true; $form['hidden']['qa_form_security_code'] = qa_get_form_security_code('admin/plugins'); $qa_content['form_plugin_options'] = $form; } } } } $qa_content['navigation']['sub'] = qa_admin_sub_navigation(); $qa_content['form'] = array( 'tags' => 'method="post" action="' . qa_self_html() . '" name="plugins_form" onsubmit="qa_get_enabled_plugins_hashes(); return true;"', 'style' => 'wide', 'buttons' => array( 'dosave' => array( 'tags' => 'name="dosave"', 'label' => qa_lang_html('admin/save_options_button'), ), ), 'hidden' => array( 'qa_form_security_code' => qa_get_form_security_code('admin/plugins'), 'enabled_plugins_hashes' => '', ), ); return $qa_content;