Example #1
0
 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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;
 }
Example #6
0
	/**
	 * 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());
	}
    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;
    }
Example #8
0
 /**
  * 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;
 }
Example #9
0
 /**
  * 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'));
 }
Example #10
0
 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;
 }
Example #11
0
 /**
  * @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;
 }
Example #12
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_\\-]/', '_', $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;
 }
Example #13
0
 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();
 }
Example #14
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 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);
 }
Example #15
0
 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());
 }
Example #16
0
 protected static function _findItem($needles = null)
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu('site');
     $language = isset($needles['language']) ? $needles['language'] : '*';
     // Prepare the reverse lookup array.
     if (!isset(self::$lookup[$language])) {
         self::$lookup[$language] = array();
         $component = JComponentHelper::getComponent('com_xch');
         $attributes = array('component_id');
         $values = array($component->id);
         if ($language != '*') {
             $attributes[] = 'language';
             $values[] = array($needles['language'], '*');
         }
         $items = $menus->getItems($attributes, $values);
         foreach ($items as $item) {
             if (isset($item->query) && isset($item->query['view'])) {
                 $view = $item->query['view'];
                 if (!isset(self::$lookup[$language][$view])) {
                     self::$lookup[$language][$view] = array();
                 }
                 if (isset($item->query['id'])) {
                     // here it will become a bit tricky
                     // language != * can override existing entries
                     // language == * cannot override existing entries
                     if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') {
                         self::$lookup[$language][$view][$item->query['id']] = $item->id;
                     }
                 }
             }
         }
     }
     if ($needles) {
         foreach ($needles as $view => $ids) {
             if (isset(self::$lookup[$language][$view])) {
                 foreach ($ids as $id) {
                     if (isset(self::$lookup[$language][$view][(int) $id])) {
                         return self::$lookup[$language][$view][(int) $id];
                     }
                 }
             }
         }
     }
     // Check if the active menuitem matches the requested language
     $active = $menus->getActive();
     if ($active && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) {
         return $active->id;
     }
     // If not found, return language specific home link
     $default = $menus->getDefault($language);
     return !empty($default->id) ? $default->id : null;
 }
Example #17
0
 /**
  * Display the view
  */
 function display($tpl = null)
 {
     require_once JPATH_COMPONENT . '/helpers/multilangstatus.php';
     $this->homes = multilangstatusHelper::getHomes();
     $this->language_filter = JLanguageMultilang::isEnabled();
     $this->switchers = multilangstatusHelper::getLangswitchers();
     $this->contentlangs = multilangstatusHelper::getContentlangs();
     $this->site_langs = multilangstatusHelper::getSitelangs();
     $this->statuses = multilangstatusHelper::getStatus();
     $this->homepages = multilangstatusHelper::getHomepages();
     parent::display($tpl);
 }
Example #18
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     JLoader::register('MultilangstatusHelper', JPATH_ADMINISTRATOR . '/components/com_languages/helpers/multilangstatus.php');
     $this->homes = MultilangstatusHelper::getHomes();
     $this->language_filter = JLanguageMultilang::isEnabled();
     $this->switchers = MultilangstatusHelper::getLangswitchers();
     $this->listUsersError = MultilangstatusHelper::getContacts();
     $this->contentlangs = MultilangstatusHelper::getContentlangs();
     $this->site_langs = JLanguageMultilang::getSiteLangs();
     $this->statuses = MultilangstatusHelper::getStatus();
     $this->homepages = JLanguageMultilang::getSiteHomePages();
     parent::display($tpl);
 }
