Exemple #1
0
 function getLimitBox($sequence = 0)
 {
     $app = JFactory::getApplication();
     // Initialize variables
     $limits = array();
     $selected = $this->limit;
     // Build the select list
     if ($app->isAdmin()) {
         if (empty($sequence)) {
             $sequence = VmConfig::get('pagseq', 0);
         }
         if (!empty($sequence)) {
             $sequenceArray = explode(',', $sequence);
             if (count($sequenceArray > 1)) {
                 foreach ($sequenceArray as $items) {
                     $limits[$items] = JHtml::_('select.option', $items);
                 }
             }
         }
         if (empty($limits)) {
             $limits[15] = JHtml::_('select.option', 15);
             $limits[30] = JHtml::_('select.option', 30);
             $limits[50] = JHtml::_('select.option', 50);
             $limits[100] = JHtml::_('select.option', 100);
             $limits[200] = JHtml::_('select.option', 200);
             $limits[400] = JHtml::_('select.option', 400);
         }
         if (!array_key_exists($this->limit, $limits)) {
             $limits[$this->limit] = JHtml::_('select.option', $this->limit);
             ksort($limits);
         }
         $namespace = 'Joomla.';
         $html = JHtml::_('select.genericlist', $limits, 'limit', 'class="inputbox" size="1" onchange="' . $namespace . 'submitform();"', 'value', 'text', $selected);
     } else {
         $getArray = vRequest::getGET();
         $link = '';
         unset($getArray['limit']);
         // foreach ($getArray as $key => $value ) $link .= '&'.$key.'='.$value;
         foreach ($getArray as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $k => $v) {
                     $link .= '&' . $key . '[' . $k . ']' . '=' . $v;
                 }
             } else {
                 $link .= '&' . $key . '=' . $value;
             }
         }
         $link = 'index.php?' . ltrim($link, '&');
         if (empty($sequence)) {
             $sequence = VmConfig::get('pagseq_' . $this->_perRow);
         }
         if (!empty($sequence)) {
             $sequenceArray = explode(',', $sequence);
             if (count($sequenceArray > 1)) {
                 foreach ($sequenceArray as $items) {
                     $limits[$items] = JHtml::_('select.option', JRoute::_($link . '&limit=' . $items, false), $items);
                 }
             }
         }
         if (empty($limits) or !is_array($limits)) {
             if ($this->_perRow === 1) {
                 $this->_perRow = 5;
             }
             $limits[$this->_perRow * 5] = JHtml::_('select.option', JRoute::_($link . '&limit=' . $this->_perRow * 5, false), $this->_perRow * 5);
             $limits[$this->_perRow * 10] = JHtml::_('select.option', JRoute::_($link . '&limit=' . $this->_perRow * 10, false), $this->_perRow * 10);
             $limits[$this->_perRow * 20] = JHtml::_('select.option', JRoute::_($link . '&limit=' . $this->_perRow * 20, false), $this->_perRow * 20);
             $limits[$this->_perRow * 50] = JHtml::_('select.option', JRoute::_($link . '&limit=' . $this->_perRow * 50, false), $this->_perRow * 50);
         }
         if (!array_key_exists($this->limit, $limits)) {
             $limits[$this->limit] = JHtml::_('select.option', JRoute::_($link . '&limit=' . $this->limit, false), $this->limit);
             ksort($limits);
         }
         $selected = JRoute::_($link . '&limit=' . $selected, false);
         $js = 'onchange="window.top.location.href=this.options[this.selectedIndex].value"';
         $html = JHtml::_('select.genericlist', $limits, '', 'class="inputbox" size="1" ' . $js, 'value', 'text', $selected);
     }
     return $html;
 }