本文整理汇总了PHP中KunenaForum::version方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForum::version方法的具体用法?PHP KunenaForum::version怎么用?PHP KunenaForum::version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaForum
的用法示例。
在下文中一共展示了KunenaForum::version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseKunenaInstallFile
public static function parseKunenaInstallFile($path) {
$xml = simplexml_load_file($path);
if (!$xml || $xml->getName() != 'kinstall') {
return false;
}
$data = new stdClass();
$data->name = (string) $xml->name;
$data->type = (string) $xml->attributes()->type;
$data->creationdate = (string) $xml->creationDate;
$data->author = (string) $xml->author;
$data->copyright = (string) $xml->copyright;
$data->authorEmail = (string) $xml->authorEmail;
$data->authorUrl = (string) $xml->authorUrl;
$data->version = (string) $xml->version;
$data->description = (string) $xml->description;
$data->thumbnail = (string) $xml->thumbnail;
if ($data->version == '@kunenaversion@') $data->version = KunenaForum::version();
if ($data->creationdate == '@kunenaversiondate@') $data->creationdate = KunenaForum::versionDate();
if (!$data->version) $data->version = JText::_('Unknown');
if (!$data->creationdate) $data->creationdate = JText::_('Unknown');
if (!$data->author) $data->author = JText::_('Unknown');
return $data;
}
示例2: onGetIcons
/**
* Display Kunena backend icon in Joomla 2.5+
*
* @param string $context
*/
public function onGetIcons($context)
{
if (!$context == 'mod_quickicon' || !JFactory::getUser()->authorise('core.manage', 'com_kunena')) {
return;
}
KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
if (KunenaForum::installed() && KunenaFactory::getConfig()->version_check && JFactory::getUser()->authorise('core.manage', 'com_installer')) {
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_kunena'));
$db->setQuery($query);
$cparams = new JRegistry((string) $db->loadResult());
//$cparams = JComponentHelper::getParams('com_kunena');
$liveupdate = new JRegistry($cparams->get('liveupdate', null));
$lastCheck = $liveupdate->get('lastcheck', 0);
$updateInfo = json_decode(trim((string) $liveupdate->get('updatedata', ''), '"'));
$valid = abs(time() - $lastCheck) <= 24 * 3600;
// 24 hours
if (!$valid) {
// If information is not valid, update it asynchronously.
$ajax_url = JURI::base() . 'index.php?option=com_kunena&view=liveupdate&task=ajax';
$script = "window.addEvent('domready', function() {\n\tvar com_kunena_updatecheck_ajax_structure = {\n\t\tonSuccess: function(msg, responseXML) {\n\t\t\tvar updateInfo = JSON.decode(msg, true);\n\t\t\tif (updateInfo.html) {\n\t\t\t\tdocument.id('com_kunena_icon').getElement('img').setProperty('src',updateInfo.img);\n\t\t\t\tdocument.id('com_kunena_icon').getElement('span').set('html', updateInfo.html);\n\t\t\t\tdocument.id('com_kunena_icon').getElement('a').set('href', updateInfo.link);\n\t\t\t}\n\t\t},\n\t\turl: '{$ajax_url}'\n\t};\n\tajax_object = new Request(com_kunena_updatecheck_ajax_structure);\n\tajax_object.send();\n});";
$document = JFactory::getDocument();
$document->addScriptDeclaration($script);
}
}
$link = 'index.php?option=com_kunena';
if (!KunenaForum::installed()) {
// Not fully installed
$img = 'kunena/icons/icon-48-kupdate-alert-white.png';
$text = JText::_('PLG_QUICKICON_KUNENA_COMPLETE_INSTALLATION');
} elseif (empty($updateInfo->supported)) {
// Unsupported
$img = 'kunena/icons/kunena-logo-48-white.png';
$text = JText::_('COM_KUNENA');
} elseif ($updateInfo->stuck) {
// Stuck
$img = 'kunena/icons/icon-48-kupdate-alert-white.png';
$text = JText::_('COM_KUNENA') . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_CRASH');
} elseif (version_compare(KunenaForum::version(), $updateInfo->version, '<')) {
// Has updates
$img = 'kunena/icons/icon-48-kupdate-update-white.png';
$text = 'Kunena ' . $updateInfo->version . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_AVAILABLE');
$link .= '&view=liveupdate';
} else {
// Already in the latest release
$img = 'kunena/icons/icon-48-kupdate-good-white.png';
$text = JText::_('COM_KUNENA');
}
return array(array('link' => JRoute::_($link), 'image' => $img, 'text' => $text, 'access' => array('core.manage', 'com_kunena'), 'id' => 'com_kunena_icon'));
}
示例3: getLatestVersion
function getLatestVersion()
{
$latestVersion = $this->getLatestKunenaVersion();
if ($latestVersion['connect']) {
if (version_compare($latestVersion['latest_version'], KunenaForum::version(), '<=')) {
$needUpgrade = JText::sprintf('COM_KUNENA_COM_A_CHECK_VERSION_CORRECT', KunenaForum::version());
} else {
$needUpgrade = JText::sprintf('COM_KUNENA_COM_A_CHECK_VERSION_NEED_UPGRADE', $latestVersion['latest_version'], $latestVersion['released']);
}
} else {
$needUpgrade = JText::_('COM_KUNENA_COM_A_CHECK_VERSION_CANNOT_CONNECT');
}
return $needUpgrade;
}
示例4: getVersion
/**
* Get forum version
*
* @param object $forum
* @return string
*/
function getVersion($forum)
{
global $_CB_database;
static $version = null;
if ($version === null) {
if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) {
if (isset($forum->config['version'])) {
$version = $forum->config['version'];
} elseif ($forum->component == 'com_fireboard' || $forum->component == 'com_kunena') {
$query = 'SELECT ' . $_CB_database->NameQuote('version') . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_version') . "\n ORDER BY " . $_CB_database->NameQuote('id') . " DESC";
$_CB_database->setQuery($query, 0, 1);
$version = $_CB_database->loadResult();
} else {
$version = '0.0.0';
}
} elseif (class_exists('KunenaForum')) {
$version = KunenaForum::version();
} else {
$version = '0.0.0';
}
}
return $version;
}
示例5: prepare
function prepare()
{
if (!JRequest::checkToken('get')) {
$this->setRedirect('index.php?option=com_kunena');
return;
}
$start = JRequest::getBool('start', false);
// Workaround situation where KunenaForum class doesn't exist (api.php was cached)
if (!class_exists('KunenaForum')) {
// TODO: add version check
$app = JFactory::getApplication();
$try = $app->getUserState('kunena-prepare', 0) + 1;
clearstatcache();
if (function_exists('apc_clear_cache')) {
apc_clear_cache('system');
}
sleep(1);
$app->setUserState('kunena-prepare', $try);
$start = $start ? '&start=1' : '';
$this->setRedirect('index.php?option=com_kunena&view=install&task=prepare&try=' . $try . $start . '&' . JUtility::getToken() . '=1');
$this->redirect();
}
$this->model->install();
if ($start) {
// Make sure that the code is identical to the installer (we can improve it later on)
$versions = $this->model->getDetectVersions();
$version = reset($versions);
if (!empty($version->state) || $version->version == KunenaForum::version() && $version->versiondate == KunenaForum::versionDate()) {
unset($version);
}
}
if (isset($version)) {
$this->setRedirect($version->link);
} else {
$this->setRedirect('index.php?option=com_kunena&view=install');
}
}
示例6: getVersionHTML
/**
* Retrieve installed Kunena version as string.
*
* @return string "Kunena X.Y.Z | YYYY-MM-DD [versionname]"
*/
static function getVersionHTML()
{
return 'Kunena ' . KunenaForum::version() . ' | ' . KunenaForum::versionDate() . ' [ ' . KunenaForum::versionName() . ' ]';
}
示例7: setToolBar
/**
* Private method to set the toolbar for this view
*
* @access private
*
* @return null
**/
function setToolBar()
{
// Set the titlebar text
JToolBarHelper::title('<span>Kunena ' . KunenaForum::version() . '</span> ' . JText::_('COM_KUNENA_INSTALLER'), 'kunena.png');
}
示例8: onGetIcons
/**
* Display Kunena backend icon in Joomla 2.5+
*
* @param string $context
*
* @return array|null
*/
public function onGetIcons($context)
{
if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_kunena')) {
return null;
}
KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
$updateInfo = null;
if (KunenaForum::installed() && JFactory::getUser()->authorise('core.manage', 'com_installer')) {
$updateSite = 'http://update.kunena.org/%';
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('*')->from($db->qn('#__updates'))->where($db->qn('extension_id') . ' > 0')->where($db->qn('detailsurl') . ' LIKE ' . $db->q($updateSite));
$db->setQuery($query);
$list = (array) $db->loadObjectList();
if ($list) {
$updateInfo = new stdClass();
$updateInfo->addons = 0;
$updateInfo->version = 0;
foreach ($list as $item) {
if ($item->element == 'pkg_kunena') {
$updateInfo->version = $item->version;
} else {
$updateInfo->addons++;
}
}
} else {
$query = $db->getQuery(true)->select('update_site_id')->from($db->qn('#__update_sites'))->where($db->qn('enabled') . ' = 0')->where($db->qn('location') . ' LIKE ' . $db->q($updateSite));
$db->setQuery($query);
$updateInfo = !$db->loadResult();
}
}
$link = 'index.php?option=com_kunena';
$useIcons = version_compare(JVERSION, '3.0', '>');
if (!KunenaForum::installed()) {
// Not fully installed
$img = $useIcons ? 'warning' : 'kunena/icons/icon-48-kupdate-alert-white.png';
$icon = 'kunena/icons/icon-48-kupdate-alert-white.png';
$text = JText::_('PLG_QUICKICON_KUNENA_COMPLETE_INSTALLATION');
} elseif ($updateInfo === null) {
// Unsupported
$img = $useIcons ? 'remove' : 'kunena/icons/kunena-logo-48-white.png';
$icon = 'kunena/icons/kunena-logo-48-white.png';
$text = JText::_('COM_KUNENA');
} elseif ($updateInfo === false) {
// Disabled
$img = $useIcons ? 'minus' : 'kunena/icons/icon-48-kupdate-alert-white.png';
$icon = 'kunena/icons/icon-48-kupdate-alert-white.png';
$text = JText::_('COM_KUNENA') . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_DISABLED');
} elseif (!empty($updateInfo->version) && version_compare(KunenaForum::version(), $updateInfo->version, '<')) {
// Has updates
$img = $useIcons ? 'download' : 'kunena/icons/icon-48-kupdate-update-white.png';
$icon = 'kunena/icons/icon-48-kupdate-update-white.png';
$text = 'Kunena ' . $updateInfo->version . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_NOW');
$link = 'index.php?option=com_installer&view=update&filter_search=kunena';
} elseif (!empty($updateInfo->addons)) {
// Has updated add-ons
$img = $useIcons ? 'download' : 'kunena/icons/icon-48-kupdate-update-white.png';
$icon = 'kunena/icons/icon-48-kupdate-update-white.png';
$text = JText::_('COM_KUNENA') . '<br />' . JText::sprintf('PLG_QUICKICON_KUNENA_UPDATE_ADDONS', $updateInfo->addons);
$link = 'index.php?option=com_installer&view=update&filter_search=kunena';
} else {
// Already in the latest release
$img = $useIcons ? 'comments' : 'kunena/icons/icon-48-kupdate-good-white.png';
$icon = 'kunena/icons/icon-48-kupdate-good-white.png';
$text = JText::_('COM_KUNENA');
}
// Use one line in J!3.0.
if (version_compare(JVERSION, '3.0', '>')) {
$text = preg_replace('|<br />|', ' - ', $text);
}
return array(array('link' => JRoute::_($link), 'image' => $img, 'text' => $text, 'icon' => $icon, 'access' => array('core.manage', 'com_kunena'), 'id' => 'com_kunena_icon'));
}
示例9: migrateExtensionCustom
/**
* Migrate custom information.
*
* This function gets called after all folders and tables have been copied.
*
* If you want to split this task into smaller chunks,
* please store your custom state variables into $this->state and return false.
* Returning false will force jUpgrade to call this function again,
* which allows you to continue import by reading $this->state before continuing.
*
* @return boolean Ready (true/false)
* @since 1.6.4
* @throws Exception
*/
protected function migrateExtensionCustom()
{
require_once JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
// Need to initialize application
jimport('joomla.environment.uri');
$app = JFactory::getApplication('administrator');
// Get component object
$component = JTable::getInstance('extension', 'JTable', array('dbo' => $this->db_new));
$component->load(array('type' => 'component', 'element' => $this->name));
// First fix all broken menu items
$query = "UPDATE #__menu SET component_id={$this->db_new->quote($component->extension_id)} WHERE type = 'component' AND link LIKE '%option={$this->name}%'";
$this->db_new->setQuery($query);
$this->db_new->query();
$menumap = $this->getMapList('menus');
// Get all menu items from the component (JMenu style)
$query = $this->db_new->getQuery(true);
$query->select('*');
$query->from('#__menu');
$query->where("component_id = {$component->extension_id}");
$query->where('client_id = 0');
$query->order('lft');
$this->db_new->setQuery($query);
$menuitems = $this->db_new->loadObjectList('id');
foreach ($menuitems as &$menuitem) {
// Get parent information.
$parent_tree = array();
if (isset($menuitems[$menuitem->parent_id])) {
$parent_tree = $menuitems[$menuitem->parent_id]->tree;
}
// Create tree.
$parent_tree[] = $menuitem->id;
$menuitem->tree = $parent_tree;
// Create the query array.
$url = str_replace('index.php?', '', $menuitem->link);
$url = str_replace('&', '&', $url);
parse_str($url, $menuitem->query);
}
// Update menu items
foreach ($menuitems as $menuitem) {
if (!isset($menuitem->query['view'])) {
continue;
}
$update = false;
switch ($menuitem->query['view']) {
case 'home':
// Update default menu item
if (!empty($menuitem->query['defaultmenu'])) {
$menuitem->query['defaultmenu'] = isset($menumap[$menuitem->query['defaultmenu']]) ? $menumap[$menuitem->query['defaultmenu']]->new : 0;
$update = true;
}
break;
}
if ($update) {
// Update menuitem link
$query_string = array();
foreach ($menuitem->query as $k => $v) {
$query_string[] = $k . '=' . $v;
}
$menuitem->link = 'index.php?' . implode('&', $query_string);
// Save menu object
$menu = JTable::getInstance('menu', 'JTable', array('dbo' => $this->db_new));
$menu->bind(get_object_vars($menuitem), array('tree', 'query'));
$success = $menu->check();
if ($success) {
$success = $menu->store();
}
if (!$success) {
echo "ERROR";
}
}
}
// Replace Joomla! 1.5 manifest file with Joomla! 2.5 version
jimport('joomla.filesystem.file');
$manifest25 = JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.j25.xml';
$manifest15 = JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.xml';
if (file_exists($manifest25)) {
$content = file_get_contents($manifest25);
// Take care of Git install
$content = preg_replace('/@kunenaversion@/', preg_replace('/-GIT/i', '', KunenaForum::version()), $content);
$content = preg_replace('/@kunenaversiondate@/', KunenaForum::versionDate(), $content);
$content = preg_replace('/@kunenaversionname@/', KunenaForum::versionName(), $content);
JFile::write($manifest15, $content);
JFile::delete($manifest25);
}
jimport('joomla.plugin.helper');
// Mark Kunena as discovered and install it
//.........这里部分代码省略.........
示例10: getInstallAction
public function getInstallAction($version = null)
{
if ($version->component === null) {
$this->_action = 'INSTALL';
} else {
if ($version->prefix != 'kunena_') {
$this->_action = 'MIGRATE';
} else {
if (version_compare(strtolower(KunenaForum::version()), strtolower($version->version), '>')) {
$this->_action = 'UPGRADE';
} else {
if (version_compare(strtolower(KunenaForum::version()), strtolower($version->version), '<')) {
$this->_action = 'DOWNGRADE';
} else {
$this->_action = 'REINSTALL';
}
}
}
}
return $this->_action;
}
示例11: onExtensionBeforeUpdate
/**
* Prevent downgrades to Kunena 1.7 and older releases
*/
public function onExtensionBeforeUpdate($type, $manifest)
{
if ($type != 'component') {
return true;
}
// Generate component name
$name = strtolower(JFilterInput::getInstance()->clean((string) $manifest->name, 'cmd'));
$element = substr($name, 0, 4) == "com_" ? $name : "com_{$name}";
if ($element != 'com_kunena') {
return true;
}
// Kunena 2.0.0-BETA2 and later support this feature in their installer
if (version_compare($manifest->version, '2.0.0', '>=')) {
return true;
}
// Check if we can downgrade to the current version
if (class_exists('KunenaInstaller') && KunenaInstaller::canDowngrade($manifest->version)) {
return true;
}
// Old version detected: emulate failed installation
$app = JFactory::getApplication();
$app->enqueueMessage(sprintf('Sorry, it is not possible to downgrade Kunena %s to version %s.', KunenaForum::version(), $manifest->version), 'warning');
$app->enqueueMessage(JText::_('JLIB_INSTALLER_ABORT_COMP_INSTALL_CUSTOM_INSTALL_FAILURE'), 'error');
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATE_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($type))));
$app->redirect('index.php?option=com_installer');
return true;
}
示例12: getKunenaCategories
/**
* Retrieves a list of categories in Kunena
*
* @param null
* @return string A JSON string
**/
private function getKunenaCategories()
{
require_once JPATH_ROOT . '/administrator/components/com_kunena/api.php';
$columnName = 'parent';
if (class_exists('KunenaForum') && KunenaForum::version() >= '2.0') {
$columnName = 'parent_id';
}
$db = DiscussHelper::getDBO();
$query = 'SELECT * FROM ' . $db->nameQuote('#__kunena_categories') . ' where ' . $db->nameQuote($columnName) . ' = ' . $db->Quote('0') . ' ORDER BY ' . $db->nameQuote('ordering') . ' ASC';
$db->setQuery($query);
$result = $db->loadObjectList();
if (!$result) {
return false;
}
return $result;
}
示例13: ajax
function ajax()
{
// Note: we don't do a token check as we're fetching information
// asynchronously. This means that between requests the token might
// change, making it impossible for AJAX to work.
$info = self::getUpdateInformation();
$lang = JFactory::getLanguage();
$lang->load('plg_quickicon_kunena.sys', JPATH_ADMINISTRATOR) || $lang->load('plg_quickicon_kunena.sys', KPATH_ADMIN);
$obj = new stdClass();
$obj->link = 'index.php?option=com_kunena';
if (empty($info->supported)) {
// Unsupported
$obj->img = 'kunena/images/icons/kunena-logo-48-white.png';
$obj->html = JText::_('COM_KUNENA');
} elseif ($info->stuck) {
// Stuck
$obj->img = 'kunena/images/icons/icon-48-kupdate-alert-white.png';
$obj->html = JText::_('COM_KUNENA') . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_CRASH');
} elseif (version_compare(KunenaForum::version(), $info->version, '<')) {
// Has updates
$obj->img = 'kunena/images/icons/icon-48-kupdate-update-white.png';
$obj->html = 'Kunena ' . $info->version . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_AVAILABLE');
$obj->link .= '&view=liveupdate';
} else {
// Already in the latest release
$obj->img = 'kunena/images/icons/icon-48-kupdate-good-white.png';
$obj->html = JText::_('COM_KUNENA');
}
$obj->img = JUri::root() . '/media/' . $obj->img;
$obj->link = JRoute::_($obj->link, false);
echo json_encode($obj);
JFactory::getApplication()->close();
}
示例14: buildVersion
protected static function buildVersion() {
if ('@kunenaversion@' == '@' . 'kunenaversion' . '@') {
$xml = KPATH_ADMIN . '/kunena.xml';
$parser = JFactory::getXMLParser ( 'Simple' );
$parser->loadFile ( $xml );
self::$version = $parser->document->getElementByPath ( 'version' )->data () . '-SVN';
} else {
self::$version = strtoupper ( '@kunenaversion@' );
}
self::$version_date = ('@kunenaversiondate@' == '@' . 'kunenaversiondate' . '@') ? JFactory::getDate()->toMySQL() : '@kunenaversiondate@';
self::$version_name = ('@kunenaversionname@' == '@' . 'kunenaversionname' . '@') ? 'SVN Revision' : '@kunenaversionname@';
}
示例15: buildVersion
protected static function buildVersion()
{
if ('2.0.1' == '@' . 'kunenaversion' . '@') {
$xml = KPATH_ADMIN . '/kunena.xml';
$parser = JFactory::getXMLParser('Simple');
$parser->loadFile($xml);
self::$version = $parser->document->getElementByPath('version')->data() . '-GIT';
} else {
self::$version = strtoupper('2.0.1');
}
self::$version_major = substr(self::$version, 0, 3);
self::$version_date = '2012-07-07' == '@' . 'kunenaversiondate' . '@' ? JFactory::getDate()->toMySQL() : '2012-07-07';
self::$version_name = 'Balozi' == '@' . 'kunenaversionname' . '@' ? 'Git Repository' : 'Balozi';
}