[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PHUIDocumentView extends AphrontTagView { 4 5 /* For mobile displays, where do you want the sidebar */ 6 const NAV_BOTTOM = 'nav_bottom'; 7 const NAV_TOP = 'nav_top'; 8 const FONT_SOURCE_SANS = 'source-sans'; 9 10 private $offset; 11 private $header; 12 private $sidenav; 13 private $topnav; 14 private $crumbs; 15 private $bookname; 16 private $bookdescription; 17 private $mobileview; 18 private $fontKit; 19 20 public function setOffset($offset) { 21 $this->offset = $offset; 22 return $this; 23 } 24 25 public function setHeader(PHUIHeaderView $header) { 26 $header->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTBLUE); 27 $this->header = $header; 28 return $this; 29 } 30 31 public function setSideNav(PHUIListView $list, $display = self::NAV_BOTTOM) { 32 $list->setType(PHUIListView::SIDENAV_LIST); 33 $this->sidenav = $list; 34 $this->mobileview = $display; 35 return $this; 36 } 37 38 public function setTopNav(PHUIListView $list) { 39 $list->setType(PHUIListView::NAVBAR_LIST); 40 $this->topnav = $list; 41 return $this; 42 } 43 44 public function setCrumbs(PHUIListView $list) { 45 $this->crumbs = $list; 46 return $this; 47 } 48 49 public function setBook($name, $description) { 50 $this->bookname = $name; 51 $this->bookdescription = $description; 52 return $this; 53 } 54 55 public function setFontKit($kit) { 56 $this->fontKit = $kit; 57 return $this; 58 } 59 60 public function getTagAttributes() { 61 $classes = array(); 62 63 if ($this->offset) { 64 $classes[] = 'phui-document-offset'; 65 }; 66 67 return array( 68 'class' => $classes, 69 ); 70 } 71 72 public function getTagContent() { 73 require_celerity_resource('phui-document-view-css'); 74 if ($this->fontKit) { 75 require_celerity_resource('phui-fontkit-css'); 76 } 77 78 switch ($this->fontKit) { 79 case self::FONT_SOURCE_SANS: 80 require_celerity_resource('font-source-sans-pro'); 81 break; 82 } 83 84 $classes = array(); 85 $classes[] = 'phui-document-view'; 86 if ($this->offset) { 87 $classes[] = 'phui-offset-view'; 88 } 89 if ($this->sidenav) { 90 $classes[] = 'phui-sidenav-view'; 91 } 92 93 $sidenav = null; 94 if ($this->sidenav) { 95 $sidenav = phutil_tag( 96 'div', 97 array( 98 'class' => 'phui-document-sidenav', 99 ), 100 $this->sidenav); 101 } 102 103 $book = null; 104 if ($this->bookname) { 105 $book = phutil_tag( 106 'div', 107 array( 108 'class' => 'phui-document-bookname grouped', 109 ), 110 array( 111 phutil_tag( 112 'span', 113 array('class' => 'bookname'), 114 $this->bookname), 115 phutil_tag( 116 'span', 117 array('class' => 'bookdescription'), 118 $this->bookdescription), 119 )); 120 } 121 122 $topnav = null; 123 if ($this->topnav) { 124 $topnav = phutil_tag( 125 'div', 126 array( 127 'class' => 'phui-document-topnav', 128 ), 129 $this->topnav); 130 } 131 132 $crumbs = null; 133 if ($this->crumbs) { 134 $crumbs = phutil_tag( 135 'div', 136 array( 137 'class' => 'phui-document-crumbs', 138 ), 139 $this->bookName); 140 } 141 142 if ($this->fontKit) { 143 $main_content = phutil_tag( 144 'div', 145 array( 146 'class' => 'phui-font-'.$this->fontKit, 147 ), 148 $this->renderChildren()); 149 } else { 150 $main_content = $this->renderChildren(); 151 } 152 153 $content_inner = phutil_tag( 154 'div', 155 array( 156 'class' => 'phui-document-inner', 157 ), 158 array( 159 $book, 160 $this->header, 161 $topnav, 162 $main_content, 163 $crumbs, 164 )); 165 166 if ($this->mobileview == self::NAV_BOTTOM) { 167 $order = array($content_inner, $sidenav); 168 } else { 169 $order = array($sidenav, $content_inner); 170 } 171 172 $content = phutil_tag( 173 'div', 174 array( 175 'class' => 'phui-document-content', 176 ), 177 $order); 178 179 $view = phutil_tag( 180 'div', 181 array( 182 'class' => implode(' ', $classes), 183 ), 184 $content); 185 186 return $view; 187 } 188 189 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |