function _checkInstallDependencies() { if (isset($this->php_min_version)) { if (version_compare(PHP_VERSION, $this->php_min_version, '<')) { echo "\n"; Ak::t("This plugin requires at least php version: %version", array('%version', $this->php_min_version)); echo "\n"; return false; } } if (isset($this->php_max_version)) { if (version_compare(PHP_VERSION, $this->php_max_version, '>')) { echo "\n"; Ak::t("This plugin runs only on php version <= %version", array('%version', $this->php_min_version)); echo "\n"; return false; } } if (isset($this->dependencies)) { $this->dependencies = Ak::toArray($this->dependencies); $pluginManager = new AkPluginManager(); $plugins = $pluginManager->getInstalledPlugins(); $missing = array(); foreach ($this->dependencies as $dependency) { if (!in_array($dependency, $plugins)) { $missing[] = $dependency; } } if (!empty($missing)) { echo "\n"; $params = array('plugin' => AkT('plugin', 'quantify(' . count($missing) . ')'), 'missing' => AkT($missing, 'toSentence')); echo Ak::t("This plugin depends on the %plugin %missing. Please install the missing plugins first.", $params); echo "\n"; return false; } else { /** * register the dependent plugins */ foreach ($this->dependencies as $dependency) { $dependencyFile = AK_PLUGINS_DIR . DS . $dependency . DS . 'dependent_plugins'; if ($fileExists = file_exists($dependencyFile)) { $dependendPlugins = file($dependencyFile); } else { $dependendPlugins = array(); } if (!in_array($this->plugin_name, $dependendPlugins)) { $dependendPlugins[] = $this->plugin_name; } if (!empty($dependendPlugins)) { Ak::file_put_contents($dependencyFile, implode("\n", $dependendPlugins)); } else { if ($fileExists) { unlink($dependencyFile); } } } } } return true; }
$args =& Console_Getargs::factory($console_configuration); if (PEAR::isError($args)) { $replacements = array('-p --parameters values(1-...)' => 'install plugin_name,URL ...', 'Usage: ' . basename(__FILE__) => "Usage: {$script_name}", '[param1] ' => 'plugin_name PLUGIN_URL'); echo "\n{$description}\n" . str_repeat('-', strlen($description) + 1) . "\n"; if ($args->getCode() === CONSOLE_GETARGS_ERROR_USER) { echo str_replace(array_keys($replacements), array_values($replacements), Console_Getargs::getHelp($console_configuration, null, $args->getMessage())) . "\n"; } else { if ($args->getCode() === CONSOLE_GETARGS_HELP) { echo str_replace(array_keys($replacements), array_values($replacements), @Console_Getargs::getHelp($console_configuration)) . "\n"; } } exit; } return $args->getValues(); } $PluginManager = new AkPluginManager(); /** * List available plugins. */ if ($command == 'list') { $options = get_console_options_for('List available plugins.', array('source' => array('short' => 's', 'desc' => "Use the specified plugin repositories. --source URL1 URL2", 'max' => -1, 'min' => 1), 'local' => array('short' => 'l', 'desc' => "List locally installed plugins.", 'max' => 0), 'remote' => array('short' => 'r', 'desc' => "List remotely available plugins. This is the default behavior", 'max' => 0))); if (isset($options['local']) && isset($options['remote'])) { die("Local and remote arguments can not be used simultaneously\n"); } if (!empty($options['source'])) { $PluginManager->tmp_repositories = Ak::toArray($options['source']); } $installed_plugins = $PluginManager->getInstalledPlugins(); if (isset($options['local'])) { if (empty($installed_plugins)) { die("There are not plugins intalled at {$ak_app_dir}/vendor/plugins\n");