3 final class AphrontMultiColumnView
extends AphrontView
{
5 const GUTTER_SMALL
= 'msr';
6 const GUTTER_MEDIUM
= 'mmr';
7 const GUTTER_LARGE
= 'mlr';
10 private $columns = array();
11 private $fluidLayout = false;
12 private $fluidishLayout = false;
16 public function setID($id) {
21 public function getID() {
25 public function addColumn(
30 $this->columns
[] = array(
34 'metadata' => $metadata,
39 public function setFluidlayout($layout) {
40 $this->fluidLayout
= $layout;
44 public function setFluidishLayout($layout) {
45 $this->fluidLayout
= true;
46 $this->fluidishLayout
= $layout;
50 public function setGutter($gutter) {
51 $this->gutter
= $gutter;
55 public function setBorder($border) {
56 $this->border
= $border;
60 public function render() {
61 require_celerity_resource('aphront-multi-column-view-css');
64 $classes[] = 'aphront-multi-column-inner';
65 $classes[] = 'grouped';
67 if ($this->fluidishLayout ||
$this->fluidLayout
) {
68 // we only support seven columns for now for fluid views; see T4054
69 if (count($this->columns
) > 7) {
70 throw new Exception(pht('No more than 7 columns per view.'));
74 $classes[] = 'aphront-multi-column-'.count($this->columns
).'-up';
78 foreach ($this->columns
as $column_data) {
79 $column_class = array('aphront-multi-column-column');
81 $column_class[] = $this->gutter
;
83 $outer_class = array('aphront-multi-column-column-outer');
84 if (++
$i === count($this->columns
)) {
85 $column_class[] = 'aphront-multi-column-column-last';
86 $outer_class[] = 'aphront-multi-colum-column-outer-last';
88 $column = $column_data['column'];
89 if ($column_data['class']) {
90 $outer_class[] = $column_data['class'];
92 $column_sigil = idx($column_data, 'sigil');
93 $column_metadata = idx($column_data, 'metadata');
94 $column_inner = javelin_tag(
97 'class' => implode(' ', $column_class),
98 'sigil' => $column_sigil,
99 'meta' => $column_metadata,
102 $columns[] = phutil_tag(
105 'class' => implode(' ', $outer_class),
113 'class' => implode(' ', $classes),
120 $classes[] = 'aphront-multi-column-outer';
121 if ($this->fluidLayout
) {
122 $classes[] = 'aphront-multi-column-fluid';
123 if ($this->fluidishLayout
) {
124 $classes[] = 'aphront-multi-column-fluidish';
127 $classes[] = 'aphront-multi-column-fixed';
133 'class' => implode(' ', $classes),
138 $board = id(new PHUIBoxView())
140 ->appendChild($board)
141 ->addPadding(PHUI
::PADDING_MEDIUM_TOP
)
142 ->addPadding(PHUI
::PADDING_MEDIUM_BOTTOM
);
148 'class' => 'aphront-multi-column-view',
149 'id' => $this->getID(),
150 // TODO: It would be nice to convert this to an AphrontTagView and
151 // use addSigil() from Workboards instead of hard-coding this.
152 'sigil' => 'aphront-multi-column-view',