/**
  * Initializes the PEAR service implementation.
  *
  * @return void
  */
 public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
 {
     // call the parent constructor
     parent::__construct($request, $response, $invokeArgs);
     // initialize the PEAR service implementation
     $this->_service = Faett_Core_Factory::get(Mage::getBaseDir());
 }
 /**
  * (non-PHPdoc)
  * @see lib/Varien/Varien_Object#_construct()
  */
 public function _construct()
 {
     // Note that the channel_id refers to the key field in your database table.
     $this->_init('manager/channel', 'channel_id');
     // initialize the PEAR service implementation
     $this->_service = Faett_Core_Factory::get(Mage::getBaseDir());
 }
 /**
  * Returns a singleton instance.
  *
  * @param string $baseDir The Magento base directory
  * @return Faett_Core_Service The singleton instance
  */
 public static function get($baseDir)
 {
     if (Faett_Core_Factory::$_i === null) {
         Faett_Core_Factory::$_i = new Faett_Core_Service($baseDir);
     }
     // return the singleton
     return Faett_Core_Factory::$_i;
 }
 /**
  * Initializes the PEAR service implementation.
  *
  * @return void
  */
 public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
 {
     // call the parent constructor
     parent::__construct($request, $response, $invokeArgs);
     // initialize the PEAR service implementation
     $this->_service = Faett_Core_Factory::get(Mage::getBaseDir());
     // initialize the console log stream in 'html' mode
     $this->_service->getUI()->setLogStream($this->_logStream = fopen('php://memory', 'w+'));
 }
 /**
  * (non-PHPdoc)
  * @see lib/Varien/Varien_Object#_construct()
  */
 public function _construct()
 {
     // initialize the model
     parent::_construct();
     $this->_init('manager/connector');
     // initialize the PEAR service implementation
     $this->_service = Faett_Core_Factory::get(Mage::getBaseDir());
     // initialize the console log stream in 'html' mode
     $this->_service->getUI()->setLogStream($this->_logStream = fopen('php://memory', 'w+'));
 }
 protected function _afterLoadCollection()
 {
     // initialize the PEAR service implementation
     $service = Faett_Core_Factory::get(Mage::getBaseDir());
     // iterate over the available packages
     foreach ($this->getCollection() as $package) {
         // load the packagename and the channel's alias
         $packageName = $package->getName();
         $alias = $package->getChannel()->getAlias();
         // check if the package is already installed
         if ($service->packageExists($packageName, $alias)) {
             $package->setState(Mage::helper('manager')->getPackageState($package));
         }
     }
     // return the Grid itself
     return $this;
 }
 /**
  * This method opens and validates the uploaded PEAR package
  * and assembles the content of the package file itself, the
  * dependencies and the release notes.
  *
  * @param Faett_Package_Model_Link $link The link with the PEAR package file
  * @return void
  */
 public function generatePEARInfos(Faett_Package_Model_Link $link)
 {
     // initialize the PEAR service implementation
     $service = Faett_Core_Factory::get(Mage::getBaseDir());
     // initialize the PEAR_PackageFile_v2 instance
     $pf = $service->packageFile($packageFile = Faett_Package_Model_Link::getBasePath() . $link->getLinkFile());
     // initialize the archive
     $tar = new Archive_Tar($packageFile);
     // try to load the content of the package2.xml file
     $contents = $tar->extractInString('package2.xml');
     // if not available, try to load from package.xml file
     if (!$contents) {
         $contents = $tar->extractInString('package.xml');
     }
     // load the data to assemble the link with
     $link->setPackageFile($contents);
     $link->setPackageName($pf->getName());
     $link->setPackageSize(filesize($packageFile));
     $link->setDependencies(serialize($pf->getDependencies()));
     $link->setState($pf->getState());
     $link->setVersion($pf->getVersion());
     $link->setReleaseDate($pf->getDate());
     $link->setLicence($pf->getLicense());
     $link->setSummary($pf->getSummary());
     $link->setDescription($pf->getDescription());
     $link->setNotes($pf->getNotes());
     // set the licence URI
     if (is_array($loc = $pf->getLicenseLocation())) {
         if (array_key_exists('uri', $loc)) {
             $link->setLicenceUri($loc['uri']);
         } elseif (array_key_exists('filesource', $loc)) {
             $link->setLicenceUri($loc['filesource']);
         }
     }
     // save the completed link
     $link->save();
 }