mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Separate out PhameDescriptionView
Summary: Make this function re-usable in other views. Ref T9897 Test Plan: View a blog, see the same information Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9897 Differential Revision: https://secure.phabricator.com/D14658
This commit is contained in:
parent
905d0f43b1
commit
7ce2ad294f
3 changed files with 74 additions and 46 deletions
|
@ -3319,6 +3319,7 @@ phutil_register_library_map(array(
|
||||||
'PhameController' => 'applications/phame/controller/PhameController.php',
|
'PhameController' => 'applications/phame/controller/PhameController.php',
|
||||||
'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php',
|
'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php',
|
||||||
'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
|
'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
|
||||||
|
'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php',
|
||||||
'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php',
|
'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php',
|
||||||
'PhamePost' => 'applications/phame/storage/PhamePost.php',
|
'PhamePost' => 'applications/phame/storage/PhamePost.php',
|
||||||
'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php',
|
'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php',
|
||||||
|
@ -7649,6 +7650,7 @@ phutil_register_library_map(array(
|
||||||
'PhameController' => 'PhabricatorController',
|
'PhameController' => 'PhabricatorController',
|
||||||
'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod',
|
'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod',
|
||||||
'PhameDAO' => 'PhabricatorLiskDAO',
|
'PhameDAO' => 'PhabricatorLiskDAO',
|
||||||
|
'PhameDescriptionView' => 'AphrontTagView',
|
||||||
'PhameHomeController' => 'PhamePostController',
|
'PhameHomeController' => 'PhamePostController',
|
||||||
'PhamePost' => array(
|
'PhamePost' => array(
|
||||||
'PhameDAO',
|
'PhameDAO',
|
||||||
|
|
|
@ -73,24 +73,7 @@ final class PhameBlogViewController extends PhameBlogController {
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->appendChild($post_list);
|
->appendChild($post_list);
|
||||||
|
|
||||||
$description = $this->renderDescription($blog, $viewer);
|
$description = null;
|
||||||
|
|
||||||
return $this->newPage()
|
|
||||||
->setTitle($blog->getName())
|
|
||||||
->setCrumbs($crumbs)
|
|
||||||
->appendChild(
|
|
||||||
array(
|
|
||||||
$page,
|
|
||||||
$description,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function renderDescription(
|
|
||||||
PhameBlog $blog,
|
|
||||||
PhabricatorUser $viewer) {
|
|
||||||
|
|
||||||
require_celerity_resource('phame-css');
|
|
||||||
|
|
||||||
if (strlen($blog->getDescription())) {
|
if (strlen($blog->getDescription())) {
|
||||||
$description = PhabricatorMarkupEngine::renderOneObject(
|
$description = PhabricatorMarkupEngine::renderOneObject(
|
||||||
id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()),
|
id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()),
|
||||||
|
@ -100,36 +83,19 @@ final class PhameBlogViewController extends PhameBlogController {
|
||||||
$description = phutil_tag('em', array(), pht('No description.'));
|
$description = phutil_tag('em', array(), pht('No description.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$picture = $blog->getProfileImageURI();
|
$about = id(new PhameDescriptionView())
|
||||||
$description = phutil_tag_div(
|
->setTitle($blog->getName())
|
||||||
'phame-blog-description-content', $description);
|
->setDescription($description)
|
||||||
|
->setImage($blog->getProfileImageURI());
|
||||||
|
|
||||||
$image = phutil_tag(
|
return $this->newPage()
|
||||||
'div',
|
->setTitle($blog->getName())
|
||||||
array(
|
->setCrumbs($crumbs)
|
||||||
'class' => 'phame-blog-description-image',
|
->appendChild(
|
||||||
'style' => 'background-image: url('.$picture.');',
|
array(
|
||||||
|
$page,
|
||||||
|
$about,
|
||||||
));
|
));
|
||||||
|
|
||||||
$header = phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'phame-blog-description-name',
|
|
||||||
),
|
|
||||||
pht('About %s', $blog->getName()));
|
|
||||||
|
|
||||||
$view = phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'phame-blog-description',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
$image,
|
|
||||||
$header,
|
|
||||||
$description,
|
|
||||||
));
|
|
||||||
|
|
||||||
return $view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) {
|
private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) {
|
||||||
|
|
60
src/applications/phame/view/PhameDescriptionView.php
Normal file
60
src/applications/phame/view/PhameDescriptionView.php
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhameDescriptionView extends AphrontTagView {
|
||||||
|
|
||||||
|
private $title;
|
||||||
|
private $description;
|
||||||
|
private $image;
|
||||||
|
private $imageHref;
|
||||||
|
|
||||||
|
public function setTitle($title) {
|
||||||
|
$this->title = $title;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription($description) {
|
||||||
|
$this->description = $description;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setImage($image) {
|
||||||
|
$this->image = $image;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setImageHref($href) {
|
||||||
|
$this->imageHref = $href;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTagAttributes() {
|
||||||
|
$classes = array();
|
||||||
|
$classes[] = 'phame-blog-description';
|
||||||
|
return array('class' => implode(' ', $classes));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTagContent() {
|
||||||
|
require_celerity_resource('phame-css');
|
||||||
|
|
||||||
|
$description = phutil_tag_div(
|
||||||
|
'phame-blog-description-content', $this->description);
|
||||||
|
|
||||||
|
$image = phutil_tag(
|
||||||
|
($this->imageHref) ? 'a' : 'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phame-blog-description-image',
|
||||||
|
'style' => 'background-image: url('.$this->image.');',
|
||||||
|
'href' => $this->imageHref,
|
||||||
|
));
|
||||||
|
|
||||||
|
$header = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phame-blog-description-name',
|
||||||
|
),
|
||||||
|
pht('About %s', $this->title));
|
||||||
|
|
||||||
|
return array($image, $header, $description);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue