当前位置: 首页>>代码示例>>PHP>>正文


PHP flexible_table::get_sort_columns方法代码示例

本文整理汇总了PHP中flexible_table::get_sort_columns方法的典型用法代码示例。如果您正苦于以下问题:PHP flexible_table::get_sort_columns方法的具体用法?PHP flexible_table::get_sort_columns怎么用?PHP flexible_table::get_sort_columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flexible_table的用法示例。


在下文中一共展示了flexible_table::get_sort_columns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

    echo $output->render($eventSelect);
    // Show user list if the user has permission to see other people's messages
    if ($canAdminUsers) {
        $optionSet = array(0 => get_string('optionallusers', 'block_moodletxt'));
        $userList = $userDAO->getAllUsers();
        foreach ($userList as $userObj) {
            $optionSet[$userObj->getId()] = $userObj->getFullNameForDisplay();
        }
        $userSelect = new single_select(new moodle_url('sent.php', array('course' => $courseId, 'instance' => $instanceId, 'events' => $includeEvents)), 'user', $optionSet, $userToView, false);
        $userSelect->set_label(get_string('labelshowmessagesforuser', 'block_moodletxt'));
        echo $output->render($userSelect);
    }
}
// Figure out which table item the user wants to sort by
$orderBy = '';
foreach ($table->get_sort_columns() as $field => $direction) {
    switch ($field) {
        case 'user':
            $databaseOrder = 'u.lastname %DIR%, u.firstname %DIR%';
            break;
        case 'account':
            $databaseOrder = 'acc.username %DIR%';
            break;
        case 'time':
            $databaseOrder = 'o.timesent %DIR%';
            break;
    }
    if ($direction == SORT_ASC) {
        $databaseOrder = str_replace('%DIR%', 'ASC', $databaseOrder);
    } else {
        $databaseOrder = str_replace('%DIR%', 'DESC', $databaseOrder);
开发者ID:educacionbe,项目名称:campus,代码行数:31,代码来源:sent.php

示例2:

$count = $DB->count_records_sql($sqlcount);
if (!$showall && !$table->is_downloading()) {
    $table->pagesize($limit, $count);
}
$table->define_columns(array('id', 'name', 'module', 'identifier', 'status', 'attempts', 'action'));
$table->define_headers(array(get_string('id', 'plagiarism_urkund'), get_string('user'), get_string('module', 'plagiarism_urkund'), get_string('identifier', 'plagiarism_urkund'), get_string('status', 'plagiarism_urkund'), get_string('attempts', 'plagiarism_urkund'), ''));
$table->define_baseurl('urkund_debug.php');
$table->sortable(true);
$table->no_sorting('file', 'action');
$table->collapsible(true);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('class', 'generaltable generalbox');
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
$table->setup();
// Work out direction of sort required.
$sortcolumns = $table->get_sort_columns();
// Now do sorting if specified.
$orderby = '';
if (!empty($sort)) {
    $direction = ' DESC';
    if (!empty($sortcolumns[$sort]) && $sortcolumns[$sort] == SORT_ASC) {
        $direction = ' ASC';
    }
    if ($sort == "name") {
        $orderby = " ORDER BY u.firstname {$direction}, u.lastname {$direction}";
    } else {
        if ($sort == "module") {
            $orderby = " ORDER BY cm.id {$direction}";
        } else {
            if ($sort == "status") {
                $orderby = " ORDER BY t.statuscode {$direction}";
开发者ID:henrikthorn,项目名称:moodle-plagiarism_urkund,代码行数:31,代码来源:urkund_debug.php


注:本文中的flexible_table::get_sort_columns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。