pluginName = $pluginName; } /** * Loads plugin metadata. @see Plugin::getInformation. * * @return array */ public function load() { return array_merge( $this->getDefaultPluginInformation(), $this->loadPluginInfoJson() ); } public function hasPluginJson() { $hasJson = $this->loadPluginInfoJson(); return !empty($hasJson); } private function getDefaultPluginInformation() { $descriptionKey = $this->pluginName . '_PluginDescription'; return array( 'description' => Piwik_Translate($descriptionKey), 'homepage' => 'http://piwik.org/', 'author' => 'Piwik', 'author_homepage' => 'http://piwik.org/', 'license' => 'GPL v3 or later', 'license_homepage' => 'http://www.gnu.org/licenses/gpl.html', 'version' => Version::VERSION, 'theme' => false, ); } private function loadPluginInfoJson() { $path = PluginsManager::getPluginsDirectory() . $this->pluginName . '/' . self::PLUGIN_JSON_FILENAME; return $this->loadJsonMetadata($path); } private function loadJsonMetadata($path) { if (!file_exists($path)) { return array(); } $json = file_get_contents($path); if (!$json) { return array(); } $info = Common::json_decode($json, $assoc = true); if (!is_array($info) || empty($info) ) { throw new Exception("Invalid JSON file: $path"); } return $info; } }