当前位置: 首页>>代码示例>>PHP>>正文


PHP AphrontPanelView::addButton方法代码示例

本文整理汇总了PHP中AphrontPanelView::addButton方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontPanelView::addButton方法的具体用法?PHP AphrontPanelView::addButton怎么用?PHP AphrontPanelView::addButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AphrontPanelView的用法示例。


在下文中一共展示了AphrontPanelView::addButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $package = id(new PhabricatorOwnersPackage())->load($this->id);
     if (!$package) {
         return new Aphront404Response();
     }
     $paths = $package->loadPaths();
     $owners = $package->loadOwners();
     $phids = array();
     foreach ($paths as $path) {
         $phids[$path->getRepositoryPHID()] = true;
     }
     foreach ($owners as $owner) {
         $phids[$owner->getUserPHID()] = true;
     }
     $phids = array_keys($phids);
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $rows = array();
     $rows[] = array('Name', phutil_escape_html($package->getName()));
     $rows[] = array('Description', phutil_escape_html($package->getDescription()));
     $primary_owner = null;
     $primary_phid = $package->getPrimaryOwnerPHID();
     if ($primary_phid && isset($handles[$primary_phid])) {
         $primary_owner = '<strong>' . $handles[$primary_phid]->renderLink() . '</strong>';
     }
     $rows[] = array('Primary Owner', $primary_owner);
     $owner_links = array();
     foreach ($owners as $owner) {
         $owner_links[] = $handles[$owner->getUserPHID()]->renderLink();
     }
     $owner_links = implode('<br />', $owner_links);
     $rows[] = array('Owners', $owner_links);
     $rows[] = array('Auditing', $package->getAuditingEnabled() ? 'Enabled' : 'Disabled');
     $rows[] = array('Related Commits', phutil_render_tag('a', array('href' => '/owners/related/view/all/?phid=' . $package->getPHID()), phutil_escape_html('Related Commits')));
     $path_links = array();
     foreach ($paths as $path) {
         $callsign = $handles[$path->getRepositoryPHID()]->getName();
         $repo = phutil_escape_html('r' . $callsign);
         $path_link = phutil_render_tag('a', array('href' => '/diffusion/' . $callsign . '/browse/:' . $path->getPath()), phutil_escape_html($path->getPath()));
         $path_links[] = $repo . ' ' . $path_link;
     }
     $path_links = implode('<br />', $path_links);
     $rows[] = array('Paths', $path_links);
     $table = new AphrontTableView($rows);
     $table->setColumnClasses(array('header', 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Package Details for "' . phutil_escape_html($package->getName()) . '"');
     $panel->addButton(javelin_render_tag('a', array('href' => '/owners/delete/' . $package->getID() . '/', 'class' => 'button grey', 'sigil' => 'workflow'), 'Delete Package'));
     $panel->addButton(phutil_render_tag('a', array('href' => '/owners/edit/' . $package->getID() . '/', 'class' => 'button'), 'Edit Package'));
     $panel->appendChild($table);
     $nav = new AphrontSideNavView();
     $nav->appendChild($panel);
     $nav->addNavItem(phutil_render_tag('a', array('href' => '/owners/package/' . $package->getID() . '/', 'class' => 'aphront-side-nav-selected'), 'Package Details'));
     return $this->buildStandardPageResponse($nav, array('title' => "Package '" . $package->getName() . "'"));
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:57,代码来源:PhabricatorOwnersDetailController.php

示例2: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:53,代码来源:PhabricatorPeopleListController.php

示例3: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $task = id(new PhabricatorWorkerTask())->load($this->id);
     if (!$task) {
         $error_view = new AphrontErrorView();
         $error_view->setTitle('No Such Task');
         $error_view->appendChild('<p>This task may have recently completed.</p>');
         $error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
         return $this->buildStandardPageResponse($error_view, array('title' => 'Task Does Not Exist'));
     }
     $data = id(new PhabricatorWorkerTaskData())->loadOneWhere('id = %d', $task->getDataID());
     $extra = null;
     switch ($task->getTaskClass()) {
         case 'PhabricatorRepositorySvnCommitChangeParserWorker':
         case 'PhabricatorRepositoryGitCommitChangeParserWorker':
             $commit_id = idx($data->getData(), 'commitID');
             if ($commit_id) {
                 $commit = id(new PhabricatorRepositoryCommit())->load($commit_id);
                 if ($commit) {
                     $repository = id(new PhabricatorRepository())->load($commit->getRepositoryID());
                     if ($repository) {
                         $extra = "<strong>NOTE:</strong> " . "You can manually retry this task by running this script:" . "<pre>" . "phabricator/\$ ./scripts/repository/reparse.php " . "r" . phutil_escape_html($repository->getCallsign()) . phutil_escape_html($commit->getCommitIdentifier()) . " " . "--change" . "</pre>";
                     }
                 }
             }
             break;
         default:
             break;
     }
     if ($data) {
         $data = json_encode($data->getData());
     }
     $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($task->getID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Type')->setValue($task->getTaskClass()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Lease Owner')->setValue($task->getLeaseOwner()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Lease Expires')->setValue($task->getLeaseExpires() - time()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Failure Count')->setValue($task->getFailureCount()))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Data')->setValue($data));
     if ($extra) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel('More')->setValue($extra));
     }
     $form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/daemon/', 'Back'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Task Detail');
     $panel->setWidth(AphrontPanelView::WIDTH_WIDE);
     $panel->appendChild($form);
     $panel->addButton(javelin_render_tag('a', array('href' => '/daemon/task/' . $task->getID() . '/delete/', 'class' => 'button grey', 'sigil' => 'workflow'), 'Delete Task'));
     $panel->addButton(javelin_render_tag('a', array('href' => '/daemon/task/' . $task->getID() . '/release/', 'class' => 'button grey', 'sigil' => 'workflow'), 'Free Lease'));
     $nav = $this->buildSideNavView();
     $nav->selectFilter('');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'Task'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:50,代码来源:PhabricatorWorkerTaskDetailController.php

