protected function _initialize() { $cachePath = sfConfig::get('sf_cache_dir') . '/sympal/' . $this->_name . '.cache'; if (!file_exists($cachePath)) { $this->_loadFromSymfonyPlugins(); if ($pluginConfiguration = sfSympalPluginToolkit::isPluginDownloaded($this->_name)) { $downloadPath = sfContext::getInstance()->getConfiguration()->getPluginConfiguration($this->_name)->getRootDir(); } else { $downloadPath = sfSympalPluginToolkit::getPluginDownloadPath($this->_name); } $packageXmlPath = $downloadPath . '/package.xml'; $readmePath = $downloadPath . '/README'; if (sfSympalToolkit::fileGetContents($packageXmlPath)) { $packageXml = simplexml_load_file($packageXmlPath); } else { if (sfSympalToolkit::fileGetContents($packageXmlPath . '.tmpl')) { $packageXml = simplexml_load_file($packageXmlPath . '.tmpl'); } } if (isset($packageXml)) { $package = sfSympalPluginApi::simpleXmlToArray($packageXml); $this->_plugin = array_merge($package, $this->_plugin); } if ($readme = sfSympalToolkit::fileGetContents($readmePath)) { $this->_plugin['readme'] = $readme; } $this->_plugin['name'] = $this->_name; file_put_contents($cachePath, serialize($this->_plugin)); } else { $serialized = file_get_contents($cachePath); $this->_plugin = unserialize($serialized); } }
public static function getPluginDownloadPath($name) { $name = self::getShortPluginName($name); $pluginName = self::getLongPluginName($name); $e = explode('.', SYMFONY_VERSION); $version = $e[0] . '.' . $e[1]; $paths = self::getDownloadablePluginPaths(); $path = ''; foreach ($paths as $pathPluginName => $path) { if ($pluginName == $pathPluginName) { $branchSvnPath = $path . '/' . $pluginName . '/branches/' . $version; $trunkSvnPath = $path . '/' . $pluginName . '/trunk'; if (sfSympalToolkit::fileGetContents($branchSvnPath) !== false || is_dir($branchSvnPath)) { $path = $branchSvnPath; break; } else { if (sfSympalToolkit::fileGetContents($trunkSvnPath) !== false || is_dir($trunkSvnPath)) { $path = $trunkSvnPath; break; } else { if (is_dir($path)) { break; } } } } } if ($path) { return $path; } else { throw new sfException('Could not find download path for ' . $pluginName); } }