本文整理汇总了PHP中JLanguageMultilang类的典型用法代码示例。如果您正苦于以下问题:PHP JLanguageMultilang类的具体用法?PHP JLanguageMultilang怎么用?PHP JLanguageMultilang使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JLanguageMultilang类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
protected function getOptions()
{
$options = array();
$option = $this->element['option'];
$view = $this->element['view'];
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('DISTINCT a.id AS value, a.title AS text, a.alias, a.level, a.menutype, a.type, a.template_style_id, a.checked_out');
$query->from('#__menu AS a');
$query->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
$query->where('a.link like ' . $db->quote('%option=' . $option . '&view=' . $view . '%'));
$query->where('a.published = 1');
if (JLanguageMultilang::isEnabled()) {
$lang = JFactory::getLanguage();
$query->where('a.language = ' . $db->quote($lang->getTag()));
}
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
return false;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例2: getList
/**
* Retrieve breadcrumb items
*
* @param \Joomla\Registry\Registry &$params module parameters
*
* @return array
*/
public static function getList(&$params)
{
// Get the PathWay object from the application
$app = JFactory::getApplication();
$pathway = $app->getPathway();
$items = $pathway->getPathWay();
$lang = JFactory::getLanguage();
$menu = $app->getMenu();
// Look for the home menu
if (JLanguageMultilang::isEnabled()) {
$home = $menu->getDefault($lang->getTag());
} else {
$home = $menu->getDefault();
}
$count = count($items);
// Don't use $items here as it references JPathway properties directly
$crumbs = array();
for ($i = 0; $i < $count; $i++) {
$crumbs[$i] = new stdClass();
$crumbs[$i]->name = stripslashes(htmlspecialchars($items[$i]->name, ENT_COMPAT, 'UTF-8'));
$crumbs[$i]->link = JRoute::_($items[$i]->link);
}
if ($params->get('showHome', 1)) {
$item = new stdClass();
$item->name = htmlspecialchars($params->get('homeText', JText::_('MOD_BREADCRUMBS_HOME')));
$item->link = JRoute::_('index.php?Itemid=' . $home->id);
array_unshift($crumbs, $item);
}
return $crumbs;
}
示例3: getItems
/**
* Gets menu items by attribute
*
* @param string $attributes The field name
* @param string $values The value of the field
* @param boolean $firstonly If true, only returns the first item found
*
* @return array
*
* @since 1.6
*/
public function getItems($attributes, $values, $firstonly = false)
{
$attributes = (array) $attributes;
$values = (array) $values;
$app = JApplicationCms::getInstance('site');
if ($app->isSite()) {
// Filter by language if not set
if (($key = array_search('language', $attributes)) === false) {
if (JLanguageMultilang::isEnabled()) {
$attributes[] = 'language';
$values[] = array(JFactory::getLanguage()->getTag(), '*');
}
} elseif ($values[$key] === null) {
unset($attributes[$key]);
unset($values[$key]);
}
// Filter by access level if not set
if (($key = array_search('access', $attributes)) === false) {
$attributes[] = 'access';
$values[] = JFactory::getUser()->getAuthorisedViewLevels();
} elseif ($values[$key] === null) {
unset($attributes[$key]);
unset($values[$key]);
}
}
// Reset arrays or we get a notice if some values were unset
$attributes = array_values($attributes);
$values = array_values($values);
return parent::getItems($attributes, $values, $firstonly);
}
示例4: displayAssociations
/**
* Method to display in frontend the associations for a given article
*
* @param integer $id Id of the article
*
* @return array An array containing the association URL and the related language object
*
* @since __DEPLOY_VERSION__
*/
public static function displayAssociations($id)
{
$return = array();
if ($associations = self::getAssociations($id)) {
$levels = JFactory::getUser()->getAuthorisedViewLevels();
$languages = JLanguageHelper::getLanguages();
foreach ($languages as $language) {
// Do not display language when no association
if (empty($associations[$language->lang_code])) {
continue;
}
// Do not display language without frontend UI
if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteLangs())) {
continue;
}
// Do not display language without specific home menu
if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteHomePages())) {
continue;
}
// Do not display language without authorized access level
if (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
continue;
}
$return[$language->lang_code] = array('item' => $associations[$language->lang_code], 'language' => $language);
}
}
return $return;
}
示例5: getForm
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to interogate.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_admin.profile', 'profile', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
// Check for username compliance and parameter set
$isUsernameCompliant = true;
if ($this->loadFormData()->username) {
$username = $this->loadFormData()->username;
$isUsernameCompliant = !(preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $username) || strlen(utf8_decode($username)) < 2 || trim($username) != $username);
}
$this->setState('user.username.compliant', $isUsernameCompliant);
if (!JComponentHelper::getParams('com_users')->get('change_login_name') && $isUsernameCompliant) {
$form->setFieldAttribute('username', 'required', 'false');
$form->setFieldAttribute('username', 'readonly', 'true');
$form->setFieldAttribute('username', 'description', 'COM_ADMIN_USER_FIELD_NOCHANGE_USERNAME_DESC');
}
// When multilanguage is set, a user's default site language should also be a Content Language
if (JLanguageMultilang::isEnabled()) {
$form->setFieldAttribute('language', 'type', 'frontend_language', 'params');
}
// If the user needs to change their password, mark the password fields as required
if (JFactory::getUser()->requireReset) {
$form->setFieldAttribute('password', 'required', 'true');
$form->setFieldAttribute('password2', 'required', 'true');
}
return $form;
}
示例6: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('site');
// Load state from the request.
$pk = $app->input->getInt('id');
$this->setState('article.id', $pk);
$offset = $app->input->getUInt('limitstart');
$this->setState('list.offset', $offset);
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
// TODO: Tune these values based on other permissions.
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content')))
{
$this->setState('filter.published', 1);
$this->setState('filter.archived', 2);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
}
示例7: getAuthorRoute
public static function getAuthorRoute($id, $lang = 0)
{
$app = JFactory::getApplication();
$db = JFactory::getDbo();
$db->setQuery('SELECT m.group_id FROM #__user_usergroup_map m
LEFT JOIN #__users u ON u.id = m.user_id
LEFT JOIN #__authorlist a ON a.userid = u.id
WHERE a.id = ' . (int) $id);
$group_ids = $db->loadObjectList();
$gids = array();
foreach ($group_ids as $gid) {
$gids[] = (int) $gid->group_id;
}
//var_dump($group_ids);
$needles = array('author' => array((int) $id), 'gids' => $gids, 'authors' => array());
$layout = '';
if ($app->input->get('layout') == 'blog') {
$layout = '&layout=blog';
}
$link = 'index.php?option=com_authorlist&view=author' . $layout . '&id=' . $id;
if (!$lang && JLanguageMultilang::isEnabled()) {
self::buildLanguageLookup();
$lang = JFactory::getLanguage()->getTag();
}
if (isset(self::$lang_lookup[$lang])) {
$link .= '&lang=' . self::$lang_lookup[$lang];
$needles['language'] = $lang;
}
if ($item = self::_findItem($needles)) {
$link .= '&Itemid=' . $item;
} elseif ($item = self::_findItem(array('author' => array(0)))) {
$link .= '&Itemid=' . $item;
}
return $link;
}
示例8: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
$fieldname = preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname);
$options = array();
foreach ($this->element->xpath('option') as $option) {
// Filter requirements
if ($requires = explode(',', (string) $option['requires'])) {
// Requires multilanguage
if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) {
continue;
}
// Requires associations
if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) {
continue;
}
}
$value = (string) $option['value'];
$text = trim((string) $option) ? trim((string) $option) : $value;
$disabled = (string) $option['disabled'];
$disabled = $disabled == 'true' || $disabled == 'disabled' || $disabled == '1';
$disabled = $disabled || $this->readonly && $value != $this->value;
$checked = (string) $option['checked'];
$checked = $checked == 'true' || $checked == 'checked' || $checked == '1';
$selected = (string) $option['selected'];
$selected = $selected == 'true' || $selected == 'selected' || $selected == '1';
$tmp = array('value' => $value, 'text' => JText::alt($text, $fieldname), 'disable' => $disabled, 'class' => (string) $option['class'], 'selected' => $checked || $selected, 'checked' => $checked || $selected);
// Set some event handler attributes. But really, should be using unobtrusive js.
$tmp['onclick'] = (string) $option['onclick'];
$tmp['onchange'] = (string) $option['onchange'];
// Add the option object to the result set.
$options[] = (object) $tmp;
}
reset($options);
return $options;
}
示例9: populateState
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is designed
* to be called on the first call to the getState() method unless the model
* configuration flag to ignore the request is set.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 12.2
*/
protected function populateState($ordering = 'ordering', $direction = 'ASC')
{
$app = JFactory::getApplication();
// List state information
$value = $app->input->get('limit', $app->get('list_limit', 0), 'uint');
$this->setState('list.limit', $value);
$value = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $value);
$orderCol = $app->input->get('filter_order', 'p.ordering');
if (!in_array($orderCol, $this->filter_fields)) {
$orderCol = 'p.ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$params = $app->getParams();
$this->setState('params', $params);
$user = JFactory::getUser();
if (!$user->authorise('core.edit.state', 'com_places') && !$user->authorise('core.edit', 'com_places')) {
// Filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.published', 1);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Process show_noauth parameter
if (!$params->get('show_noauth')) {
$this->setState('filter.access', true);
} else {
$this->setState('filter.access', false);
}
$this->setState('layout', $app->input->getString('layout'));
}
示例10: getRoute
public static function getRoute($task, $language = 0)
{
$needles = array('task' => $task);
//Create the link
$link = 'index.php?option=com_asom&task=' . $task;
if ($language && $language != "*" && JLanguageMultilang::isEnabled()) {
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('a.sef AS sef');
$query->select('a.lang_code AS lang_code');
$query->from('#__languages AS a');
$query->where('a.lang_code = ' . $language);
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang) {
if ($language == $lang->lang_code) {
$language = $lang->sef;
$link .= '&lang=' . $language;
}
}
}
if ($item = self::_findItem($needles)) {
$link .= '&Itemid=' . $item;
} elseif ($item = self::_findItem()) {
$link .= '&Itemid=' . $item;
}
return $link;
}
示例11: getArticleRoute
/**
* @param int The route of the content item
*/
public static function getArticleRoute($id, $catid = 0, $language = 0)
{
$needles = array('article' => array((int) $id));
//Create the link
$link = 'index.php?option=com_content&view=article&id=' . $id;
if ((int) $catid > 1) {
$categories = JCategories::getInstance('Content');
$category = $categories->get((int) $catid);
if ($category) {
$needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category'];
$link .= '&catid=' . $catid;
}
}
if ($language && $language != "*" && JLanguageMultilang::isEnabled()) {
self::buildLanguageLookup();
if (isset(self::$lang_lookup[$language])) {
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles)) {
$link .= '&Itemid=' . $item;
}
return $link;
}
示例12: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
$options = array();
foreach ($this->element->children() as $option) {
// Only add <option /> elements.
if ($option->getName() != 'option') {
continue;
}
// Filter requirements
if ($requires = explode(',', (string) $option['requires'])) {
// Requires multilanguage
if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) {
continue;
}
// Requires associations
if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) {
continue;
}
}
$value = (string) $option['value'];
$disabled = (string) $option['disabled'];
$disabled = $disabled == 'true' || $disabled == 'disabled' || $disabled == '1';
$disabled = $disabled || $this->readonly && $value != $this->value;
// Create a new option object based on the <option /> element.
$tmp = JHtml::_('select.option', $value, JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', $disabled);
// Set some option attributes.
$tmp->class = (string) $option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $option['onclick'];
// Add the option object to the result set.
$options[] = $tmp;
}
reset($options);
return $options;
}
示例13: __construct
public function __construct()
{
$this->app = \JApplicationCms::getInstance('site');
$lang = \JFactory::getLanguage();
$tag = \JLanguageMultilang::isEnabled() ? $lang->getTag() : '*';
$this->menu = $this->app->getMenu();
$this->default = $this->menu->getDefault($tag);
$this->active = $this->menu->getActive();
}
示例14: display
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a Error object.
*/
public function display($tpl = null)
{
$user = JFactory::getUser();
$app = JFactory::getApplication();
// Get model data.
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
$this->return_page = $this->get('ReturnPage');
if (empty($this->item->id)) {
$authorised = $user->authorise('core.create', 'com_content') || count($user->getAuthorisedCategories('com_content', 'core.create'));
} else {
$authorised = $this->item->params->get('access-edit');
}
if ($authorised !== true) {
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->setHeader('status', 403, true);
return false;
}
$this->item->tags = new JHelperTags();
if (!empty($this->item->id)) {
$this->item->tags->getItemTags('com_content.article.', $this->item->id);
}
if (!empty($this->item) && isset($this->item->id)) {
$this->item->images = json_decode($this->item->images);
$this->item->urls = json_decode($this->item->urls);
$tmp = new stdClass();
$tmp->images = $this->item->images;
$tmp->urls = $this->item->urls;
$this->form->bind($tmp);
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Create a shortcut to the parameters.
$params =& $this->state->params;
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->params = $params;
// Override global params with article specific params
$this->params->merge($this->item->params);
$this->user = $user;
if ($params->get('enable_category') == 1) {
$this->form->setFieldAttribute('catid', 'default', $params->get('catid', 1));
$this->form->setFieldAttribute('catid', 'readonly', 'true');
}
// Propose current language as default when creating new article
if (JLanguageMultilang::isEnabled() && empty($this->item->id)) {
$lang = JFactory::getLanguage()->getTag();
$this->form->setFieldAttribute('language', 'default', $lang);
}
$this->_prepareDocument();
parent::display($tpl);
}
示例15: populateState
protected function populateState()
{
$app = JFactory::getApplication('site');
$pageId = $app->input->getInt('id');
$this->setState('page.id', $pageId);
$user = JFactory::getUser();
if (!$user->authorise('core.edit.state', 'com_sppagebuilder') && !$user->authorise('core.edit', 'com_sppagebuilder')) {
$this->setState('filter.published', 1);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
}