[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/ponder/view/ -> PonderVotableView.php (source)

   1  <?php
   2  
   3  final class PonderVotableView extends AphrontView {
   4  
   5    private $phid;
   6    private $uri;
   7    private $count;
   8    private $vote;
   9  
  10    public function setPHID($phid) {
  11      $this->phid = $phid;
  12      return $this;
  13    }
  14  
  15    public function setURI($uri) {
  16      $this->uri = $uri;
  17      return $this;
  18    }
  19  
  20    public function setCount($count) {
  21      $this->count = $count;
  22      return $this;
  23    }
  24  
  25    public function setVote($vote) {
  26      $this->vote = $vote;
  27      return $this;
  28    }
  29  
  30    public function render() {
  31      require_celerity_resource('ponder-vote-css');
  32      require_celerity_resource('javelin-behavior-ponder-votebox');
  33  
  34      Javelin::initBehavior('ponder-votebox', array());
  35  
  36      $uri = id(new PhutilURI($this->uri))->alter('phid', $this->phid);
  37  
  38      $up = javelin_tag(
  39        'a',
  40        array(
  41          'href'        => (string)$uri,
  42          'sigil'       => 'upvote',
  43          'mustcapture' => true,
  44          'class'       => ($this->vote > 0) ? 'ponder-vote-active' : null,
  45        ),
  46        "\xE2\x96\xB2");
  47  
  48      $down = javelin_tag(
  49        'a',
  50        array(
  51          'href'        => (string)$uri,
  52          'sigil'       => 'downvote',
  53          'mustcapture' => true,
  54          'class'       => ($this->vote < 0) ? 'ponder-vote-active' : null,
  55        ),
  56        "\xE2\x96\xBC");
  57  
  58      $count = javelin_tag(
  59        'div',
  60        array(
  61          'class'       => 'ponder-vote-count',
  62          'sigil'       => 'ponder-vote-count',
  63        ),
  64        $this->count);
  65  
  66      return javelin_tag(
  67        'div',
  68        array(
  69          'class' => 'ponder-votable',
  70          'sigil' => 'ponder-votable',
  71          'meta' => array(
  72            'count' => (int)$this->count,
  73            'vote'  => (int)$this->vote,
  74          ),
  75        ),
  76        array(
  77          javelin_tag(
  78            'div',
  79            array(
  80              'class' => 'ponder-votebox',
  81            ),
  82            array($up, $count, $down)),
  83          phutil_tag(
  84            'div',
  85            array(
  86              'class' => 'ponder-votebox-content',
  87            ),
  88            $this->renderChildren()),
  89        ));
  90    }
  91  
  92  }


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