Ejemplo n.º 1
1
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * Get the associated language flags
  *
  * @param   int  $contactid  The item id to search associations
  *
  * @return  string  The language HTML
  */
 public static function association($contactid)
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $contactid)) {
         foreach ($associations as $tag => $associated) {
             $associations[$tag] = (int) $associated->id;
         }
         // Get the associated contact items
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.*')->from('#__contact_details as c')->select('cat.title as category_title')->join('LEFT', '#__categories as cat ON cat.id=c.catid')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (runtimeException $e) {
             throw new Exception($e->getMessage(), 500);
             return false;
         }
         $flags = array();
         // Construct html
         foreach ($associations as $tag => $associated) {
             if ($associated != $contactid) {
                 $flags[] = JText::sprintf('COM_CONTACT_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->name, $items[$associated]->category_title);
             }
         }
         $html = JHtml::_('tooltip', implode('<br />', $flags), JText::_('COM_CONTACT_TIP_ASSOCIATION'), 'admin/icon-16-links.png');
     }
     return $html;
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 /**
  * Method to get the associations for a given item
  *
  * @param   integer  $id    Id of the item
  * @param   string   $view  Name of the view
  *
  * @return  array   Array of associations for the item
  *
  * @since  3.0
  */
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = is_null($view) ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view == 'article') {
         if ($id) {
             $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = TZ_PortfolioHelperRoute::getArticleRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     } elseif ($view == 'p_article') {
         if ($id) {
             $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     }
     if ($view == 'category' || $view == 'categories') {
         return self::getCategoryAssociations($id, 'com_content');
     }
     return array();
 }
Ejemplo n.º 6
0
 /**
  * Get the associated language flags
  *
  * @param   int  $newsfeedid  The item id to search associations
  *
  * @return  string  The language HTML
  */
 public static function association($newsfeedid)
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $newsfeedid)) {
         foreach ($associations as $tag => $associated) {
             $associations[$tag] = (int) $associated->id;
         }
         // Get the associated newsfeed items
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.name as title')->select('l.sef as lang_sef')->from('#__newsfeeds as c')->select('cat.title as category_title')->join('LEFT', '#__categories as cat ON cat.id=c.catid')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_newsfeeds&task=newsfeed.edit&id=' . (int) $item->id);
                 $tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title, '(' . $item->category_title . ')');
                 $item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, 'hasTooltip label label-association label-' . $item->lang_sef);
             }
         }
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
Ejemplo n.º 7
0
 /**
  * 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);
 }
Ejemplo n.º 8
0
 /**
  * Get the associated language flags
  *
  * @param   integer  $contactid  The item id to search associations
  *
  * @return  string  The language HTML
  *
  * @throws  Exception
  */
 public static function association($contactid)
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $contactid)) {
         foreach ($associations as $tag => $associated) {
             $associations[$tag] = (int) $associated->id;
         }
         // Get the associated contact items
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.name as title')->select('l.sef as lang_sef, lang_code')->from('#__contact_details as c')->select('cat.title as category_title')->join('LEFT', '#__categories as cat ON cat.id=c.catid')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_contact&task=contact.edit&id=' . (int) $item->id);
                 $tooltip = $item->title . '<br />' . JText::sprintf('JCATEGORY_SPRINTF', $item->category_title);
                 $classes = 'hasPopover label label-association label-' . $item->lang_sef;
                 $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $tooltip . '" data-placement="top">' . $text . '</a>';
             }
         }
         JHtml::_('bootstrap.popover');
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
Ejemplo n.º 9
0
 /**
  * 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();
 }
Ejemplo n.º 10
0
 /**
  * Gets a list of associations for a given item.
  *
  * @param   integer  $pk         Content item key.
  * @param   string   $extension  Optional extension name.
  *
  * @return  array of associations.
  */
 public static function getAssociations($pk, $extension = 'com_content')
 {
     $langAssociations = JLanguageAssociations::getAssociations($extension, '#__categories', 'com_categories.item', $pk, 'id', 'alias', '');
     $associations = array();
     foreach ($langAssociations as $langAssociation) {
         $associations[$langAssociation->language] = $langAssociation->id;
     }
     return $associations;
 }