Example #19
0
 /**
  * Class constructor.
  *
  * @param   array  $options  The class options.
  *
  * @since   1.5
  */
 public function __construct($options = array())
 {
     $this->_pathway = array();
     $app = JApplication::getInstance('site');
     $menu = $app->getMenu();
     $lang = JFactory::getLanguage();
     if ($item = $menu->getActive()) {
         $menus = $menu->getMenu();
         // Look for the home menu
         if (JLanguageMultilang::isEnabled()) {
             $home = $menu->getDefault($lang->getTag());
         } else {
             $home = $menu->getDefault();
         }
         if (is_object($home) && $item->id != $home->id) {
             foreach ($item->tree as $menupath) {
                 $url = '';
                 $link = $menu->getItem($menupath);
                 switch ($link->type) {
                     case 'separator':
                     case 'heading':
                         $url = null;
                         break;
                     case 'url':
                         if (strpos($link->link, 'index.php?') === 0 && strpos($link->link, 'Itemid=') === false) {
                             // If this is an internal Joomla link, ensure the Itemid is set.
                             $url = $link->link . '&Itemid=' . $link->id;
                         } else {
                             $url = $link->link;
                         }
                         break;
                     case 'alias':
                         // If this is an alias use the item id stored in the parameters to make the link.
                         $url = 'index.php?Itemid=' . $link->params->get('aliasoptions');
                         break;
                     default:
                         $router = $app::getRouter();
                         if ($router->getMode() == JROUTER_MODE_SEF) {
                             $url = 'index.php?Itemid=' . $link->id;
                         } else {
                             $url .= $link->link . '&Itemid=' . $link->id;
                         }
                         break;
                 }
                 $this->addItem($menus[$menupath]->title, $url);
             }
         }
     }
 }
 /**
  * Retrieve the url where the user should be returned after logging in
  *
  * @param   \Joomla\Registry\Registry  $params  module parameters
  * @param   string                     $type    return type
  *
  * @return string
  */
 public static function getReturnUrl($params, $type)
 {
     $app = JFactory::getApplication();
     $item = $app->getMenu()->getItem($params->get($type));
     // Stay on the same page
     $url = JUri::getInstance()->toString();
     if ($item) {
         $lang = '';
         if (JLanguageMultilang::isEnabled() && $item->language !== '*') {
             $lang = '&lang=' . $item->language;
         }
         $url = 'index.php?Itemid=' . $item->id . $lang;
     }
     return base64_encode($url);
 }
Example #21
0
 /**
  * Display the view
  */
 function display($tpl = null)
 {
     require_once JPATH_COMPONENT . '/helpers/multilangstatus.php';
     $this->homes = multilangstatusHelper::getHomes();
     $this->language_filter = JLanguageMultilang::isEnabled();
     $this->switchers = multilangstatusHelper::getLangswitchers();
     if (JComponentHelper::isEnabled('com_contact', true)) {
         $this->listUsersError = multilangstatusHelper::getContacts();
     }
     $this->contentlangs = multilangstatusHelper::getContentlangs();
     $this->site_langs = multilangstatusHelper::getSitelangs();
     $this->statuses = multilangstatusHelper::getStatus();
     $this->homepages = multilangstatusHelper::getHomepages();
     parent::display($tpl);
 }
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since   1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Load the parameters. Merge Global and Menu Item params into new object
     $params = $app->getParams();
     $menuParams = new JRegistry();
     if ($menu = $app->getMenu()->getActive()) {
         $menuParams->loadString($menu->params);
     }
     $mergedParams = clone $menuParams;
     $mergedParams->merge($params);
     $this->setState('params', $mergedParams);
     // List state information
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $mergedParams->get('category_number_of_items', 12));
     $this->setState('list.limit', $limit);
     $value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0);
     $limitstart = $limit != 0 ? floor($value / $limit) * $limit : 0;
     $this->setState('list.start', $limitstart);
     // Check if the ordering field is in the white list, otherwise use the incoming value.
     $value = $mergedParams->get('category_order_by', 'created');
     if (!in_array($value, $this->filter_fields)) {
         $value = $ordering;
         $app->setUserState($this->context . '.ordercol', $value);
     }
     $this->setState('list.ordering', $value);
     // Check if the ordering direction is valid, otherwise use the incoming value.
     $value = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $mergedParams->get('category_order_direction', 'DESC'));
     if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) {
         $value = $direction;
         $app->setUserState($this->context . '.orderdirn', $value);
     }
     $this->setState('list.direction', $value);
     $this->setState('filter.language', JLanguageMultilang::isEnabled());
     $catid = $app->input->get('id', 'root');
     $this->setState('filter.catid', $catid);
     $display_items = $app->input->get('display_items', 'all');
     $this->setState('filter.display_items', $display_items);
     $types = $app->input->get('special_types', array(), 'array');
     foreach ($types as $type) {
         $this->setState('filter.' . $type, true);
     }
     // Filter by search keywords
     $filter_search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string');
     if (!empty($filter_search)) {
         $this->setState('filter.search', $filter_search);
     }
 }
 /**
  * Method to determine if the language filter Items Associations parameter is enabled.
  * This works for both site and administrator.
  *
  * @return  boolean  True if the parameter is implemented; false otherwise.
  *
  * @since   3.2
  */
 public static function isEnabled()
 {
     // Flag to avoid doing multiple database queries.
     static $tested = false;
     // Status of language filter parameter.
     static $enabled = false;
     if (JLanguageMultilang::isEnabled()) {
         // If already tested, don't test again.
         if (!$tested) {
             $params = new JRegistry(JPluginHelper::getPlugin('system', 'languagefilter')->params);
             $enabled = (bool) $params->get('item_associations', true);
             $tested = true;
         }
     }
     return $enabled;
 }
