コード例 #1
0
ファイル: model.php プロジェクト: densem-2013/exikom
 /**
  * Method to get latest dependency version.
  *
  * @param   string  $identified_name        Dependency's identified name.
  * @param   string  $current_version        Current dependency version.
  * @param   string  $requiredJoomlaVersion  Joomla version required by extension, e.g. 2.5, 3.0, etc.
  * @param   object  $version                Latest version object used for recursive calls.
  *
  * @return  mixed  Object containing update information if dependency is outdated, FALSE otherwise.
  */
 protected function hasUpdate($identified_name, $current_version, $requiredJoomlaVersion = JSN_EASYSLIDER_REQUIRED_JOOMLA_VER, $version = '')
 {
     static $result;
     // Only communicate with server if check update URLs is not load before
     if (empty($version)) {
         if (!isset(self::$versions)) {
             try {
                 // Get Joomla config
                 $config = JFactory::getConfig();
                 // Generate cache file path
                 $cache = $config->get('tmp_path') . '/JoomlaShineUpdates.json';
                 // Get latest version from local file if not timed out
                 if (is_readable($cache) and time() - filemtime($cache) < CHECK_UPDATE_PERIOD) {
                     // Decode JSON encoded update details
                     self::$versions = json_decode(JFile::read($cache));
                 } else {
                     // Always update cache file modification time
                     is_readable($cache) and touch($cache, time());
                     try {
                         self::$versions = $this->fetchHttp($this->checkLink);
                         // Cache latest version to local file system
                         JFile::write($cache, self::$versions);
                         // Decode JSON encoded update details
                         self::$versions = json_decode(self::$versions);
                     } catch (Exception $e) {
                         throw $e;
                     }
                 }
             } catch (Exception $e) {
                 return $e;
             }
         }
         $version = self::$versions;
         $result = false;
     }
     // Get installed Joomla version
     $JVersion = new JVersion();
     // Get latest dependency version
     if (!$result) {
         foreach ($version->items as $item) {
             if (isset($item->items)) {
                 $this->hasUpdate($identified_name, $current_version, $requiredJoomlaVersion, $item);
                 continue;
             }
             if (isset($item->identified_name) and $item->identified_name == $identified_name) {
                 $result = $item;
                 break;
             }
         }
         if (is_object($result)) {
             // Does product support installed Joomla version?
             $tags = explode(';', $result->tags);
             if (!in_array($JVersion->RELEASE, $tags)) {
                 $result = false;
             }
             // Does product upgradable?
             if ($result and !empty($requiredJoomlaVersion) and !$this->isJoomlaCompatible($requiredJoomlaVersion) and !version_compare($result->version, $current_version, '>=')) {
                 $result = false;
             }
             // Does product have newer version?
             if ($result and (empty($requiredJoomlaVersion) or $this->isJoomlaCompatible($requiredJoomlaVersion)) and !version_compare($result->version, $current_version, '>')) {
                 $result = false;
             }
         }
     }
     return $result;
 }
コード例 #2
0
ファイル: installer.php プロジェクト: NallelyFlores89/basvec
 function __construct($config = array())
 {
     parent::__construct($config);
 }