本文整理汇总了PHP中JLanguageAssociations::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP JLanguageAssociations::isEnabled方法的具体用法?PHP JLanguageAssociations::isEnabled怎么用?PHP JLanguageAssociations::isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JLanguageAssociations
的用法示例。
在下文中一共展示了JLanguageAssociations::isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
$this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
$this->assoc = $this->get('Assoc');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Check for tag type
$this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
JFactory::getApplication()->input->set('hidemainmenu', true);
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例2: 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_\\-]/', '_', trim((string) $option))), '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;
}
示例3: display
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$user = JFactory::getUser();
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->modules = $this->get('Modules');
$this->levels = $this->get('ViewLevels');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));
// Check if we're allowed to edit this item
// No need to check for create, because then the moduletype select is empty
if (!empty($this->item->id) && !$this->canDo->get('core.edit')) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
parent::display($tpl);
$this->addToolbar();
}
示例4: preprocessForm
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 3.0
*/
protected function preprocessForm(JForm $form, $data, $group = 'jevents')
{
// Association content items
$app = JFactory::getApplication();
$assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
if ($assoc) {
$languages = JLanguageHelper::getLanguages('lang_code');
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
$fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
$add = false;
foreach ($languages as $tag => $language) {
if (empty($data->language) || $tag != $data->language) {
$add = true;
$field = $fieldset->addChild('field');
$field->addAttribute('name', $tag);
$field->addAttribute('type', 'modal_article');
$field->addAttribute('language', $tag);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
}
}
if ($add) {
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
示例5: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
// Initialise variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例6: getLabel
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 2.5.5
*/
protected function getLabel()
{
$label = '';
if ($this->hidden) {
return $label;
}
// Get the label text from the XML element, defaulting to the element name.
$text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
$text = $this->translateLabel ? JText::_($text) : $text;
// Set required to true as this field is not displayed at all if not required.
$this->required = true;
// Add CSS and JS for the TOS field
$doc = JFactory::getDocument();
$css = "#jform_profile_tos {width: 18em; margin: 0 !important; padding: 0 2px !important;}\n\t\t\t\t#jform_profile_tos input {margin:0 5px 0 0 !important; width:10px !important;}\n\t\t\t\t#jform_profile_tos label {margin:0 15px 0 0 !important; width:auto;}\n\t\t\t\t";
$doc->addStyleDeclaration($css);
JHtml::_('behavior.modal');
// Build the class for the label.
$class = !empty($this->description) ? 'hasTooltip' : '';
$class = $class . ' required';
$class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class;
// Add the opening label tag and main attributes attributes.
$label .= '<label id="' . $this->id . '-lbl" for="' . $this->id . '" class="' . $class . '"';
// If a description is specified, use it to build a tooltip.
if (!empty($this->description)) {
$label .= ' title="' . htmlspecialchars(trim($text, ':') . '<br />' . ($this->translateDescription ? JText::_($this->description) : $this->description), ENT_COMPAT, 'UTF-8') . '"';
}
$tosarticle = $this->element['article'] > 0 ? (int) $this->element['article'] : 0;
if ($tosarticle) {
JLoader::register('ContentHelperRoute', JPATH_BASE . '/components/com_content/helpers/route.php');
$attribs = array();
$attribs['class'] = 'modal';
$attribs['rel'] = '{handler: \'iframe\', size: {x:800, y:500}}';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, alias, catid, language')->from('#__content')->where('id = ' . $tosarticle);
$db->setQuery($query);
$article = $db->loadObject();
if (JLanguageAssociations::isEnabled()) {
$tosassociated = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $tosarticle);
}
$current_lang = JFactory::getLanguage()->getTag();
if (isset($tosassociated) && $current_lang != $article->language && array_key_exists($current_lang, $tosassociated)) {
$url = ContentHelperRoute::getArticleRoute($tosassociated[$current_lang]->id, $tosassociated[$current_lang]->catid);
$link = JHtml::_('link', JRoute::_($url . '&tmpl=component&lang=' . $tosassociated[$current_lang]->language), $text, $attribs);
} else {
$slug = $article->alias ? $article->id . ':' . $article->alias : $article->id;
$url = ContentHelperRoute::getArticleRoute($slug, $article->catid);
$link = JHtml::_('link', JRoute::_($url . '&tmpl=component&lang=' . $article->language), $text, $attribs);
}
} else {
$link = $text;
}
// Add the label text and closing tag.
$label .= '>' . $link . '<span class="star"> *</span></label>';
return $label;
}
示例7: __construct
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'a.id', 'name', 'a.name', 'groups', 'a.groups', 'site', 'a.site', 'work_start', 'a.work_start');
if (JLanguageAssociations::isEnabled()) {
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config);
}
示例8: __construct
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'a.id', 'num', 'a.num', 'model', 'a.model', 'position', 'a.position', 'use_time', 'a.use_time', 'weld_time', 'a.weld_time', 'times', 'welder_name');
if (JLanguageAssociations::isEnabled()) {
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config);
}
示例9: __construct
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @since 1.6
* @see JController
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'created_by_alias', 'a.created_by_alias', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'published', 'a.published', 'author_id', 'category_id', 'level', 'tag');
if (JLanguageAssociations::isEnabled()) {
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config);
}
示例10: __construct
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'a.id', 'num', 'a.num', 'brand', 'a.brand');
if (JLanguageAssociations::isEnabled()) {
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config);
}
示例11: __construct
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.7.0
*/
public function __construct($config = [])
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = ['id', 'a.id', 'name', 'a.name', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'user_id', 'a.user_id', 'published', 'a.published', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'ordering', 'a.ordering', 'language', 'a.language', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'ul.name', 'linked_user', 'tag', 'level', 'c.level'];
$assoc = JLanguageAssociations::isEnabled();
if ($assoc) {
$config['filter_fields'][] = 'association';
}
}
parent::__construct($config);
}
示例12: store
public function store($updateNulls = false)
{
if (is_array($this->params)) {
$registry = new JRegistry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
$date = JFactory::getDate();
$user = JFactory::getUser();
$db = JFactory::getDBO();
$db->setQuery('SELECT username FROM #__users WHERE id=' . $this->userid);
$this->alias = $db->loadResult();
$this->alias = JApplication::stringURLSafe($this->alias);
$table = JTable::getInstance('Author', 'AuthorListTable');
if (!$this->userid) {
$this->setError(JText::_('COM_AUTHORLIST_STORE_ERROR_USER_REQUIRED'));
return false;
}
if ($table->load(array('userid' => $this->userid)) && ($table->id != $this->id || $this->id == 0)) {
$app = JFactory::getApplication();
$assoc = JLanguageAssociations::isEnabled();
if ($assoc) {
if ($table->language == $this->language || $this->language == '*' || $table->language == '*') {
$this->setError(JText::_('COM_AUTHORLIST_STORE_ERROR_AUTHOR_EXISTS_LANGUAGE'));
return false;
}
} else {
$this->setError(JText::_('COM_AUTHORLIST_STORE_ERROR_AUTHOR_EXISTS'));
return false;
}
}
if (!$this->id) {
if (!intval($this->created)) {
$this->created = $date->toSql();
}
if (empty($this->created_by)) {
$this->created_by = $user->get('id');
}
// Include user into the Editor Group
$db->setQuery('SELECT user_id FROM #__user_usergroup_map WHERE user_id = ' . $this->userid . ' AND group_id = 3');
if (!$db->loadResult()) {
$db->setQuery('INSERT INTO `#__user_usergroup_map` (`user_id`,`group_id`) VALUES (' . $this->userid . ',3)');
$db->query();
}
}
return parent::store($updateNulls);
}
示例13: 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 an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
if ($this->getLayout() == 'pagebreak') {
// TODO: This is really dogy - should change this one day.
$eName = JFactory::getApplication()->input->getCmd('e_name');
$eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName);
$this->document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
$this->eName =& $eName;
return parent::display($tpl);
}
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_content', 'article', $this->item->id);
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例14: preprocessForm
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
// Association content items
$app = JFactory::getApplication();
$assoc = JLanguageAssociations::isEnabled();
if ($assoc) {
$languages = JLanguageHelper::getLanguages('lang_code');
// force to array (perhaps move to $this->loadFormData())
$data = (array) $data;
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
$fieldset->addAttribute('description', 'COM_CONTACT_ITEM_ASSOCIATIONS_FIELDSET_DESC');
$add = false;
foreach ($languages as $tag => $language) {
if (empty($data['language']) || $tag != $data['language']) {
$add = true;
$field = $fieldset->addChild('field');
$field->addAttribute('name', $tag);
$field->addAttribute('type', 'modal_contact');
$field->addAttribute('language', $tag);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
}
}
if ($add) {
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
示例15: getList
/**
* Gets a list of available languages
*
* @param JRegistry &$params module params
*
* @return array
*/
public static function getList(&$params)
{
$user = JFactory::getUser();
$lang = JFactory::getLanguage();
$app = JFactory::getApplication();
$menu = $app->getMenu();
// Get menu home items
$homes = array();
foreach ($menu->getMenu() as $item) {
if ($item->home) {
$homes[$item->language] = $item;
}
}
// Load associations
$assoc = JLanguageAssociations::isEnabled();
if ($assoc) {
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
// Load component associations
$option = $app->input->get('option');
$eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
$cName = JString::ucfirst($eName . 'HelperAssociation');
JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
$cassociations = call_user_func(array($cName, 'getAssociations'));
}
}
$levels = $user->getAuthorisedViewLevels();
$languages = JLanguageHelper::getLanguages();
// Filter allowed languages
foreach ($languages as $i => &$language) {
// Do not display language without frontend UI
if (!JLanguage::exists($language->lang_code)) {
unset($languages[$i]);
} elseif (!isset($homes[$language->lang_code])) {
unset($languages[$i]);
} elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
unset($languages[$i]);
} else {
$language->active = $language->lang_code == $lang->getTag();
if (JLanguageMultilang::isEnabled()) {
if (isset($cassociations[$language->lang_code])) {
$language->link = JRoute::_($cassociations[$language->lang_code] . '&lang=' . $language->sef);
} elseif (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) {
$itemid = $associations[$language->lang_code];
if ($app->get('sef') == '1') {
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid;
}
} else {
if ($app->get('sef') == '1') {
$itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id;
$language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid);
} else {
$language->link = 'index.php?lang=' . $language->sef;
}
}
} else {
$language->link = JRoute::_('&Itemid=' . $homes['*']->id);
}
}
}
return $languages;
}