Example #24
0
 function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     $app = JFactory::getApplication('site');
     $params = $app->getParams('com_tz_portfolio_plus');
     $global_params = JComponentHelper::getParams('com_tz_portfolio_plus');
     if ($layout_type = $params->get('layout_type', array())) {
         if (!count($layout_type)) {
             $params->set('layout_type', $global_params->get('layout_type', array()));
         }
     } else {
         $params->set('layout_type', $global_params->get('layout_type', array()));
     }
     $user = JFactory::getUser();
     $offset = $app->input->getUInt('limitstart', 0);
     if ($params->get('show_limit_box', 0) && $params->get('tz_portfolio_plus_layout') == 'default') {
         $limit = $app->getUserStateFromRequest('com_tz_portfolio_plus.portfolio.limit', 'limit', $params->get('tz_article_limit', 10));
     } else {
         $limit = (int) $params->get('tz_article_limit', 10);
     }
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     if (!$user->authorise('core.edit.state', 'com_tz_portfolio_plus') && !$user->authorise('core.edit', 'com_tz_portfolio_plus')) {
         // limit to published for people who can't edit or edit.state.
         $this->setState('filter.published', 1);
         // Filter by start and end dates.
         $nullDate = $db->Quote($db->getNullDate());
         $nowDate = $db->Quote(JFactory::getDate()->toSQL());
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     } else {
         $this->setState('filter.published', array(0, 1, 2));
     }
     $this->setState('filter.language', JLanguageMultilang::isEnabled());
     $this->setState('params', $params);
     $this->setState('list.start', $offset);
     $this->setState('Itemid', $params->get('id'));
     $this->setState('list.limit', $limit);
     $this->setState('catid', $params->get('catid'));
     $this->setState('filter.char', $app->input->getString('char', null));
     $this->setState('filter.tagId', null);
     $this->setState('filter.userId', null);
     $this->setState('filter.featured', null);
     $this->setState('filter.year', null);
     $this->setState('filter.month', null);
     $this->setState('filter.category_id', $app->input->getInt('id'));
 }
Example #25
0
	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 */
	protected function populateState()
	{
		$app = JFactory::getApplication('site');

		// Load state from the request.
		$pk = $app->input->getInt('id', 0);
		$this->setState('event.id', $pk);

		$offset = $app->input->getInt('limitstart', 0);
		$this->setState('list.offset', $offset);

		// Load the parameters.
		$params = $app->getParams('com_jem');
		$this->setState('params', $params);

		$this->setState('filter.language', JLanguageMultilang::isEnabled());
	}
Example #26
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  */
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     $jinput = JFactory::getApplication()->input;
     $f_marked_files_id = $jinput->get('f_marked_files_id', 0, 'string');
     $f_cat_id = $jinput->get('f_cat_id', 0, 'integer');
     $marked_files_id = array();
     // Load state from the request.
     // get file id
     $fileid = JRequest::getInt('id');
     // get cat id
     $catid = JRequest::getInt('catid');
     // get file-id from the marked files - only when is used 'mass download' layout
     if (!$catid) {
         $catid = $f_cat_id;
     }
     // get file-id from the marked files - only when is used 'mass download' layout
     $marked_files_id = $jinput->get('cb_arr', 0, 'array');
     if ($marked_files_id) {
         for ($i = 0, $n = count($marked_files_id); $i < $n; $i++) {
             $marked_files_id[$i] = intval($marked_files_id[$i]);
         }
     }
     // required vor form submit when captcha is used
     if (!$fileid && !$marked_files_id && $f_marked_files_id) {
         $marked_files_id = explode(',', $f_marked_files_id);
     }
     // set selected cat for category select box
     if ($catid) {
         $selected_cat_id = $catid;
     }
     // is mirror file selected
     $is_mirror = JRequest::getInt('m', 0);
     $this->setState('download.id', $fileid);
     $this->setState('download.catid', $catid);
     $this->setState('download.mirror.id', $is_mirror);
     $this->setState('download.marked_files.id', $marked_files_id);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_jdownloads') && !$user->authorise('core.edit', 'com_jdownloads')) {
         $this->setState('filter.published', 1);
     }
     $this->setState('filter.language', JLanguageMultilang::isEnabled());
 }
