本文整理汇总了PHP中JVersion类的典型用法代码示例。如果您正苦于以下问题:PHP JVersion类的具体用法?PHP JVersion怎么用?PHP JVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadPackage
/**
* Downloads a package
*
* @param string $url URL of file to download
* @param string $target Download target filename [optional]
*
* @return mixed Path to downloaded package or boolean false on failure
*
* @since 11.1
*/
public static function downloadPackage($url, $target = false)
{
$config = JFactory::getConfig();
// Capture PHP errors
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
// Set user agent
$version = new JVersion();
ini_set('user_agent', $version->getUserAgent('Installer'));
$http = JHttpFactory::getHttp();
$response = $http->get($url);
if (200 != $response->code) {
JLog::add(JText::_('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT'), JLog::WARNING, 'jerror');
return false;
}
if ($response->headers['wrapper_data']['Content-Disposition']) {
$contentfilename = explode("\"", $response->headers['wrapper_data']['Content-Disposition']);
$target = $contentfilename[1];
}
// Set the target path if not given
if (!$target) {
$target = $config->get('tmp_path') . '/' . self::getFilenameFromURL($url);
} else {
$target = $config->get('tmp_path') . '/' . basename($target);
}
// Write buffer to file
JFile::write($target, $response->body);
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
// Bump the max execution time because not using built in php zip libs are slow
@set_time_limit(ini_get('max_execution_time'));
// Return the name of the downloaded package
return basename($target);
}
示例2: delete
public function delete()
{
// Check for request forgeries
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// Get items to remove from the request.
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
if (!is_array($cid) || count($cid) < 1) {
JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
} else {
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
jimport('joomla.utilities.arrayhelper');
JArrayHelper::toInteger($cid);
// Remove the items.
if ($model->delete($cid)) {
$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
} else {
$this->setMessage($model->getError());
}
}
$version = new JVersion();
if ($version->isCompatible('3.0')) {
// Invoke the postDelete method to allow for the child class to access the model.
$this->postDeleteHook($model, $cid);
}
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}
示例3: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$html = '';
$minversion = $this->element['minversion'];
$downloadlink = $this->element['downloadlink'];
$version = new JVersion();
$jversion = explode('.', $version->getShortVersion());
$class = '';
$style = '';
if (intval($jversion[0]) > 2) {
$class = 'alert alert-warning';
} else {
$style = 'margin: 5px 0; padding: 8px 35px 8px 14px; border-radius: 4px; border: 1px solid #FBEED5; background-color: #FCF8E3; color: #C09853;';
}
if (!JFolder::exists(JPATH_ROOT . '/libraries/syw')) {
$html .= '<div class="' . $class . '" style="' . $style . '">';
$html .= ' <span>' . JText::_('SYW_MISSING_SYWLIBRARY') . '</span><br />';
$html .= ' <a href="' . $downloadlink . '" target="_blank">' . JText::_('SYW_DOWNLOAD_SYWLIBRARY') . '</a>';
$html .= '</div>';
} else {
jimport('syw.version');
if (!SYWVersion::isCompatible($minversion)) {
$html .= '<div class="' . $class . '" style="' . $style . '">';
$html .= ' <span>' . JText::_('SYW_NONCOMPATIBLE_SYWLIBRARY') . '</span><br />';
$html .= ' <span>' . JText::_('SYW_UPDATE_SYWLIBRARY') . JText::_('SYW_OR') . '</span>';
$html .= ' <a href="' . $downloadlink . '" target="_blank">' . strtolower(JText::_('SYW_DOWNLOAD_SYWLIBRARY')) . '</a>';
$html .= '</div>';
}
}
return $html;
}
示例4: preflight
public function preflight($type, $parent)
{
if ($type == 'uninstall') {
return true;
}
try {
$source = $parent->getParent()->getPath('source');
$jversion = new JVersion();
if (!$jversion->isCompatible('2.5.5')) {
throw new Exception('Please upgrade to at least Joomla! 2.5.5 before continuing!');
}
if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/rsform.php')) {
throw new Exception('Please install the RSForm! Pro component before continuing.');
}
if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/version.php')) {
throw new Exception('Please upgrade RSForm! Pro to at least R45 before continuing!');
}
// Copy needed files
$this->copyFiles($source);
// Update? Run our SQL file
if ($type == 'update') {
$this->runSQL($source, 'install');
}
} catch (Exception $e) {
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return false;
}
return true;
}
示例5: display
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->categories = Djc2Categories::getInstance();
$user = JFactory::getUser();
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->ordering = array();
foreach ($this->items as &$item) {
if (!isset($this->ordering[$item->parent_id])) {
$this->ordering[$item->parent_id] = array();
}
$this->ordering[$item->parent_id][] = $item->id;
}
$this->addToolbar();
if (class_exists('JHtmlSidebar') && $user->authorise('core.admin')) {
$this->sidebar = JHtmlSidebar::render();
}
$version = new JVersion();
if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
$tpl = 'legacy';
}
parent::display($tpl);
}
示例6: com_uninstall
function com_uninstall()
{
jimport('joomla.filesystem.file');
jimport('joomla.version');
$version = new JVersion();
if (version_compare($version->getShortVersion(), '1.6', '>=')) {
$db = JFactory::getDBO();
$db->setQuery("Delete From #__menu Where `link` Like 'index.php?option=com_breezingforms&act=%'");
$db->query();
$db->setQuery("Delete From #__menu Where `alias` Like 'BreezingForms' And `path` Like 'breezingforms'");
$db->query();
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'breezingforms' . DS . 'facileforms.config.php')) {
JFile::delete(JPATH_SITE . DS . 'media' . DS . 'breezingforms' . DS . 'facileforms.config.php');
}
if (JFile::exists(JPATH_SITE . "/components/com_sh404sef/sef_ext/com_breezingforms.php")) {
JFile::delete(JPATH_SITE . "/components/com_sh404sef/sef_ext/com_breezingforms.php");
}
if (JFile::exists(JPATH_SITE . '/ff_secimage.php')) {
JFile::delete(JPATH_SITE . '/ff_secimage.php');
}
if (JFile::exists(JPATH_SITE . '/templates/system/ff_secimage.php')) {
JFile::delete(JPATH_SITE . '/templates/system/ff_secimage.php');
}
if (JFile::exists(JPATH_SITE . "/administrator/components/com_joomfish/contentelements/breezingforms_elements.xml")) {
JFile::delete(JPATH_SITE . "/administrator/components/com_joomfish/contentelements/breezingforms_elements.xml");
}
if (JFile::exists(JPATH_SITE . "/administrator/components/com_joomfish/contentelements/translationFformFilter.php")) {
JFile::delete(JPATH_SITE . "/administrator/components/com_joomfish/contentelements/translationFformFilter.php");
}
if (JFile::exists(JPATH_SITE . "/administrator/components/com_joomfish/contentelements/translationFformoptions_emptyFilter.php")) {
JFile::delete(JPATH_SITE . "/administrator/components/com_joomfish/contentelements/translationFformoptions_emptyFilter.php");
}
}
示例7: com_install
function com_install()
{
if (defined('_JEXEC') && class_exists('JApplication')) {
$config = JFactory::getConfig();
$config->setValue('config.live_site', substr_replace(JURI::root(), '', -1, 1));
$url = JURI::root() . 'administrator/index.php?option=com_jcomments&task=postinstall';
$version = new JVersion();
if (version_compare('1.6.0', $version->getShortVersion()) > 0) {
require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'language.php';
JCommentsInstallerLanguageHelper::convertLanguages15();
}
} else {
global $mainframe;
$componentPath = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_jcomments';
require_once $componentPath . DS . 'libraries' . DS . 'joomlatune' . DS . 'filesystem.php';
require_once $componentPath . DS . 'jcomments.legacy.php';
require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'installer.php';
JCommentsInstallerHelper::extractJCommentsLibraryConvert();
if (is_file($componentPath . DS . 'libraries' . DS . 'convert' . DS . 'utf8.class.php')) {
require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'language.php';
JCommentsInstallerLanguageHelper::convertLanguages10();
}
$url = $mainframe->getCfg('live_site') . '/administrator/index2.php?option=com_jcomments&task=postinstall';
}
if (headers_sent()) {
echo '<script type="text/javascript">document.location.href="' . $url . '";</script>';
} else {
header('Location: ' . $url);
}
}
示例8: display
/**
* Display the view
*
* @access public
*/
function display($tpl = null)
{
$app = JFactory::getApplication();
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
$version = new JVersion();
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
JHTML::stylesheet('administrator/components/com_xmap/css/xmap.css');
// Convert dates from UTC
$offset = $app->getCfg('offset');
if (intval($this->item->created)) {
$this->item->created = JHtml::date($this->item->created, '%Y-%m-%d %H-%M-%S', $offset);
}
$this->_setToolbar();
if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
$tpl = 'legacy';
}
parent::display($tpl);
JRequest::setVar('hidemainmenu', true);
}
示例9: preflight
function preflight($type, $parent)
{
$jversion = new JVersion();
// Installing component manifest file version
$this->release = $parent->get("manifest")->version;
// Manifest file minimum Joomla version
$this->minimum_joomla_release = $parent->get("manifest")->attributes()->version;
// Show the essential information at the install/update back-end
echo '<p>Installing component manifest file version = ' . $this->release;
echo '<br />Current manifest cache commponent version (if any) = ' . $this->getParam('version');
echo '<br />Installing component manifest file minimum Joomla version = ' . $this->minimum_joomla_release;
echo '<br />Current Joomla version = ' . $jversion->getShortVersion();
// abort if the current Joomla release is older
if (version_compare($jversion->getShortVersion(), $this->minimum_joomla_release, 'lt')) {
Jerror::raiseWarning(null, 'Cannot install com_improvemycity in a Joomla release prior to ' . $this->minimum_joomla_release);
return false;
}
// abort if the component being installed is not newer than the currently installed version
if ($type == 'update') {
$oldRelease = $this->getParam('version');
$rel = $oldRelease . ' to ' . $this->release;
if (version_compare($this->release, $oldRelease, 'lt')) {
Jerror::raiseWarning(null, 'Incorrect version sequence. Cannot upgrade ' . $rel);
return false;
}
} else {
$rel = $this->release;
}
//echo '<p>' . JText::_('COM_IMPROVEMYCITY_PREFLIGHT_' . $type . ' ' . $rel) . '</p>';
}
示例10: __construct
function __construct()
{
parent::__construct();
// Load the database and execute our sql file
$this->db = JFactory::getDBO();
// Get information of our plugin so we can pass it on to MDS Collivery for Logs
$sel_query = "SELECT * FROM `#__extensions` where type = 'plugin' and element = 'mds_shipping' and folder = 'vmshipment';";
$this->db->setQuery($sel_query);
$this->db->query();
$this->extension_id = $this->db->loadObjectList()[0]->extension_id;
$this->app_name = $this->db->loadObjectList()[0]->extension_id;
$this->app_info = json_decode($this->db->loadObjectList()[0]->manifest_cache);
// Get our login information
$config_query = "SELECT * FROM `#__mds_collivery_config` where id = 1;";
$this->db->setQuery($config_query);
$this->db->query();
$this->password = $this->db->loadObjectList()[0]->password;
$this->username = $this->db->loadObjectList()[0]->username;
$this->risk_cover = $this->db->loadObjectList()[0]->risk_cover;
$version = new JVersion();
require_once preg_replace('|com_installer|i', "", JPATH_COMPONENT_ADMINISTRATOR) . '/helpers/config.php';
$config = array('app_name' => $this->app_info->name, 'app_version' => $this->app_info->version, 'app_host' => "Joomla: " . $version->getShortVersion() . ' - Virtuemart: ' . VmConfig::getInstalledVersion(), 'app_url' => JURI::base(), 'user_email' => $this->username, 'user_password' => $this->password);
// Use the MDS API Files
require_once JPATH_PLUGINS . '/vmshipment/mds_shipping/Mds/Cache.php';
require_once JPATH_PLUGINS . '/vmshipment/mds_shipping/Mds/Collivery.php';
$this->collivery = new Mds\Collivery($config);
// Get some information from the API
$this->towns = $this->collivery->getTowns();
$this->services = $this->collivery->getServices();
$this->location_types = $this->collivery->getLocationTypes();
$this->suburbs = $this->collivery->getSuburbs(null);
}
示例11: preflight
function preflight($type, $parent)
{
$jversion = new JVersion();
// Installing component manifest file version
$this->release = $parent->get("manifest")->version;
// If fresh install, lang file can't be loaded yet so use the tmp dir one.
$lang = JFactory::getLanguage();
$lang->load('com_jckman', dirname(__FILE__));
$lang->load('com_jckman.sys', dirname(__FILE__));
// Manifest file minimum Joomla version
$this->minimum_joomla_release = $parent->get("manifest")->attributes()->version;
if (version_compare($jversion->getShortVersion(), $this->minimum_joomla_release, 'lt')) {
JError::raiseWarning(null, JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_NOT_JOOMLA_PRIOR', $this->minimum_joomla_release));
return false;
}
//Workaround I shouldn't have to do
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$sql = $db->getQuery(true);
$sql->select('1')->from('#__extensions')->where('`name` = "com_jckman"');
if (!$db->setQuery($sql)->loadResult()) {
$sql = $db->getQuery(true);
$sql->delete('#__assets')->where('`title` like "%JCK%MAN%"');
$db->setQuery($sql)->query();
}
}
示例12: display
function display($tpl = null)
{
if (JFactory::getUser()->get('guest')) {
$msg = JText::_("ORDER_PLEASE_LOGIN_BEFORE");
$redirectUrl = base64_encode("index.php?option=com_enmasse&view=orderList");
$version = new JVersion();
$joomla = $version->getShortVersion();
if (substr($joomla, 0, 3) >= '1.6') {
$link = JRoute::_("index.php?option=com_users&view=login&return=" . $redirectUrl, false);
} else {
$link = JRoute::_("index.php?option=com_user&view=login&return=" . $redirectUrl, false);
}
JFactory::getApplication()->redirect($link, $msg);
}
$orderList = JModel::getInstance('order', 'enmasseModel')->listForBuyer(JFactory::getUser()->id);
for ($count = 0; $count < count($orderList); $count++) {
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderList[$count]->id);
$orderList[$count]->orderItem = $orderItemList[0];
$orderList[$count]->display_id = EnmasseHelper::displayOrderDisplayId($orderList[$count]->id);
}
$this->assignRef('orderList', $orderList);
$this->_setPath('template', JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "theme" . DS . EnmasseHelper::getThemeFromSetting() . DS . "tmpl" . DS);
$this->_layout = "order_list";
parent::display($tpl);
}
示例13: getValidationPlugins
function getValidationPlugins()
{
jimport('joomla.version');
$db = JFactory::getDBO();
$version = new JVersion();
if (version_compare($version->getShortVersion(), '1.6', '>=')) {
$db->setQuery("Select `element` From #__extensions Where `folder` = 'contentbuilder_validation' And `enabled` = 1");
jimport('joomla.version');
$version = new JVersion();
if (version_compare($version->getShortVersion(), '3.0', '>=')) {
$res = $db->loadColumn();
} else {
$res = $db->loadResultArray();
}
return $res;
} else {
$db->setQuery("Select `element` From #__plugins Where `folder` = 'contentbuilder_validation' And `published` = 1");
jimport('joomla.version');
$version = new JVersion();
if (version_compare($version->getShortVersion(), '3.0', '>=')) {
$res = $db->loadColumn();
} else {
$res = $db->loadResultArray();
}
return $res;
}
return array();
}
示例14: getJoomlaVersion
private function getJoomlaVersion()
{
$VERSION = new JVersion();
// Store in our object for switching configs
$this->version = $VERSION->getShortVersion();
return $VERSION->getShortVersion();
}
示例15: load
public static function load()
{
if (self::$loaded) {
return;
}
self::$loaded = true;
include_once JPATH_ROOT . '/administrator/components/com_eventgallery/version.php';
$document = JFactory::getDocument();
//JHtml::_('behavior.framework', true);
JHtml::_('behavior.formvalidation');
$params = JComponentHelper::getParams('com_eventgallery');
$doDebug = $params->get('debug', 0) == 1;
$doManualDebug = JRequest::getString('debug', '') == 'true';
$CSSs = array();
$JSs = array();
if (version_compare(JVERSION, '3.0', 'gt')) {
JHtml::_('jquery.framework');
} else {
$JSs[] = 'common/js/jquery/jquery.min.js';
$JSs[] = 'common/js/jquery/jquery-migrate-1.2.1.min.js';
}
$JSs[] = 'common/js/jquery/namespace.js';
// load script and styles in debug mode or compressed
if ($doDebug || $doManualDebug) {
$CSSs[] = 'frontend/css/eventgallery.css';
$CSSs[] = 'frontend/css/colorbox.css';
$joomlaVersion = new JVersion();
if (!$joomlaVersion->isCompatible('3.0')) {
$CSSs[] = 'frontend/css/legacy.css';
}
$JSs = array_merge($JSs, array('frontend/js/EventgalleryTools.js', 'frontend/js/EventgalleryTouch.js', 'frontend/js/jquery.colorbox.js', 'frontend/js/jquery.colorbox.init.js', 'frontend/js/EventgallerySizeCalculator.js', 'frontend/js/EventgalleryImage.js', 'frontend/js/EventgalleryRow.js', 'frontend/js/EventgalleryImageList.js', 'frontend/js/EventgalleryEventsList.js', 'frontend/js/EventgalleryEventsTiles.js', 'frontend/js/EventgalleryGridCollection.js', 'frontend/js/EventgalleryTilesCollection.js', 'frontend/js/EventgalleryCart.js', 'frontend/js/EventgallerySocialShareButton.js', 'frontend/js/EventgalleryJSGallery2.js', 'frontend/js/EventgalleryLazyload.js', 'frontend/js/EventgalleryBehavior.js'));
} else {
$joomlaVersion = new JVersion();
if (!$joomlaVersion->isCompatible('3.0')) {
$CSSs[] = 'frontend/css/eg-l-compressed.css';
} else {
$CSSs[] = 'frontend/css/eg-compressed.css';
}
$JSs[] = 'frontend/js/eg-compressed.js';
}
foreach ($CSSs as $css) {
$script = JUri::root(true) . '/media/com_eventgallery/' . $css . '?v=' . EVENTGALLERY_VERSION;
$document->addStyleSheet($script);
}
foreach ($JSs as $js) {
$script = JUri::root(true) . '/media/com_eventgallery/' . $js . '?v=' . EVENTGALLERY_VERSION;
$document->addScript($script);
}
/*
* Let's add a global configuration object for the color box slideshow.
*/
$slideshowConfiguration = array();
$slideshowConfiguration['slideshow'] = $params->get('use_lightbox_slideshow', 0) == 1 ? true : false;
$slideshowConfiguration['slideshowAuto'] = $params->get('use_lightbox_slideshow_autoplay', 0) == 1 ? true : false;
$slideshowConfiguration['slideshowSpeed'] = $params->get('lightbox_slideshow_speed', 3000);
$slideshowConfiguration['slideshowStart'] = JText::_('COM_EVENTGALLERY_LIGHTBOX_SLIDESHOW_START');
$slideshowConfiguration['slideshowStop'] = JText::_('COM_EVENTGALLERY_LIGHTBOX_SLIDESHOW_STOP');
$slideshowConfiguration['slideshowRightClickProtection'] = $params->get('lightbox_prevent_right_click', 0) == 1 ? true : false;
$document->addScriptDeclaration("EventGallerySlideShowConfiguration=" . json_encode($slideshowConfiguration) . ";");
}