@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.

Moderize Slowvote

Summary: phts everywhere, crumbs, and mobile views.

Test Plan: Created Questions, Voted, tested Chrome and iOS, Looked at ALLCAPS

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

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

+144 -84
+49 -1
src/applications/slowvote/controller/PhabricatorSlowvoteController.php
··· 5 5 */ 6 6 abstract class PhabricatorSlowvoteController extends PhabricatorController { 7 7 8 + const VIEW_ALL = 'all'; 9 + const VIEW_CREATED = 'created'; 10 + const VIEW_VOTED = 'voted'; 11 + 8 12 public function buildStandardPageResponse($view, array $data) { 9 13 $page = $this->buildStandardPageView(); 10 14 11 - $page->setApplicationName('Slowvote'); 15 + $page->setApplicationName(pht('Slowvote')); 12 16 $page->setBaseURI('/vote/'); 13 17 $page->setTitle(idx($data, 'title')); 14 18 $page->setGlyph("\xE2\x9C\x94"); ··· 17 21 18 22 $response = new AphrontWebpageResponse(); 19 23 return $response->setContent($page->render()); 24 + } 25 + 26 + public function buildSideNavView($filter = null, $for_app = false) { 27 + 28 + $views = $this->getViews(); 29 + $side_nav = new AphrontSideNavFilterView(); 30 + $side_nav->setBaseURI(new PhutilURI('/vote/view/')); 31 + foreach ($views as $key => $name) { 32 + $side_nav->addFilter($key, $name); 33 + } 34 + if ($filter) { 35 + $side_nav->selectFilter($filter, null); 36 + } 37 + 38 + if ($for_app) { 39 + $side_nav->addFilter('', pht('Create Question'), 40 + $this->getApplicationURI('create/')); 41 + } 42 + 43 + return $side_nav; 44 + } 45 + 46 + public function buildApplicationMenu() { 47 + return $this->buildSideNavView(null, true)->getMenu(); 48 + } 49 + 50 + public function buildApplicationCrumbs() { 51 + $crumbs = parent::buildApplicationCrumbs(); 52 + 53 + $crumbs->addAction( 54 + id(new PhabricatorMenuItemView()) 55 + ->setName(pht('Create Question')) 56 + ->setHref($this->getApplicationURI('create/')) 57 + ->setIcon('create')); 58 + 59 + return $crumbs; 60 + } 61 + 62 + public function getViews() { 63 + return array( 64 + self::VIEW_ALL => pht('All Slowvotes'), 65 + self::VIEW_CREATED => pht('Created'), 66 + self::VIEW_VOTED => pht('Voted In'), 67 + ); 20 68 } 21 69 22 70 }
+43 -23
src/applications/slowvote/controller/PhabricatorSlowvoteCreateController.php
··· 27 27 $poll->setMethod($request->getInt('method')); 28 28 29 29 if (!strlen($poll->getQuestion())) { 30 - $e_question = 'Required'; 31 - $errors[] = 'You must ask a poll question.'; 30 + $e_question = pht('Required'); 31 + $errors[] = pht('You must ask a poll question.'); 32 32 } else { 33 33 $e_question = null; 34 34 } 35 35 36 36 $responses = array_filter($responses); 37 37 if (empty($responses)) { 38 - $errors[] = 'You must offer at least one response.'; 39 - $e_response = 'Required'; 38 + $errors[] = pht('You must offer at least one response.'); 39 + $e_response = pht('Required'); 40 40 } else { 41 41 $e_response = null; 42 42 } ··· 59 59 $error_view = null; 60 60 if ($errors) { 61 61 $error_view = new AphrontErrorView(); 62 - $error_view->setTitle('Form Errors'); 62 + $error_view->setTitle(pht('Form Errors')); 63 63 $error_view->setErrors($errors); 64 64 } 65 65 66 + $instructions = 67 + phutil_tag( 68 + 'p', 69 + array( 70 + 'class' => 'aphront-form-instructions', 71 + ), 72 + pht('Resolve issues and build consensus through '. 73 + 'protracted deliberation.') 74 + ); 75 + 66 76 $form = id(new AphrontFormView()) 67 77 ->setUser($user) 68 - ->appendChild(hsprintf( 69 - '<p class="aphront-form-instructions">Resolve issues and build '. 70 - 'consensus through protracted deliberation.</p>')) 78 + ->appendChild($instructions) 71 79 ->appendChild( 72 80 id(new AphrontFormTextControl()) 73 - ->setLabel('Question') 81 + ->setLabel(pht('Question')) 74 82 ->setName('question') 75 83 ->setValue($poll->getQuestion()) 76 84 ->setError($e_question)); ··· 78 86 for ($ii = 0; $ii < 10; $ii++) { 79 87 $n = ($ii + 1); 80 88 $response = id(new AphrontFormTextControl()) 81 - ->setLabel("Response {$n}") 89 + ->setLabel(pht("Response %d", $n)) 82 90 ->setName('response[]') 83 91 ->setValue(idx($responses, $ii, '')); 84 92 ··· 90 98 } 91 99 92 100 $poll_type_options = array( 93 - PhabricatorSlowvotePoll::METHOD_PLURALITY => 'Plurality (Single Choice)', 94 - PhabricatorSlowvotePoll::METHOD_APPROVAL => 'Approval (Multiple Choice)', 101 + PhabricatorSlowvotePoll::METHOD_PLURALITY => 102 + pht('Plurality (Single Choice)'), 103 + PhabricatorSlowvotePoll::METHOD_APPROVAL => 104 + pht('Approval (Multiple Choice)'), 95 105 ); 96 106 97 107 $response_type_options = array( 98 108 PhabricatorSlowvotePoll::RESPONSES_VISIBLE 99 - => 'Allow anyone to see the responses', 109 + => pht('Allow anyone to see the responses'), 100 110 PhabricatorSlowvotePoll::RESPONSES_VOTERS 101 - => 'Require a vote to see the responses', 111 + => pht('Require a vote to see the responses'), 102 112 PhabricatorSlowvotePoll::RESPONSES_OWNER 103 - => 'Only I can see the responses', 113 + => pht('Only I can see the responses'), 104 114 ); 105 115 106 116 $form 107 117 ->appendChild( 108 118 id(new AphrontFormSelectControl()) 109 - ->setLabel('Vote Type') 119 + ->setLabel(pht('Vote Type')) 110 120 ->setName('method') 111 121 ->setValue($poll->getMethod()) 112 122 ->setOptions($poll_type_options)) 113 123 ->appendChild( 114 124 id(new AphrontFormSelectControl()) 115 - ->setLabel('Responses') 125 + ->setLabel(pht('Responses')) 116 126 ->setName('response_visibility') 117 127 ->setValue($poll->getResponseVisibility()) 118 128 ->setOptions($response_type_options)) 119 129 ->appendChild( 120 130 id(new AphrontFormCheckboxControl()) 121 - ->setLabel('Shuffle') 131 + ->setLabel(pht('Shuffle')) 122 132 ->addCheckbox( 123 133 'shuffle', 124 134 1, 125 - 'Show choices in random order', 135 + pht('Show choices in random order'), 126 136 $poll->getShuffle())) 127 137 ->appendChild( 128 138 id(new AphrontFormSubmitControl()) 129 - ->setValue('Create Slowvote') 139 + ->setValue(pht('Create Slowvote')) 130 140 ->addCancelButton('/vote/')); 131 141 132 142 $panel = new AphrontPanelView(); 133 143 $panel->setWidth(AphrontPanelView::WIDTH_FORM); 134 - $panel->setHeader('Create Slowvote'); 144 + $panel->setHeader(pht('Create Slowvote')); 145 + $panel->setNoBackground(); 135 146 $panel->appendChild($form); 136 147 137 - return $this->buildStandardPageResponse( 148 + $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); 149 + $crumbs->addCrumb( 150 + id(new PhabricatorCrumbView()) 151 + ->setName(pht('Create Slowvote')) 152 + ->setHref($this->getApplicationURI().'create/') 153 + ); 154 + 155 + return $this->buildApplicationPage( 138 156 array( 157 + $crumbs, 139 158 $error_view, 140 159 $panel, 141 160 ), 142 161 array( 143 - 'title' => 'Create Slowvote', 162 + 'title' => pht('Create Slowvote'), 163 + 'device' => true, 144 164 )); 145 165 } 146 166
+37 -46
src/applications/slowvote/controller/PhabricatorSlowvoteListController.php
··· 8 8 9 9 private $view; 10 10 11 - const VIEW_ALL = 'all'; 12 - const VIEW_CREATED = 'created'; 13 - const VIEW_VOTED = 'voted'; 14 - 15 11 public function willProcessRequest(array $data) { 16 - $this->view = idx($data, 'view'); 12 + $this->view = idx($data, 'view', parent::VIEW_ALL); 17 13 } 18 14 19 15 public function processRequest() { ··· 21 17 $request = $this->getRequest(); 22 18 $user = $request->getUser(); 23 19 24 - $views = array( 25 - self::VIEW_ALL => 'All Slowvotes', 26 - self::VIEW_CREATED => 'Created', 27 - self::VIEW_VOTED => 'Voted In', 28 - ); 20 + $view = $this->view; 21 + $views = $this->getViews(); 29 22 30 - $view = isset($views[$this->view]) 31 - ? $this->view 32 - : self::VIEW_ALL; 33 - 34 - $side_nav = $this->renderSideNav($views, $view); 23 + $side_nav = $this->buildSideNavView($view); 35 24 36 25 $pager = new AphrontPagerView(); 37 26 $pager->setOffset($request->getInt('page')); ··· 69 58 )); 70 59 $table->setHeaders( 71 60 array( 72 - 'ID', 73 - 'Poll', 74 - 'Author', 75 - 'Date', 76 - 'Time', 61 + pht('ID'), 62 + pht('Poll'), 63 + pht('Author'), 64 + pht('Date'), 65 + pht('Time'), 77 66 )); 78 67 68 + switch ($view) { 69 + case self::VIEW_ALL: 70 + $table_header = 71 + pht('Slowvotes Not Yet Consumed by the Ravages of Time'); 72 + break; 73 + case self::VIEW_CREATED: 74 + $table_header = 75 + pht('Slowvotes Birthed from Your Noblest of Great Minds'); 76 + break; 77 + case self::VIEW_VOTED: 78 + $table_header = 79 + pht('Slowvotes Within Which You Express Your Mighty Opinion'); 80 + break; 81 + } 82 + 79 83 $panel = new AphrontPanelView(); 80 - $panel->setHeader($this->getTableHeader($view)); 81 - $panel->setCreateButton('Create Slowvote', '/vote/create/'); 84 + $panel->setHeader($table_header); 85 + $panel->setNoBackground(); 82 86 $panel->appendChild($table); 83 87 $panel->appendChild($pager); 84 88 85 89 $side_nav->appendChild($panel); 86 90 87 - return $this->buildStandardPageResponse( 91 + $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); 92 + $crumbs->addCrumb( 93 + id(new PhabricatorCrumbView()) 94 + ->setName($views[$view]) 95 + ->setHref($this->getApplicationURI()) 96 + ); 97 + $side_nav->setCrumbs($crumbs); 98 + 99 + return $this->buildApplicationPage( 88 100 $side_nav, 89 101 array( 90 - 'title' => 'Slowvotes', 102 + 'title' => pht('Slowvotes'), 103 + 'device' => true, 91 104 )); 92 105 } 93 106 ··· 140 153 141 154 $data = $pager->sliceResults($data); 142 155 return $poll->loadAllFromArray($data); 143 - } 144 - 145 - private function renderSideNav(array $views, $view) { 146 - $side_nav = new AphrontSideNavFilterView(); 147 - $side_nav->setBaseURI(new PhutilURI('/vote/view/')); 148 - foreach ($views as $key => $name) { 149 - $side_nav->addFilter($key, $name); 150 - } 151 - $side_nav->selectFilter($view, null); 152 - return $side_nav; 153 - } 154 - 155 - private function getTableHeader($view) { 156 - static $headers = array( 157 - self::VIEW_ALL 158 - => 'Slowvotes Not Yet Consumed by the Ravages of Time', 159 - self::VIEW_CREATED 160 - => 'Slowvotes Birthed from Your Noblest of Great Minds', 161 - self::VIEW_VOTED 162 - => 'Slowvotes Within Which You Express Your Mighty Opinion', 163 - ); 164 - return idx($headers, $view); 165 156 } 166 157 167 158 }
+15 -14
src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
··· 147 147 148 148 if ($viewer_choices) { 149 149 $instructions = 150 - 'Your vote has been recorded... but there is still ample time to '. 150 + pht('Your vote has been recorded... but there is still ample time to '. 151 151 'rethink your position. Have you thoroughly considered all possible '. 152 - 'eventualities?'; 152 + 'eventualities?'); 153 153 } else { 154 154 $instructions = 155 - 'This is a weighty matter indeed. Consider your choices with the '. 156 - 'greatest of care.'; 155 + pht('This is a weighty matter indeed. Consider your choices with the '. 156 + 'greatest of care.'); 157 157 } 158 158 159 159 $form = id(new AphrontFormView()) ··· 163 163 $instructions)) 164 164 ->appendChild( 165 165 id(new AphrontFormMarkupControl()) 166 - ->setLabel('Vote') 166 + ->setLabel(pht('Vote')) 167 167 ->setValue($option_markup)) 168 168 ->appendChild( 169 169 id(new AphrontFormTextAreaControl()) 170 - ->setLabel('Comments') 170 + ->setLabel(pht('Comments')) 171 171 ->setHeight(AphrontFormTextAreaControl::HEIGHT_SHORT) 172 172 ->setName('comments') 173 173 ->setValue($comment_text)) 174 174 ->appendChild( 175 175 id(new AphrontFormSubmitControl()) 176 - ->setValue('Cautiously Engage in Deliberations')); 176 + ->setValue(pht('Engage in Deliberations'))); 177 177 178 178 179 179 $panel = new AphrontPanelView(); 180 180 $panel->setHeader($poll->getQuestion()); 181 181 $panel->setWidth(AphrontPanelView::WIDTH_WIDE); 182 - 182 + $panel->setNoBackground(); 183 183 $panel->appendChild($form); 184 184 $panel->appendChild(hsprintf('<br /><br />')); 185 185 $panel->appendChild($result_markup); 186 186 187 - return $this->buildStandardPageResponse( 187 + return $this->buildApplicationPage( 188 188 $panel, 189 189 array( 190 190 'title' => 'V'.$poll->getID().' '.$poll->getQuestion(), 191 + 'device' => true, 191 192 )); 192 193 } 193 194 ··· 372 373 } 373 374 374 375 $result_markup = id(new AphrontFormLayoutView()) 375 - ->appendChild(phutil_tag('h1', array(), 'Ongoing Deliberation')); 376 + ->appendChild(phutil_tag('h1', array(), pht('Ongoing Deliberation'))); 376 377 377 378 if (!$can_see_responses) { 378 379 if ($need_vote) { 379 - $reason = "You must vote to see the results."; 380 + $reason = pht("You must vote to see the results."); 380 381 } else { 381 - $reason = "The results are not public."; 382 + $reason = pht("The results are not public."); 382 383 } 383 384 $result_markup 384 385 ->appendChild(hsprintf( ··· 415 416 ))); 416 417 } 417 418 } else { 418 - $user_markup = 'This option has failed to appeal to anyone.'; 419 + $user_markup = pht('This option has failed to appeal to anyone.'); 419 420 } 420 421 421 422 $comment_markup = $this->renderComments( ··· 449 450 $comments, 450 451 $handles); 451 452 $result_markup->appendChild( 452 - phutil_tag('h1', array(), 'Motions Proposed for Consideration')); 453 + phutil_tag('h1', array(), pht('Motions Proposed for Consideration'))); 453 454 $result_markup->appendChild($comment_markup); 454 455 } 455 456