Beispiel #1
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     // curl check
     if (!function_exists('curl_version')) {
         $upd = "<span class='download-update'>";
         $upd .= "\t\t<a href='http://www.php.net/manual/en/book.curl.php'>";
         $upd .= "\t\t\t<span>Learn more about cURL</span>";
         $upd .= "\t\t</a>";
         $upd .= "</span>";
         return "\n\t\t\t<div id='versioncheck' class='update-available'>\n\t\t\t\t<div id='versioncheck-bar' class='g-title'><b>ERROR - </b> cURL is required in order to check Gantry updates." . $upd . "</div>\n\t\t\t</div>";
     }
     gantry_import('core.gantryini');
     gantry_import('core.utilities.gantryxml');
     global $gantry;
     $klass = "no-updates";
     $output = "";
     $statusText = "";
     $now =& JFactory::getDate();
     $cache_file = $gantry->custom_dir . DS . 'gantry_version';
     if (file_exists($cache_file) && is_file($cache_file) && is_readable($cache_file)) {
         $old_cache_data = GantryINI::read($cache_file, $this->_name, 'check');
     } else {
         $old_cache_data['version'] = GANTRY_VERSION;
         $old_cache_data['date'] = 1;
         $old_cache_data['link'] = '';
     }
     $old_cache_date =& JFactory::getDate($old_cache_data['date']);
     // only grab from the web if its been more the 24 hours since the last check
     if ($old_cache_date->toUNIX() + 24 * 60 * 60 < $now->toUNIX()) {
         $data = $this->_get_url_contents('http://code.google.com/feeds/p/gantry-framework/downloads/basic');
         if (!empty($this->_error)) {
             $output = "<span id='version-warning'> [ <strong>Error checking version:</strong> " . $this->_error . "  ]</span>";
             $latest_version = GANTRY_VERSION;
         } else {
             $xml = new GantryXML();
             $xml->loadString($data);
             foreach ($xml->document->entry as $entry) {
                 $title = (string) $entry->title[0]->data();
                 if (preg_match('/gantry_joomla_framework-(.*).zip/', $title, $matches)) {
                     $linkattribs = $entry->link[0]->attributes();
                     $link = (string) $linkattribs['href'];
                     $latest_version = $matches[1];
                     $cache_data[$this->_name]['check']['version'] = $latest_version;
                     $cache_data[$this->_name]['check']['link'] = $link;
                     $cache_data[$this->_name]['check']['date'] = $now->toUNIX();
                     GantryINI::write($cache_file, $cache_data, false);
                     break;
                 }
             }
         }
     } else {
         $latest_version = $old_cache_data['version'];
         $link = $old_cache_data['link'];
     }
     $upd = "";
     if ($latest_version != GANTRY_VERSION) {
         $klass = "update-available";
         $statusText = "- Notice: <b>New Version Available!</b>";
         $upd = "<span class='download-update'>";
         $upd .= "\t\t<a href='" . $link . "'>";
         $upd .= "\t\t\t<span>Download Gantry " . $latest_version . "</span>";
         $upd .= "\t\t</a>";
         $upd .= "</span>";
     } else {
         $upd = "<span class='download-update'>";
         $upd .= "\t\t<span>No update available</span>";
         $upd .= "</span>";
     }
     return "\n\t\t<div id='versioncheck' class='" . $klass . "'>\n\t\t\t<div id='versioncheck-bar' class='g-title'>Gantry v" . GANTRY_VERSION . " " . JText::_($statusText) . $upd . "</div>\n\t\t</div>";
 }
Beispiel #2
0
 public function getInput()
 {
     global $gantry;
     $currentVersion = GANTRY_VERSION;
     if ($currentVersion == ".26") {
         $currentVersion = "[DEV]";
     }
     // curl check
     if (!function_exists('curl_version')) {
         $upd = "<strong>cURL is required to check for latest versions of the Gantry Framework. </strong> Learn more at <a href='http://www.php.net/manual/en/book.curl.php'>http://www.php.net</a>";
         return "\n\t\t\t\t<div id='updater' class='update'>\n\t\t\t\t\t<div id='updater-bar' class='h2bar'>Gantry <span>v" . $currentVersion . "</span></div>\n\t\t\t\t\t<div id='updater-desc'>" . $upd . "</div>\n\t\t\t\t</div>\n\t\t\t";
     }
     gantry_import('core.gantryini');
     gantry_import('core.utilities.gantryxml');
     global $gantry;
     $klass = "noupdate";
     $output = "";
     $statusText = "";
     $now = time();
     $cache_file = $gantry->custom_dir . DS . 'gantry_version';
     if (file_exists($cache_file) && is_file($cache_file) && is_readable($cache_file)) {
         $old_cache_data = GantryINI::read($cache_file, $this->_name, 'check');
     } else {
         $old_cache_data['version'] = GANTRY_VERSION;
         $old_cache_data['date'] = 1;
         $old_cache_data['link'] = '';
     }
     $old_cache_date = time($old_cache_data['date']);
     // only grab from the web if its been more the 24 hours since the last check
     if ($old_cache_date + 24 * 60 * 60 < $now) {
         $data = $this->_get_url_contents('http://code.google.com/feeds/p/gantry-framework/downloads/basic');
         if (!empty($this->_error)) {
             $klass = "update";
             $upd = "<strong>Error checking version:</strong> " . $this->_error;
             $latest_version = GANTRY_VERSION;
         } else {
             $xml = new GantryXML();
             $xml->loadString($data);
             foreach ($xml->document->entry as $entry) {
                 $title = (string) $entry->title[0]->data();
                 if (preg_match('/gantry_wordpress_framework-(.*).zip/', $title, $matches)) {
                     $linkattribs = $entry->link[0]->attributes();
                     $link = (string) $linkattribs['href'];
                     $latest_version = $matches[1];
                     $cache_data[$this->_name]['check']['version'] = $latest_version;
                     $cache_data[$this->_name]['check']['link'] = $link;
                     $cache_data[$this->_name]['check']['date'] = $now->toUNIX();
                     GantryINI::write($cache_file, $cache_data, false);
                     break;
                 }
             }
         }
     } else {
         $latest_version = $old_cache_data['version'];
         $link = $old_cache_data['link'];
     }
     if ($latest_version != GANTRY_VERSION) {
         $klass = "update";
         $upd = "<strong>Version " . $latest_version . " of the Gantry Framework is Available</strong>.  Please <a href='" . $link . "'>download the latest version</a> now.";
     } else {
         $upd = "<strong>The Gantry Framework is up-to-date!</strong><br />You are running the latest version, you will be notified here if a newer version is available.";
     }
     $output = "\n\t\t<div id='updater' class='" . $klass . "'>\n\t\t\t<div id='updater-bar' class='h2bar'>Gantry <span>v" . $currentVersion . "</span></div>\n\t\t\t<div id='updater-desc'>" . $upd . "<br />\n\t\t\tYour server is using <b>" . php_sapi_name() . "</b> as PHP interface.</div>\n\t\t</div>";
     return $output;
 }