本文整理汇总了PHP中JApplicationCms::getUserState方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::getUserState方法的具体用法?PHP JApplicationCms::getUserState怎么用?PHP JApplicationCms::getUserState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCms
的用法示例。
在下文中一共展示了JApplicationCms::getUserState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
*
* @since 3.3.4
* @throws Exception
*/
public function __construct($config = array())
{
$this->app = JArrayHelper::getValue($config, 'app', JFactory::getApplication());
$this->user = JArrayHelper::getValue($config, 'user', JFactory::getUser());
$this->config = JArrayHelper::getValue($config, 'config', JFactory::getConfig());
$this->session = JArrayHelper::getValue($config, 'session', JFactory::getSession());
$this->date = JArrayHelper::getValue($config, 'date', JFactory::getDate());
$this->lang = JArrayHelper::getValue($config, 'lang', JFactory::getLanguage());
$this->package = $this->app->getUserState('com_fabrik.package', 'fabrik');
parent::__construct($config);
}
示例2: onUserLogin
/**
* Method to handle any login logic and report back to the subject.
*
* @param array $user Holds the user data.
* @param array $options Array holding options (remember, autoregister, group).
*
* @return boolean True on success.
*
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$menu = $this->app->getMenu();
if ($this->app->isSite()) {
if ($this->params->get('automatic_change', 1)) {
$assoc = JLanguageAssociations::isEnabled();
$lang_code = $user['language'];
// If no language is specified for this user, we set it to the site default language
if (empty($lang_code)) {
$lang_code = $this->default_lang;
}
jimport('joomla.filesystem.folder');
// The language has been deleted/disabled or the related content language does not exist/has been unpublished
// or the related home page does not exist/has been unpublished
if (!array_key_exists($lang_code, $this->lang_codes) || !array_key_exists($lang_code, JLanguageMultilang::getSiteHomePages()) || !JFolder::exists(JPATH_SITE . '/language/' . $lang_code)) {
$lang_code = $this->current_lang;
}
// Try to get association from the current active menu item
$active = $menu->getActive();
$foundAssociation = false;
if ($active) {
if ($assoc) {
$associations = MenusHelper::getAssociations($active->id);
}
// The login menu item contains a redirection.
// This will override the automatic change to the user preferred language
if ($active->params['login_redirect_url']) {
$this->app->setUserState('users.login.form.return', JRoute::_($this->app->getUserState('users.login.form.return'), false));
} elseif ($this->app->getUserState('users.login.form.return')) {
// The login module contains a menu item redirection. Try to get association from that menu item.
$itemid = preg_replace('/\\D+/', '', $this->app->getUserState('users.login.form.return'));
if ($assoc) {
$associations = MenusHelper::getAssociations($itemid);
}
if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
$associationItemid = $associations[$lang_code];
$this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $associationItemid);
$foundAssociation = true;
}
} elseif (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
$associationItemid = $associations[$lang_code];
$this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $associationItemid);
$foundAssociation = true;
} elseif ($active->home) {
// We are on a Home page, we redirect to the user site language home page
$item = $menu->getDefault($lang_code);
if ($item && $item->language != $active->language && $item->language != '*') {
$this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $item->id);
$foundAssociation = true;
}
}
}
if ($foundAssociation && $lang_code != $this->current_lang) {
// Change language.
$this->current_lang = $lang_code;
// Create a cookie.
$this->setLanguageCookie($lang_code);
// Change the language code.
JFactory::getLanguage()->setLanguage($lang_code);
}
} else {
if ($this->app->getUserState('users.login.form.return')) {
$this->app->setUserState('users.login.form.return', JRoute::_($this->app->getUserState('users.login.form.return'), false));
}
}
}
}
示例3: loadTabs
/**
* Set the List's tab HTML
*
* @return array Tabs
*/
public function loadTabs()
{
$this->tabs = array();
$tabs = $this->getTabCategories();
if (!is_array($tabs) || empty($tabs)) {
return $this->tabs;
}
$package = $this->app->getUserState('com_fabrik.package', 'fabrik');
$listId = $this->getId();
$tabsField = $this->getTabField();
$itemId = FabrikWorker::itemId();
$uri = JURI::getInstance();
$urlBase = $uri->toString(array('path'));
$urlBase .= '?option=com_' . $package . '&';
if ($this->app->isAdmin()) {
$urlBase .= 'task=list.view&';
} else {
$urlBase .= 'view=list&';
}
$urlBase .= 'listid=' . $listId . '&resetfilters=1';
$urlEquals = $urlBase . '&' . $tabsField . '=%s';
$urlRange = $urlBase . '&' . $tabsField . '[value][]=%s&' . $tabsField . '[value][]=%s&' . $tabsField . '[condition]=BETWEEN';
$uri = JURI::getInstance();
$thisUri = rawurldecode($uri->toString(array('path', 'query')));
foreach ($tabs as $i => $tabArray) {
$row = new stdClass();
list($label, $range) = $tabArray;
$row->label = $label;
if (is_null($range)) {
$row->href = $urlBase;
} elseif (!is_array($range)) {
$row->href = sprintf($urlEquals, $range);
} else {
list($low, $high) = $range;
$row->href = sprintf($urlEquals, sprintf($urlRange, $low, $high));
}
if ($itemId) {
$row->href .= '&Itemid=' . $itemId;
}
$row->id = 'list_tabs_' . $this->getId() . '_' . $i;
$row->js = false;
$row->class = $thisUri == $row->href ? 'active' : '';
$this->tabs[] = $row;
}
return $this->tabs;
}