Exemple #1
0
 public function getInput()
 {
     global $gantry;
     $currentVersion = "3.2.3";
     if ($currentVersion == ".2.11") {
         $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";
     }
     jimport('joomla.utilities.date');
     gantry_import('core.gantryini');
     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->type, 'check');
         $old_cache_date = $old_cache_data['date'];
     } else {
         $old_cache_data['version'] = GANTRY_VERSION;
         $old_cache_data['date'] = 1;
         $old_cache_data['link'] = '';
         $old_cache_date = 0;
     }
     // 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 SimpleXMLElement($data);
             foreach ($xml->entry as $entry) {
                 $title = (string) $entry->title;
                 if (preg_match('/gantry_framework_joomla16-(.*).zip/', $title, $matches)) {
                     $linkattribs = $entry->link[0]->attributes();
                     $link = (string) $linkattribs['href'];
                     $latest_version = $matches[1];
                     $cache_data[$this->type]['check']['version'] = $latest_version;
                     $cache_data[$this->type]['check']['link'] = $link;
                     $cache_data[$this->type]['check']['date'] = $now;
                     GantryINI::write($cache_file, $cache_data, false);
                     break;
                 }
             }
         }
     } else {
         $latest_version = $old_cache_data['version'];
         $link = $old_cache_data['link'];
     }
     if ($latest_version != $currentVersion) {
         $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 {
         $ms = $old_cache_date + 24 * 60 * 60 - $now;
         $hours = round($ms / 60 / 60);
         $minutes = $hours / 60;
         $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.<br />";
         $upd .= "An update check will be executed every 24hr. Next check in: <dev>";
     }
     $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 . "</div>\n\t\t</div>";
     return $output;
 }
 function _array_merge_replace_recursive(&$array1, &$array2)
 {
     $merged = $array1;
     foreach ($array2 as $key => $value) {
         if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
             $merged[$key] = GantryINI::_array_merge_replace_recursive($merged[$key], $value);
         } else {
             $merged[$key] = $value;
         }
     }
     return $merged;
 }
 /**
  * @return void
  */
 protected function customPresets()
 {
     $this->originalPresets = $this->presets;
     if (file_exists($this->custom_presets_file)) {
         $customPresets = GantryINI::read($this->custom_presets_file);
         $this->customPresets = $customPresets;
         $this->originalPresets = $this->presets;
         if (count($customPresets)) {
             $this->presets = $this->array_merge_replace_recursive($this->presets, $customPresets);
             foreach ($this->presets as $key => $preset) {
                 uksort($preset, array($this, "_compareKeys"));
                 $this->presets[$key] = $preset;
             }
         }
     }
 }
global $gantry;


$file = $gantry->custom_presets_file;
$action = JRequest::getString('action');

if ($action == 'add') {
	$data = GantryJSON::decode(JRequest::getString('presets-data'), false);

	if (!file_exists($file)) {
		$handle = @fopen($file, 'w');
		@fwrite($handle, "");
	}

	gantry_import('core.gantryini');
	$newEntry = GantryINI::write($file, $data);

	if ($newEntry) echo "success";
} else if ($action == 'delete') {
	$presetTitle = JRequest::getString('preset-title');
	$presetKey = JRequest::getString('preset-key');
	if (!$presetKey || !$presetTitle) return "error";
	
	GantryINI::write($file, array($presetTitle => array($presetKey => array())), 'delete-key');
	
} else {
	return "error";
}

?>
Exemple #5
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>";
 }
Exemple #6
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;
 }