1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 09:22:40 +01:00
phorge-phorge/src/view/layout/AphrontPanelView.php
Chad Little e2e890672a Adds a new 'setnobackground' panel class, implements in Differential / Diffusion.
Summary: Still working through basic re-design. Adds the ability to re-use panel view without the background.

Test Plan: Viewed Diffusion and Differential in Chrome, FF, Safari.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4430
2013-01-14 16:40:04 -08:00

110 lines
2.2 KiB
PHP

<?php
final class AphrontPanelView extends AphrontView {
const WIDTH_FULL = 'full';
const WIDTH_FORM = 'form';
const WIDTH_WIDE = 'wide';
private $buttons = array();
private $header;
private $caption;
private $width;
private $classes = array();
private $id;
public function setCreateButton($create_button, $href) {
$this->addButton(
phutil_render_tag(
'a',
array(
'href' => $href,
'class' => 'button green',
),
$create_button));
return $this;
}
public function addClass($class) {
$this->classes[] = $class;
return $this;
}
public function addButton($button) {
$this->buttons[] = $button;
return $this;
}
public function setHeader($header) {
$this->header = $header;
return $this;
}
public function setWidth($width) {
$this->width = $width;
return $this;
}
public function setID($id) {
$this->id = $id;
return $this;
}
public function setCaption($caption) {
$this->caption = $caption;
return $this;
}
public function setNoBackground() {
$this->classes[] = 'aphront-panel-plain';
return $this;
}
public function render() {
if ($this->header !== null) {
$header = '<h1>'.$this->header.'</h1>';
} else {
$header = null;
}
if ($this->caption !== null) {
$caption =
'<div class="aphront-panel-view-caption">'.
$this->caption.
'</div>';
} else {
$caption = null;
}
$buttons = null;
if ($this->buttons) {
$buttons =
'<div class="aphront-panel-view-buttons">'.
implode(" ", $this->buttons).
'</div>';
}
$header_elements =
'<div class="aphront-panel-header">'.
$buttons.$header.$caption.
'</div>';
$table = $this->renderChildren();
require_celerity_resource('aphront-panel-view-css');
$classes = $this->classes;
$classes[] = 'aphront-panel-view';
if ($this->width) {
$classes[] = 'aphront-panel-width-'.$this->width;
}
return phutil_render_tag(
'div',
array(
'class' => implode(' ', $classes),
'id' => $this->id,
),
$header_elements.$table);
}
}