/** * Returns a list of label filters * * @param string $asset The asset filter group * @param integer $project The project filter * * @return string The label html */ public static function filter($asset, $project = 0, $selected = array(), $filter_style = '') { if (!$project) { $project = ProjectforkHelper::getActiveProjectId(); } if (!$project) { return ''; } if (!is_array($selected)) { $selected = array(); } $db = JFactory::getDbo(); $query = $db->getQuery(true); if ($asset == 'com_pfrepo') { $asset = $db->quote('com_pfrepo.directory') . 'OR a.asset_group = ' . $db->quote('com_pfrepo.file') . 'OR a.asset_group = ' . $db->quote('com_pfrepo.note'); } else { $asset = $db->quote($db->escape($asset)); } $query->select('a.id, a.title, a.style')->from('#__pf_labels AS a')->where('a.project_id = ' . $db->quote((int) $project))->where('(a.asset_group = ' . $db->quote('com_pfprojects.project') . ' OR a.asset_group = ' . $asset . ')')->order('a.style, a.title ASC'); $db->setQuery($query); $items = (array) $db->loadObjectList(); $html = array(); if (!count($items)) { return ''; } $html[] = '<ul class="unstyled">'; foreach ($items as $item) { $checked = in_array($item->id, $selected) ? ' checked="checked"' : ''; $class = $item->style != '' ? ' ' . $item->style : ''; $cbid = htmlspecialchars(str_replace('.', '_', $asset) . '_label_' . $item->id, ENT_COMPAT, 'UTF-8'); $html[] = '<li class="pull-left btn-group">'; $html[] = '<label class="checkbox" for="' . $cbid . '" style="cursor:pointer">'; $html[] = '<input type="checkbox" id="' . $cbid . '" class="inputbox" name="filter_label[]" value="' . (int) $item->id . '"' . $checked . '/>'; $html[] = '<span class="label' . $class . '">' . htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</span>'; $html[] = '</label>'; $html[] = '</li>'; } $html[] = '</ul>'; $html[] = '<div class="clearfix clr"></div>'; $html[] = '<div class="btn-group">'; $html[] = '<button class="btn" onclick="this.form.submit()">' . JText::_('JSEARCH_FILTER_SUBMIT') . '</button>'; $html[] = '</div>'; return implode('', $html); }
public function display($cachable = false, $urlparams = false) { ProjectforkHelper::addSubmenu(JFactory::getApplication()->input->get('view', $this->default_view)); parent::display(); return $this; }