Example #27
0
 /**
  * Get the category route.
  *
  * @param   integer  $catid     The category ID.
  * @param   integer  $language  The language code.
  *
  * @return  string  The article route.
  *
  * @since   1.5
  */
 public static function getCategoryRoute($catid, $language = 0)
 {
     if ($catid instanceof JCategoryNode) {
         $id = $catid->id;
     } else {
         $id = (int) $catid;
     }
     if ($id < 1) {
         $link = '';
     } else {
         $link = 'index.php?option=com_content&view=category&id=' . $id;
         if ($language && $language != "*" && JLanguageMultilang::isEnabled()) {
             $link .= '&lang=' . $language;
         }
     }
     return $link;
 }
Example #28
0
 protected static function lookupItem($needles = array(), $view = '')
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu('site');
     $language = isset($needles['language']) ? $needles['language'] : '*';
     if (!isset(static::$lookup[$language])) {
         static::$lookup[$language] = array();
         $component = JComponentHelper::getComponent('com_hikashop');
         $attributes = array('component_id');
         $values = array($component->id);
         if ($language != '*') {
             $attributes[] = 'language';
             $values[] = array($needles['language'], '*');
         }
         $items = $menus->getItems($attributes, $values);
         foreach ($items as $item) {
             if (isset($item->query) && isset($item->query['view'])) {
                 $view = $item->query['view'];
                 if (!isset(static::$lookup[$language][$view])) {
                     static::$lookup[$language][$view] = array();
                 }
                 if (isset($item->query['layout'])) {
                     if (!isset(static::$lookup[$language][$view][$item->query['layout']]) || $item->language != '*') {
                         static::$lookup[$language][$view][$item->query['layout']] = $item->id;
                     }
                 }
             }
         }
     }
     if ($needles) {
         foreach ($needles as $layout) {
             if (isset(static::$lookup[$language][$view])) {
                 if (isset(static::$lookup[$language][$view][$layout])) {
                     return static::$lookup[$language][$view][$layout];
                 }
             }
         }
     }
     $active = $menus->getActive();
     if ($active && $active->component == 'com_hikashop' && ($active->language == '*' || !JLanguageMultilang::isEnabled())) {
         return $active->id;
     }
     $default = $menus->getDefault($language);
     return !empty($default->id) ? $default->id : null;
 }
Example #29
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  */
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     $jinput = JFactory::getApplication()->input;
     // Load state from the request.
     $pk = $jinput->get('id');
     $this->setState('download.id', $pk);
     $offset = $jinput->get('limitstart', 0, 'uint');
     $this->setState('list.offset', $offset);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_jdownloads') && !$user->authorise('core.edit', 'com_jdownloads') && !$user->authorise('core.edit.own', 'com_jdownloads')) {
         $this->setState('filter.published', 1);
     }
     $this->setState('filter.language', JLanguageMultilang::isEnabled());
 }
Example #30
0
 /**
  * Retrieve Contact
  *
  * @param   int  $created_by  Id of the user who created the contact
  *
  * @return  mixed|null|integer
  */
 protected function getContactId($created_by)
 {
     static $contacts = array();
     if (isset($contacts[$created_by])) {
         return $contacts[$created_by];
     }
     $query = $this->db->getQuery(true);
     $query->select('MAX(contact.id) AS contactid');
     $query->from($this->db->quoteName('#__contact_details', 'contact'));
     $query->where('contact.published = 1');
     $query->where('contact.user_id = ' . (int) $created_by);
     if (JLanguageMultilang::isEnabled() == 1) {
         $query->where('(contact.language in ' . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' . ' OR contact.language IS NULL)');
     }
     $this->db->setQuery($query);
     $contacts[$created_by] = $this->db->loadResult();
     return $contacts[$created_by];
 }