本文整理汇总了PHP中SEFTools::getExtVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP SEFTools::getExtVersion方法的具体用法?PHP SEFTools::getExtVersion怎么用?PHP SEFTools::getExtVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SEFTools
的用法示例。
在下文中一共展示了SEFTools::getExtVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkExtVersions
/**
* Checks if the installed JoomSEF extensions support current JoomSEF version
*/
function checkExtVersions()
{
// Check VM and Digistore versions
$v1 = SEFTools::getExtVersion('com_virtuemart');
$v2 = SEFTools::getExtVersion('com_digistore');
$exts = array();
if (!is_null($v1) && version_compare('2.0.32', $v1) > 0) {
$exts[] = 'VirtueMart';
}
if (!is_null($v2) && version_compare('2.1.1', $v2) > 0) {
$exts[] = 'iJoomla Digistore';
}
if (count($exts) > 0) {
JError::raiseWarning(100, JText::sprintf('WARNING_EXTENSION_OLD_VERSION', implode(', ', $exts), '<a href="index.php?option=com_sef&controller=extension">' . JText::_('Manage Extensions') . '</a>'));
}
}
示例2: upgrade
function upgrade()
{
$extDir = JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef_ext';
$fromServer = JRequest::getVar('fromserver');
$extension = JRequest::getVar('ext');
if (!empty($extension) && !JFile::exists($extDir . DS . $extension . '.php')) {
$this->setState('message', JText::_('You are not allowed to upgrade this extension.'));
return false;
}
if (is_null($fromServer)) {
$this->setState('message', JText::_('Upgrade source not given.'));
return false;
}
if ($fromServer == 1) {
$package = $this->_getPackageFromServer($extension);
} else {
$package = $this->_getPackageFromUpload();
}
// was the package unpacked?
if (!$package) {
$this->setState('message', 'Unable to find install package.');
return false;
}
// create an array of upgrade files
$upgradeDir = $package['dir'] . DS . 'upgrade';
$upgradeFiles = JFolder::files($upgradeDir, '.php$');
if (empty($upgradeFiles)) {
$this->setState('message', JText::_('This package does not contain any upgrade informations.'));
JFolder::delete($package['dir']);
return false;
}
// Find the XML file in the package
$xmlFile = $package['dir'] . DS . 'sef.xml';
if (!JFile::exists($xmlFile)) {
// Try to find the extension XML file
$xmlFiles = JFolder::files($package['dir'], '^com_[^.]+\\.xml$');
if (empty($xmlFiles)) {
$this->setState('message', 'Could not find the installation XML file.');
return false;
}
// Set the file and the extension
$xmlFile = $xmlFiles[0];
$extension = substr($xmlFile, 0, -4);
}
// get current version
if (empty($extension)) {
$curVersion = SEFTools::getSEFVersion();
} else {
$curVersion = SEFTools::getExtVersion($extension);
}
if (empty($curVersion)) {
$this->setState('message', JText::_('Could not find current version.'));
JFolder::delete($package['dir']);
return false;
}
// check if current version is upgradeable with downloaded package
$reinstall = false;
if (!in_array($curVersion . '.php', $upgradeFiles)) {
if (empty($extension)) {
// check if current version is being manually reinstalled with the same version package
$xmlFile = $package['dir'] . DS . 'sef.xml';
$packVersion = $this->_getXmlText($xmlFile, 'version');
if ($packVersion == $curVersion && JFile::exists($upgradeDir . DS . 'reinstall.php')) {
// initiate the reinstall
$reinstall = true;
$mainframe =& JFactory::getApplication();
$mainframe->enqueueMessage(JText::_('INFO_SEF_REINSTALL'));
}
}
if (!$reinstall) {
$this->setState('message', JText::_('ERROR_CANT_UPGRADE'));
JFolder::delete($package['dir']);
return false;
}
}
natcasesort($upgradeFiles);
// prepare arrays of upgrade operations and functions to manipulate them
$this->_fileError = false;
$this->_fileList = array();
$this->_sqlList = array();
$this->_scriptList = array();
if (!$reinstall) {
// load each upgrade file starting with current version in ascending order
foreach ($upgradeFiles as $uFile) {
//if (!eregi("^[0-9]+\.[0-9]+\.[0-9]+\.php$", $uFile)) {
if (!preg_match("/^[0-9]+\\.[0-9]+\\.[0-9]+\\.php\$/i", $uFile)) {
continue;
}
if (strnatcasecmp($uFile, $curVersion . ".php") >= 0) {
require_once $upgradeDir . DS . $uFile;
}
}
} else {
// create list of all files to upgrade
require_once $upgradeDir . DS . 'reinstall.php';
}
// Check if the free/paid version of JoomSEF is being changed
if (empty($extension) && !$reinstall) {
$xmlFile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sef' . DS . 'sef.xml';
$license = $this->_getXmlText($xmlFile, 'license');
//.........这里部分代码省略.........
示例3: findUpdate
function findUpdate($data)
{
$this->_update_site_id = $data["update_site_id"];
$this->base = array();
$this->update_sites = array();
$this->updates = array();
$ext_data = SEFTools::postRequest($data['location']);
$details = $ext_data->content;
$db = JFactory::getDBO();
if (!strlen($details)) {
$query = $db->getQuery(true);
$query->update('#__update_sites')->set('enabled=0')->where('update_site=' . $data["update_site_id"]);
$db->query();
JError::raiseWarning('101', JText::sprintf('JLIB_UPDATER_ERROR_SEFEXT_OPEN_URL', $data["url"]));
return false;
}
if (preg_match("/^[0-9]{2}/", $details, $status)) {
$details = $status[0];
$url = explode("/", $data['location']);
$ext = array_pop($url);
$ext = str_replace('.xml', '', $ext);
if (substr_count($ext, "-")) {
$ext_name_arr = explode("-", $ext);
$ext_name = $ext_name_arr[0];
} else {
$ext_name = $ext;
}
if (substr_count($ext, 'com_joomsef4')) {
$data["name"] = "Artio JoomSEF 4";
} else {
$query = $db->getQuery(true);
$query->select('name')->from('#__extensions')->where('element=' . $db->quote($ext_name))->where('type=' . $db->quote('sef_ext'));
$db->setQuery($query);
$data["name"] = $db->loadResult();
if (is_null($data['name'])) {
// Extension not found
return true;
}
$data['name'] .= ' (JoomSEF extension)';
}
}
switch ($details) {
case '20':
JError::raiseWarning('101', $data["name"] . ': ' . JText::sprintf('COM_SEF_EXPIRED', $data["name"]));
break;
case '30':
JError::raiseWarning('101', $data["name"] . ': ' . JText::sprintf('COM_SEF_NOT_ACTIVATED', $data["name"]));
break;
case '40':
JError::raiseWarning('101', $data["name"] . ': ' . JText::sprintf('COM_SEF_ERR_DOMAIN_NOT_MATCH', $data["name"]));
break;
case '50':
JError::raiseWarning('101', $data["name"] . ': ' . JText::sprintf('COM_SEF_DOWLOAD_ID_INVALID', $data["name"]));
break;
case '90':
// Commercial extension
$location_match = array();
if (preg_match("/(-([A-Za-z0-9]*)).xml/", $data["location"], $location_match)) {
JError::raiseWarning('101', $data["name"] . ': ' . JText::sprintf('COM_SEF_ERROR_DOWNLOAD_ID_NOT_FOUND', $location_match[2]));
// Free extension
} else {
JError::raiseWarning('101', $data["name"] . ': ' . JText::sprintf('COM_SEF_NOT_FOUND', $data["name"]));
}
break;
default:
$xml = simplexml_load_string($details);
if (is_object($xml)) {
foreach ($xml->children() as $update) {
$table = JTable::getInstance('update');
$table->update_site_id = $this->_update_site_id;
$table->version = (string) $update->version;
if ((string) $update->element == 'com_joomsef4') {
$sef_version = SEFTools::getSEFVersion();
$table->name = (string) $update->name;
$table->element = 'com_sef';
$table->client_id = 1;
$table->type = 'component';
} else {
$sefext_version = SEFTools::getExtVersion((string) $update->name);
$table->name = (string) $update->name;
$table->element = (string) $update->element;
$table->client_id = 0;
$table->type = 'sef_ext';
}
$table->detailsurl = $data["location"];
$this->updates[] = $table;
}
}
}
return array('update_sites' => $this->update_sites, 'updates' => $this->updates);
}