本文整理汇总了PHP中JFactory::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::getCache方法的具体用法?PHP JFactory::getCache怎么用?PHP JFactory::getCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::getCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save()
{
$mainframe =& JFactory::getApplication();
$row =& JTable::getInstance('K2UserGroup', 'Table');
if (!$row->bind(JRequest::get('post'))) {
$mainframe->redirect('index.php?option=com_k2&view=userGroups', $row->getError(), 'error');
}
if (!$row->check()) {
$mainframe->redirect('index.php?option=com_k2&view=userGroup&cid=' . $row->id, $row->getError(), 'error');
}
if (!$row->store()) {
$mainframe->redirect('index.php?option=com_k2&view=userGroups', $row->getError(), 'error');
}
$cache =& JFactory::getCache('com_k2');
$cache->clean();
switch (JRequest::getCmd('task')) {
case 'apply':
$msg = JText::_('Changes to User Group saved');
$link = 'index.php?option=com_k2&view=userGroup&cid=' . $row->id;
break;
case 'save':
default:
$msg = JText::_('User Group Saved');
$link = 'index.php?option=com_k2&view=userGroups';
break;
}
$mainframe->redirect($link, $msg);
}
示例2: getList
/**
* get list articles
*/
public static function getList($params)
{
$list = array();
if ($params->get('enable_cache')) {
$cache =& JFactory::getCache('mod_ice_carousel');
$cache->setCaching(true);
$cache->setLifeTime($params->get('cache_time', 15) * 60);
$list = $cache->get(array('modIceCarousel', 'getGroupObject'), array($params));
} else {
$list = self::getGroupObject($params);
}
if ($list) {
$grouped = false;
$article_grouping = $params->get('article_grouping', 'none');
$article_grouping_direction = $params->get('article_grouping_direction', 'ksort');
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
$item_heading = $params->get('item_heading');
if ($article_grouping !== 'none') {
$grouped = true;
switch ($article_grouping) {
case 'year':
case 'month_year':
$list = self::groupByDate($list, $article_grouping, $article_grouping_direction, $params->get('month_year_format', 'F Y'));
break;
case 'author':
case 'category_title':
$list = self::groupBy($list, $article_grouping, $article_grouping_direction);
break;
default:
break;
}
}
}
return $list;
}
示例3: postflight
public function postflight($type, $parent)
{
// Clear Joomla system cache.
/** @var JCache|JCacheController $cache */
$cache = JFactory::getCache();
$cache->clean('_system');
// Clear Gantry5 cache.
$path = JFactory::getConfig()->get('cache_path', JPATH_SITE . '/cache') . '/gantry5';
if (is_dir($path)) {
JFolder::delete($path);
}
// Make sure that PHP has the latest data of the files.
clearstatcache();
// Remove all compiled files from opcode cache.
if (function_exists('opcache_reset')) {
@opcache_reset();
} elseif (function_exists('apc_clear_cache')) {
@apc_clear_cache();
}
if ($type == 'uninstall') {
return true;
}
/** @var JInstallerAdapter $parent */
$manifest = $parent->getManifest();
// Enable and lock extensions to prevent uninstalling them individually.
$this->prepareExtensions($manifest, 1);
// Make sure that all file formats used by Gantry 5 are editable from template manager.
$this->adjustTemplateSettings();
return true;
}
示例4:
/**
* @return object A function cache object
*/
function &getCache(&$sitemap)
{
$cache =& JFactory::getCache('com_xmap_' . $sitemap->id);
$cache->setCaching($sitemap->usecache);
$cache->setLifeTime($sitemap->cachelifetime);
return $cache;
}
示例5: __construct
public function __construct($groupName)
{
$this->cache = JFactory::getCache($groupName, 'output');
$handler = 'output';
$options = array('storage' => 'file', 'defaultgroup' => $groupName, 'locking' => true, 'locktime' => 15, 'checkTime' => false, 'caching' => true);
$this->cache = JCache::getInstance($handler, $options);
}
示例6: __construct
public function __construct()
{
$app = JFactory::getApplication();
$this->params = $app->getTemplate(true)->params;
$this->cache = JFactory::getCache(self::CACHEKEY, '');
$this->cache->setCaching(true);
}
示例7: getFeedParser
/**
* Get a parsed XML Feed Source
*
* @param string $url Url for feed source.
* @param integer $cache_time Time to cache feed for (using internal cache mechanism).
*
* @return mixed SimplePie parsed object on success, false on failure.
*
* @since 12.2
* @deprecated 4.0 Use JFeedFactory($url) instead.
*
* @note In 3.2 will be proxied to JFeedFactory()
*/
public static function getFeedParser($url, $cache_time = 0)
{
JLog::add(__METHOD__ . ' is deprecated. Use JFeedFactory() or supply Simple Pie instead.', JLog::WARNING, 'deprecated');
$cache = JFactory::getCache('feed_parser', 'callback');
if ($cache_time > 0)
{
$cache->setLifeTime($cache_time);
}
$simplepie = new SimplePie(null, null, 0);
$simplepie->enable_cache(false);
$simplepie->set_feed_url($url);
$simplepie->force_feed(true);
$contents = $cache->get(array($simplepie, 'init'), null, false, false);
if ($contents)
{
return $simplepie;
}
JLog::add(JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'), JLog::WARNING, 'jerror');
return false;
}
示例8: __construct
/**
* Constructor
*
* Prevent creating instances of this class by making the contructor private
*
* @param object An optional KConfig object with configuration options
*/
public function __construct(KConfig $config)
{
parent::__construct($config);
if (JFactory::getConfig()->getValue('config.caching')) {
$this->_cache = JFactory::getCache('template', 'output');
}
}
示例9: postflight
public function postflight($type, $parent)
{
$this->fixUpdateSite();
// Clear Joomla system cache.
/** @var JCache|JCacheController $cache */
$cache = JFactory::getCache();
$cache->clean('_system');
// Remove all compiled files from APC cache.
if (function_exists('apc_clear_cache')) {
@apc_clear_cache();
}
if ($type == 'uninstall') {
return true;
}
$this->enablePlugin('system', 'kunena');
$this->enablePlugin('quickicon', 'kunena');
$app = JFactory::getApplication();
if (version_compare(JVERSION, '3.0', '>')) {
$modal = <<<EOS
<div id="kunena-modal" class="modal hide fade"><div class="modal-body"></div></div><script>jQuery('#kunena-modal').remove().prependTo('body').modal({backdrop: 'static', keyboard: false, remote: '{$this->makeRoute('index.php?option=com_kunena&view=install&format=raw')}'})</script>
EOS;
} else {
$modal = "<script>window.addEvent('domready',function(){SqueezeBox.open('{$this->makeRoute('index.php?option=com_kunena&view=install&tmpl=component')}',{size:{x:530,y:140},sizeLoading:{x:530,y:140},closable:false,handler:'iframe'});});</script>";
}
$app->enqueueMessage('Installing Kunena... ' . $modal);
return true;
}
示例10: remove
/**
* Logic to remove
*/
function remove()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
// Get the model
$model = $this->getModel('groups');
// Get the selected items
$cid = JRequest::getVar('cid', array(0), 'post', 'array');
// Force array elements to be integers
JArrayHelper::toInteger($cid, array(0));
$msg = '';
// No items are selected
if (!is_array($cid) || count($cid) < 1) {
JError::raiseWarning(500, JText::_('SELECT ITEM DELETE'));
} else {
$model->remove($cid);
$total = count($cid);
$msg = JText::sprintf('RST_GROUPS_DELETED', $total);
// Clean the cache, if any
$cache =& JFactory::getCache('com_rsticketspro');
$cache->clean();
}
// Redirect
$this->setRedirect('index.php?option=com_rsticketspro&view=groups', $msg);
}
示例11: getBalance
private function getBalance()
{
$cache = JFactory::getCache('paypal', 'output');
$cache->setCaching(1);
$cache->setLifeTime($this->params->get('cache', 60) * 60);
$key = md5($this->params->toString());
if (!($result = $cache->get($key))) {
try {
$http = JHttpFactory::getHttp();
$data = array('USER' => $this->params->get('apiuser'), 'PWD' => $this->params->get('apipw'), 'SIGNATURE' => $this->params->get('apisig'), 'VERSION' => '112', 'METHOD' => 'GetBalance');
$result = $http->post($this->url, $data);
} catch (Exception $e) {
JFactory::getApplication()->enqueueMessage($e->getMessage());
return $this->output = JText::_('ERROR');
}
$cache->store($result, $key);
}
if ($result->code != 200) {
$msg = __CLASS__ . ' HTTP-Status ' . JHtml::_('link', 'http://wikipedia.org/wiki/List_of_HTTP_status_codes#' . $result->code, $result->code, array('target' => '_blank'));
JFactory::getApplication()->enqueueMessage($msg, 'error');
return $this->output = JText::_('ERROR');
}
parse_str($result->body, $result->body);
if (!isset($result->body['ACK']) || $result->body['ACK'] != 'Success') {
return $this->output = $result->body['L_SHORTMESSAGE0'];
}
$this->success = true;
$this->output = $result->body['L_AMT0'] . ' ' . $result->body['L_CURRENCYCODE0'];
}
示例12: onContentPrepare
public function onContentPrepare($context, $article, $params, $page = 0)
{
//running from the backend
if (JFactory::getApplication()->isAdmin()) {
return false;
}
if (strpos($context, 'productlist') !== false) {
return;
}
if ($this->_cleaned == false) {
$cache = JFactory::getCache();
$cache->clean('com_content');
$cache->clean('com_j2store');
$this->_cleaned = true;
}
$j2params = J2Store::config();
$placement = $j2params->get('addtocart_placement', 'default');
if (strpos($context, 'com_content') !== false) {
if ($placement == 'default' || $placement == 'both') {
$this->defaultPosition($context, $article, $params, $page);
}
}
if ($placement == 'tag' || $placement == 'both') {
$this->withinArticle($context, $article, $params, $page);
}
$this->processShortCodes($context, $article, $params, $page);
}
示例13: display
/**
* Pulls together data and options and outputs the build feed.
* Header and mime is automaticly set.
*
* @access public
* @uses JCache
* @see JFactory::getCache()
* @see CKunenaRSSData::fetch()
* @see self::buildFeed()
* @return void
*/
public function display()
{
$cache = JFactory::getCache('com_kunena_rss');
if ($this->caching) {
$cache->setCaching(1);
$cache->setLifeTime($this->caching);
}
// Fetch data
$data = $cache->call(array('CKunenaRSSData', 'fetch'), $this->type, $this->incl_cat, $this->excl_cat, $this->limit, $this->timelimit);
// Set datas document header
$this->document = $this->document->getInstance('feed');
$this->document->setLink('/');
$this->document->setTitle($this->app->getCfg('sitename') . ' - Forum');
$this->document->setDescription('Kunena Site Syndication');
$this->document->setGenerator('Kunena 1.6');
// Image link for feed
$link = JURI::root();
$rss_url = $this->uri->toString(array('scheme', 'host', 'port')) . $_SERVER["REQUEST_URI"];
$rss_icon = KUNENA_URLICONSPATH . 'rss.png';
// Create image for feed
$image = new JFeedImage();
$image->title = $this->document->getTitle();
$image->url = $rss_icon;
$image->link = $link;
$image->description = $this->document->getDescription();
$this->document->image = $image;
$this->buildFeed($data);
// Render the feed
echo $this->document->render();
}
示例14: display
/**
* Display the view
*/
function display()
{
$document =& JFactory::getDocument();
$viewName = str_replace('FabrikControllerVisualization', '', get_class($this));
$viewType = $document->getType();
// Set the default view name from the Request
$view =& $this->getView($viewName, $viewType);
//create a form view as well to render the add event form.
$view->_formView =& $this->getView('Form', $viewType);
$formModel =& $this->getModel('Form');
$view->_formView->setModel($formModel, true);
// Push a model into the view
$model =& $this->getModel($viewName);
if (!JError::isError($model)) {
//$model->setAdmin( false);
$view->setModel($model, true);
}
// Display the view
$view->assign('error', $this->getError());
$post = JRequest::get('post');
//build unique cache id on url, post and user id
$user =& JFactory::getUser();
$cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
$cache =& JFactory::getCache('com_fabrik', 'view');
echo $cache->get($view, 'display', $cacheid);
}
示例15: onProfileDisplay
function onProfileDisplay()
{
JPlugin::loadLanguage('plg_community_mygoogleads', JPATH_ADMINISTRATOR);
$config = CFactory::getConfig();
$config = CFactory::getConfig();
$this->loadUserParams();
$uri = JURI::base();
$user = CFactory::getRequestUser();
$document = JFactory::getDocument();
$css = $uri . 'plugins/community/mygoogleads/mygoogleads/style.css';
$document->addStyleSheet($css);
$googleCode = $this->userparams->get('googleCode');
$content = '';
if (!empty($googleCode)) {
$mainframe = JFactory::getApplication();
$caching = $this->params->get('cache', 1);
if ($caching) {
$caching = $mainframe->getCfg('caching');
}
$cache = JFactory::getCache('plgCommunityMyGoogleAds');
$cache->setCaching($caching);
$callback = array('plgCommunityMyGoogleAds', '_getGoogleAdsHTML');
$content = $cache->call($callback, $googleCode, $user->id);
} else {
// $content = "<div class=\"icon-nopost\"><img src=\"".JURI::base()."components/com_community/assets/error.gif\" alt=\"\" /></div>";
$content .= "<div class=\"content-nopost\">" . JText::_('PLG_GOOGLE_ADS_NOT_SET') . "</div>";
}
return $content;
}