[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/uiexample/examples/ -> PHUIFeedStoryExample.php (source)

   1  <?php
   2  
   3  final class PHUIFeedStoryExample extends PhabricatorUIExample {
   4  
   5    public function getName() {
   6      return 'Feed Story';
   7    }
   8  
   9    public function getDescription() {
  10      return 'An outlandish exaggeration of intricate tales from '.
  11        'around the realm';
  12    }
  13  
  14    public function renderExample() {
  15      $request = $this->getRequest();
  16      $user = $request->getUser();
  17  
  18      /* Basic Story */
  19      $text = hsprintf(
  20        '<strong><a>harding (Tom Harding)</a></strong> closed <a>'.
  21        'D12: New spacer classes for blog views</a>.');
  22      $story1 = id(new PHUIFeedStoryView())
  23        ->setTitle($text)
  24        ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
  25        ->setImageHref('http://en.wikipedia.org/wiki/Warren_G._Harding')
  26        ->setEpoch(1)
  27        ->setAppIcon('differential-dark')
  28        ->setUser($user);
  29  
  30      /* Text Story, useful in Blogs, Ponders, Status */
  31      $tokens = array(
  32        'like-1',
  33        'like-2',
  34        'heart-1',
  35        'heart-2',
  36      );
  37      $tokenview = array();
  38      foreach ($tokens as $token) {
  39        $tokenview[] =
  40          id(new PHUIIconView())
  41            ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS)
  42            ->setSpriteIcon($token);
  43      }
  44      $text = hsprintf('<strong><a>lincoln (Honest Abe)</a></strong> wrote a '.
  45        'new blog post.');
  46      $story2 = id(new PHUIFeedStoryView())
  47        ->setTitle($text)
  48        ->setImage(celerity_get_resource_uri('/rsrc/image/people/lincoln.png'))
  49        ->setImageHref('http://en.wikipedia.org/wiki/Abraham_Lincoln')
  50        ->setEpoch(strtotime('November 19, 1863'))
  51        ->setAppIcon('phame-dark')
  52        ->setUser($user)
  53        ->setTokenBar($tokenview)
  54        ->setPontification('Four score and seven years ago our fathers brought '.
  55          'forth on this continent, a new nation, conceived in Liberty, and '.
  56          'dedicated to the proposition that all men are created equal. '.
  57          'Now we are engaged in a great civil war, testing whether that '.
  58          'nation, or any nation so conceived and so dedicated, can long '.
  59          'endure. We are met on a great battle-field of that war. We have '.
  60          'come to dedicate a portion of that field, as a final resting '.
  61          'place for those who here gave their lives that that nation might '.
  62          'live. It is altogether fitting and proper that we should do this.',
  63          'Gettysburg Address');
  64  
  65      /* Action Story, let's give people tokens! */
  66  
  67      $text = hsprintf('<strong><a>harding (Tom Harding)</a></strong> awarded '.
  68        '<a>M10: Workboards</a> a token.');
  69      $action1 = id(new PHUIIconView())
  70        ->setIconFont('fa-trophy bluegrey')
  71        ->setHref('#');
  72      $token =
  73          id(new PHUIIconView())
  74            ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS)
  75            ->setSpriteIcon('like-1');
  76      $story3 = id(new PHUIFeedStoryView())
  77        ->setTitle($text)
  78        ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
  79        ->setImageHref('http://en.wikipedia.org/wiki/Warren_G._Harding')
  80        ->appendChild($token)
  81        ->setEpoch(1)
  82        ->addAction($action1)
  83        ->setAppIcon('token-dark')
  84        ->setUser($user);
  85  
  86      /* Image Story, used in Pholio, Macro */
  87      $text = hsprintf('<strong><a>wgharding (Warren Harding)</a></strong> '.
  88        'asked a new question.');
  89      $action1 = id(new PHUIIconView())
  90        ->setIconFont('fa-chevron-up bluegrey')
  91        ->setHref('#');
  92      $action2 = id(new PHUIIconView())
  93        ->setIconFont('fa-chevron-down bluegrey')
  94        ->setHref('#');
  95      $story4 = id(new PHUIFeedStoryView())
  96        ->setTitle($text)
  97        ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
  98        ->setImageHref('http://en.wikipedia.org/wiki/Warren_G._Harding')
  99        ->setEpoch(1)
 100        ->setAppIcon('ponder-dark')
 101        ->setPontification('Why does inline-block add space under my spans and '.
 102          'anchors?')
 103        ->addAction($action1)
 104        ->addAction($action2)
 105        ->setUser($user);
 106  
 107      /* Text Story, useful in Blogs, Ponders, Status */
 108      $text = hsprintf('<strong><a>lincoln (Honest Abe)</a></strong> updated '.
 109        'his status.');
 110      $story5 = id(new PHUIFeedStoryView())
 111        ->setTitle($text)
 112        ->setImage(celerity_get_resource_uri('/rsrc/image/people/lincoln.png'))
 113        ->setImageHref('http://en.wikipedia.org/wiki/Abraham_Lincoln')
 114        ->setEpoch(strtotime('November 19, 1863'))
 115        ->setAppIcon('phame-dark')
 116        ->setUser($user)
 117        ->setPontification('If we ever create a lightweight status app '.
 118        'this story would be how that would be displayed.');
 119  
 120      /* Basic "One Line" Story */
 121      $text = hsprintf(
 122        '<strong><a>harding (Tom Harding)</a></strong> updated <a>'.
 123        'D12: New spacer classes for blog views</a>.');
 124      $story6 = id(new PHUIFeedStoryView())
 125        ->setTitle($text)
 126        ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
 127        ->setImageHref('http://en.wikipedia.org/wiki/Warren_G._Harding')
 128        ->setEpoch(1)
 129        ->setAppIcon('differential-dark')
 130        ->setUser($user);
 131  
 132  
 133      $head1 = id(new PHUIHeaderView())
 134        ->setHeader(pht('Basic Story'));
 135  
 136      $head2 = id(new PHUIHeaderView())
 137        ->setHeader(pht('Title / Text Story'));
 138  
 139      $head3 = id(new PHUIHeaderView())
 140        ->setHeader(pht('Token Story'));
 141  
 142      $head4 = id(new PHUIHeaderView())
 143        ->setHeader(pht('Action Story'));
 144  
 145      $head5 = id(new PHUIHeaderView())
 146        ->setHeader(pht('Status Story'));
 147  
 148      $head6 = id(new PHUIHeaderView())
 149        ->setHeader(pht('One Line Story'));
 150  
 151      $wrap1 =
 152        array(
 153          id(new PHUIBoxView())
 154            ->appendChild($story1)
 155            ->addMargin(PHUI::MARGIN_MEDIUM)
 156            ->addPadding(PHUI::PADDING_SMALL),
 157        );
 158  
 159      $wrap2 =
 160        array(
 161          id(new PHUIBoxView())
 162            ->appendChild($story2)
 163            ->addMargin(PHUI::MARGIN_MEDIUM)
 164            ->addPadding(PHUI::PADDING_SMALL),
 165        );
 166  
 167      $wrap3 =
 168        array(
 169          id(new PHUIBoxView())
 170            ->appendChild($story3)
 171            ->addMargin(PHUI::MARGIN_MEDIUM)
 172            ->addPadding(PHUI::PADDING_SMALL),
 173        );
 174  
 175      $wrap4 =
 176        array(
 177          id(new PHUIBoxView())
 178            ->appendChild($story4)
 179            ->addMargin(PHUI::MARGIN_MEDIUM)
 180            ->addPadding(PHUI::PADDING_SMALL),
 181        );
 182  
 183      $wrap5 =
 184        array(
 185          id(new PHUIBoxView())
 186            ->appendChild($story5)
 187            ->addMargin(PHUI::MARGIN_MEDIUM)
 188            ->addPadding(PHUI::PADDING_SMALL),
 189        );
 190  
 191      $wrap6 =
 192        array(
 193          id(new PHUIBoxView())
 194            ->appendChild($story6)
 195            ->addMargin(PHUI::MARGIN_MEDIUM)
 196            ->addPadding(PHUI::PADDING_SMALL),
 197        );
 198  
 199      return phutil_tag(
 200        'div',
 201          array(),
 202          array(
 203            $head1,
 204            $wrap1,
 205            $head2,
 206            $wrap2,
 207            $head3,
 208            $wrap3,
 209            $head4,
 210            $wrap4,
 211            $head5,
 212            $wrap5,
 213            $head6,
 214            $wrap6,
 215          ));
 216    }
 217  }


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