本文整理汇总了PHP中Pager::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::sort方法的具体用法?PHP Pager::sort怎么用?PHP Pager::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::sort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent()
{
global $sql;
$pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users'));
$pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc');
$query = $sql->query('
SELECT id, name, inline, members
FROM ' . DB_PREFIX . 'groups
ORDER BY display_order');
while ($row = $query->fetch()) {
if ($row['inline']) {
$row['name'] = sprintf($row['inline'], $row['name']);
}
$groups[] = $row;
}
$query = $sql->query('
SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name
FROM ' . DB_PREFIX . 'users u
LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id
ORDER BY ' . $pager->orderBy . '
LIMIT ' . $pager->limit . '
OFFSET ' . $pager->offset);
while ($row = $query->fetch()) {
$row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']);
switch ($row['gender']) {
case 1:
$row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />';
break;
case 2:
$row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />';
break;
default:
$row['gender'] = '';
}
$users[] = $row;
}
try {
$tpl = new PHPTAL('modules/users/users.tpl.html');
$tpl->sort = $pager->sorters;
$tpl->users = $users;
$tpl->groups = $groups;
$tpl->pagination = $pager->getLinks();
return $tpl->execute();
} catch (Exception $e) {
return template_error($e);
}
}
示例2: current
<?php
// KioCMS - Kiofol Content Managment System
// modules/news/admin/categories.php
$total_categories = current($sql->query('SELECT COUNT(id) AS categories FROM ' . DB_PREFIX . 'news_categories')->fetch());
if ($total_categories) {
$pager = new Pager('admin/modules/news/categories', $total_categories);
$pager->limit();
$pager->sort(array($lang2['ID'] => 'id', $lang2['CATEGORY_NAME'] => 'name', $lang2['DESCRIPTION'] => 'description', $lang2['TOTAL_ENTRIES'] => 'entries'), 'id', 'desc');
$query = $sql->query('
SELECT *
FROM ' . DB_PREFIX . 'news_categories
ORDER BY ' . $pager->order . '
LIMIT ' . $pager->limit . '
OFFSET ' . $pager->offset);
while ($row = $query->fetch()) {
$categories[] = $row;
}
$tpl = new PHPTAL('modules/news/admin/categories.html');
$tpl->system = $system;
$tpl->total_categories = $total_categories;
$tpl->sorters = $pager->sorters;
$tpl->limit_form = $pager->limit_form;
$tpl->categories = $categories;
$tpl->lang_admin = $lang_admin;
$tpl->lang_system = $lang_system;
$tpl->pagination = $pager->paginate();
echo $tpl->execute();
} else {
echo $lang[14];
}
示例3: Pager
<?php
// KioCMS - Kiofol Content Managment System
// modules/pm/box.php
$kio->addPath(t(ucfirst(u1)), 'pm/' . u1);
$module->subcodename = 'box';
$pager = new Pager('pm/' . u1, $user->{'pm_' . u1}, $cfg->pm['limit']);
$pager->sort(array(t('Subject') => 'subject', t('Message') => 'message', u1 == 'outbox' ? t('To') : t('From') => 'nickname', t('Sent') => 'sent'), 'sent', 'asc');
// Reset new messages counter
if ($user->pm_new) {
$sql->exec('UPDATE ' . DB_PREFIX . 'users SET pm_new = 0 WHERE id = ' . $user->id);
}
switch ($_POST['action']) {
// Delete messages
case 'delete':
$delete = true;
break;
// Mark messages as read
// Mark messages as read
case 'read':
$set = 'is_read = 1';
break;
// Mark messages as unread
// Mark messages as unread
case 'unread':
$set = 'is_read = 0';
}
if ($set || $delete && is_array($_POST['messages'])) {
if ($set) {
$sql->exec('UPDATE ' . DB_PREFIX . 'pm SET ' . $set);
} else {
示例4: getFolder
private function getFolder($folder_id)
{
global $sql;
Kio::addTitle(t(ucfirst(u1)));
Kio::addBreadcrumb(t(ucfirst(u1)), 'pm/' . u1);
$note = new Notifier();
$this->subcodename = 'box';
$pager = new Pager('pm/' . u1, User::${'pm' . ucfirst(u1)}, Kio::getConfig('limit', 'pm'));
$pager->sort(array(t('Subject') => 'subject', t('Message') => 'message', u1 == 'outbox' ? t('To') : t('From') => 'nickname', t('Sent') => 'sent'), 'sent', 'asc');
// Reset new messages counter
if (User::$pmNew) {
$sql->exec('UPDATE ' . DB_PREFIX . 'users SET pm_new = 0 WHERE id = ' . UID);
}
if (isset($_POST['action']) && !empty($_POST['messages'])) {
$action_messages = implode(', ', array_map('intval', $_POST['messages']));
switch ($_POST['action']) {
// Mark messages as read
case 'read':
$sql->exec('
UPDATE ' . DB_PREFIX . 'pm
SET is_read = 1
WHERE id IN(' . $action_messages . ')
AND folder = ' . $folder_id . '
AND owner_id = ' . UID);
break;
// Mark messages as unread
// Mark messages as unread
case 'unread':
$sql->exec('
UPDATE ' . DB_PREFIX . 'pm
SET is_read = 0
WHERE id IN(' . $action_messages . ')
AND folder = ' . $folder_id . '
AND owner_id = ' . UID);
break;
// Delete messages
// Delete messages
case 'delete':
$sql->exec('
DELETE FROM ' . DB_PREFIX . 'pm
WHERE id IN(' . $action_messages . ')
AND folder = ' . $folder_id . '
AND owner_id = ' . UID);
}
redirect(HREF . PATH);
}
$stmt = $sql->query('
SELECT pm.*, u.nickname, u.group_id
FROM ' . DB_PREFIX . 'pm pm
LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = pm.connector_id
WHERE pm.owner_id = ' . UID . ' AND pm.folder = ' . $folder_id . '
ORDER BY ' . $pager->orderBy . '
LIMIT ' . $pager->limit . '
OFFSET ' . $pager->offset);
if ($stmt->rowCount()) {
$messages = array();
while ($row = $stmt->fetch()) {
if ($row['connector_id']) {
$row['nickname'] = User::format($row['connector_id'], $row['nickname'], $row['group_id']);
}
$messages[] = $row;
}
try {
$tpl = new PHPTAL('modules/pm/pm.tpl.html');
$tpl->messages = $messages;
$tpl->sort = $pager->sorters;
$tpl->total = User::${'pm' . ucfirst(u1)};
$tpl->max = Kio::getConfig(u1 . '_max', 'pm');
$tpl->note = $note;
$tpl->pager = $pager;
$tpl->pagination = $pager->getLinks();
return $tpl->execute();
} catch (Exception $e) {
return template_error($e);
}
} else {
return $note->info(t('There is no messages in the box.'));
}
}