protected function getInput() { $this->params = $this->element->attributes(); if (!is_array($this->value)) { $this->value = explode(',', $this->value); } $group = $this->get('group', 'countries'); $options = array(); foreach ($this->{$group} as $key => $val) { if (!$val) { $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true); } else { if ($key['0'] == '-') { $options[] = JHtml::_('select.option', '-', $val, 'value', 'text', true); } else { $val = RLText::prepareSelectItem($val); $options[] = JHtml::_('select.option', $key, $val); } } } $size = (int) $this->get('size'); $multiple = $this->get('multiple'); require_once dirname(__DIR__) . '/helpers/html.php'; return RLHtml::selectlistsimple($options, $this->name, $this->value, $this->id, $size, $multiple); }
function getCategories() { $query = $this->db->getQuery(true)->select('COUNT(c.id)')->from('#__zoo_category AS c')->where('c.published > -1'); $this->db->setQuery($query); $total = $this->db->loadResult(); if ($total > $this->max_list_count) { return -1; } $options = array(); if ($this->get('show_ignore')) { if (in_array('-1', $this->value)) { $this->value = array('-1'); } $options[] = JHtml::_('select.option', '-1', '- ' . JText::_('RL_IGNORE') . ' -', 'value', 'text', 0); $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', 1); } $query->clear()->select('a.id, a.name')->from('#__zoo_application AS a')->order('a.name, a.id'); $this->db->setQuery($query); $apps = $this->db->loadObjectList(); foreach ($apps as $i => $app) { $query->clear()->select('c.id, c.parent AS parent_id, c.name AS title, c.published')->from('#__zoo_category AS c')->where('c.application_id = ' . (int) $app->id)->where('c.published > -1')->order('c.ordering, c.name'); $this->db->setQuery($query); $items = $this->db->loadObjectList(); if ($i) { $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', 1); } // establish the hierarchy of the menu // TODO: use node model $children = array(); if ($items) { // first pass - collect children foreach ($items as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } } // second pass - get an indent list of the items $list = JHtml::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0); // assemble items to the array $options[] = JHtml::_('select.option', 'app' . $app->id, '[' . $app->name . ']', 'value', 'text', 0); foreach ($list as $item) { $item->treename = ' ' . str_replace('  - ', ' ', $item->treename); $item->treename = RLText::prepareSelectItem($item->treename, $item->published); $option = JHtml::_('select.option', $item->id, $item->treename, 'value', 'text', 0); $option->level = 1; $options[] = $option; } } return $options; }
function getOptionsTreeByList($items = array(), $root = 0) { // establish the hierarchy of the menu // TODO: use node model $children = array(); if (!empty($items)) { // first pass - collect children foreach ($items as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } } // second pass - get an indent list of the items $list = JHtml::_('menu.treerecurse', $root, '', array(), $children, 9999, 0, 0); // assemble items to the array $options = array(); if ($this->get('show_ignore')) { if (in_array('-1', $this->value)) { $this->value = array('-1'); } $options[] = JHtml::_('select.option', '-1', '- ' . JText::_('RL_IGNORE') . ' -', 'value', 'text', 0); $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', 1); } foreach ($list as $item) { $item->treename = RLText::prepareSelectItem($item->treename, $item->published, '', 1); $options[] = JHtml::_('select.option', $item->id, $item->treename, 'value', 'text', 0); } return $options; }
protected function getInput() { $this->params = $this->element->attributes(); JHtml::_('behavior.modal', 'a.modal'); $size = $this->get('size') ? 'style="width:' . $this->get('size') . 'px"' : ''; $multiple = $this->get('multiple'); $showtype = $this->get('showtype'); $showid = $this->get('showid'); $showinput = $this->get('showinput'); // load the list of modules $query = $this->db->getQuery(true)->select('m.id, m.title, m.position, m.module, m.published, m.language')->from('#__modules AS m')->where('m.client_id = 0')->where('m.published > -2')->order('m.position, m.title, m.ordering, m.id'); $this->db->setQuery($query); $modules = $this->db->loadObjectList(); // assemble menu items to the array $options = array(); $p = 0; foreach ($modules as $item) { if ($p !== $item->position) { $pos = $item->position; if ($pos == '') { $pos = ':: ' . JText::_('JNONE') . ' ::'; } $options[] = JHtml::_('select.option', '-', '[ ' . $pos . ' ]', 'value', 'text', true); } $p = $item->position; $item->title = $item->title; if ($showtype) { $item->title .= ' [' . $item->module . ']'; } if ($showinput || $showid) { $item->title .= ' [' . $item->id . ']'; } if ($item->language && $item->language != '*') { $item->title .= ' (' . $item->language . ')'; } $item->title = RLText::prepareSelectItem($item->title, $item->published); $options[] = JHtml::_('select.option', $item->id, $item->title); } if ($showinput) { array_unshift($options, JHtml::_('select.option', '-', ' ', 'value', 'text', true)); array_unshift($options, JHtml::_('select.option', '-', '- ' . JText::_('Select Item') . ' -')); if ($multiple) { $onchange = 'if ( this.value ) { if ( ' . $this->id . '.value ) { ' . $this->id . '.value+=\',\'; } ' . $this->id . '.value+=this.value; } this.value=\'\';'; } else { $onchange = 'if ( this.value ) { ' . $this->id . '.value=this.value;' . $this->id . '_text.value=this.options[this.selectedIndex].innerHTML.replace( /^((&|&| )nbsp;|-)*/gm, \'\' ).trim(); } this.value=\'\';'; } $attribs = 'class="inputbox" onchange="' . $onchange . '"'; $html = '<table cellpadding="0" cellspacing="0"><tr><td style="padding: 0px;">' . "\n"; if (!$multiple) { $val_name = $this->value; if ($this->value) { foreach ($modules as $item) { if ($item->id == $this->value) { $val_name = $item->title; if ($showtype) { $val_name .= ' [' . $item->module . ']'; } $val_name .= ' [' . $this->value . ']'; break; } } } $html .= '<input type="text" id="' . $this->id . '_text" value="' . $val_name . '" class="inputbox" ' . $size . ' disabled="disabled">'; $html .= '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $this->value . '">'; } else { $html .= '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="' . $this->value . '" class="inputbox" ' . $size . '>'; } $html .= '</td><td style="padding: 0px;"padding-left: 5px;>' . "\n"; $html .= JHtml::_('select.genericlist', $options, '', $attribs, 'value', 'text', '', ''); $html .= '</td></tr></table>' . "\n"; } else { $attr = $size; $attr .= $multiple ? ' multiple="multiple"' : ''; $attr .= ' class="input-xxlarge"'; $html = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); $html = '<div class="input-maximize">' . $html . '</div>'; } return preg_replace('#>\\[\\[\\:(.*?)\\:\\]\\]#si', ' style="\\1">', $html); }