mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20: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',
|
||||
'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php',
|
||||
'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
|
||||
'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php',
|
||||
'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php',
|
||||
'PhamePost' => 'applications/phame/storage/PhamePost.php',
|
||||
'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php',
|
||||
|
@ -7649,6 +7650,7 @@ phutil_register_library_map(array(
|
|||
'PhameController' => 'PhabricatorController',
|
||||
'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod',
|
||||
'PhameDAO' => 'PhabricatorLiskDAO',
|
||||
'PhameDescriptionView' => 'AphrontTagView',
|
||||
'PhameHomeController' => 'PhamePostController',
|
||||
'PhamePost' => array(
|
||||
'PhameDAO',
|
||||
|
|
|
@ -73,24 +73,7 @@ final class PhameBlogViewController extends PhameBlogController {
|
|||
->setHeader($header)
|
||||
->appendChild($post_list);
|
||||
|
||||
$description = $this->renderDescription($blog, $viewer);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($blog->getName())
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$page,
|
||||
$description,
|
||||
));
|
||||
}
|
||||
|
||||
private function renderDescription(
|
||||
PhameBlog $blog,
|
||||
PhabricatorUser $viewer) {
|
||||
|
||||
require_celerity_resource('phame-css');
|
||||
|
||||
$description = null;
|
||||
if (strlen($blog->getDescription())) {
|
||||
$description = PhabricatorMarkupEngine::renderOneObject(
|
||||
id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()),
|
||||
|
@ -100,36 +83,19 @@ final class PhameBlogViewController extends PhameBlogController {
|
|||
$description = phutil_tag('em', array(), pht('No description.'));
|
||||
}
|
||||
|
||||
$picture = $blog->getProfileImageURI();
|
||||
$description = phutil_tag_div(
|
||||
'phame-blog-description-content', $description);
|
||||
$about = id(new PhameDescriptionView())
|
||||
->setTitle($blog->getName())
|
||||
->setDescription($description)
|
||||
->setImage($blog->getProfileImageURI());
|
||||
|
||||
$image = phutil_tag(
|
||||
'div',
|
||||
return $this->newPage()
|
||||
->setTitle($blog->getName())
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
'class' => 'phame-blog-description-image',
|
||||
'style' => 'background-image: url('.$picture.');',
|
||||
$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) {
|
||||
|
|
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