2012-05-10 00:56:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class AphrontMoreView extends AphrontView {
|
|
|
|
|
|
|
|
private $some;
|
|
|
|
private $more;
|
2012-09-13 17:13:03 +02:00
|
|
|
private $expandtext;
|
2012-05-10 00:56:37 +02:00
|
|
|
|
|
|
|
public function setSome($some) {
|
|
|
|
$this->some = $some;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMore($more) {
|
|
|
|
$this->more = $more;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-09-13 17:13:03 +02:00
|
|
|
public function setExpandText($text) {
|
|
|
|
$this->expandtext = $text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-05-10 00:56:37 +02:00
|
|
|
public function render() {
|
|
|
|
|
2013-01-31 18:08:02 +01:00
|
|
|
$content = array();
|
|
|
|
$content[] = $this->some;
|
2012-09-13 17:13:03 +02:00
|
|
|
|
2012-05-10 00:56:37 +02:00
|
|
|
if ($this->more && $this->more != $this->some) {
|
2015-05-22 09:27:56 +02:00
|
|
|
$text = "(".pht('Show More')."\xE2\x80\xA6)";
|
2013-01-31 18:08:02 +01:00
|
|
|
if ($this->expandtext !== null) {
|
|
|
|
$text = $this->expandtext;
|
|
|
|
}
|
|
|
|
|
2012-05-10 00:56:37 +02:00
|
|
|
Javelin::initBehavior('aphront-more');
|
2013-01-31 18:08:02 +01:00
|
|
|
$content[] = ' ';
|
|
|
|
$content[] = javelin_tag(
|
2012-05-10 00:56:37 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'sigil' => 'aphront-more-view-show-more',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'href' => '#',
|
|
|
|
'meta' => array(
|
|
|
|
'more' => $this->more,
|
|
|
|
),
|
|
|
|
),
|
2012-09-13 17:13:03 +02:00
|
|
|
$text);
|
2012-05-10 00:56:37 +02:00
|
|
|
}
|
|
|
|
|
2013-01-31 18:08:02 +01:00
|
|
|
return javelin_tag(
|
2012-05-10 00:56:37 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'sigil' => 'aphront-more-view',
|
|
|
|
),
|
2013-01-31 18:08:02 +01:00
|
|
|
$content);
|
2012-05-10 00:56:37 +02:00
|
|
|
}
|
|
|
|
}
|