From bd70693d8443398e36c39bbb799422e91958176d Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 17 Dec 2012 14:48:47 -0800 Subject: [PATCH] tweak pager and title in basic => template skin Summary: its a bit confusing but "newer" posts are the "previous" page and "older" posts are the "next" page. this is because newer posts are those with higher ids. also make the title be the title of the post if we have an actual post. Test Plan: set page limit to 5 and got somewhat sensical results (note this pagination seems to break with my test data set where there's fun gaps in the contiguity of the ids in a given blog) viewed an actual post and noted the page title was the post title Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4222 --- .../phame/skins/PhameBasicBlogSkin.php | 17 ++++++++++++++--- .../phame/skins/PhameBasicTemplateBlogSkin.php | 16 ++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/applications/phame/skins/PhameBasicBlogSkin.php b/src/applications/phame/skins/PhameBasicBlogSkin.php index addf25eedd..420a52ae85 100644 --- a/src/applications/phame/skins/PhameBasicBlogSkin.php +++ b/src/applications/phame/skins/PhameBasicBlogSkin.php @@ -8,6 +8,15 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { private $pager; + private $title; + + protected function setTitle($title) { + $this->title = $title; + return $this; + } + protected function getTitle() { + return $this->title; + } public function processRequest() { $request = $this->getRequest(); @@ -145,7 +154,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { */ protected function getNewerPageURI() { if ($this->pager) { - $next = $this->pager->getNextPageID(); + $next = $this->pager->getPrevPageID(); if ($next) { return $this->getURI('newer/'.$next.'/'); } @@ -183,6 +192,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { $matches = null; $path = $request->getPath(); + $this->setTitle($this->getBlog()->getName()); if (preg_match('@^/post/(?P.*)$@', $path, $matches)) { $post = id(new PhamePostQuery()) ->setViewer($user) @@ -191,6 +201,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { ->executeOne(); if ($post) { + $this->setTitle($post->getTitle()); $view = head($this->buildPostViews(array($post))); return $this->renderPostDetail($view); } @@ -198,9 +209,9 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { $pager = new AphrontCursorPagerView(); if (preg_match('@^/older/(?P\d+)/$@', $path, $matches)) { - $pager->setBeforeID($matches['before']); + $pager->setAfterID($matches['before']); } else if (preg_match('@^/newer/(?P\d)/$@', $path, $matches)) { - $pager->setAfterID($matches['after']); + $pager->setBeforeID($matches['after']); } else if (preg_match('@^/$@', $path, $matches)) { // Just show the first page. } else { diff --git a/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php b/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php index 28ae0e99ea..23f94f71d0 100644 --- a/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php +++ b/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php @@ -80,18 +80,18 @@ final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin { private function getDefaultScope() { return array( - 'skin' => $this, - 'blog' => $this->getBlog(), - 'uri' => $this->getURI(''), + 'skin' => $this, + 'blog' => $this->getBlog(), + 'uri' => $this->getURI(''), + 'title' => $this->getTitle(), ); } protected function renderHeader() { return $this->renderTemplate( 'header.php', - array( - 'title' => $this->getBlog()->getName(), - )); + array() + ); } protected function renderFooter() { @@ -115,8 +115,8 @@ final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin { 'post-list.php', array( 'posts' => $posts, - 'older' => $this->renderNewerPageLink(), - 'newer' => $this->renderOlderPageLink(), + 'older' => $this->renderOlderPageLink(), + 'newer' => $this->renderNewerPageLink(), )); }