本文整理汇总了PHP中JUpdater类的典型用法代码示例。如果您正苦于以下问题:PHP JUpdater类的具体用法?PHP JUpdater怎么用?PHP JUpdater使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUpdater类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getUpdates
/**
* @param bool $returnCount
*
* @return bool|int|string
*/
public function getUpdates($returnCount = FALSE)
{
// If Joomla 1.5 - No concept of updates
if (!file_exists(JPATH_LIBRARIES . '/joomla/updater/updater.php')) {
return FALSE;
}
// Joomla 1.7.x has to be a pain in the arse!
if (!class_exists('JUpdater')) {
require JPATH_LIBRARIES . '/joomla/updater/updater.php';
}
// Let Joomla to the caching of the latest version of updates available from vendors
$updater = JUpdater::getInstance();
$updater->findUpdates();
// get the resultant list of updates available
$db = JFactory::getDbo();
$db->setQuery('SELECT * from #__updates');
$updates = $db->LoadObjectList();
// reformat into a useable array with the extension_id as the array key
$extensionUpdatesAvailable = array();
foreach ($updates as $update) {
$extensionUpdatesAvailable[$update->extension_id] = $update;
}
// get all the installed extensions from the site
$db->setQuery('SELECT * from #__extensions');
$items = $db->LoadObjectList();
// init what we will return, a neat and tidy array
$updatesAvailable = array();
// for all installed items...
foreach ($items as $item) {
// merge by inject all known info into this item
foreach ($extensionUpdatesAvailable[$item->extension_id] as $k => $v) {
$item->{$k} = $v;
}
// Crappy Joomla
$item->current_version = array_key_exists(@$item->extension_id, @$extensionUpdatesAvailable) ? @$extensionUpdatesAvailable[@$item->extension_id]->version : @$item->version;
// if there is a newer version we want that!
if ($item->current_version !== NULL) {
// compose a nice new class, doesnt matter as we are json_encoding later anyway
$i = new stdClass();
$i->name = $item->name;
$i->eid = $item->extension_id;
$i->current_version = $item->current_version;
$i->infourl = $item->infourl;
// inject to our array we will return
$updatesAvailable[] = $i;
}
}
// Harvest update sites for better features in the future
$db->setQuery('SELECT * from #__update_sites');
$updateSites = $db->LoadObjectList();
// if we are in bfAuditor then we want just a count of the items or the actual items?
if (FALSE === $returnCount) {
$data = array();
$data['updates'] = $updatesAvailable;
$data['sites'] = json_encode($updateSites);
return $data;
} else {
return count($updatesAvailable);
}
}
开发者ID:ranamimran,项目名称:persivia,代码行数:65,代码来源:bfUpdates.php
示例2: __construct
public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
{
// CLI Constructor
parent::__construct($input, $config, $dispatcher);
// Utilities
$this->db = JFactory::getDBO();
$this->updater = JUpdater::getInstance();
$this->installer = JComponentHelper::getComponent('com_installer');
// Validate Log Path
$logPath = $this->config->get('log_path');
if (!is_dir($logPath) || !is_writeable($logPath)) {
$logPath = JPATH_BASE . '/logs';
if (!is_dir($logPath) || !is_writeable($logPath)) {
$this->out('Log Path not found - ' . $logPath);
}
$this->config->set('log_path', JPATH_BASE . '/logs');
}
// Validate Tmp Path
$tmpPath = $this->config->get('tmp_path');
if (!is_writeable($tmpPath)) {
$tmpPath = JPATH_BASE . '/tmp';
if (!is_dir($tmpPath) || !is_writeable($tmpPath)) {
$this->out('Tmp Path not found - ' . $tmpPath);
}
$this->config->set('tmp_path', JPATH_BASE . '/tmp');
}
// Push to Global Config
$config = JFactory::getConfig();
$config->set('tmp_path', $this->config->get('tmp_path'));
$config->set('log_path', $this->config->get('log_path'));
}
开发者ID:oookubox,项目名称:Joomla-cli-autoupdate,代码行数:31,代码来源:autoupdate.php
示例3: getItems
/**
* Generate a list of language choices to install in the Joomla CMS.
*
* @return boolean True if successful.
*
* @since 3.1
*/
public function getItems()
{
// Get the extension_id of the en-GB package.
$db = JFactory::getDbo();
$extQuery = $db->getQuery(true);
$extQuery->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('language'))->where($db->qn('element') . ' = ' . $db->q('en-GB'))->where($db->qn('client_id') . ' = 0');
$db->setQuery($extQuery);
$extId = (int) $db->loadResult();
if ($extId) {
$updater = JUpdater::getInstance();
/*
* The following function call uses the extension_id of the en-GB package.
* In #__update_sites_extensions you should have this extension_id linked
* to the Accredited Translations Repo.
*/
$updater->findUpdates(array($extId), 0);
$query = $db->getQuery(true);
// Select the required fields from the updates table.
$query->select($db->qn(array('update_id', 'name', 'version')))->from($db->qn('#__updates'))->order($db->qn('name'));
$db->setQuery($query);
$list = $db->loadObjectList();
if (!$list || $list instanceof Exception) {
$list = array();
}
} else {
$list = array();
}
return $list;
}
开发者ID:klas,项目名称:joomla-cms,代码行数:36,代码来源:languages.php
示例4: getInstance
/**
* Returns a reference to the global Installer object, only creating it
* if it doesn't already exist.
*
* @return JUpdater An installer object
*
* @since 11.1
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new JUpdater();
}
return self::$instance;
}
开发者ID:grlf,项目名称:eyedock,代码行数:15,代码来源:updater.php
示例5: search
/**
* Search for 3rd party extensions
*
* @return bool True if everything is ok
* @since 0.4.5
* @throws Exception
*/
public function search()
{
$updater = JUpdater::getInstance();
//print_r($updater);
/*
$rows = parent::getSourceData(
'`bid` AS id,`cid`,`type`,`name`,`alias`, `imptotal` ,`impmade`, `clicks`, '
.'`clickurl`, `checked_out`, `checked_out_time`, `showBanner` AS state,'
.' `custombannercode`, `description`, `sticky`, `ordering`, `publish_up`, '
.' `publish_down`, `params`',
null,
'bid'
);
// Do some custom post processing on the list.
foreach ($rows as &$row)
{
$row['params'] = $this->convertParams($row['params']);
// Remove unused fields.
unset($row['gid']);
}
*/
//return $rows;
}
开发者ID:sangkasi,项目名称:joomla,代码行数:32,代码来源:extensions.php
示例6: findUpdates
public function findUpdates($eid = 0, $cache_timeout = 0)
{
$updater = JUpdater::getInstance();
$error_r = error_reporting();
error_reporting(0);
$results = $updater->findUpdates($eid, $cache_timeout);
error_reporting($error_r);
return $results;
}
开发者ID:greyhat777,项目名称:vuslinterliga,代码行数:9,代码来源:b2jupdate.php
示例7: refreshUpdates
/**
* Me aseguro que el cache esta realmente actualizado
*
* @param bool $force Force reload, ignoring the cache timeout
* @return void
* @since 2.5.4
*/
public function refreshUpdates($force = false)
{
if ($force) {
$cache_timeout = 0;
} else {
$update_params = JComponentHelper::getParams('com_installer');
$cache_timeout = $update_params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
}
$updater = JUpdater::getInstance();
}
开发者ID:networksoft,项目名称:seekerplus2.com,代码行数:18,代码来源:default.php
示例8: minCmsVersion
/**
* Return min or recommend Joomla! version
* @param $recommended
* @return array
*/
public static function minCmsVersion($recommended = false)
{
$updater = JUpdater::getInstance();
$updater->findUpdates(700, 0);
$version = SPFactory::db()->select('version', '#__updates', array('extension_id' => 700))->loadResult();
$recommendedVersion = array('major' => 3, 'minor' => 2, 'build' => 3);
if ($version) {
$version = explode('.', $version);
$recommendedVersion = array('major' => $version[0], 'minor' => $version[1], 'build' => $version[2]);
}
return $recommended ? $recommendedVersion : array('major' => 3, 'minor' => 2, 'build' => 0);
}
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:17,代码来源:helper.php
示例9: checkForGantryUpdate
protected function checkForGantryUpdate()
{
$updates = RTMCUpdates::getInstance();
$last_updated = $updates->getLastUpdated();
$diff = time() - $last_updated;
if ($diff > 60 * 60 * 24) {
jimport('joomla.updater.updater');
// check for update
$updater = JUpdater::getInstance();
$results = $updater->findUpdates($updates->getExtensionId());
$updates->setLastChecked(time());
}
}
开发者ID:Simarpreet05,项目名称:joomla,代码行数:13,代码来源:updatecheck.php
示例10: doExecute
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
// Get the update cache time
$component = JComponentHelper::getComponent('com_installer');
$params = $component->params;
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
// Find all updates
$this->out('Fetching updates...');
$updater = JUpdater::getInstance();
$updater->findUpdates(0, $cache_timeout);
$this->out('Finished fetching updates');
}
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:20,代码来源:update_cron.php
示例11: doExecute
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
// Purge all old records
$db = JFactory::getDBO();
// Get the update cache time
jimport('joomla.application.component.helper');
$component = JComponentHelper::getComponent('com_installer');
$params = $component->params;
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
// Find all updates
$this->out('Fetching updates...');
$updater = JUpdater::getInstance();
$results = $updater->findUpdates(0, $cache_timeout);
$this->out('Finished fetching updates');
}
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:23,代码来源:update_cron.php
示例12: getItems
/**
* Generate a list of language choices to install in the Joomla CMS
*
* @return boolean True if successful
*
* @since 3.1
*/
public function getItems()
{
$updater = JUpdater::getInstance();
/*
* The following function uses extension_id 600, that is the English language extension id.
* In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo
*/
$updater->findUpdates(array(600), 0);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the updates table
$query->select('update_id, name, version')->from('#__updates')->order('name');
$db->setQuery($query);
$list = $db->loadObjectList();
if (!$list || $list instanceof Exception) {
$list = array();
}
return $list;
}
开发者ID:Tommar,项目名称:remate,代码行数:26,代码来源:languages.php
示例13: checkUpdates
function checkUpdates()
{
//get cache timeout from com_installer params
jimport('joomla.application.component.helper');
$component = JComponentHelper::getComponent('com_installer');
$params = $component->params;
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
//find $eid Extension identifier to look for
$dbo = JFactory::getDBO();
$query = $dbo->getQuery(true);
$query->select($dbo->qn('extension_id'))->from($dbo->qn('#__extensions'))->where($dbo->qn('element') . ' = ' . $dbo->Quote('pkg_falang'));
$dbo->setQuery($query);
$dbo->query();
$result = $dbo->loadObject();
$eid = $result->extension_id;
//find update for pkg_falang
$updater = JUpdater::getInstance();
$update = $updater->findUpdates(array($eid), $cache_timeout);
//seem $update has problem with cache
//check manually
$query = $dbo->getQuery(true);
$query->select('version')->from('#__updates')->where('element = ' . $dbo->Quote('pkg_falang'));
$dbo->setQuery($query);
$dbo->query();
$result = $dbo->loadObject();
$document =& JFactory::getDocument();
$document->setMimeEncoding('application/json');
$version = new FalangVersion();
if (!$result) {
echo json_encode(array('update' => "false", 'version' => $version->getVersionShort()));
return true;
}
$last_version = $result->version;
if (version_compare($last_version, $version->getVersionShort(), '>')) {
echo json_encode(array('update' => "true", 'version' => $last_version));
} else {
echo json_encode(array('update' => "false", 'version' => $version->getVersionShort()));
}
return true;
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:41,代码来源:cpanel.php
示例14: __construct
/**
* Public constructor. Initialises the protected members as well. Useful $config keys:
* update_component The component name, e.g. com_foobar
* update_version The default version if the manifest cache is unreadable
* update_site The URL to the component's update XML stream
* update_extraquery The extra query to append to (commercial) components' download URLs
* update_sitename The update site's name (description)
*
* @param array $config
*/
public function __construct($config = array())
{
parent::__construct($config);
// Get an instance of the updater class
$this->updater = JUpdater::getInstance();
// Get the component name
if (isset($config['update_component'])) {
$this->component = $config['update_component'];
} else {
$this->component = $this->input->getCmd('option', '');
}
// Get the component version
if (isset($config['update_version'])) {
$this->version = $config['update_version'];
}
// Get the update site
if (isset($config['update_site'])) {
$this->updateSite = $config['update_site'];
}
// Get the extra query
if (isset($config['update_extraquery'])) {
$this->extraQuery = $config['update_extraquery'];
}
// Get the extra query
if (isset($config['update_sitename'])) {
$this->updateSiteName = $config['update_sitename'];
}
// Find the extension ID
$db = $this->getDbo();
$query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q($this->component));
$db->setQuery($query);
$extension = $db->loadObject();
if (is_object($extension)) {
$this->extension_id = $extension->extension_id;
$data = json_decode($extension->manifest_cache, true);
if (isset($data['version'])) {
$this->version = $data['version'];
}
}
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:50,代码来源:update.php
示例15: find
/**
* Finds new Languages.
*
* @return void
*
* @since 2.5.7
*/
public function find()
{
require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/update.php';
// Purge the updates list
$config = array();
$model = new InstallerModelUpdate($config);
$model->purge();
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the caching duration
$params = JComponentHelper::getParams('com_installer');
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
// Find updates
$updater = JUpdater::getInstance();
/*
* The following function uses extension_id 600, that is the english language extension id.
* In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo
*/
$updater->findUpdates(array(600), $cache_timeout);
$this->setRedirect(JRoute::_('index.php?option=com_jalang&view=tool', false));
}
开发者ID:thumbs-up-sign,项目名称:TuVanDuAn,代码行数:29,代码来源:tool.php
示例16: checkForSelfUpdate
/**
* Makes sure that the Joomla! Update Component Update is in the database and check if there is a new version.
*
* @return boolean True if there is an update else false
*
* @since 3.6.3
*/
private function checkForSelfUpdate()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($db->quoteName('element') . " = " . $db->quote('com_joomlaupdate'));
$db->setQuery($query);
try {
// Get the component extension ID
$joomlaUpdateComponentId = $db->loadResult();
} catch (RuntimeException $e) {
// Something is wrong here!
$joomlaUpdateComponentId = 0;
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
// Try the update only if we have an extension id
if ($joomlaUpdateComponentId != 0) {
// Allways force to check for an update!
$cache_timeout = 0;
$updater = JUpdater::getInstance();
$updater->findUpdates($joomlaUpdateComponentId, $cache_timeout, JUpdater::STABILITY_STABLE);
// Fetch the update information from the database.
$query = $db->getQuery(true)->select('*')->from($db->quoteName('#__updates'))->where($db->quoteName('extension_id') . ' = ' . $db->quote($joomlaUpdateComponentId));
$db->setQuery($query);
try {
$joomlaUpdateComponentObject = $db->loadObject();
} catch (RuntimeException $e) {
// Something is wrong here!
$joomlaUpdateComponentObject = null;
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
if (is_null($joomlaUpdateComponentObject)) {
// No Update great!
return false;
}
return true;
}
}
开发者ID:eshiol,项目名称:joomla-cms,代码行数:43,代码来源:view.html.php
示例17: checkForGantryUpdate
public function checkForGantryUpdate()
{
gantry_import('core.gantryupdates');
$gantry_updates = GantryUpdates::getInstance();
$last_updated = $gantry_updates->getLastUpdated();
$diff = time() - $last_updated;
if ($diff > 60 * 60 * 24) {
jimport('joomla.updater.updater');
// check for update
$updater = JUpdater::getInstance();
$results = @$updater->findUpdates($gantry_updates->getGantryExtensionId());
$gantry_updates->setLastChecked(time());
}
}
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:14,代码来源:template.php
示例18: findLanguages
/**
* Method to find available languages in the Accredited Languages Update Site.
*
* @param int $cache_timeout time before refreshing the cached updates
*
* @return bool
*
* @since 2.5.7
*/
public function findLanguages($cache_timeout = 0)
{
if (!$this->enableUpdateSite()) {
return false;
}
if (!$this->enGbExtensionId) {
return false;
}
$updater = JUpdater::getInstance();
/*
* The following function call uses the extension_id of the en-GB package.
* In #__update_sites_extensions you should have this extension_id linked
* to the Accredited Translations Repo.
*/
$updater->findUpdates(array($this->enGbExtensionId), $cache_timeout);
return true;
}
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:26,代码来源:languages.php
示例19: findUpdates
/**
* Finds updates for an extension.
*
* @param int Extension identifier to look for
* @return boolean Result
* @since 2.5
*/
public function findUpdates($cid = 0)
{
$updater = JUpdater::getInstance();
$results = $updater->findUpdates($cid);
return true;
}
开发者ID:rdeutz,项目名称:square-one-cms,代码行数:13,代码来源:site.php
示例20: onAfterRender
/**
* The update check and notification email code is triggered after the page has fully rendered.
*
* @return void
*
* @since 3.5
*/
public function onAfterRender()
{
// Get the timeout for Joomla! updates, as configured in com_installer's component parameters
JLoader::import('joomla.application.component.helper');
$component = JComponentHelper::getComponent('com_installer');
/** @var \Joomla\Registry\Registry $params */
$params = $component->params;
$cache_timeout = (int) $params->get('cachetimeout', 6);
$cache_timeout = 3600 * $cache_timeout;
// Do we need to run? Compare the last run timestamp stored in the plugin's options with the current
// timestamp. If the difference is greater than the cache timeout we shall not execute again.
$now = time();
$last = (int) $this->params->get('lastrun', 0);
if (!defined('PLG_SYSTEM_UPDATENOTIFICATION_DEBUG') && abs($now - $last) < $cache_timeout) {
return;
}
// Update last run status
// If I have the time of the last run, I can update, otherwise insert
$this->params->set('lastrun', $now);
$db = JFactory::getDbo();
$query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($this->params->toString('JSON')))->where($db->qn('type') . ' = ' . $db->q('plugin'))->where($db->qn('folder') . ' = ' . $db->q('system'))->where($db->qn('element') . ' = ' . $db->q('updatenotification'));
try {
// Lock the tables to prevent multiple plugin executions causing a race condition
$db->lockTable('#__extensions');
} catch (Exception $e) {
// If we can't lock the tables it's too risky to continue execution
return;
}
try {
// Update the plugin parameters
$result = $db->setQuery($query)->execute();
$this->clearCacheGroups(array('com_plugins'), array(0, 1));
} catch (Exception $exc) {
// If we failed to execite
$db->unlockTables();
$result = false;
}
try {
// Unlock the tables after writing
$db->unlockTables();
} catch (Exception $e) {
// If we can't lock the tables assume we have somehow failed
$result = false;
}
// Abort on failure
if (!$result) {
return;
}
// This is the extension ID for Joomla! itself
$eid = 700;
// Get any available updates
$updater = JUpdater::getInstance();
$results = $updater->findUpdates(array($eid), $cache_timeout);
// If there are no updates our job is done. We need BOTH this check AND the one below.
if (!$results) {
return;
}
// Unfortunately Joomla! MVC doesn't allow us to autoload classes
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_installer/models', 'InstallerModel');
// Get the update model and retrieve the Joomla! core updates
$model = JModelLegacy::getInstance('Update', 'InstallerModel');
$model->setState('filter.extension_id', $eid);
$updates = $model->getItems();
// If there are no updates we don't have to notify anyone about anything. This is NOT a duplicate check.
if (empty($updates)) {
return;
}
// Get the available update
$update = array_pop($updates);
// Check the available version. If it's the same as the installed version we have no updates to notify about.
if (version_compare($update->version, JVERSION, 'eq')) {
return;
}
// If we're here, we have updates. First, get a link to the Joomla! Update component.
$baseURL = JUri::base();
$baseURL = rtrim($baseURL, '/');
$baseURL .= substr($baseURL, -13) != 'administrator' ? '/administrator/' : '/';
$baseURL .= 'index.php?option=com_joomlaupdate';
$uri = new JUri($baseURL);
/**
* Some third party security solutions require a secret query parameter to allow log in to the administrator
* backend of the site. The link generated above will be invalid and could probably block the user out of their
* site, confusing them (they can't understand the third party security solution is not part of Joomla! proper).
* So, we're calling the onBuildAdministratorLoginURL system plugin event to let these third party solutions
* add any necessary secret query parameters to the URL. The plugins are supposed to have a method with the
* signature:
*
* public function onBuildAdministratorLoginURL(JUri &$uri);
*
* The plugins should modify the $uri object directly and return null.
*/
JEventDispatcher::getInstance()->trigger('onBuildAdministratorLoginURL', array(&$uri));
// Let's find out the email addresses to notify
//.........这里部分代码省略.........
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:101,代码来源:updatenotification.php
注:本文中的JUpdater类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论