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; }
public function test_singularize() { $text = "Comments"; $string =& AkT($text); $this->assertEqual('Comment', $string->singularize()); $string =& AkT($text, 'singularize'); $this->assertEqual('Comment', $string); }
public function test_since() { $now = time(); $since = $now - AkT(20,'minutes'); $since_date = date('Y-m-d H:i:s', $since); $result_timestamp = AkT(20,'minutes.since('.$since_date.')'); $this->assertEqual($now,$result_timestamp); $result_date = date('Y-m-d H:i:s', $result_timestamp); }