本文整理汇总了PHP中CriteriaCompo::addSort方法的典型用法代码示例。如果您正苦于以下问题:PHP CriteriaCompo::addSort方法的具体用法?PHP CriteriaCompo::addSort怎么用?PHP CriteriaCompo::addSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CriteriaCompo
的用法示例。
在下文中一共展示了CriteriaCompo::addSort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
require dirname(__FILE__) . '/../../mainfile.php';
require_once XOOPS_ROOT_PATH . "/core/XCube_PageNavigator.class.php";
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('level', 0, '>'));
// We can not use IN statement here,
// because XoopsObjectGenericHandler doesn't support a conditon which is not a property of an XoopsObject
$subcriteria = new CriteriaCompo();
foreach ($xoopsModuleConfig['listed_groups'] as $groupId) {
$subcriteria->add(new Criteria('g.groupid', $groupId), 'OR');
}
$criteria->add($subcriteria);
$criteria->addSort('uname', 'ASC');
$userGroupHandler = xoops_getmodulehandler('UserGroup');
$total = $userGroupHandler->getCount($criteria);
$pageNavigator = new XCube_PageNavigator('./index.php');
$pageNavigator->setPerpage($xoopsModuleConfig['users_per_page']);
$pageNavigator->setTotalItems($total);
$pageNavigator->fetch();
$criteria->setStart($pageNavigator->getStart());
$criteria->setLimit($pageNavigator->getPerpage());
/** @var $userGroupHandler Xoopsmembers_UserGroupHandler */
$xoopsTpl->assign('total', $total);
$xoopsTpl->assign('users', $userGroupHandler->getObjects($criteria));
$xoopsTpl->assign('pageNavigator', $pageNavigator);
require_once XOOPS_ROOT_PATH . "/header.php";
$xoopsOption['template_main'] = 'xoopsmembers_index.html';
require_once XOOPS_ROOT_PATH . "/footer.php";
示例2: im_admin_list
public function im_admin_list()
{
xoops_cp_header();
$this->mm_admin_menu(intval($this->mnum), _AD_MULTIMENU_ADMIN . $this->mnum);
echo '<fieldset style="padding: 5px;"><legend style="font-weight: bold; color: #900;">' . _AD_MULTIMENU_ADMIN . $this->mnum . '</legend>';
echo '<form action="index.php?mnum=' . $this->mnum . '&op=new" method="post" name="form1">
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="outer"><tr>
<th align="center">' . _AD_MULTIMENU_TITLE . '</th>
<th align="center">' . _AD_MULTIMENU_HIDE . '</th>
<th align="center">' . _AD_MULTIMENU_LINK . '</th>
<th align="center">' . _AD_MULTIMENU_OPERATION . '</th></tr>';
$modhand = xoops_getmodulehandler('menu');
$modhand->setTable($this->mnum);
$mCriteria = new CriteriaCompo();
$mCriteria->addSort('weight');
$modhand->im_admin_clean();
$objcts = $modhand->getObjects($mCriteria);
$class = 'even';
foreach ($objcts as $obj) {
if ($obj->get('weight') != 0) {
$moveup = "<a href='index.php?mnum=" . $this->mnum . "&op=move&id=" . $obj->get('id') . "&weight=" . ($obj->get('weight') - 1) . "'>[" . _AD_MULTIMENU_UP . "]</a>";
} else {
$moveup = "[" . _AD_MULTIMENU_UP . "]";
}
if ($obj->get('weight') != count($objcts) - 1) {
$movedown = "<a href='index.php?mnum=" . $this->mnum . "&op=move&id=" . $obj->get('id') . "&weight=" . ($obj->get('weight') + 2) . "'>[" . _AD_MULTIMENU_DOWN . "]</a>";
} else {
$movedown = "[" . _AD_MULTIMENU_DOWN . "]";
}
//fix by domifara Notice [PHP]: Undefined variable: status
$status = $obj->get('hide') ? _YES : _NO;
echo "<tr>\n <td class='{$class}'>" . $obj->get('title') . "</td>\n <td class='{$class}' align='center'>{$status}</td>\n <td class='{$class}'>" . $obj->get('link') . "</td>\n <td class='{$class}' align='center'><small><a href='index.php?mnum=" . $this->mnum . "&op=del&id=" . $obj->get('id') . "'>[" . _DELETE . "]</a>\n <a href='index.php?mnum=" . $this->mnum . "&op=edit&id=" . $obj->get('id') . "'>[" . _EDIT . "]</a>" . $moveup . $movedown . "</small></td></tr>";
$class = $class == 'odd' ? 'even' : 'odd';
}
echo "<tr><td class='foot' colspan='4' align='right'>";
// echo $GLOBALS['xoopsSecurity']->getTokenHTML();
echo $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__);
echo "<input type='submit' name='submit' value='" . _AD_MULTIMENU_NEW . "'>\n </td></tr></table></form>";
echo "</fieldset><br />";
xoops_cp_footer();
}
示例3: getCommonModuleList
/**
* getCommonModuleList
*
* @param string $role ex) cat, group, workflow, image
*
* @return string[] dirnames
**/
public static function getCommonModuleList($role)
{
$list = array();
$cri = new CriteriaCompo();
$cri->add(new Criteria('isactive', 0, '>'));
$cri->add(new Criteria('role', $role));
$cri->addSort('weight', 'ASC');
$cri->addSort('mid', 'ASC');
foreach (xoops_gethandler('module')->getObjects($cri) as $module) {
$list[] = $module->get('dirname');
}
return $list;
}
示例4: getListCriteria
/**
* getListCriteria
*
* @param string $dirname
* @param int $categoryId
* @param bool $childCategory Get child categories of $categodyId ?
* @param int[] $sortArr
* @param Lenum_Status $status
* @param bool $term if between startdate and enddate
*
* @return CriteriaCompo
**/
public static function getListCriteria($dirname, $categoryId = 0, $childCategory = false, $sortArr = null, $status = Lenum_Status::PUBLISHED, $term = true)
{
static $idList = array();
if (!isset($idList[$dirname])) {
$idList[$dirname] = self::getPermittedIdList($dirname);
}
$accessController = self::getAccessController($dirname);
$cri = new CriteriaCompo();
//category
if ($categoryId > 0) {
//get child category of $categoryId ?
if ($childCategory === true) {
$ids = array($categoryId);
$tree = array();
// Legacy_Category Objects array
$categoryDir = $accessController->dirname();
XCube_DelegateUtils::call('Legacy_Category.' . $categoryDir . '.GetTree', new XCube_Ref($tree), $categoryDir, 'viewer', $categoryId);
foreach ($tree as $cat) {
$ids[] = $cat->get('cat_id');
}
$cri->add(new Criteria('category_id', $ids, 'IN'));
} else {
$cri->add(new Criteria('category_id', $categoryId));
}
} else {
//get permitted categories to show
if ($accessController instanceof XoopsModule && ($accessController->get('role') === 'cat' || $accessController->get('role') === 'group')) {
if (count($idList[$dirname]) > 0) {
$cri->add(new Criteria('category_id', $idList[$dirname], 'IN'));
} else {
//no date will be return by this criteria.
$cri->add(new Criteria('category_id', array(0), 'IN'));
}
}
}
//Is hierarchical ?
if (self::getModuleConfig($dirname, 'hierarchical') == true && self::getModuleConfig($dirname, 'list_order') !== 'categorized') {
$cri->add(new Criteria('p_id', 0));
}
//status
if ($status <= Lenum_Status::PUBLISHED) {
$cri->add(new Criteria('status', $status));
}
//startdate and enddate
if ($term === true) {
$defHandler = Legacy_Utils::getModuleHandler('definition', $dirname);
if ($startField = $defHandler->getStartField()) {
$cri->add(new Criteria($startField->get('field_name'), time(), '<'));
}
if ($endField = $defHandler->getEndField()) {
$endCri = new CriteriaCompo();
$endCri->add(new Criteria($endField->get('field_name'), time(), '>'));
$endCri->add(new Criteria($endField->get('field_name'), 0), 'OR');
$cri->add($endCri);
}
}
//set sort/order
$list = self::getOrderList($dirname);
if (is_array($sortArr)) {
foreach ($sortArr as $sort) {
if (abs($sort) > 0 && in_array(abs($sort), array_keys($list))) {
$cri->addSort($list[abs($sort)], $sort > 0 ? 'ASC' : 'DESC');
}
}
} else {
$default = self::getModuleConfig($dirname, 'default_order');
if (in_array(abs($default), array_keys($list))) {
$cri->setSort($list[abs($default)], $default > 0 ? 'ASC' : 'DESC');
} else {
$cri->setSort('weight', 'ASC');
}
}
XCube_DelegateUtils::call('Module.' . $dirname . '.SetupListCriteria', $cri);
return $cri;
}