Ejemplo n.º 11
0
 /**
  * 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">&#160;*</span></label>';
     return $label;
 }
Ejemplo n.º 12
0
 /**
  * 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);
 }
Ejemplo n.º 13
0
 /**
  * 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);
 }
Ejemplo n.º 14
0
 /**
  * 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);
 }
Ejemplo n.º 15
0
 /**
  * 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);
 }
 /**
  * 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);
 }
 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);
 }
Ejemplo n.º 18
0
 public static function getAssociationsForm($id, $name, $config = array())
 {
     $addform = new SimpleXMLElement('<form />');
     $fields = $addform->addChild('fields');
     $fields->addAttribute('name', $name);
     $fieldset = $fields->addChild('fieldset');
     $fieldset->addAttribute('name', 'item_associations');
     $fieldset->addAttribute('description', 'COM_CONTENT_ITEM_ASSOCIATIONS_FIELDSET_DESC');
     $fieldset->addAttribute('addfieldpath', '/administrator/components/com_content/models/fields');
     $hasForm = false;
     $languages = JLanguageHelper::getLanguages('lang_code');
     foreach ($languages as $tag => $language) {
         if (empty($config['language']) || $tag != $config['language']) {
             $hasForm = true;
             $f = $fieldset->addChild('field');
             $f->addAttribute('name', $tag);
             $f->addAttribute('type', 'modal_article');
             $f->addAttribute('language', $tag);
             $f->addAttribute('label', $language->title);
             $f->addAttribute('translate_label', 'false');
         }
     }
     $form = JForm::getInstance($id, $addform->asXML());
     if ($hasForm) {
         $form->load($addform, false);
         $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $config['pk']);
         if (count($associations)) {
             foreach ($associations as $tag => $association) {
                 $form->setValue($tag, $name, $association->id);
             }
         }
         if ($config['translate_id'] && isset($config['translate'])) {
             $form->setValue($config['translate'], $name, $config['translate_id']);
         }
     }
     // Render Form
     $fields = $form->getFieldset('item_associations');
     $form = '';
     foreach ($fields as $f) {
         $form .= '<div class="control-group"><div class="control-label">' . $f->label . '</div><div class="controls">' . $f->input . '</div></div>';
     }
     return $form;
 }
Ejemplo n.º 19
0
 /**
  * Method to get the associations for a given item
  *
  * @param   integer  $id    Id of the item
  * @param   string   $view  Name of the view
  *
  * @return  array   Array of associations for the item
  *
  * @since  3.0
  */
 public static function getAssociations($id = 0, $view = null)
 {
     $jinput = JFactory::getApplication()->input;
     $view = $view === null ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view === 'contact') {
         if ($id) {
             $associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = ContactHelperRoute::getContactRoute($item->id, (int) $item->catid, $item->language);
             }
             return $return;
         }
     }
     if ($view === 'category' || $view === 'categories') {
         return self::getCategoryAssociations($id, 'com_contact');
     }
     return array();
 }
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = is_null($view) ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view == 'author') {
         if ($id) {
             $associations = JLanguageAssociations::getAssociations('com_authorlist', '#__authorlist', 'com_authorlist.author', $id, 'id', '', '');
             $return = array();
             foreach ($associations as $tag => $item) {
                 $author_slug = AuthorListHelperRoute::getAuthorSlug($item->id);
                 $return[$tag] = AuthorListHelperRoute::getAuthorRoute($author_slug, $item->language);
             }
             return $return;
         }
     }
     return array();
 }
Ejemplo n.º 21
0
 /**
  * Render the list of associated items
  * 
  * @param	integer $competitie_id	The competitie item id
  * 
  * @return  string  The language HTML
  */
 public static function association($competitie_id)
 {
     // Get the associations
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = JLanguageAssociations::getAssociations('com_knvbapi', '#__knvbapi_competities', 'com_knvbapi.competitie.item', $competitie_id, 'id', 'alias', 'catid')) {
         foreach ($associations as $tag => $associated) {
             $associations[$tag] = (int) $associated->id;
         }
         // Get the associated menu items
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('a.*');
         $query->from($db->quoteName('#__knvbapi_competities') . ' as a');
         $query->select($db->quoteName('c.title') . ' as category_title');
         $query->join('LEFT', $db->quoteName('#__categories') . ' as c ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'));
         $query->where($db->quoteName('a.id') . ' IN (' . implode(',', array_values($associations)) . ')');
         $query->join('LEFT', $db->quoteName('#__languages') . ' as l ON ' . $db->quoteName('a.language') . ' = ' . $db->quoteName('l.lang_code'));
         $query->select($db->quoteName('l.image'));
         $query->select($db->quoteName('l.title') . ' as language_title');
         $query->select($db->quoteName('l.sef') . ' as lang_sef');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (runtimeException $e) {
             throw new Exception($e->getMessage(), 500);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_knvbapi&task=competitie.edit&id=' . (int) $item->id);
                 $tooltip_parts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->name, '(' . $item->category_title . ')');
                 $item->link = JHtml::_('tooltip', implode(' ', $tooltip_parts), null, null, $text, $url, null, 'hasTooltip label label-association label-' . $item->lang_sef);
             }
         }
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
Ejemplo n.º 22
0
 /**
  * Method to get the associations for a given item
  *
  * @param   integer  $id    Id of the item
  * @param   string   $view  Name of the view
  *
  * @return  array   Array of associations for the item
  *
  * @since  3.0
  */
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = is_null($view) ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view == 'newsfeed') {
         if ($id) {
             $associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = NewsfeedsHelperRoute::getNewsfeedRoute($item->id, (int) $item->catid, $item->language);
             }
             return $return;
         }
     }
     if ($view == 'category' || $view == 'categories') {
         return self::getCategoryAssociations($id, 'com_newsfeeds');
     }
     return array();
 }
