本文整理汇总了PHP中ContentHelperQuery::orderbyPrimary方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelperQuery::orderbyPrimary方法的具体用法?PHP ContentHelperQuery::orderbyPrimary怎么用?PHP ContentHelperQuery::orderbyPrimary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentHelperQuery
的用法示例。
在下文中一共展示了ContentHelperQuery::orderbyPrimary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering The field to order on.
* @param string $direction The direction to order on.
*
* @return void.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
parent::populateState($ordering, $direction);
$input = JFactory::getApplication()->input;
$user = JFactory::getUser();
// List state information
$limitstart = $input->getUInt('limitstart', 0);
$this->setState('list.start', $limitstart);
$params = $this->state->params;
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
$this->setState('list.limit', $limit);
$this->setState('list.links', $params->get('num_links'));
$this->setState('filter.frontpage', true);
if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
// Filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.published', 1);
} else {
$this->setState('filter.published', array(0, 1, 2));
}
// Check for category selection
if ($params->get('featured_categories') && implode(',', $params->get('featured_categories')) == true) {
$featuredCategories = $params->get('featured_categories');
$this->setState('filter.frontpage.categories', $featuredCategories);
}
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate);
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$this->setState('list.ordering', $primary . $secondary . ', a.created DESC');
$this->setState('list.direction', '');
}
示例2: getListQuery
/**
* @return JDatabaseQuery
*/
function getListQuery()
{
// Set the archive ordering
$params = $this->state->params;
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
// No category ordering
$categoryOrderby = '';
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby = $primary . ' ' . $secondary . ' a.created DESC ';
$this->setState('list.ordering', $orderby);
$this->setState('list.direction', '');
// Create a new query object.
$query = parent::getListQuery();
// Add routing for archive
$query->select(' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug');
$query->select(' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug');
// Filter on month, year
// First, get the date field
$queryDate = ContentHelperQuery::getQueryDate($articleOrderDate);
if ($month = $this->getState('filter.month')) {
$query->where('MONTH(' . $queryDate . ') = ' . $month);
}
if ($year = $this->getState('filter.year')) {
$query->where('YEAR(' . $queryDate . ') = ' . $year);
}
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
示例3: getListQuery
/**
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Set the archive ordering
$params = $this->state->params;
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
// No category ordering
$categoryOrderby = '';
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby = $primary . ' ' . $secondary . ' a.created DESC ';
$this->setState('list.ordering', $orderby);
$this->setState('list.direction', '');
// Create a new query object.
$query = parent::getListQuery();
// Add routing for archive
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$query->select($case_when);
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('c.alias', '!=', '0');
$case_when .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $c_id . ' END as catslug';
$query->select($case_when);
// Filter on month, year
// First, get the date field
$queryDate = ContentHelperQuery::getQueryDate($articleOrderDate);
if ($month = $this->getState('filter.month')) {
$query->where('MONTH(' . $queryDate . ') = ' . $month);
}
if ($year = $this->getState('filter.year')) {
$query->where('YEAR(' . $queryDate . ') = ' . $year);
}
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
示例4: _buildContentOrderBy
function _buildContentOrderBy()
{
global $mainframe;
// Get the page/component configuration
$params =& $mainframe->getParams();
if (!is_object($params)) {
$params =& JComponentHelper::getParams('com_content');
}
$orderby_sec = $params->def('orderby_sec', '');
$orderby_pri = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
$orderby = ' ORDER BY ' . $primary . ' ' . $secondary;
return $orderby;
}
示例5: _buildContentOrderBy
/**
* Build the orderby for the query
*
* @return string $orderby portion of query
* @since 1.5
*/
protected function _buildContentOrderBy()
{
$app = JFactory::getApplication('site');
$db = $this->getDbo();
$params = $this->state->params;
$itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
$orderby = ' ';
if (!in_array($orderCol, $this->filter_fields)) {
$orderCol = null;
}
if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
$orderDirn = 'ASC';
}
if ($orderCol && $orderDirn) {
$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
}
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby .= $primary . ' ' . $secondary . ' a.created ';
return $orderby;
}
示例6: _buildContentOrderBy
function _buildContentOrderBy($state = 1)
{
global $mainframe;
// Get the page/component configuration
$params =& $mainframe->getParams();
$itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0);
$filter_order = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
if (!in_array($filter_order, array('a.title', 'author', 'a.hits', 'a.created', 'a.publish_up', 'a.publish_down', 'a.modified'))) {
$filter_order = '';
}
if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) {
$filter_order_Dir = 'ASC';
}
$orderby = ' ORDER BY ';
if ($filter_order && $filter_order_Dir) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
if ($filter_order == 'author') {
$orderby .= 'created_by_alias ' . $filter_order_Dir . ', ';
}
switch ($state) {
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
$primary = '';
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
break;
}
$orderby .= $primary . ' ' . $secondary . ' a.created DESC';
return $orderby;
}
示例7: getListQuery
/**
* Get the list of items.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Set the blog ordering
$params = $this->state->params;
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby = $primary . ' ' . $secondary . ' a.created DESC ';
$this->setState('list.ordering', $orderby);
$this->setState('list.direction', '');
// Create a new query object.
$query = parent::getListQuery();
// Filter by frontpage.
if ($this->getState('filter.frontpage')) {
$query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');
}
// Filter by categories
$featuredCategories = $this->getState('filter.frontpage.categories');
if (is_array($featuredCategories) && !in_array('', $featuredCategories)) {
$query->where('a.catid IN (' . implode(',', $featuredCategories) . ')');
}
return $query;
}
示例8: _buildContentOrderBy
function _buildContentOrderBy($state = 1)
{
$filter_order = JRequest::getCmd('filter_order');
$filter_order_Dir = JRequest::getWord('filter_order_Dir');
$orderby = ' ORDER BY ';
if ($filter_order && $filter_order_Dir) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
// Get the page/component configuration
$app =& JFactory::getApplication();
$params =& $app->getParams();
switch ($state) {
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = '';
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
break;
}
$orderby .= "{$primary} {$secondary}";
return $orderby;
}
示例9: _buildContentOrderBy
function _buildContentOrderBy($state = 1)
{
$filter_order = JRequest::getCmd('filter_order');
$filter_order_Dir = JRequest::getWord('filter_order_Dir');
if (!in_array($filter_order, array('a.id', 'a.title', 'a.alias', 'a.title_alias', 'a.introtext', 'a.fulltext', 'a.sectionid', 'a.state', 'a.catid', 'a.created', 'a.created_by', 'a.created_by_alias', 'a.modified', 'a.modified_by', 'a.checked_out', 'a.checked_out_time', 'a.hits', 'a.ordering', 'a.metakey', 'a.access'))) {
$filter_order = 'a.ordering';
}
if (!in_array(trim(strtoupper($filter_order_Dir)), array('ASC', 'DESC'))) {
$filter_order_Dir = 'ASC';
}
$orderby = ' ORDER BY ';
if ($filter_order) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
// Get the page/component configuration
$app =& JFactory::getApplication();
$params =& $app->getParams();
switch ($state) {
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = '';
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
break;
}
$orderby .= "{$primary} {$secondary}";
return $orderby;
}
示例10: buildContentOrderBy
function buildContentOrderBy()
{
$orderby = array();
$orderby_sec = $this->params->def('orderby_sec', 'rdate');
if ($orderby_sec == 'random') {
return ' ORDER BY RAND() ';
} else {
$orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
$orderby_pri = $this->params->def('orderby_pri', '');
$orderby[] = ContentHelperQuery::orderbySecondary($orderby_sec);
$orderby[] = ContentHelperQuery::orderbyPrimary($orderby_pri);
$orderby = array_filter($orderby);
if (!count($orderby)) {
$orderby[] = 'a.created DESC';
}
return ' ORDER BY ' . implode(',', $orderby);
}
}
示例11: _buildContentOrderBy
function _buildContentOrderBy($state = 1)
{
global $mainframe;
// Get the page/component configuration
$params =& $mainframe->getParams();
$filter_order = JRequest::getCmd('filter_order');
$filter_order_Dir = JRequest::getWord('filter_order_Dir');
$orderby = ' ORDER BY ';
if ($filter_order && $filter_order_Dir) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
if ($filter_order == 'author') {
$orderby .= 'created_by_alias ' . $filter_order_Dir . ', ';
}
switch ($state) {
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
$primary = '';
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
break;
}
$orderby .= $primary . ' ' . $secondary . ' a.created DESC';
return $orderby;
}
示例12: _buildContentOrderBy
function _buildContentOrderBy($state = 1)
{
$filter_order = JRequest::getCmd('filter_order');
$filter_order_Dir = JRequest::getWord('filter_order_Dir');
$orderby = ' ORDER BY ';
if ($filter_order && $filter_order_Dir) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
// Get the parameters of the active menu item
$menu =& JSite::getMenu();
$item = $menu->getActive();
$params =& $menu->getParams($item->id);
switch ($state) {
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = '';
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
$primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
break;
}
$orderby .= "{$primary} {$secondary}";
return $orderby;
}
示例13: _buildContentOrderBy
public static function _buildContentOrderBy($atribmenu)
{
$app = JFactory::getApplication('site');
$db = JFactory::getDbo();
$params = $atribmenu;
$itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
$orderby = ' ';
/*if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = null;
}*/
if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
$orderDirn = 'ASC';
}
if ($orderCol && $orderDirn) {
$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
}
$articleOrderby = $atribmenu['orderby_sec'] ? $atribmenu['orderby_sec'] : 'rdate';
$articleOrderDate = $atribmenu['order_date'];
$categoryOrderby = $atribmenu['orderby_pri'];
require_once JPATH_SITE . '/components/com_content/helpers/query.php';
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby .= $primary . ' ' . $secondary . ' a.created ';
return $orderby;
}
示例14: _buildContentOrderBy
/**
* Build the orderby for the query
*
* @return string $orderby portion of query
*/
protected function _buildContentOrderBy()
{
$app =& JFactory::getApplication('site');
$params = $this->_state->params;
$itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0);
$filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
$orderby = ' ';
if ($filter_order && $filter_order_Dir) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
$articleOrderby = $params->get('article_orderby', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('category_orderby', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby .= $primary . ' ' . $secondary . ' a.created DESC ';
return $orderby;
}
示例15: _buildContentOrderBy
protected function _buildContentOrderBy()
{
$app = JFactory::getApplication();
$db = JFactory::getDbo();
$params = JComponentHelper::getParams('com_content');
$itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
$orderby = ' ';
$_filter_fields = array('id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'modified', 'a.modified', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'author', 'a.author');
if (!in_array($orderCol, $_filter_fields)) {
$orderCol = null;
}
if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
$orderDirn = 'ASC';
}
if ($orderCol && $orderDirn) {
$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
}
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby .= $primary . ' ' . $secondary . ' a.created ';
return $orderby;
}