/** * Method to generate filters using select box dropdown controls. * * @param FinderIndexerQuery $idxQuery A FinderIndexerQuery object. * @param array $options An array of options. * * @return mixed A rendered HTML widget on success, null otherwise. * * @since 2.5 */ public static function select($idxQuery, $options) { $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $filter = null; // Get the configuration options. $classSuffix = $options->get('class_suffix', null); $showDates = $options->get('show_date_filters', false); // Try to load the results from cache. $cache = JFactory::getCache('com_finder', ''); $cacheId = 'filter_select_' . serialize(array($idxQuery->filter, $options, $groups, JFactory::getLanguage()->getTag())); // Check the cached results. if (!($branches = $cache->get($cacheId))) { $db = JFactory::getDbo(); $query = $db->getQuery(true); // Load the predefined filter if specified. if (!empty($idxQuery->filter)) { $query->select('f.data, ' . $db->quoteName('f.params'))->from($db->quoteName('#__finder_filters') . ' AS f')->where('f.filter_id = ' . (int) $idxQuery->filter); // Load the filter data. $db->setQuery($query); try { $filter = $db->loadObject(); } catch (RuntimeException $e) { return null; } // Initialize the filter parameters. if ($filter) { $registry = new Registry(); $registry->loadString($filter->params); $filter->params = $registry; } } // Build the query to get the branch data and the number of child nodes. $query->clear()->select('t.*, count(c.id) AS children')->from($db->quoteName('#__finder_taxonomy') . ' AS t')->join('INNER', $db->quoteName('#__finder_taxonomy') . ' AS c ON c.parent_id = t.id')->where('t.parent_id = 1')->where('t.state = 1')->where('t.access IN (' . $groups . ')')->where('c.state = 1')->where('c.access IN (' . $groups . ')')->group($db->quoteName('t.id'))->order('t.ordering, t.title'); // Limit the branch children to a predefined filter. if (!empty($filter->data)) { $query->where('c.id IN(' . $filter->data . ')'); } // Load the branches. $db->setQuery($query); try { $branches = $db->loadObjectList('id'); } catch (RuntimeException $e) { return null; } // Check that we have at least one branch. if (count($branches) === 0) { return null; } // Iterate through the branches and build the branch groups. foreach ($branches as $bk => $bv) { // If the multi-lang plugin is enabled then drop the language branch. if ($bv->title == 'Language' && JLanguageMultilang::isEnabled()) { continue; } // Build the query to get the child nodes for this branch. $query->clear()->select('t.*')->from($db->quoteName('#__finder_taxonomy') . ' AS t')->where('t.parent_id = ' . (int) $bk)->where('t.state = 1')->where('t.access IN (' . $groups . ')')->order('t.ordering, t.title'); // Self-join to get the parent title. $query->select('e.title AS parent_title')->join('LEFT', $db->quoteName('#__finder_taxonomy', 'e') . ' ON ' . $db->quoteName('e.id') . ' = ' . $db->quoteName('t.parent_id')); // Limit the nodes to a predefined filter. if (!empty($filter->data)) { $query->where('t.id IN(' . $filter->data . ')'); } // Load the branches. $db->setQuery($query); try { $branches[$bk]->nodes = $db->loadObjectList('id'); } catch (RuntimeException $e) { return null; } // Translate branch nodes if possible. $language = JFactory::getLanguage(); foreach ($branches[$bk]->nodes as $node_id => $node) { if (trim($node->parent_title, '**') == 'Language') { $title = FinderHelperLanguage::branchLanguageTitle($node->title); } else { $key = FinderHelperLanguage::branchPlural($node->title); $title = $language->hasKey($key) ? JText::_($key) : $node->title; } $branches[$bk]->nodes[$node_id]->title = $title; } // Add the Search All option to the branch. array_unshift($branches[$bk]->nodes, array('id' => null, 'title' => JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL'))); } // Store the data in cache. $cache->store($branches, $cacheId); } $html = ''; // Add the dates if enabled. if ($showDates) { $html .= JHtml::_('filter.dates', $idxQuery, $options); } $html .= '<div class="filter-branch' . $classSuffix . ' control-group">'; // Iterate through all branches and build code. foreach ($branches as $bk => $bv) { // If the multi-lang plugin is enabled then drop the language branch. if ($bv->title == 'Language' && JLanguageMultilang::isEnabled()) { continue; } $active = null; // Check if the branch is in the filter. if (array_key_exists($bv->title, $idxQuery->filters)) { // Get the request filters. $temp = JFactory::getApplication()->input->request->get('t', array(), 'array'); // Search for active nodes in the branch and get the active node. $active = array_intersect($temp, $idxQuery->filters[$bv->title]); $active = count($active) === 1 ? array_shift($active) : null; } // Build a node. $html .= '<div class="controls finder-selects">'; $html .= '<label for="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '" class="control-label">'; $html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title))); $html .= '</label>'; $html .= '<br />'; $html .= JHtml::_('select.genericlist', $branches[$bk]->nodes, 't[]', 'class="inputbox advancedSelect"', 'id', 'title', $active, 'tax-' . JFilterOutput::stringUrlSafe($bv->title)); $html .= '</div>'; } $html .= '</div>'; return $html; }
/** * Method to generate filters using select box drop down controls. * * @param FinderIndexerQuery $query A FinderIndexerQuery object. * @param array $options An array of options. * * @return mixed A rendered HTML widget on success, null otherwise. * * @since 2.5 */ public static function select($query, $options) { $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $filter = null; // Get the configuration options. $classSuffix = $options->get('class_suffix', null); $loadMedia = $options->get('load_media', true); $showDates = $options->get('show_date_filters', false); // Try to load the results from cache. $cache = JFactory::getCache('com_finder', ''); $cacheId = 'filter_select_' . serialize(array($query->filter, $options, $groups, JFactory::getLanguage()->getTag())); // Check the cached results. if (!($branches = $cache->get($cacheId))) { $db = JFactory::getDBO(); $sql = $db->getQuery(true); // Load the predefined filter if specified. if (!empty($query->filter)) { $sql->select($db->quoteName('f') . '.' . $db->quoteName('data') . ', ' . $db->quoteName('f') . '.' . $db->quoteName('params')); $sql->from($db->quoteName('#__finder_filters') . ' AS f'); $sql->where($db->quoteName('f') . '.' . $db->quoteName('filter_id') . ' = ' . (int) $query->filter); // Load the filter data. $db->setQuery($sql); $filter = $db->loadObject(); // Check for an error. if ($db->getErrorNum()) { return null; } // Initialize the filter parameters. if ($filter) { $registry = new JRegistry(); $registry->loadString($filter->params); $filter->params = $registry; } } // Build the query to get the branch data and the number of child nodes. $sql->clear(); $sql->select('t.*, count(c.id) AS children'); $sql->from($db->quoteName('#__finder_taxonomy') . ' AS t'); $sql->join('INNER', $db->quoteName('#__finder_taxonomy') . ' AS c ON c.parent_id = t.id'); $sql->where($db->quoteName('t') . '.' . $db->quoteName('parent_id') . ' = 1'); $sql->where($db->quoteName('t') . '.' . $db->quoteName('state') . ' = 1'); $sql->where($db->quoteName('t') . '.' . $db->quoteName('access') . ' IN (' . $groups . ')'); $sql->where($db->quoteName('c') . '.' . $db->quoteName('state') . ' = 1'); $sql->where($db->quoteName('t') . '.' . $db->quoteName('access') . ' IN (' . $groups . ')'); $sql->group($db->quoteName('t') . '.' . $db->quoteName('id')); $sql->order('t.ordering, t.title'); // Limit the branch children to a predefined filter. if (!empty($filter->data)) { $sql->where('c.id IN(' . $filter->data . ')'); } // Load the branches. $db->setQuery($sql); $branches = $db->loadObjectList('id'); // Check for an error. if ($db->getErrorNum()) { return null; } // Check that we have at least one branch. if (count($branches) === 0) { return null; } // Iterate through the branches and build the branch groups. foreach ($branches as $bk => $bv) { // If the multi-lang plug-in is enabled then drop the language branch. if ($bv->title == 'Language' && JLanguageMultilang::isEnabled()) { continue; } // Build the query to get the child nodes for this branch. $sql->clear(); $sql->select('t.*'); $sql->from($db->quoteName('#__finder_taxonomy') . ' AS t'); $sql->where($db->quoteName('t') . '.' . $db->quoteName('parent_id') . ' = ' . (int) $bk); $sql->where($db->quoteName('t') . '.' . $db->quoteName('state') . ' = 1'); $sql->where($db->quoteName('t') . '.' . $db->quoteName('access') . ' IN (' . $groups . ')'); $sql->order('t.ordering, t.title'); // Limit the nodes to a predefined filter. if (!empty($filter->data)) { $sql->where('t.id IN(' . $filter->data . ')'); } // Load the branches. $db->setQuery($sql); $branches[$bk]->nodes = $db->loadObjectList('id'); // Check for an error. if ($db->getErrorNum()) { return null; } // Translate branch nodes if possible. $language = JFactory::getLanguage(); foreach ($branches[$bk]->nodes as $node_id => $node) { $key = FinderHelperLanguage::branchPlural($node->title); if ($language->hasKey($key)) { $branches[$bk]->nodes[$node_id]->title = JText::_($key); } } // Add the Search All option to the branch. array_unshift($branches[$bk]->nodes, array('id' => null, 'title' => JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL'))); } // Store the data in cache. $cache->store($branches, $cacheId); } $html = ''; // Add the dates if enabled. if ($showDates) { $html .= JHtml::_('filter.dates', $query, $options); } $html .= '<ul id="finder-filter-select-list">'; // Iterate through all branches and build code. foreach ($branches as $bk => $bv) { // If the multi-lang plug-in is enabled then drop the language branch. if ($bv->title == 'Language' && JLanguageMultilang::isEnabled()) { continue; } $active = null; // Check if the branch is in the filter. if (array_key_exists($bv->title, $query->filters)) { // Get the request filters. $temp = JFactory::getApplication()->input->request->get('t', array(), 'array'); // Search for active nodes in the branch and get the active node. $active = array_intersect($temp, $query->filters[$bv->title]); $active = count($active) === 1 ? array_shift($active) : null; } $html .= '<li class="filter-branch' . $classSuffix . '">'; $html .= '<label for="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '">'; $html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title))); $html .= '</label>'; $html .= JHtml::_('select.genericlist', $branches[$bk]->nodes, 't[]', 'class="inputbox"', 'id', 'title', $active, 'tax-' . JFilterOutput::stringUrlSafe($bv->title)); $html .= '</li>'; } // Close the widget. $html .= '</ul>'; // Load the CSS/JS resources. if ($loadMedia) { JHtml::stylesheet('com_finder/sliderfilter.css', false, true, false); } return $html; }
function save(&$data) { $table =& $this->getTable(); if (!$table->bind($data)) { $this->setError($table->getErrorMsg()); return false; } // for allow html records... // fix up special html fields $fields = $table->getFields(); foreach ($fields as $field) { if ($field->Type == 'text' && $field->Field != 'params') { $name = $field->Field; $table->{$name} = JRequest::getVar($name, '', 'post', 'string', JREQUEST_ALLOWHTML); } } if (!$table->id) { $where = @$table->catid ? 'catid = ' . (int) $table->catid : null; $table->ordering = $table->getNextOrder($where); $user =& JFactory::getUser(); $table->created_by = $user->get('id'); } // $user = &JFactory::getUser(); // $table->created_by = $table->created_by ? $table->created_by : $user->get('id'); if ($table->created && strlen(trim($table->created)) <= 10) { $table->created .= ' 00:00:00'; } $config =& JFactory::getConfig(); $tzoffset = $config->getValue('config.offset'); $date =& JFactory::getDate($table->created, $tzoffset); $table->created = $date->toMySQL(); if (!$table->check()) { $this->setError($table->getError()); return false; } // image upload jimport('joomla.filesystem.file'); $image = JRequest::getVar('image', null, 'files', 'array'); if (strtolower(JFile::getExt($image['name'])) == 'jpg') { $imageFilename = JFilterOutput::stringUrlSafe($table->name) . '_' . time() . '.jpg'; $src = $image['tmp_name']; $dest = JPATH_ROOT . '/media/com_arcnaanimals/' . $imageFilename; if (JFile::upload($src, $dest)) { } } // auto publish $table->published = 1; $table->image = $imageFilename; if (!$table->store()) { $this->setError($table->getError()); return false; } return $table->id; }
</thead> <tfoot> <tr> <td colspan="23"> <?php echo $this->pagination->getListFooter(); ?> </td> </tr> </tfoot> <tbody> <?php $k = 0; for ($i = 0, $n = count($this->items); $i < $n; $i++) { $item =& $this->items[$i]; $slug = JFilterOutput::stringUrlSafe($item->location_state . '-' . $item->location_city . '-' . $item->name); $url = JRoute::_("index.php?option={$option}&task=edit&cid[]={$item->id}:{$slug}"); $checked = JHTML::_('grid.checkedout', $item, $i); $published = JHTML::_('grid.published', $item, $i); $isCheckedOut = JTable::isCheckedOut($this->user->get('id'), $item->checked_out); $thumbnail = JHTML::_('arcna.thumbnail', $item->image, 100, 100); ?> <tr class="<?php echo "row{$k}"; ?> "> <td align="center"> <?php