示例4: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildSideNav('resource');
     $pager = new AphrontPagerView();
     $pager->setURI(new PhutilURI('/drydock/resource/'), 'page');
     $data = id(new DrydockResource())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $data = $pager->sliceResults($data);
     $phids = mpull($data, 'getOwnerPHID');
     $handles = $this->loadViewerHandles($phids);
     $rows = array();
     foreach ($data as $resource) {
         $rows[] = array($resource->getID(), $resource->getOwnerPHID() ? $handles[$resource->getOwnerPHID()]->renderLink() : null, phutil_escape_html($resource->getType()), DrydockResourceStatus::getNameForStatus($resource->getStatus()), phutil_escape_html(nonempty($resource->getName(), 'Unnamed')), phabricator_datetime($resource->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Owner', 'Type', 'Status', 'Resource', 'Created'));
     $table->setColumnClasses(array('', '', '', '', 'pri wide', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Drydock Resources');
     $panel->addButton(phutil_render_tag('a', array('href' => '/drydock/resource/allocate/', 'class' => 'green button'), 'Allocate Resource'));
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Resources'));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:26,代码来源:DrydockResourceListController.php

示例5: processRequest

 public function processRequest()
 {
     $phid = $this->getAuthorizationPHID();
     $title = 'Edit OAuth Client Authorization';
     $request = $this->getRequest();
     $current_user = $request->getUser();
     $authorization = id(new PhabricatorOAuthClientAuthorization())->loadOneWhere('phid = %s', $phid);
     if (empty($authorization)) {
         return new Aphront404Response();
     }
     if ($authorization->getUserPHID() != $current_user->getPHID()) {
         $message = 'Access denied to client authorization with phid ' . $phid . '. ' . 'Only the user who authorized the client has permission to ' . 'edit the authorization.';
         return id(new Aphront403Response())->setForbiddenText($message);
     }
     if ($request->isFormPost()) {
         $scopes = PhabricatorOAuthServerScope::getScopesFromRequest($request);
         $authorization->setScope($scopes);
         $authorization->save();
         return id(new AphrontRedirectResponse())->setURI('/oauthserver/clientauthorization/?edited=' . $phid);
     }
     $client_phid = $authorization->getClientPHID();
     $client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $client_phid);
     $created = phabricator_datetime($authorization->getDateCreated(), $current_user);
     $updated = phabricator_datetime($authorization->getDateModified(), $current_user);
     $panel = new AphrontPanelView();
     $delete_button = phutil_render_tag('a', array('href' => $authorization->getDeleteURI(), 'class' => 'grey button'), 'Delete OAuth Client Authorization');
     $panel->addButton($delete_button);
     $panel->setHeader($title);
     $form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormMarkupControl())->setLabel('Client')->setValue(phutil_render_tag('a', array('href' => $client->getViewURI()), phutil_escape_html($client->getName()))))->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated))->appendChild(PhabricatorOAuthServerScope::getCheckboxControl($authorization->getScope()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save OAuth Client Authorization')->addCancelButton('/oauthserver/clientauthorization/'));
     $panel->appendChild($form);
     return $this->buildStandardPageResponse($panel, array('title' => $title));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:32,代码来源:PhabricatorOAuthClientAuthorizationEditController.php

示例6: processRequest

 public function processRequest()
 {
     $drequest = $this->diffusionRequest;
     $request = $this->getRequest();
     $page_size = $request->getInt('pagesize', 100);
     $offset = $request->getInt('page', 0);
     $history_query = DiffusionHistoryQuery::newFromDiffusionRequest($drequest);
     $history_query->setOffset($offset);
     $history_query->setLimit($page_size + 1);
     if (!$request->getBool('copies')) {
         $history_query->needDirectChanges(true);
         $history_query->needChildChanges(true);
     }
     $history = $history_query->loadHistory();
     $phids = array();
     foreach ($history as $item) {
         $data = $item->getCommitData();
         if ($data) {
             if ($data->getCommitDetail('authorPHID')) {
                 $phids[$data->getCommitDetail('authorPHID')] = true;
             }
         }
     }
     $phids = array_keys($phids);
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $pager = new AphrontPagerView();
     $pager->setPageSize($page_size);
     $pager->setOffset($offset);
     if (count($history) == $page_size + 1) {
         array_pop($history);
         $pager->setHasMorePages(true);
     } else {
         $pager->setHasMorePages(false);
     }
     $pager->setURI($request->getRequestURI(), 'page');
     $content = array();
     $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history'));
     if ($request->getBool('copies')) {
         $button_title = 'Hide Copies/Branches';
     } else {
         $button_title = 'Show Copies/Branches';
     }
     $button_uri = $request->getRequestURI()->alter('copies', !$request->getBool('copies'));
     $button = phutil_render_tag('a', array('class' => 'button small grey', 'href' => $button_uri), phutil_escape_html($button_title));
     $history_table = new DiffusionHistoryTableView();
     $history_table->setDiffusionRequest($drequest);
     $history_table->setHandles($handles);
     $history_table->setHistory($history);
     $history_panel = new AphrontPanelView();
     $history_panel->setHeader('History');
     $history_panel->addButton($button);
     $history_panel->appendChild($history_table);
     $history_panel->appendChild($pager);
     $content[] = $history_panel;
     // TODO: Sometimes we do have a change view, we need to look at the most
     // recent history entry to figure it out.
     $nav = $this->buildSideNav('history', false);
     $nav->appendChild($content);
     return $this->buildStandardPageResponse($nav, array('title' => 'history'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:60,代码来源:DiffusionHistoryController.php

示例7: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $current_user = $request->getUser();
     $error = null;
     $phid = $this->getClientPHID();
     $client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $phid);
     $title = 'View OAuth Client';
     // validate the client
     if (empty($client)) {
         $message = 'No client found with id ' . $phid . '.';
         return $this->buildStandardPageResponse($this->buildErrorView($message), array('title' => $title));
     }
     $panel = new AphrontPanelView();
     $panel->setHeader($title);
     $form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormStaticControl())->setLabel('Name')->setValue($client->getName()))->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($phid));
     if ($current_user->getPHID() == $client->getCreatorPHID()) {
         $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Secret')->setValue($client->getSecret()));
     }
     $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Redirect URI')->setValue($client->getRedirectURI()));
     $created = phabricator_datetime($client->getDateCreated(), $current_user);
     $updated = phabricator_datetime($client->getDateModified(), $current_user);
     $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated));
     $panel->appendChild($form);
     $admin_panel = null;
     if ($client->getCreatorPHID() == $current_user->getPHID()) {
         $edit_button = phutil_render_tag('a', array('href' => $client->getEditURI(), 'class' => 'grey button'), 'Edit OAuth Client');
         $panel->addButton($edit_button);
         $create_authorization_form = id(new AphrontFormView())->setUser($current_user)->addHiddenInput('action', 'testclientauthorization')->addHiddenInput('client_phid', $phid)->setAction('/oauthserver/test/')->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Scopeless Test Authorization'));
         $admin_panel = id(new AphrontPanelView())->setHeader('Admin Tools')->appendChild($create_authorization_form);
     }
     return $this->buildStandardPageResponse(array($error, $panel, $admin_panel), array('title' => $title));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:33,代码来源:PhabricatorOAuthClientViewController.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $paste = id(new PhabricatorPasteQuery())->setViewer($user)->withPasteIDs(array($this->id))->executeOne();
     if (!$paste) {
         return new Aphront404Response();
     }
     $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $paste->getFilePHID());
     if (!$file) {
         return new Aphront400Response();
     }
     $corpus = $this->buildCorpus($paste, $file);
     $paste_panel = new AphrontPanelView();
     $author_phid = $paste->getAuthorPHID();
     $header = 'Viewing Paste ' . $paste->getID() . ' by ' . PhabricatorObjectHandleData::loadOneHandle($author_phid)->renderLink();
     if (strlen($paste->getTitle())) {
         $header .= ' - ' . phutil_escape_html($paste->getTitle());
     }
     $paste_panel->setHeader($header);
     $paste_panel->setWidth(AphrontPanelView::WIDTH_FULL);
     $paste_panel->addButton(phutil_render_tag('a', array('href' => '/paste/?fork=' . $paste->getID(), 'class' => 'green button'), 'Fork This'));
     $raw_uri = $file->getBestURI();
     $paste_panel->addButton(phutil_render_tag('a', array('href' => $raw_uri, 'class' => 'button'), 'View Raw Text'));
     $paste_panel->appendChild($corpus);
     $forks_panel = null;
     $forks_of_this_paste = id(new PhabricatorPaste())->loadAllWhere('parentPHID = %s', $paste->getPHID());
     if ($forks_of_this_paste) {
         $forks_panel = new AphrontPanelView();
         $forks_panel->setHeader("Forks of this paste");
         $forks = array();
         foreach ($forks_of_this_paste as $fork) {
             $forks[] = array($fork->getID(), phutil_render_tag('a', array('href' => '/P' . $fork->getID()), phutil_escape_html($fork->getTitle())));
         }
         $forks_table = new AphrontTableView($forks);
         $forks_table->setHeaders(array('Paste ID', 'Title'));
         $forks_table->setColumnClasses(array(null, 'wide pri'));
         $forks_panel->appendChild($forks_table);
     }
     return $this->buildStandardPageResponse(array($paste_panel, $forks_panel), array('title' => 'Paste: ' . nonempty($paste->getTitle(), 'P' . $paste->getID()), 'tab' => 'view'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:41,代码来源:PhabricatorPasteViewController.php

示例9: render

 public function render()
 {
     DarkConsoleXHProfPluginAPI::includeXHProfLib();
     $GLOBALS['display_calls'] = true;
     $totals = array();
     $flat = xhprof_compute_flat_info($this->profileData, $totals);
     unset($GLOBALS['display_calls']);
     $aggregated = array();
     foreach ($flat as $call => $counters) {
         $parts = explode('@', $call, 2);
         $agg_call = reset($parts);
         if (empty($aggregated[$agg_call])) {
             $aggregated[$agg_call] = $counters;
         } else {
             foreach ($aggregated[$agg_call] as $key => $val) {
                 if ($key != 'wt') {
                     $aggregated[$agg_call][$key] += $counters[$key];
                 }
             }
         }
     }
     $flat = $aggregated;
     $flat = isort($flat, 'wt');
     $flat = array_reverse($flat);
     $rows = array();
     $rows[] = array('Total', number_format($totals['ct']), number_format($totals['wt']) . ' us', '100.0%', number_format($totals['wt']) . ' us', '100.0%');
     if ($this->limit) {
         $flat = array_slice($flat, 0, $this->limit);
     }
     foreach ($flat as $call => $counters) {
         $rows[] = array($this->renderSymbolLink($call), number_format($counters['ct']), number_format($counters['wt']) . ' us', sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']), number_format($counters['excl_wt']) . ' us', sprintf('%.1f%%', 100 * $counters['excl_wt'] / $totals['wt']));
     }
     Javelin::initBehavior('phabricator-tooltips');
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Symbol', 'Count', javelin_render_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => 'Total wall time spent in this function and all of ' . 'its children (chilren are other functions it called ' . 'while executing).', 'size' => 200)), 'Wall Time (Inclusive)'), '%', javelin_render_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => 'Wall time spent in this function, excluding time ' . 'spent in children (children are other functions it ' . 'called while executing).', 'size' => 200)), 'Wall Time (Exclusive)'), '%'));
     $table->setColumnClasses(array('wide pri', 'n', 'n', 'n', 'n', 'n'));
     $panel = new AphrontPanelView();
     $panel->setHeader('XHProf Profile');
     if ($this->file) {
         $panel->addButton(phutil_render_tag('a', array('href' => $this->file->getBestURI(), 'class' => 'green button'), 'Download .xhprof Profile'));
     }
     $panel->appendChild($table);
     return $panel->render();
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:44,代码来源:PhabricatorXHProfProfileTopLevelView.php

示例10: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/notification/'));
     $nav->addFilter('all', 'All Notifications');
     $nav->addFilter('unread', 'Unread Notifications');
     $filter = $nav->selectFilter($this->filter, 'all');
     $pager = new AphrontPagerView();
     $pager->setURI($request->getRequestURI(), 'offset');
     $pager->setOffset($request->getInt('offset'));
     $query = new PhabricatorNotificationQuery();
     $query->setUserPHID($user->getPHID());
     switch ($filter) {
         case 'unread':
             $query->withUnread(true);
             $header = pht('Unread Notifications');
             $no_data = pht('You have no unread notifications.');
             break;
         default:
             $header = pht('Notifications');
             $no_data = pht('You have no notifications.');
             break;
     }
     $notifications = $query->executeWithOffsetPager($pager);
     if ($notifications) {
         $builder = new PhabricatorNotificationBuilder($notifications);
         $view = $builder->buildView();
     } else {
         $view = '<div class="phabricator-notification no-notifications">' . $no_data . '</div>';
     }
     $view = array('<div class="phabricator-notification-list">', $view, '</div>');
     $panel = new AphrontPanelView();
     $panel->setHeader($header);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     $panel->addButton(javelin_render_tag('a', array('href' => '/notification/clear/', 'class' => 'button', 'sigil' => 'workflow'), 'Mark All Read'));
     $panel->appendChild($view);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Notifications'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:42,代码来源:PhabricatorNotificationListController.php

示例11: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildBaseSideNav();
     $queries = id(new ManiphestSavedQuery())->loadAllWhere('userPHID = %s ORDER BY name ASC', $user->getPHID());
     $default = null;
     if ($request->isFormPost()) {
         $new_default = null;
         foreach ($queries as $query) {
             if ($query->getID() == $request->getInt('default')) {
                 $new_default = $query;
             }
         }
         if ($this->getDefaultQuery()) {
             $this->getDefaultQuery()->setIsDefault(0)->save();
         }
         if ($new_default) {
             $new_default->setIsDefault(1)->save();
         }
         return id(new AphrontRedirectResponse())->setURI('/maniphest/custom/');
     }
     $rows = array();
     foreach ($queries as $query) {
         if ($query->getIsDefault()) {
             $default = $query;
         }
         $rows[] = array(phutil_render_tag('input', array('type' => 'radio', 'name' => 'default', 'value' => $query->getID(), 'checked' => $query->getIsDefault() ? 'checked' : null)), phutil_render_tag('a', array('href' => '/maniphest/view/custom/?key=' . $query->getQueryKey()), phutil_escape_html($query->getName())), phutil_render_tag('a', array('href' => '/maniphest/custom/edit/' . $query->getID() . '/', 'class' => 'grey small button'), 'Edit'), javelin_render_tag('a', array('href' => '/maniphest/custom/delete/' . $query->getID() . '/', 'class' => 'grey small button', 'sigil' => 'workflow'), 'Delete'));
     }
     $rows[] = array(phutil_render_tag('input', array('type' => 'radio', 'name' => 'default', 'value' => 0, 'checked' => $default === null ? 'checked' : null)), '<em>No Default</em>', '', '');
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Default', 'Name', 'Edit', 'Delete'));
     $table->setColumnClasses(array('radio', 'wide pri', 'action', 'action'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Saved Custom Queries');
     $panel->addButton(phutil_render_tag('button', array(), 'Save Default Query'));
     $panel->appendChild($table);
     $form = phabricator_render_form($user, array('method' => 'POST', 'action' => $request->getRequestURI()), $panel->render());
     $nav->selectFilter('saved', 'saved');
     $nav->appendChild($form);
     return $this->buildStandardPageResponse($nav, array('title' => 'Saved Queries'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:42,代码来源:ManiphestSavedQueryListController.php

示例12: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorUser())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     $rows = array();
     foreach ($users as $user) {
         $status = '';
         if ($user->getIsDisabled()) {
             $status = 'Disabled';
         } else {
             if ($user->getIsAdmin()) {
                 $status = 'Admin';
             } else {
                 $status = '-';
             }
         }
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Status', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
     }
     return $this->buildStandardPageResponse($panel, array('title' => 'People', 'tab' => 'directory'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:40,代码来源:PhabricatorPeopleListController.php

示例13: processRequest


//.........这里部分代码省略.........
     $this->loadEdgesAndBlogs();
     if ($request->isFormPost()) {
         $saved = true;
         $visibility = $request->getInt('visibility');
         $comments = $request->getStr('comments_widget');
         $data = array('comments_widget' => $comments);
         $phame_title = $request->getStr('phame_title');
         $phame_title = PhabricatorSlug::normalize($phame_title);
         $title = $request->getStr('title');
         $post->setTitle($title);
         $post->setPhameTitle($phame_title);
         $post->setBody($request->getStr('body'));
         $post->setVisibility($visibility);
         $post->setConfigData($data);
         // only publish once...!
         if ($visibility == PhamePost::VISIBILITY_PUBLISHED) {
             if (!$post->getDatePublished()) {
                 $post->setDatePublished(time());
             }
             // this is basically a cast of null to 0 if its a new post
         } else {
             if (!$post->getDatePublished()) {
                 $post->setDatePublished(0);
             }
         }
         if ($phame_title == '/') {
             $errors[] = 'Phame title must be nonempty.';
             $e_phame_title = 'Required';
         }
         if (empty($title)) {
             $errors[] = 'Title must be nonempty.';
             $e_title = 'Required';
         }
         $blogs_published = array_keys($this->getPostBlogs());
         $blogs_to_publish = array();
         $blogs_to_depublish = array();
         if ($visibility == PhamePost::VISIBILITY_PUBLISHED) {
             $blogs_arr = $request->getArr('blogs');
             $blogs_to_publish = array_values($blogs_arr);
             $blogs_to_depublish = array_diff($blogs_published, $blogs_to_publish);
         } else {
             $blogs_to_depublish = $blogs_published;
         }
         if (empty($errors)) {
             try {
                 $post->save();
                 $editor = new PhabricatorEdgeEditor();
                 $edge_type = PhabricatorEdgeConfig::TYPE_POST_HAS_BLOG;
                 $editor->setUser($user);
                 foreach ($blogs_to_publish as $phid) {
                     $editor->addEdge($post->getPHID(), $edge_type, $phid);
                 }
                 foreach ($blogs_to_depublish as $phid) {
                     $editor->removeEdge($post->getPHID(), $edge_type, $phid);
                 }
                 $editor->save();
             } catch (AphrontQueryDuplicateKeyException $e) {
                 $saved = false;
                 $e_phame_title = 'Not Unique';
                 $errors[] = 'Another post already uses this slug. ' . 'Each post must have a unique slug.';
             }
         } else {
             $saved = false;
         }
         if ($saved) {
             $uri = new PhutilURI($post->getViewURI($user->getUsername()));
             $uri->setQueryParam('saved', true);
             return id(new AphrontRedirectResponse())->setURI($uri);
         }
     }
     $panel = new AphrontPanelView();
     $panel->setHeader($page_title);
     $panel->setWidth(AphrontPanelView::WIDTH_FULL);
     if ($delete_button) {
         $panel->addButton($delete_button);
     }
     $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormTextControl())->setLabel('Title')->setName('title')->setValue($post->getTitle())->setID('post-title')->setError($e_title))->appendChild(id(new AphrontFormTextControl())->setLabel('Phame Title')->setName('phame_title')->setValue(rtrim($post->getPhameTitle(), '/'))->setID('post-phame-title')->setCaption('Up to 64 alphanumeric characters ' . 'with underscores for spaces. ' . 'Formatting is enforced.')->setError($e_phame_title))->appendChild(id(new PhabricatorRemarkupControl())->setLabel('Body')->setName('body')->setValue($post->getBody())->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setID('post-body'))->appendChild(id(new AphrontFormSelectControl())->setLabel('Visibility')->setName('visibility')->setValue($post->getVisibility())->setOptions(PhamePost::getVisibilityOptionsForSelect())->setID('post-visibility'))->appendChild($this->getBlogCheckboxControl($post))->appendChild(id(new AphrontFormSelectControl())->setLabel('Comments Widget')->setName('comments_widget')->setvalue($post->getCommentsWidget())->setOptions($post->getCommentsWidgetOptionsForSelect()))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($submit_button));
     $panel->appendChild($form);
     $preview_panel = '<div class="aphront-panel-preview ">
      <div class="phame-post-preview-header">
        Post Preview
      </div>
      <div id="post-preview">
        <div class="aphront-panel-preview-loading-text">
          Loading preview...
        </div>
      </div>
    </div>';
     Javelin::initBehavior('phame-post-preview', array('preview' => 'post-preview', 'body' => 'post-body', 'title' => 'post-title', 'phame_title' => 'post-phame-title', 'uri' => '/phame/post/preview/'));
     $visibility_data = array('select_id' => 'post-visibility', 'current' => $post->getVisibility(), 'published' => PhamePost::VISIBILITY_PUBLISHED, 'draft' => PhamePost::VISIBILITY_DRAFT, 'change_uri' => $post->getChangeVisibilityURI());
     $blogs_data = array('checkbox_id' => 'post-blogs', 'have_published' => (bool) count($this->getPostBlogs()));
     Javelin::initBehavior('phame-post-blogs', array('blogs' => $blogs_data, 'visibility' => $visibility_data));
     if ($errors) {
         $error_view = id(new AphrontErrorView())->setTitle('Errors saving post.')->setErrors($errors);
     } else {
         $error_view = null;
     }
     $this->setShowSideNav(true);
     return $this->buildStandardPageResponse(array($error_view, $panel, $preview_panel), array('title' => $page_title));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:101,代码来源:PhamePostEditController.php

示例14: buildCommitPanel

 public function buildCommitPanel()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $phids = array($user->getPHID());
     $query = new PhabricatorAuditCommitQuery();
     $query->withAuthorPHIDs($phids);
     $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
     $query->needCommitData(true);
     $query->setLimit(10);
     $commits = $query->execute();
     if (!$commits) {
         return $this->renderMinipanel('No Problem Commits', 'No one has raised concerns with your commits.');
     }
     $view = new PhabricatorAuditCommitListView();
     $view->setCommits($commits);
     $view->setUser($user);
     $phids = $view->getRequiredHandlePHIDs();
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $view->setHandles($handles);
     $panel = new AphrontPanelView();
     $panel->setHeader('Problem Commits');
     $panel->setCaption('Commits which auditors have raised concerns about.');
     $panel->appendChild($view);
     $panel->addButton(phutil_render_tag('a', array('href' => '/audit/', 'class' => 'button grey'), "View Problem Commits »"));
     return $panel;
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:27,代码来源:PhabricatorDirectoryMainController.php

示例15: processRequest

 public function processRequest()
 {
     $drequest = $this->getDiffusionRequest();
     $request = $this->getRequest();
     $user = $request->getUser();
     $callsign = $drequest->getRepository()->getCallsign();
     $content = array();
     $content[] = $this->buildCrumbs(array('commit' => true));
     $detail_panel = new AphrontPanelView();
     $repository = $drequest->getRepository();
     $commit = $drequest->loadCommit();
     if (!$commit) {
         // TODO: Make more user-friendly.
         throw new Exception('This commit has not parsed yet.');
     }
     $commit_data = $drequest->loadCommitData();
     $is_foreign = $commit_data->getCommitDetail('foreign-svn-stub');
     if ($is_foreign) {
         $subpath = $commit_data->getCommitDetail('svn-subpath');
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Commit Not Tracked');
         $error_panel->setSeverity(AphrontErrorView::SEVERITY_WARNING);
         $error_panel->appendChild("This Diffusion repository is configured to track only one " . "subdirectory of the entire Subversion repository, and this commit " . "didn't affect the tracked subdirectory ('" . phutil_escape_html($subpath) . "'), so no information is available.");
         $content[] = $error_panel;
     } else {
         $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
         require_celerity_resource('diffusion-commit-view-css');
         require_celerity_resource('phabricator-remarkup-css');
         $property_table = $this->renderPropertyTable($commit, $commit_data);
         $detail_panel->appendChild('<div class="diffusion-commit-view">' . '<div class="diffusion-commit-dateline">' . 'r' . $callsign . $commit->getCommitIdentifier() . ' &middot; ' . phabricator_datetime($commit->getEpoch(), $user) . '</div>' . '<h1>Revision Detail</h1>' . '<div class="diffusion-commit-details">' . $property_table . '<hr />' . '<div class="diffusion-commit-message phabricator-remarkup">' . $engine->markupText($commit_data->getCommitMessage()) . '</div>' . '</div>' . '</div>');
         $content[] = $detail_panel;
     }
     $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
     $changes = $change_query->loadChanges();
     $original_changes_count = count($changes);
     if ($request->getStr('show_all') !== 'true' && $original_changes_count > self::CHANGES_LIMIT) {
         $changes = array_slice($changes, 0, self::CHANGES_LIMIT);
     }
     $change_table = new DiffusionCommitChangeTableView();
     $change_table->setDiffusionRequest($drequest);
     $change_table->setPathChanges($changes);
     $count = count($changes);
     $bad_commit = null;
     if ($count == 0) {
         $bad_commit = queryfx_one(id(new PhabricatorRepository())->establishConnection('r'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, 'r' . $callsign . $commit->getCommitIdentifier());
     }
     if ($bad_commit) {
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Bad Commit');
         $error_panel->appendChild(phutil_escape_html($bad_commit['description']));
         $content[] = $error_panel;
     } else {
         if ($is_foreign) {
             // Don't render anything else.
         } else {
             if (!count($changes)) {
                 $no_changes = new AphrontErrorView();
                 $no_changes->setWidth(AphrontErrorView::WIDTH_WIDE);
                 $no_changes->setSeverity(AphrontErrorView::SEVERITY_WARNING);
                 $no_changes->setTitle('Not Yet Parsed');
                 // TODO: This can also happen with weird SVN changes that don't do
                 // anything (or only alter properties?), although the real no-changes case
                 // is extremely rare and might be impossible to produce organically. We
                 // should probably write some kind of "Nothing Happened!" change into the
                 // DB once we parse these changes so we can distinguish between
                 // "not parsed yet" and "no changes".
                 $no_changes->appendChild("This commit hasn't been fully parsed yet (or doesn't affect any " . "paths).");
                 $content[] = $no_changes;
             } else {
                 $change_panel = new AphrontPanelView();
                 $change_panel->setHeader("Changes (" . number_format($count) . ")");
                 if ($count !== $original_changes_count) {
                     $show_all_button = phutil_render_tag('a', array('class' => 'button green', 'href' => '?show_all=true'), phutil_escape_html('Show All Changes'));
                     $warning_view = id(new AphrontErrorView())->setSeverity(AphrontErrorView::SEVERITY_WARNING)->setTitle(sprintf("Showing only the first %d changes out of %s!", self::CHANGES_LIMIT, number_format($original_changes_count)));
                     $change_panel->appendChild($warning_view);
                     $change_panel->addButton($show_all_button);
                 }
                 $change_panel->appendChild($change_table);
                 $content[] = $change_panel;
                 $changesets = DiffusionPathChange::convertToDifferentialChangesets($changes);
                 $vcs = $repository->getVersionControlSystem();
                 switch ($vcs) {
                     case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                         $vcs_supports_directory_changes = true;
                         break;
                     case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                         $vcs_supports_directory_changes = false;
                         break;
                     default:
                         throw new Exception("Unknown VCS.");
                 }
                 $references = array();
                 foreach ($changesets as $key => $changeset) {
                     $file_type = $changeset->getFileType();
                     if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
                         if (!$vcs_supports_directory_changes) {
                             unset($changesets[$key]);
                             continue;
//.........这里部分代码省略.........
开发者ID:hwang36,项目名称:phabricator,代码行数:101,代码来源:DiffusionCommitController.php


注:本文中的AphrontPanelView::addButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。