本文整理汇总了PHP中ContentHelper::filterCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelper::filterCategory方法的具体用法?PHP ContentHelper::filterCategory怎么用?PHP ContentHelper::filterCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentHelper
的用法示例。
在下文中一共展示了ContentHelper::filterCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getLists
function _getLists()
{
global $mainframe;
// Initialize variables
$db =& JFactory::getDBO();
// Get some variables from the request
$sectionid = JRequest::getVar('sectionid', -1, '', 'int');
$redirect = $sectionid;
$option = JRequest::getCmd('option');
$filter_order = $mainframe->getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_state = $mainframe->getUserStateFromRequest('articleelement.filter_state', 'filter_state', '', 'word');
$catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int');
$filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int');
$filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int');
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int');
$search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string');
$search = JString::strtolower($search);
// get list of categories for dropdown filter
$filter = $filter_sectionid >= 0 ? ' WHERE cc.section = ' . $db->Quote($filter_sectionid) : '';
// get list of categories for dropdown filter
$query = 'SELECT cc.id AS value, cc.title AS text, section' . ' FROM #__categories AS cc' . ' INNER JOIN #__sections AS s ON s.id = cc.section' . $filter . ' ORDER BY s.ordering, cc.ordering';
$lists['catid'] = ContentHelper::filterCategory($query, $catid);
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
$lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript);
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// search filter
$lists['search'] = $search;
return $lists;
}
示例2: viewContent
//.........这里部分代码省略.........
$search = $mainframe->getUserStateFromRequest($context . 'search', 'search', '', 'string');
if (strpos($search, '"') !== false) {
$search = str_replace(array('=', '<'), '', $search);
}
$search = JString::strtolower($search);
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0, 'int');
// In case limit has been changed, adjust limitstart accordingly
$limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
//$where[] = "c.state >= 0";
$where[] = 'c.state != -2';
// ensure we have a valid value for filter_order
if (!in_array($filter_order, array('c.title', 'c.state', 'frontpage', 'c.ordering', 'groupname', 'section_name', 'cc.title', 'author', 'c.created', 'c.hits', 'c.id'))) {
$filter_order = 'section_name';
}
if ($filter_order == 'c.ordering') {
$order = ' ORDER BY section_name, cc.title, c.ordering ' . $filter_order_Dir;
} else {
$order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', section_name, cc.title, c.ordering';
}
$all = 1;
if ($filter_sectionid >= 0) {
$filter = ' WHERE cc.section = ' . (int) $filter_sectionid;
}
$section->title = 'All Articles';
$section->id = 0;
/*
* Add the filter specific information to the where clause
*/
// Section filter
if ($filter_sectionid >= 0) {
$where[] = 'c.sectionid = ' . (int) $filter_sectionid;
}
// Category filter
if ($catid > 0) {
$where[] = 'c.catid = ' . (int) $catid;
}
// Author filter
if ($filter_authorid > 0) {
$where[] = 'c.created_by = ' . (int) $filter_authorid;
}
// Content state filter
if ($filter_state) {
if ($filter_state == 'P') {
$where[] = 'c.state = 1';
} else {
if ($filter_state == 'U') {
$where[] = 'c.state = 0';
} else {
if ($filter_state == 'A') {
$where[] = 'c.state = -1';
} else {
$where[] = 'c.state != -2';
}
}
}
}
// Keyword filter
if ($search) {
$where[] = '(LOWER( c.title ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false) . ' OR c.id = ' . (int) $search . ')';
}
// Build the where clause of the content record query
$where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
// Get the total number of records
$query = 'SELECT COUNT(*)' . ' FROM #__content AS c' . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . $where;
$db->setQuery($query);
$total = $db->loadResult();
// Create the pagination object
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
// Get the articles
$query = 'SELECT c.*, g.name AS groupname, cc.title AS name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . ' FROM #__content AS c' . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . ' LEFT JOIN #__groups AS g ON g.id = c.access' . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . ' LEFT JOIN #__users AS v ON v.id = c.created_by' . ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . $where . $order;
$db->setQuery($query, $pagination->limitstart, $pagination->limit);
$rows = $db->loadObjectList();
// If there is a database query error, throw a HTTP 500 and exit
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
return false;
}
// get list of categories for dropdown filter
$query = 'SELECT cc.id AS value, cc.title AS text, section' . ' FROM #__categories AS cc' . ' INNER JOIN #__sections AS s ON s.id = cc.section ' . $filter . ' ORDER BY s.ordering, cc.ordering';
$lists['catid'] = ContentHelper::filterCategory($query, $catid);
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
$lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript);
// get list of Authors for dropdown filter
$query = 'SELECT c.created_by, u.name' . ' FROM #__content AS c' . ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . ' LEFT JOIN #__users AS u ON u.id = c.created_by' . ' WHERE c.state <> -1' . ' AND c.state <> -2' . ' GROUP BY u.name' . ' ORDER BY u.name';
$authors[] = JHTML::_('select.option', '0', '- ' . JText::_('Select Author') . ' -', 'created_by', 'name');
$db->setQuery($query);
$authors = array_merge($authors, $db->loadObjectList());
$lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid);
// state filter
$lists['state'] = JHTML::_('grid.state', $filter_state, 'Published', 'Unpublished', 'Archived');
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// search filter
$lists['search'] = $search;
ContentView::showContent($rows, $lists, $pagination, $redirect);
}
示例3: viewArchive
/**
* Shows a list of archived articles
* @param int The section id
*/
function viewArchive()
{
global $mainframe;
// Initialize variables
$db =& JFactory::getDBO();
$sectionid = JRequest::getVar('sectionid', 0, '', 'int');
$option = JRequest::getCmd('option');
$filter_order = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.filter_order", 'filter_order', 'sectname', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.filter_order_Dir", 'filter_order_Dir', '', 'word');
$catid = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.catid", 'catid', 0, 'int');
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.limitstart", 'limitstart', 0, 'int');
$filter_authorid = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.filter_authorid", 'filter_authorid', 0, 'int');
$filter_sectionid = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.filter_sectionid", 'filter_sectionid', 0, 'int');
$search = $mainframe->getUserStateFromRequest("{$option}.{$sectionid}.viewarchive.search", 'search', '', 'string');
$search = JString::strtolower($search);
$redirect = $sectionid;
// A section id of zero means view all articles [all sections]
if ($sectionid == 0) {
$where = array('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"');
$filter = ' , #__sections AS s WHERE s.id = c.section';
$all = 1;
} else {
//We are viewing a specific section
$where = array('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"', 'c.sectionid= ' . (int) $sectionid);
$filter = ' WHERE section = ' . $db->Quote($sectionid);
$all = NULL;
}
// Section filter
if ($filter_sectionid > 0) {
$where[] = 'c.sectionid = ' . (int) $filter_sectionid;
}
// Author filter
if ($filter_authorid > 0) {
$where[] = 'c.created_by = ' . (int) $filter_authorid;
}
// Category filter
if ($catid > 0) {
$where[] = 'c.catid = ' . (int) $catid;
}
// Keyword filter
if ($search) {
$where[] = 'LOWER( c.title ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false);
}
// TODO: Sanitise $filter_order
$filter_order_Dir = $filter_order_Dir == 'ASC' ? 'ASC' : 'DESC';
$orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', sectname, cc.name, c.ordering';
$where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
// get the total number of records
$query = 'SELECT COUNT(*)' . ' FROM #__content AS c' . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . $where;
$db->setQuery($query);
$total = $db->loadResult();
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
$query = 'SELECT c.*, g.name AS groupname, cc.name, v.name AS author, s.title AS sectname' . ' FROM #__content AS c' . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . ' LEFT JOIN #__groups AS g ON g.id = c.access' . ' LEFT JOIN #__users AS v ON v.id = c.created_by' . $where . $orderby;
$db->setQuery($query, $pagination->limitstart, $pagination->limit);
$rows = $db->loadObjectList();
// If there is a database query error, throw a HTTP 500 and exit
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
return false;
}
// get list of categories for dropdown filter
$query = 'SELECT c.id AS value, c.title AS text' . ' FROM #__categories AS c' . $filter . ' ORDER BY c.ordering';
$lists['catid'] = ContentHelper::filterCategory($query, $catid);
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
$lists['sectionid'] = JAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript);
$section =& JTable::getInstance('section');
$section->load($sectionid);
// get list of Authors for dropdown filter
$query = 'SELECT c.created_by, u.name' . ' FROM #__content AS c' . ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . ' LEFT JOIN #__users AS u ON u.id = c.created_by' . ' WHERE c.state = -1' . ' GROUP BY u.name' . ' ORDER BY u.name';
$db->setQuery($query);
$authors[] = JHTML::_('select.option', '0', '- ' . JText::_('Select Author') . ' -', 'created_by', 'name');
$authors = array_merge($authors, $db->loadObjectList());
$lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid);
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// search filter
$lists['search'] = $search;
ContentView::showArchive($rows, $section, $lists, $pagination, $option, $all, $redirect);
}