slug = $data['slug'];
}
public function processRequest() {
$request = $this->getRequest();
$slug = PhrictionDocument::normalizeSlug($this->slug);
if ($slug != $this->slug) {
$uri = PhrictionDocument::getSlugURI($slug);
// Canonicalize pages to their one true URI.
return id(new AphrontRedirectResponse())->setURI($uri);
}
require_celerity_resource('phriction-document-css');
$document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$slug);
if (!$document) {
$create_uri = '/phriction/edit/?slug='.$slug;
$page_content =
'
'.
'No content here!
'.
'No document found at '.phutil_escape_html($slug).'. '.
'You can '.
phutil_render_tag(
'a',
array(
'href' => $create_uri,
),
'create a new document').'.'.
'
';
$page_title = 'Page Not Found';
$button = phutil_render_tag(
'a',
array(
'href' => $create_uri,
'class' => 'green button',
),
'Create Page');
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
$page_title = $content->getTitle();
$phids = array($content->getAuthorPHID());
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$age = time() - $content->getDateCreated();
$age = floor($age / (60 * 60 * 24));
if ($age < 1) {
$when = 'today';
} else if ($age == 1) {
$when = 'yesterday';
} else {
$when = "{$age} days ago";
}
$byline =
''.
"Last updated {$when} by ".
$handles[$content->getAuthorPHID()]->renderLink().'.'.
'
';
$engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine();
$page_content =
''.
$byline.
''.
'
';
$button = phutil_render_tag(
'a',
array(
'href' => '/phriction/edit/'.$document->getID().'/',
'class' => 'button',
),
'Edit Page');
}
$page =
''.
$page_content;
return $this->buildStandardPageResponse(
$page,
array(
'title' => 'Phriction - '.$page_title,
'history' => PhrictionDocument::getSlugURI($slug, 'history'),
));
}
}