[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin { 4 5 private $cssResources; 6 7 public function processRequest() { 8 $root = dirname(phutil_get_library_root('phabricator')); 9 require_once $root.'/support/phame/libskin.php'; 10 11 $this->cssResources = array(); 12 $css = $this->getPath('css/'); 13 14 if (Filesystem::pathExists($css)) { 15 foreach (Filesystem::listDirectory($css) as $path) { 16 if (!preg_match('/.css$/', $path)) { 17 continue; 18 } 19 $this->cssResources[] = phutil_tag( 20 'link', 21 array( 22 'rel' => 'stylesheet', 23 'type' => 'text/css', 24 'href' => $this->getResourceURI('css/'.$path), 25 )); 26 } 27 } 28 29 $map = CelerityResourceMap::getNamedInstance('phabricator'); 30 $resource_symbol = 'syntax-highlighting-css'; 31 $resource_uri = $map->getURIForSymbol($resource_symbol); 32 33 $this->cssResources[] = phutil_tag( 34 'link', 35 array( 36 'rel' => 'stylesheet', 37 'type' => 'text/css', 38 'href' => PhabricatorEnv::getCDNURI($resource_uri), 39 )); 40 41 $this->cssResources = phutil_implode_html("\n", $this->cssResources); 42 43 $request = $this->getRequest(); 44 45 // Render page parts in order so the templates execute in order, if we're 46 // using templates. 47 $header = $this->renderHeader(); 48 $content = $this->renderContent($request); 49 $footer = $this->renderFooter(); 50 51 if (!$content) { 52 $content = $this->render404Page(); 53 } 54 55 $content = array( 56 $header, 57 $content, 58 $footer, 59 ); 60 61 $response = new AphrontWebpageResponse(); 62 $response->setContent(phutil_implode_html("\n", $content)); 63 64 return $response; 65 } 66 67 public function getCSSResources() { 68 return $this->cssResources; 69 } 70 71 public function getName() { 72 return $this->getSpecification()->getName(); 73 } 74 75 public function getPath($to_file = null) { 76 $path = $this->getSpecification()->getRootDirectory(); 77 if ($to_file) { 78 $path = $path.DIRECTORY_SEPARATOR.$to_file; 79 } 80 return $path; 81 } 82 83 private function renderTemplate($__template__, array $__scope__) { 84 chdir($this->getPath()); 85 ob_start(); 86 87 if (Filesystem::pathExists($this->getPath($__template__))) { 88 // Fool lint. 89 $__evil__ = 'extract'; 90 $__evil__($__scope__ + $this->getDefaultScope()); 91 require $this->getPath($__template__); 92 } 93 94 return phutil_safe_html(ob_get_clean()); 95 } 96 97 private function getDefaultScope() { 98 return array( 99 'skin' => $this, 100 'blog' => $this->getBlog(), 101 'uri' => $this->getURI($this->getURIPath()), 102 'home_uri' => $this->getURI(''), 103 'title' => $this->getTitle(), 104 'description' => $this->getDescription(), 105 'og_type' => $this->getOGType(), 106 ); 107 } 108 109 protected function renderHeader() { 110 return $this->renderTemplate( 111 'header.php', 112 array()); 113 } 114 115 protected function renderFooter() { 116 return $this->renderTemplate('footer.php', array()); 117 } 118 119 protected function render404Page() { 120 return $this->renderTemplate('404.php', array()); 121 } 122 123 protected function renderPostDetail(PhamePostView $post) { 124 return $this->renderTemplate( 125 'post-detail.php', 126 array( 127 'post' => $post, 128 )); 129 } 130 131 protected function renderPostList(array $posts) { 132 return $this->renderTemplate( 133 'post-list.php', 134 array( 135 'posts' => $posts, 136 'older' => $this->renderOlderPageLink(), 137 'newer' => $this->renderNewerPageLink(), 138 )); 139 } 140 141 }
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 |