本文整理汇总了PHP中Criteria::addOrderDescending方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addOrderDescending方法的具体用法?PHP Criteria::addOrderDescending怎么用?PHP Criteria::addOrderDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::addOrderDescending方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build($runData)
{
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
$categoryName = $pl->getParameterValue("category", "MODULE", "AMODULE");
$details = $pl->getParameterValue("details", "MODULE", "AMODULE");
$preview = $pl->getParameterValue("preview", "MODULE", "AMODULE");
$order = $pl->getParameterValue("order", "MODULE", "AMODULE");
$limit = $pl->getParameterValue("limit", "MODULE", "AMODULE");
if ($categoryName !== null) {
$category = DB_CategoryPeer::instance()->selectByName($categoryName, $site->getSiteId());
if ($category == null) {
throw new ProcessException(_("The category can not be found."));
}
}
// now select pages according to the specified criteria
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
if ($category) {
$c->add("category_id", $category->getCategoryId());
}
switch ($order) {
case 'dateCreatedDesc':
$c->addOrderDescending('page_id');
break;
case 'dateCreatedAsc':
$c->addOrderAscending('page_id');
break;
case 'dateEditedDesc':
$c->addOrderDescending('date_last_edited');
break;
case 'dateEditedAsc':
$c->addOrderAscending('date_last_edited');
break;
case 'titleDesc':
$c->addOrderDescending("COALESCE(title, unix_name)");
break;
default:
$c->addOrderAscending("COALESCE(title, unix_name)");
}
if ($limit && is_numeric($limit) && $limit > 0) {
$c->setLimit($limit);
}
$pages = DB_PagePeer::instance()->select($c);
// by default cathegorize by first letter...
$runData->contextAdd("pages", $pages);
$runData->contextAdd("details", $details);
$runData->contextAdd("preview", $preview);
}
示例2: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$limit = $pl->getParameterValue("limit", "MODULE");
if ($limit == null || !is_numeric($limit) || $limit < 1 || $limit > 300) {
$limit = 5;
}
$categoryId = $pl->getParameterValue("categoryId", "MODULE", "AMODULE");
if ($categoryId !== null) {
$category = DB_ForumCategoryPeer::instance()->selectByPrimaryKey($categoryId);
if ($category == null || $category->getSiteId() != $site->getSiteId()) {
throw new ProcessException(_("The category can not be found."));
}
}
// get recent forum posts
$c = new Criteria();
$c->add("forum_post.site_id", $site->getSiteId());
if ($category) {
$c->add("forum_post.category_id", $category->getCategoryId());
}
$c->addJoin("thread_id", "forum_thread.thread_id");
$c->addOrderDescending("post_id");
$c->setLimit($limit);
$posts = DB_ForumPostPeer::instance()->select($c);
$runData->contextAdd("posts", $posts);
}
示例3: build
public function build($runData)
{
$site = $runData->getTemp("site");
// now just get notifications for the site...
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$c->addOrderDescending('notification_id');
$c->setLimit(20);
$nots = DB_AdminNotificationPeer::instance()->select($c);
$channel['title'] = _('Admin notifications for site') . ' "' . htmlspecialchars($site->getName()) . '"';
$channel['link'] = "http://" . $site->getDomain() . "/admin:manage/start/notifications";
$items = array();
foreach ($nots as $not) {
$extra = $not->getExtra();
$item = array();
$item['title'] = $not->getTitle();
switch ($not->getType()) {
case "NEW_MEMBER_APPLICATION":
$item['link'] = "http://" . $site->getDomain() . "/admin:manage/start/ma";
break;
default:
$item['link'] = "http://" . $site->getDomain() . "/admin:manage/start/notifications" . "#notification-" . $not->getNotificationId();
}
$body = $not->getBody();
$body = preg_replace('/onclick="[^"]+"/', '', $body);
$item['description'] = $body;
$item['guid'] = $channel['link'] . "#notification-" . $not->getNotificationId();
$item['date'] = date('r', $not->getDate()->getTimestamp());
// TODO: replace relative links with absolute links!
$content = '';
$items[] = $item;
}
$runData->contextAdd("channel", $channel);
$runData->contextAdd("items", $items);
}
示例4: build
public function build($runData)
{
$pl = $runData->getParameterList();
$threadId = $pl->getParameterValue("threadId");
$site = $runData->getTemp("site");
$db = Database::connection();
$db->begin();
$thread = DB_ForumThreadPeer::instance()->selectByPrimaryKey($threadId);
if ($thread == null || $thread->getSiteId() !== $site->getSiteId()) {
throw new ProcessException(_("No thread found... Is it deleted?"), "no_thread");
}
$category = $thread->getForumCategory();
WDPermissionManager::instance()->hasForumPermission('moderate_forum', $runData->getUser(), $category);
$runData->contextAdd("thread", $thread);
$runData->contextAdd("category", $thread->getForumCategory());
// and select categories to move into too.
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$c->addOrderDescending("visible");
$c->addOrderAscending("sort_index");
$groups = DB_ForumGroupPeer::instance()->select($c);
$res = array();
foreach ($groups as $g) {
$c = new Criteria();
$c->add("group_id", $g->getGroupId());
$c->addOrderAscending("sort_index");
$categories = DB_ForumCategoryPeer::instance()->select($c);
foreach ($categories as $cat) {
$res[] = array('group' => $g, 'category' => $cat);
}
}
$runData->contextAdd("categories", $res);
$db->commit();
}
示例5: build
public function build($runData)
{
$userId = $runData->getUserId();
$pl = $runData->getParameterList();
$messageId = $pl->getParameterValue("message_id");
$message = DB_PrivateMessagePeer::instance()->selectByPrimaryKey($messageId);
if ($message->getFromUserId() != $userId) {
throw new ProcessException(_("Error selecting message."), "no_message");
}
$runData->contextAdd("message", $message);
// get next & previous message
$messageId = $message->getMessageId();
$c = new Criteria();
$c->add("from_user_id", $userId);
$c->add("message_id", $messageId, ">");
$c->add("flag", 1);
$c->addOrderAscending("message_id");
$newerMessage = DB_PrivateMessagePeer::instance()->selectOne($c);
$c = new Criteria();
$c->add("from_user_id", $userId);
$c->add("message_id", $messageId, "<");
$c->add("flag", 1);
$c->addOrderDescending("message_id");
$olderMessage = DB_PrivateMessagePeer::instance()->selectOne($c);
$runData->contextAdd("newerMessage", $newerMessage);
$runData->contextAdd("olderMessage", $olderMessage);
}
示例6: run
public function run()
{
// check!
$c = new Criteria();
$c->add("status", null);
$c->addOrderDescending("backup_id");
$sb = DB_SiteBackupPeer::instance()->selectOne($c);
// select only one!
if (!$sb) {
return;
}
$db = Database::connection();
$sb->setStatus("started");
$sb->save();
$db->begin();
try {
$b = new Backuper();
$b->setConfig($sb);
$b->backup();
// check
$sb->setStatus("completed");
$sb->setDate(new ODate());
$sb->setRand($b->getRand());
$sb->save();
} catch (Exception $e) {
$sb->setStatus("failed");
$sb->save();
}
$db->commit();
}
示例7: build
public function build($runData)
{
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
// get the petition campaign...
$campaignId = $pl->getParameterValue("id");
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$c->add("deleted", false);
$c->add("identifier", $campaignId);
$camp = DB_PetitionCampaignPeer::instance()->selectOne($c);
if (!$camp) {
throw new ProcessException(_("The campaign can not be found."));
}
// get signatures!
$limit = $pl->getParameterValue("limit");
if ($limit === null || !is_numeric($limit)) {
$limit = 50;
}
$c = new Criteria();
$c->add("campaign_id", $camp->getCampaignId());
$c->add("confirmed", true);
$c->addOrderDescending("signature_id");
if ($limit > 0) {
$c->setLimit($limit);
}
$signatures = DB_PetitionSignaturePeer::instance()->select($c);
$runData->contextAdd("signatures", $signatures);
$runData->contextAdd("campaign", $camp);
}
示例8: build
public function build($runData)
{
$site = $runData->getTemp("site");
$c = new Criteria();
$c->addJoin("page_id", "page.page_id");
$c->addJoin("user_id", "ozone_user.user_id");
$c->add("page.site_id", $site->getSiteId());
$c->addOrderDescending("page_revision.revision_id");
$c->setLimit(30);
$revisions = DB_PageRevisionPeer::instance()->select($c);
$channel['title'] = _('Recent page changes from site') . ' "' . htmlspecialchars($site->getName()) . '" (a Wikidot site)';
$channel['link'] = "http://" . $site->getDomain();
$items = array();
foreach ($revisions as $rev) {
$page = $rev->getPage();
$item = array();
$item['link'] = 'http://' . $site->getDomain() . '/' . $page->getUnixName();
$desc = '';
$flags = array();
if ($rev->getFlagText()) {
$flags[] = _("source change");
}
if ($rev->getFlagTitle()) {
$flags[] = _("title change");
}
if ($rev->getFlagFile()) {
$flags[] = _("file action");
}
if ($rev->getFlagRename()) {
$flags[] = _("page move/rename");
}
if ($rev->getFlagMeta()) {
$flags[] = _("metadata changed");
}
if ($rev->getFlagNew()) {
$flags[] = _("new page");
}
$item['title'] = '"' . $page->getTitleOrUnixName() . '" - ' . implode(', ', $flags);
$desc = '';
$desc .= _('Page') . ': <a href="http://' . $site->getDomain() . '/' . $page->getUnixName() . '">' . htmlspecialchars($page->getTitle()) . '</a> (' . $page->getUnixName() . ')<br/>';
$desc .= _('Current revision number') . ': ' . $rev->getRevisionNumber() . '<br/>';
$desc .= _('Date changed') . ': ' . date('r', $rev->getDateLastEdited()->getTimestamp()) . '<br/>';
$desc .= _('Change type') . ': ' . implode(', ', $flags) . '<br/>';
if ($rev->getComments()) {
$desc .= _('Change comments') . ': ' . htmlspecialchars($rev->getComments()) . '<br/>';
}
$desc .= _('By') . ': ' . WDRenderUtils::renderUser($rev->getUserOrString()) . '<br/>';
$desc .= '<br/>' . _('Page content preview') . ': <br/>' . $page->getPreview();
$item['description'] = $desc;
$item['content'] = $desc;
$item['guid'] = $item['link'] . "#revision-" . $rev->getRevisionId();
$item['date'] = date('r', $rev->getDateLastEdited()->getTimestamp());
$content = '';
$items[] = $item;
}
$runData->contextAdd("channel", $channel);
$runData->contextAdd("items", $items);
}
示例9: build
public function build($runData)
{
// find all current applications
$c = new Criteria();
$c->add("site_id", $runData->getTemp("site")->getSiteId());
$c->add("status", "pending");
$c->addOrderDescending("application_id");
$applications = DB_MemberApplicationPeer::instance()->select($c);
$runData->contextAdd("applications", $applications);
}
示例10: build
public function build($runData)
{
// get current blocks!
$c = new Criteria();
$c->add("user_id", $runData->getUserId());
$c->addOrderDescending("block_id");
$blocks = DB_PrivateUserBlockPeer::instance()->select($c);
if (count($blocks) > 0) {
$runData->contextAdd("blocks", $blocks);
}
}
示例11: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$categoryId = $pl->getParameterValue("c");
$channel = array();
$channel['title'] = $site->getName() . " - " . _("new forum threads");
$channel['link'] = "http://" . $site->getDomain() . "/forum/start";
$channel['description'] = _("Threads in forums of the site") . " \"" . $site->getName() . "\"";
if ($site->getSubtitle()) {
$channel['description'] .= " - " . $site->getSubtitle();
}
$items = array();
$c = new Criteria();
$c->add("forum_thread.site_id", $site->getSiteId());
$c->add("forum_group.visible", true);
$c->addJoin("user_id", "ozone_user.user_id");
$c->addJoin("forum_thread.category_id", "forum_category.category_id");
$c->addJoin("forum_category.group_id", "forum_group.group_id");
$c->addOrderDescending("thread_id");
$c->setLimit(20);
$threads = DB_ForumThreadPeer::instance()->select($c);
foreach ($threads as $thread) {
$item = array();
$item['title'] = $thread->getTitle();
$item['link'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle();
$item['guid'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId();
$item['date'] = date('r', $thread->getDateStarted()->getTimestamp());
//replace relative links with absolute links!
$post = $thread->getFirstPost();
if (!$post) {
continue;
}
$content = $post->getText();
$content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="http://' . $site->getDomain() . '/\\3"\\4', $content);
$content = preg_replace(';<script\\s+[^>]+>.*?</script>;is', '', $content);
$content = preg_replace(';(<[^>]*\\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
if ($thread->getDescription()) {
$item['description'] = $thread->getDescription();
}
$item['content'] = $content;
if ($post->getUserId() > 0) {
$item['authorUserId'] = $post->getUserId();
$user = $post->getUser();
$item['author'] = $user->getNickName();
} else {
$item['author'] = $post->getUserString();
}
$items[] = $item;
}
$runData->contextAdd("channel", $channel);
$runData->contextAdd("items", $items);
}
示例12: build
public function build($runData)
{
// just get invitations
$userId = $runData->getUserId();
$c = new Criteria();
$c->add("user_id", $userId);
$c->addOrderDescending("invitation_id");
$invs = DB_MemberInvitationPeer::instance()->select($c);
if (count($invs) > 0) {
$runData->contextAdd("invitations", $invs);
}
}
示例13: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$userId = $pl->getParameterValue("userId");
if ($runData->getUser() && $userId == $runData->getUser()->getUserId()) {
$own = true;
}
$categoryId = $pl->getParameterValue("categoryId");
$limit = $pl->getParameterValue("limit");
if ($limit == null || !is_numeric($limit)) {
$limit = 20;
}
$pageNumber = $pl->getParameterValue("page");
$op = $pl->getParameterValue("options");
if ($pageNumber === null) {
$pageNumber = 1;
}
$perPage = $limit;
$offset = ($pageNumber - 1) * $perPage;
$count = $perPage * 2 + 1;
$c = new Criteria();
if ($categoryId !== null && is_numeric($categoryId)) {
$c->add("forum_thread.category_id", $categoryId);
}
$c->add("forum_post.user_id", $userId);
if (!$own) {
$c->add("site.private", false);
}
$c->addJoin("thread_id", "forum_thread.thread_id");
$c->addJoin("user_id", "ozone_user.user_id");
$c->addJoin("forum_post.site_id", "site.site_id");
$c->add("site.deleted", false);
$c->addOrderDescending("post_id");
$c->setLimit($count, $offset);
$posts = DB_ForumPostPeer::instance()->select($c);
$counted = count($posts);
$pagerData = array();
$pagerData['currentPage'] = $pageNumber;
if ($counted > $perPage * 2) {
$knownPages = $pageNumber + 2;
$pagerData['knownPages'] = $knownPages;
} elseif ($counted > $perPage) {
$knownPages = $pageNumber + 1;
$pagerData['totalPages'] = $knownPages;
} else {
$totalPages = $pageNumber;
$pagerData['totalPages'] = $totalPages;
}
$posts = array_slice($posts, 0, $perPage);
$runData->contextAdd("pagerData", $pagerData);
$runData->contextAdd("posts", $posts);
}
示例14: build
public function build($runData)
{
// get current blocks!
$site = $runData->getTemp("site");
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$c->addOrderDescending("block_id");
$blocks = DB_IpBlockPeer::instance()->select($c);
if (count($blocks) > 0) {
$runData->contextAdd("blocks", $blocks);
}
}
示例15: build
public function build($runData)
{
$pageId = $runData->getParameterList()->getParameterValue("page_id");
if (!$pageId || !is_numeric($pageId)) {
throw new ProcessException(_("The page can not be found or does not exist."), "no_page");
}
$c = new Criteria();
$c->add('page_id', $pageId);
$c->addOrderDescending('revision_id');
$pageRevisions = DB_PageRevisionPeer::instance()->select($c);
$runData->contextAdd("pageRevisions", $pageRevisions);
}