[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/page/ -> AphrontPageView.php (source)

   1  <?php
   2  
   3  abstract class AphrontPageView extends AphrontView {
   4  
   5    private $title;
   6  
   7    public function setTitle($title) {
   8      $this->title = $title;
   9      return $this;
  10    }
  11  
  12    public function getTitle() {
  13      $title = $this->title;
  14      if (is_array($title)) {
  15        $title = implode(" \xC2\xB7 ", $title);
  16      }
  17      return $title;
  18    }
  19  
  20    protected function getHead() {
  21      return '';
  22    }
  23  
  24    protected function getBody() {
  25      return phutil_implode_html('', $this->renderChildren());
  26    }
  27  
  28    protected function getTail() {
  29      return '';
  30    }
  31  
  32    protected function willRenderPage() {
  33      return;
  34    }
  35  
  36    protected function willSendResponse($response) {
  37      return $response;
  38    }
  39  
  40    protected function getBodyClasses() {
  41      return null;
  42    }
  43  
  44    public function render() {
  45  
  46      $this->willRenderPage();
  47  
  48      $title = $this->getTitle();
  49      $head  = $this->getHead();
  50      $body  = $this->getBody();
  51      $tail  = $this->getTail();
  52  
  53      $body_classes = $this->getBodyClasses();
  54  
  55      $body = phutil_tag(
  56        'body',
  57        array(
  58          'class' => nonempty($body_classes, null),
  59        ),
  60        array($body, $tail));
  61  
  62      $response = hsprintf(
  63        '<!DOCTYPE html>'.
  64        '<html>'.
  65          '<head>'.
  66            '<meta charset="UTF-8" />'.
  67            '<title>%s</title>'.
  68            '%s'.
  69          '</head>'.
  70          '%s'.
  71        '</html>',
  72        $title,
  73        $head,
  74        $body);
  75  
  76      $response = $this->willSendResponse($response);
  77  
  78      return $response;
  79  
  80    }
  81  
  82  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1