本文整理汇总了PHP中JUpdater类的典型用法代码示例。如果您正苦于以下问题:PHP JUpdater类的具体用法?PHP JUpdater怎么用?PHP JUpdater使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUpdater类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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'));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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());
}
}
示例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');
}
示例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');
}
示例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;
}
示例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;
}
示例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'];
}
}
}
示例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));
}