*/ class Mage_Connect_Helper_Data extends Mage_Core_Helper_Data { /** * Retrieve file system path for local extension packages * Return path with last directory separator * * @return string */ public function getLocalPackagesPath() { return Mage::getBaseDir('var') . DS . 'connect' . DS; } /** * Retrieve file system path for local extension packages (for version 1 packages only) * Return path with last directory separator * * @return string */ public function getLocalPackagesPathV1x() { return Mage::getBaseDir('var') . DS . 'pear' . DS; } /** * Retrieve a map to convert a channel from previous version of Magento Connect Manager * * @return array */ public function getChannelMapFromV1x() { return array( 'connect.magentocommerce.com/community' => 'community', 'connect.magentocommerce.com/core' => 'community' ); } /** * Retrieve a map to convert a channel to previous version of Magento Connect Manager * * @return array */ public function getChannelMapToV1x() { return array( 'community' => 'connect.magentocommerce.com/community' ); } /** * Convert package channel in order for it to be compatible with current version of Magento Connect Manager * * @param string $channel * * @return string */ public function convertChannelFromV1x($channel) { $channelMap = $this->getChannelMapFromV1x(); if (isset($channelMap[$channel])) { $channel = $channelMap[$channel]; } return $channel; } /** * Convert package channel in order for it to be compatible with previous version of Magento Connect Manager * * @param string $channel * * @return string */ public function convertChannelToV1x($channel) { $channelMap = $this->getChannelMapToV1x(); if (isset($channelMap[$channel])) { $channel = $channelMap[$channel]; } return $channel; } /** * Load local package data array * * @param string $packageName without extension * @return array|false */ public function loadLocalPackage($packageName) { //check LFI protection $this->checkLfiProtection($packageName); $path = $this->getLocalPackagesPath(); $xmlFile = $path . $packageName . '.xml'; $serFile = $path . $packageName . '.ser'; if (file_exists($xmlFile) && is_readable($xmlFile)) { $xml = simplexml_load_file($xmlFile); $data = Mage::helper('core')->xmlToAssoc($xml); if (!empty($data)) { return $data; } } if (file_exists($serFile) && is_readable($xmlFile)) { $data = unserialize(file_get_contents($serFile)); if (!empty($data)) { return $data; } } return false; } }