Ejemplo n.º 23
0
 /**
  * Method to get the associations for a given item
  *
  * @param   integer  $id    Id of the item
  * @param   string   $view  Name of the view
  *
  * @return  array   Array of associations for the item
  *
  * @since  3.0
  */
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = is_null($view) ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view == 'article') {
         if ($id) {
             $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id);
             $return = array();
             JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php');
             foreach ($associations as $tag => $item) {
                 $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     }
     if ($view == 'category' || $view == 'categories') {
         return self::getCategoryAssociations($id, 'com_jevents');
     }
     return array();
 }
Ejemplo n.º 24
0
 /**
  * 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);
 }
Ejemplo n.º 25
0
 /**
  * Build an SQL query to load the list data.
  *
  * @return  JDatabaseQuery
  *
  * @since   1.6
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $user = JFactory::getUser();
     // Select the required fields from the table.
     $query->select($db->quoteName(explode(', ', $this->getState('list.select', 'a.id, a.name, a.alias, a.checked_out, a.checked_out_time, a.catid, a.user_id' . ', a.published, a.access, a.created, a.created_by, a.ordering, a.featured, a.language' . ', a.publish_up, a.publish_down'))));
     $query->from($db->quoteName('#__contact_details', 'a'));
     // Join over the users for the linked user.
     $query->select(array($db->quoteName('ul.name', 'linked_user'), $db->quoteName('ul.email')))->join('LEFT', $db->quoteName('#__users', 'ul') . ' ON ' . $db->quoteName('ul.id') . ' = ' . $db->quoteName('a.user_id'));
     // Join over the language
     $query->select($db->quoteName('l.title', 'language_title'))->join('LEFT', $db->quoteName('#__languages', 'l') . ' ON ' . $db->quoteName('l.lang_code') . ' = ' . $db->quoteName('a.language'));
     // Join over the users for the checked out user.
     $query->select($db->quoteName('uc.name', 'editor'))->join('LEFT', $db->quoteName('#__users', 'uc') . ' ON ' . $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out'));
     // Join over the asset groups.
     $query->select($db->quoteName('ag.title', 'access_level'))->join('LEFT', $db->quoteName('#__viewlevels', 'ag') . ' ON ' . $db->quoteName('ag.id') . ' = ' . $db->quoteName('a.access'));
     // Join over the categories.
     $query->select($db->quoteName('c.title', 'category_title'))->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'));
     // Join over the associations.
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $query->select('COUNT(' . $db->quoteName('asso2.id') . ') > 1 as ' . $db->quoteName('association'))->join('LEFT', $db->quoteName('#__associations', 'asso') . ' ON ' . $db->quoteName('asso.id') . ' = ' . $db->quoteName('a.id') . ' AND ' . $db->quoteName('asso.context') . ' = ' . $db->quote('com_contact.item'))->join('LEFT', $db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso2.key') . ' = ' . $db->quoteName('asso.key'))->group($db->quoteName(array('a.id', 'ul.name', 'l.title', 'uc.name', 'ag.title', 'c.title')));
     }
     // Filter by access level.
     if ($access = $this->getState('filter.access')) {
         $query->where($db->quoteName('a.access') . ' = ' . (int) $access);
     }
     // Implement View Level Access
     if (!$user->authorise('core.admin')) {
         $groups = implode(',', $user->getAuthorisedViewLevels());
         $query->where($db->quoteName('a.access') . ' IN (' . $groups . ')');
     }
     // Filter by published state
     $published = $this->getState('filter.published');
     if (is_numeric($published)) {
         $query->where($db->quoteName('a.published') . ' = ' . (int) $published);
     } elseif ($published === '') {
         $query->where('(' . $db->quoteName('a.published') . ' = 0 OR ' . $db->quoteName('a.published') . ' = 1)');
     }
     // Filter by a single or group of categories.
     $categoryId = $this->getState('filter.category_id');
     if (is_numeric($categoryId)) {
         $query->where($db->quoteName('a.catid') . ' = ' . (int) $categoryId);
     } elseif (is_array($categoryId)) {
         $categoryId = Joomla\Utilities\ArrayHelper::toInteger($categoryId);
         $categoryId = implode(',', $categoryId);
         $query->where($db->quoteName('a.catid') . ' IN (' . $categoryId . ')');
     }
     // Filter by search in name.
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } elseif (stripos($search, 'author:') === 0) {
             $search = $db->quote('%' . $db->escape(substr($search, 7), true) . '%');
             $query->where('(' . $db->quoteName('uc.name') . ' LIKE ' . $search . ' OR ' . $db->quoteName('uc.username') . ' LIKE ' . $search . ')');
         } else {
             $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
             $query->where('(' . $db->quoteName('a.name') . ' LIKE ' . $search . ' OR ' . $db->quoteName('a.alias') . ' LIKE ' . $search . ')');
         }
     }
     // Filter on the language.
     if ($language = $this->getState('filter.language')) {
         $query->where($db->quoteName('a.language') . ' = ' . $db->quote($language));
     }
     // Filter by a single tag.
     $tagId = $this->getState('filter.tag');
     if (is_numeric($tagId)) {
         $query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId)->join('LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap') . ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id') . ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_contact.contact'));
     }
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering', 'a.name');
     $orderDirn = $this->state->get('list.direction', 'asc');
     if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
         $orderCol = $db->quoteName('c.title') . ' ' . $orderDirn . ', ' . $db->quoteName('a.ordering');
     }
     $query->order($db->escape($orderCol . ' ' . $orderDirn));
     return $query;
 }
Ejemplo n.º 26
0
/**
 * @package     Joomla.Administrator
 * @subpackage  com_contact
 *
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
$app = JFactory::getApplication();
$input = $app->input;
$assoc = JLanguageAssociations::isEnabled();
?>
<script type="text/javascript">
	Joomla.submitbutton = function(task)
	{
		if (task == 'contact.cancel' || document.formvalidator.isValid(document.id('contact-form')))
		{
			<?php 
echo $this->form->getField('misc')->save();
?>

			if (window.opener && (task == 'contact.save' || task == 'contact.cancel'))
			{
				window.opener.document.closeEditWindow = self;
				window.opener.setTimeout('window.document.closeEditWindow.close()', 1000);
			}
Ejemplo n.º 27
0
 /**
  * Method to determine if a category association is available.
  *
  * @return  boolean True if a category association is available; false otherwise.
  */
 public function getAssoc()
 {
     static $assoc = null;
     if (!is_null($assoc)) {
         return $assoc;
     }
     $app = JFactory::getApplication();
     $extension = $this->getState('category.extension');
     $assoc = JLanguageAssociations::isEnabled();
     $extension = explode('.', $extension);
     $component = array_shift($extension);
     $cname = str_replace('com_', '', $component);
     if (!$assoc || !$component || !$cname) {
         $assoc = false;
     } else {
         $hname = $cname . 'HelperAssociation';
         JLoader::register($hname, JPATH_SITE . '/components/' . $component . '/helpers/association.php');
         $assoc = class_exists($hname) && !empty($hname::$category_association);
     }
     return $assoc;
 }
 /**
  * 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())
 {
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     if ($app->isSite() && $this->params->get('automatic_change', 1)) {
         // Load associations.
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $active = $menu->getActive();
             if ($active) {
                 $associations = MenusHelper::getAssociations($active->id);
             }
         }
         $lang_code = $user['language'];
         if (empty($lang_code)) {
             $lang_code = self::$default_lang;
         }
         if ($lang_code != self::$tag) {
             // Change language.
             self::$tag = $lang_code;
             // Create a cookie.
             $conf = JFactory::getConfig();
             $cookie_domain = $conf->get('cookie_domain', '');
             $cookie_path = $conf->get('cookie_path', '/');
             setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
             // Change the language code.
             JFactory::getLanguage()->setLanguage($lang_code);
             // Change the redirect (language has changed).
             if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
                 $itemid = $associations[$lang_code];
                 $app->setUserState('users.login.form.return', 'index.php?&Itemid=' . $itemid);
             } else {
                 $itemid = isset(self::$homes[$lang_code]) ? self::$homes[$lang_code]->id : self::$homes['*']->id;
                 $app->setUserState('users.login.form.return', 'index.php?&Itemid=' . $itemid);
             }
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * 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));
             }
         }
     }
 }
Ejemplo n.º 30
0
 /**
  * Builds an SQL query to load the list data.
  *
  * @return  JDatabaseQuery    A query object.
  *
  * @since   1.6
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     // Select all fields from the table.
     $query->select($this->getState('list.select', $db->quoteName(array('a.id', 'a.menutype', 'a.title', 'a.alias', 'a.note', 'a.path', 'a.link', 'a.type', 'a.parent_id', 'a.level', 'a.published', 'a.component_id', 'a.checked_out', 'a.checked_out_time', 'a.browserNav', 'a.access', 'a.img', 'a.template_style_id', 'a.params', 'a.lft', 'a.rgt', 'a.home', 'a.language', 'a.client_id'), array(null, null, null, null, null, null, null, null, null, null, 'apublished', null, null, null, null, null, null, null, null, null, null, null, null, null))));
     $query->select('CASE ' . ' WHEN a.type = ' . $db->quote('component') . ' THEN a.published+2*(e.enabled-1) ' . ' WHEN a.type = ' . $db->quote('url') . 'AND a.published != -2 THEN a.published+2 ' . ' WHEN a.type = ' . $db->quote('url') . 'AND a.published = -2 THEN a.published-1 ' . ' WHEN a.type = ' . $db->quote('alias') . 'AND a.published != -2 THEN a.published+4 ' . ' WHEN a.type = ' . $db->quote('alias') . 'AND a.published = -2 THEN a.published-1 ' . ' WHEN a.type = ' . $db->quote('separator') . 'AND a.published != -2 THEN a.published+6 ' . ' WHEN a.type = ' . $db->quote('separator') . 'AND a.published = -2 THEN a.published-1 ' . ' WHEN a.type = ' . $db->quote('heading') . 'AND a.published != -2 THEN a.published+8 ' . ' WHEN a.type = ' . $db->quote('heading') . 'AND a.published = -2 THEN a.published-1 ' . ' END AS published ');
     $query->from($db->quoteName('#__menu') . ' AS a');
     // Join over the language
     $query->select('l.title AS language_title, l.image AS language_image')->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
     // Join over the users.
     $query->select('u.name AS editor')->join('LEFT', $db->quoteName('#__users') . ' AS u ON u.id = a.checked_out');
     // Join over components
     $query->select('c.element AS componentname')->join('LEFT', $db->quoteName('#__extensions') . ' AS c ON c.extension_id = a.component_id');
     // Join over the asset groups.
     $query->select('ag.title AS access_level')->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
     // Join over the associations.
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $query->select('COUNT(asso2.id)>1 as association')->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_menus.item'))->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')->group('a.id, e.enabled, l.title, l.image, u.name, c.element, ag.title, e.name');
     }
     // Join over the extensions
     $query->select('e.name AS name')->join('LEFT', '#__extensions AS e ON e.extension_id = a.component_id');
     // Exclude the root category.
     $query->where('a.id > 1')->where('a.client_id = 0');
     // Filter on the published state.
     $published = $this->getState('filter.published');
     if (is_numeric($published)) {
         $query->where('a.published = ' . (int) $published);
     } elseif ($published === '') {
         $query->where('(a.published IN (0, 1))');
     }
     // Filter by search in title, alias or id
     if ($search = trim($this->getState('filter.search'))) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } elseif (stripos($search, 'link:') === 0) {
             if ($search = substr($search, 5)) {
                 $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
                 $query->where('a.link LIKE ' . $search);
             }
         } else {
             $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
             $query->where('(' . 'a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
         }
     }
     // Filter the items over the parent id if set.
     $parentId = $this->getState('filter.parent_id');
     if (!empty($parentId)) {
         $query->where('p.id = ' . (int) $parentId);
     }
     // Filter the items over the menu id if set.
     $menuType = $this->getState('filter.menutype');
     if (!empty($menuType)) {
         $query->where('a.menutype = ' . $db->quote($menuType));
     }
     // Filter on the access level.
     if ($access = $this->getState('filter.access')) {
         $query->where('a.access = ' . (int) $access);
     }
     // Implement View Level Access
     if (!$user->authorise('core.admin')) {
         $groups = implode(',', $user->getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
     }
     // Filter on the level.
     if ($level = $this->getState('filter.level')) {
         $query->where('a.level <= ' . (int) $level);
     }
     // Filter on the language.
     if ($language = $this->getState('filter.language')) {
         $query->where('a.language = ' . $db->quote($language));
     }
     // Add the list ordering clause.
     $query->order($db->escape($this->getState('list.ordering', 'a.lft')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
     return $query;
 }