@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert Macro to PHUITwoColumnView

Summary: Converts Macro to new layout

Test Plan: Add Macro, Edit Macro, Mobile, Desktop layouts

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15372

+81 -39
+81 -39
src/applications/macro/controller/PhabricatorMacroViewController.php
··· 20 20 return new Aphront404Response(); 21 21 } 22 22 23 - $file = $macro->getFile(); 24 - 25 23 $title_short = pht('Macro "%s"', $macro->getName()); 26 24 $title_long = pht('Image Macro "%s"', $macro->getName()); 27 25 28 26 $actions = $this->buildActionView($macro); 27 + $subheader = $this->buildSubheaderView($macro); 28 + $properties = $this->buildPropertyView($macro); 29 + $file = $this->buildFileView($macro); 30 + $details = $this->buildPropertySectionView($macro); 29 31 30 32 $crumbs = $this->buildApplicationCrumbs(); 31 - $crumbs->addTextCrumb( 32 - $title_short, 33 - $this->getApplicationURI('/view/'.$macro->getID().'/')); 34 - 35 - $properties = $this->buildPropertyView($macro, $actions); 36 - if ($file) { 37 - $file_view = new PHUIPropertyListView(); 38 - $file_view->addImageContent( 39 - phutil_tag( 40 - 'img', 41 - array( 42 - 'src' => $file->getViewURI(), 43 - 'class' => 'phabricator-image-macro-hero', 44 - ))); 45 - } 33 + $crumbs->addTextCrumb($macro->getName()); 34 + $crumbs->setBorder(true); 46 35 47 36 $timeline = $this->buildTransactionTimeline( 48 37 $macro, ··· 75 64 ->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/')) 76 65 ->setSubmitButtonName(pht('Add Comment')); 77 66 78 - $object_box = id(new PHUIObjectBoxView()) 67 + $view = id(new PHUITwoColumnView()) 79 68 ->setHeader($header) 80 - ->addPropertyList($properties); 81 - 82 - if ($file_view) { 83 - $object_box->addPropertyList($file_view); 84 - } 85 - 86 - return $this->buildApplicationPage( 87 - array( 88 - $crumbs, 89 - $object_box, 69 + ->setSubheader($subheader) 70 + ->setMainColumn(array( 90 71 $timeline, 91 72 $add_comment_form, 92 - ), 93 - array( 94 - 'title' => $title_short, 95 - 'pageObjects' => array($macro->getPHID()), 73 + )) 74 + ->addPropertySection(pht('MACRO'), $file) 75 + ->addPropertySection(pht('DETAILS'), $details) 76 + ->setPropertyList($properties) 77 + ->setActionList($actions); 78 + 79 + return $this->newPage() 80 + ->setTitle($title_short) 81 + ->setCrumbs($crumbs) 82 + ->setPageObjectPHIDs(array($macro->getPHID())) 83 + ->appendChild( 84 + array( 85 + $view, 96 86 )); 97 87 } 98 88 99 - private function buildActionView(PhabricatorFileImageMacro $macro) { 89 + private function buildActionView( 90 + PhabricatorFileImageMacro $macro) { 100 91 $can_manage = $this->hasApplicationCapability( 101 92 PhabricatorMacroManageCapability::CAPABILITY); 102 93 ··· 141 132 return $view; 142 133 } 143 134 144 - private function buildPropertyView( 145 - PhabricatorFileImageMacro $macro, 146 - PhabricatorActionListView $actions) { 135 + private function buildSubheaderView( 136 + PhabricatorFileImageMacro $macro) { 137 + $viewer = $this->getViewer(); 138 + 139 + $author_phid = $macro->getAuthorPHID(); 140 + 141 + $author = $viewer->renderHandle($author_phid)->render(); 142 + $date = phabricator_datetime($macro->getDateCreated(), $viewer); 143 + $author = phutil_tag('strong', array(), $author); 144 + 145 + $handles = $viewer->loadHandles(array($author_phid)); 146 + $image_uri = $handles[$author_phid]->getImageURI(); 147 + $image_href = $handles[$author_phid]->getURI(); 148 + 149 + $content = pht('Masterfully imagined by %s on %s.', $author, $date); 150 + 151 + return id(new PHUIHeadThingView()) 152 + ->setImage($image_uri) 153 + ->setImageHref($image_href) 154 + ->setContent($content); 155 + } 156 + 157 + private function buildPropertySectionView( 158 + PhabricatorFileImageMacro $macro) { 147 159 $viewer = $this->getViewer(); 148 160 149 161 $view = id(new PHUIPropertyListView()) 150 - ->setUser($this->getRequest()->getUser()) 151 - ->setObject($macro) 152 - ->setActionList($actions); 162 + ->setUser($viewer); 153 163 154 164 switch ($macro->getAudioBehavior()) { 155 165 case PhabricatorFileImageMacro::AUDIO_BEHAVIOR_ONCE: ··· 166 176 pht('Audio'), 167 177 $viewer->renderHandle($audio_phid)); 168 178 } 179 + 180 + return $view; 181 + } 182 + 183 + private function buildFileView( 184 + PhabricatorFileImageMacro $macro) { 185 + $viewer = $this->getViewer(); 186 + 187 + $view = id(new PHUIPropertyListView()) 188 + ->setUser($viewer); 189 + 190 + $file = $macro->getFile(); 191 + if ($file) { 192 + $view->addImageContent( 193 + phutil_tag( 194 + 'img', 195 + array( 196 + 'src' => $file->getViewURI(), 197 + 'class' => 'phabricator-image-macro-hero', 198 + ))); 199 + return $view; 200 + } 201 + return null; 202 + } 203 + 204 + private function buildPropertyView( 205 + PhabricatorFileImageMacro $macro) { 206 + $viewer = $this->getViewer(); 207 + 208 + $view = id(new PHUIPropertyListView()) 209 + ->setUser($this->getRequest()->getUser()) 210 + ->setObject($macro); 169 211 170 212 $view->invokeWillRenderEvent(); 171 213