本文整理汇总了PHP中PHUIObjectBoxView::setTable方法的典型用法代码示例。如果您正苦于以下问题:PHP PHUIObjectBoxView::setTable方法的具体用法?PHP PHUIObjectBoxView::setTable怎么用?PHP PHUIObjectBoxView::setTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHUIObjectBoxView
的用法示例。
在下文中一共展示了PHUIObjectBoxView::setTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
if ($request->isFormPost()) {
$uri = new PhutilURI('/fact/chart/');
$uri->setQueryParam('y1', $request->getStr('y1'));
return id(new AphrontRedirectResponse())->setURI($uri);
}
$types = array('+N:*', '+N:DREV', 'updated');
$engines = PhabricatorFactEngine::loadAllEngines();
$specs = PhabricatorFactSpec::newSpecsForFactTypes($engines, $types);
$facts = id(new PhabricatorFactAggregate())->loadAllWhere('factType IN (%Ls)', $types);
$rows = array();
foreach ($facts as $fact) {
$spec = $specs[$fact->getFactType()];
$name = $spec->getName();
$value = $spec->formatValueForDisplay($viewer, $fact->getValueX());
$rows[] = array($name, $value);
}
$table = new AphrontTableView($rows);
$table->setHeaders(array(pht('Fact'), pht('Value')));
$table->setColumnClasses(array('wide', 'n'));
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Facts'));
$panel->setTable($table);
$chart_form = $this->buildChartForm();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Home'));
$title = pht('Facts');
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($chart_form, $panel));
}
示例2: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $this->getUser();
$viewer = $request->getUser();
$keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->execute();
$table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys."));
$panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$upload_icon = id(new PHUIIconView())->setIconFont('fa-upload');
$upload_button = id(new PHUIButtonView())->setText(pht('Upload Public Key'))->setHref('/auth/sshkey/upload/?objectPHID=' . $user->getPHID())->setWorkflow(true)->setTag('a')->setIcon($upload_icon);
try {
PhabricatorSSHKeyGenerator::assertCanGenerateKeypair();
$can_generate = true;
} catch (Exception $ex) {
$can_generate = false;
}
$generate_icon = id(new PHUIIconView())->setIconFont('fa-lock');
$generate_button = id(new PHUIButtonView())->setText(pht('Generate Keypair'))->setHref('/auth/sshkey/generate/?objectPHID=' . $user->getPHID())->setTag('a')->setWorkflow(true)->setDisabled(!$can_generate)->setIcon($generate_icon);
$header->setHeader(pht('SSH Public Keys'));
$header->addActionLink($generate_button);
$header->addActionLink($upload_button);
$panel->setHeader($header);
$panel->setTable($table);
return $panel;
}
示例3: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$db_values = id(new PhabricatorConfigEntry())->loadAllWhere('namespace = %s', 'default');
$db_values = mpull($db_values, null, 'getConfigKey');
$rows = array();
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
ksort($options);
foreach ($options as $option) {
$key = $option->getKey();
if ($option->getHidden()) {
$value = phutil_tag('em', array(), pht('Hidden'));
} else {
$value = PhabricatorEnv::getEnvConfig($key);
$value = PhabricatorConfigJSON::prettyPrintJSON($value);
}
$db_value = idx($db_values, $key);
$rows[] = array(phutil_tag('a', array('href' => $this->getApplicationURI('edit/' . $key . '/')), $key), $value, $db_value && !$db_value->getIsDeleted() ? pht('Customized') : '');
}
$table = id(new AphrontTableView($rows))->setColumnClasses(array('', 'wide'))->setHeaders(array(pht('Key'), pht('Value'), pht('Customized')));
$title = pht('Current Settings');
$crumbs = $this->buildApplicationCrumbs()->addTextCrumb($title);
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Current Settings'));
$panel->setTable($table);
$nav = $this->buildSideNavView();
$nav->selectFilter('all/');
$view = id(new PHUITwoColumnView())->setNavigation($nav)->setMainColumn(array($panel));
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例4: processRequest
public function processRequest(AphrontRequest $request)
{
if ($request->getExists('new')) {
return $this->processNew($request);
}
if ($request->getExists('edit')) {
return $this->processEdit($request);
}
if ($request->getExists('delete')) {
return $this->processDelete($request);
}
$user = $this->getUser();
$viewer = $request->getUser();
$factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere('userPHID = %s', $user->getPHID());
$rows = array();
$rowc = array();
$highlight_id = $request->getInt('id');
foreach ($factors as $factor) {
$impl = $factor->getImplementation();
if ($impl) {
$type = $impl->getFactorName();
} else {
$type = $factor->getFactorKey();
}
if ($factor->getID() == $highlight_id) {
$rowc[] = 'highlighted';
} else {
$rowc[] = null;
}
$rows[] = array(javelin_tag('a', array('href' => $this->getPanelURI('?edit=' . $factor->getID()), 'sigil' => 'workflow'), $factor->getFactorName()), $type, phabricator_datetime($factor->getDateCreated(), $viewer), javelin_tag('a', array('href' => $this->getPanelURI('?delete=' . $factor->getID()), 'sigil' => 'workflow', 'class' => 'small grey button'), pht('Remove')));
}
$table = new AphrontTableView($rows);
$table->setNoDataString(pht("You haven't added any authentication factors to your account yet."));
$table->setHeaders(array(pht('Name'), pht('Type'), pht('Created'), ''));
$table->setColumnClasses(array('wide pri', '', 'right', 'action'));
$table->setRowClasses($rowc);
$table->setDeviceVisibility(array(true, false, false, true));
$panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$help_uri = PhabricatorEnv::getDoclink('User Guide: Multi-Factor Authentication');
$help_icon = id(new PHUIIconView())->setIconFont('fa-info-circle');
$help_button = id(new PHUIButtonView())->setText(pht('Help'))->setHref($help_uri)->setTag('a')->setIcon($help_icon);
$create_icon = id(new PHUIIconView())->setIconFont('fa-plus');
$create_button = id(new PHUIButtonView())->setText(pht('Add Authentication Factor'))->setHref($this->getPanelURI('?new=true'))->setTag('a')->setWorkflow(true)->setIcon($create_icon);
$header->setHeader(pht('Authentication Factors'));
$header->addActionLink($help_button);
$header->addActionLink($create_button);
$panel->setHeader($header);
$panel->setTable($table);
return $panel;
}
示例5: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$drequest = $this->diffusionRequest;
$results = $this->getBrowseQueryResults();
$reason = $results->getReasonForEmptyResultSet();
$content = array();
$actions = $this->buildActionView($drequest);
$properties = $this->buildPropertyView($drequest, $actions);
$object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties);
$content[] = $object_box;
$content[] = $this->renderSearchForm($collapsed = true);
if (!$results->isValidResults()) {
$empty_result = new DiffusionEmptyResultView();
$empty_result->setDiffusionRequest($drequest);
$empty_result->setDiffusionBrowseResultSet($results);
$empty_result->setView($request->getStr('view'));
$content[] = $empty_result;
} else {
$phids = array();
foreach ($results->getPaths() as $result) {
$data = $result->getLastCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
}
}
$phids = array_keys($phids);
$handles = $this->loadViewerHandles($phids);
$browse_table = new DiffusionBrowseTableView();
$browse_table->setDiffusionRequest($drequest);
$browse_table->setHandles($handles);
$browse_table->setPaths($results->getPaths());
$browse_table->setUser($request->getUser());
$browse_panel = new PHUIObjectBoxView();
$browse_panel->setHeaderText($drequest->getPath(), '/');
$browse_panel->setTable($browse_table);
$content[] = $browse_panel;
}
$content[] = $this->buildOpenRevisions();
$readme_path = $results->getReadmePath();
if ($readme_path) {
$readme_content = $this->callConduitWithDiffusionRequest('diffusion.filecontentquery', array('path' => $readme_path, 'commit' => $drequest->getStableCommit()));
if ($readme_content) {
$content[] = id(new DiffusionReadmeView())->setUser($this->getViewer())->setPath($readme_path)->setContent($readme_content['corpus']);
}
}
$crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(nonempty(basename($drequest->getPath()), '/'), pht('%s Repository', $drequest->getRepository()->getCallsign()))));
}
示例6: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $this->getUser();
$viewer = $request->getUser();
$keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->withIsActive(true)->execute();
$table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys."));
$panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$ssh_actions = PhabricatorAuthSSHKeyTableView::newKeyActionsMenu($viewer, $user);
$header->setHeader(pht('SSH Public Keys'));
$header->addActionLink($ssh_actions);
$panel->setHeader($header);
$panel->setTable($table);
return $panel;
}
示例7: render
public function render()
{
DarkConsoleXHProfPluginAPI::includeXHProfLib();
$data = $this->profileData;
$GLOBALS['display_calls'] = true;
$totals = array();
$flat = xhprof_compute_flat_info($data, $totals);
unset($GLOBALS['display_calls']);
$symbol = $this->symbol;
$children = array();
$parents = array();
foreach ($this->profileData as $key => $counters) {
if (strpos($key, '==>') !== false) {
list($parent, $child) = explode('==>', $key, 2);
} else {
continue;
}
if ($parent == $symbol) {
$children[$key] = $child;
} else {
if ($child == $symbol) {
$parents[$key] = $parent;
}
}
}
$rows = array();
$rows[] = array(pht('Metrics for this Call'), '', '', '');
$rows[] = $this->formatRow(array($symbol, $flat[$symbol]['ct'], $flat[$symbol]['wt'], 1.0));
$rows[] = array(pht('Parent Calls'), '', '', '');
foreach ($parents as $key => $name) {
$rows[] = $this->formatRow(array($name, $data[$key]['ct'], $data[$key]['wt'], ''));
}
$rows[] = array(pht('Child Calls'), '', '', '');
$child_rows = array();
foreach ($children as $key => $name) {
$child_rows[] = array($name, $data[$key]['ct'], $data[$key]['wt'], $data[$key]['wt'] / $flat[$symbol]['wt']);
}
$child_rows = isort($child_rows, 2);
$child_rows = array_reverse($child_rows);
$rows = array_merge($rows, array_map(array($this, 'formatRow'), $child_rows));
$table = new AphrontTableView($rows);
$table->setHeaders(array(pht('Symbol'), pht('Count'), pht('Wall Time'), '%'));
$table->setColumnClasses(array('wide pri', 'n', 'n', 'n'));
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('XHProf Profile'));
$panel->setTable($table);
return $panel->render();
}
示例8: render
public function render()
{
$project_phid = $this->request->getStr('project');
$project_handle = null;
if ($project_phid) {
$phids = array($project_phid);
$project_handle = $this->getProjectHandle($phids, $project_phid, $this->request);
$tasks = $this->getOpenTasksforProject($this->user, $phids);
} else {
$tasks = $this->getOpenTasks($this->user);
}
$recently_closed = $this->loadRecentlyClosedTasks();
$date = phabricator_date(time(), $this->user);
$viewer_task_view = new UserOpenTasksView();
$project_task_view = new ProjectOpenTasksView();
if ($this->view == 'user') {
list($leftover, $leftover_closed, $base_link, $leftover_name, $col_header, $header, $result_closed, $result) = $viewer_task_view->execute($tasks, $recently_closed, $date);
} else {
if ($this->view == 'project') {
list($leftover, $base_link, $leftover_name, $col_header, $header, $result_closed, $leftover_closed, $result) = $project_task_view->execute($tasks, $recently_closed, $date);
} else {
$result = array();
$result_closed = array();
$base_link = null;
$leftover = array();
$leftover_closed = array();
$leftover_name = null;
$col_header = '';
$header = '';
}
}
$order = $this->request->getStr('order', 'name');
list($order, $reverse) = AphrontTableView::parseSort($order);
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips', array());
$rows = $this->buildRowsfromResult($project_handle, $result, $result_closed, $base_link, $leftover, $leftover_name, $leftover_closed, $order, $reverse);
list($cname, $cclass) = $this->buildTableColumns($col_header);
$table = $this->buildOpenTasksTable($rows, $cname, $cclass, $order, $reverse);
$panel = new PHUIObjectBoxView();
$panel->setHeaderText($header);
$panel->setTable($table);
$tokens = array();
if ($project_handle) {
$tokens = array($project_handle);
}
$filter = $this->renderReportFilters($tokens, $has_window = false, $this->request, $this->user);
return array($filter, $panel);
}
示例9: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$db_values = id(new PhabricatorConfigEntry())->loadAllWhere('namespace = %s', 'default');
$db_values = mpull($db_values, null, 'getConfigKey');
$rows = array();
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
ksort($options);
foreach ($options as $option) {
$key = $option->getKey();
if ($option->getHidden()) {
$value = phutil_tag('em', array(), pht('Hidden'));
} else {
$value = PhabricatorEnv::getEnvConfig($key);
$value = PhabricatorConfigJSON::prettyPrintJSON($value);
}
$db_value = idx($db_values, $key);
$rows[] = array(phutil_tag('a', array('href' => $this->getApplicationURI('edit/' . $key . '/')), $key), $value, $db_value && !$db_value->getIsDeleted() ? pht('Customized') : '');
}
$table = id(new AphrontTableView($rows))->setColumnClasses(array('', 'wide'))->setHeaders(array(pht('Key'), pht('Value'), pht('Customized')));
$title = pht('Current Settings');
$crumbs = $this->buildApplicationCrumbs()->addTextCrumb($title);
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Current Settings'));
$panel->setTable($table);
$versions = $this->loadVersions();
$version_property_list = id(new PHUIPropertyListView());
foreach ($versions as $version) {
list($name, $hash) = $version;
$version_property_list->addProperty($name, $hash);
}
$object_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Current Version'))->addPropertyList($version_property_list);
$phabricator_root = dirname(phutil_get_library_root('phabricator'));
$version_path = $phabricator_root . '/conf/local/VERSION';
if (Filesystem::pathExists($version_path)) {
$version_from_file = Filesystem::readFile($version_path);
$version_property_list->addProperty(pht('Local Version'), $version_from_file);
}
$nav = $this->buildSideNavView();
$nav->selectFilter('all/');
$nav->setCrumbs($crumbs);
$nav->appendChild($object_box);
$nav->appendChild($panel);
return $this->buildApplicationPage($nav, array('title' => $title));
}
示例10: 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(pht('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(pht('Symbol'), pht('Count'), javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Total wall time spent in this function and all of ' . 'its children (children are other functions it called ' . 'while executing).'), 'size' => 200)), pht('Wall Time (Inclusive)')), '%', javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Wall time spent in this function, excluding time ' . 'spent in children (children are other functions it ' . 'called while executing).'), 'size' => 200)), pht('Wall Time (Exclusive)')), '%'));
$table->setColumnClasses(array('wide pri', 'n', 'n', 'n', 'n', 'n'));
$panel = new PHUIObjectBoxView();
$header = id(new PHUIHeaderView())->setHeader(pht('XHProf Profile'));
if ($this->file) {
$button = id(new PHUIButtonView())->setHref($this->file->getBestURI())->setText(pht('Download %s Profile', '.xhprof'))->setTag('a');
$header->addActionLink($button);
}
$panel->setHeader($header);
$panel->setTable($table);
return $panel->render();
}
示例11: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$drequest = $this->diffusionRequest;
$viewer = $request->getUser();
$repository = $drequest->getRepository();
$page_size = $request->getInt('pagesize', 100);
$offset = $request->getInt('offset', 0);
$params = array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => $offset, 'limit' => $page_size + 1);
if (!$request->getBool('copies')) {
$params['needDirectChanges'] = true;
$params['needChildChanges'] = true;
}
$history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', $params);
$history = DiffusionPathChange::newFromConduit($history_results['pathChanges']);
$pager = new PHUIPagerView();
$pager->setPageSize($page_size);
$pager->setOffset($offset);
$history = $pager->sliceResults($history);
$pager->setURI($request->getRequestURI(), 'offset');
$show_graph = !strlen($drequest->getPath());
$content = array();
$history_table = new DiffusionHistoryTableView();
$history_table->setUser($request->getUser());
$history_table->setDiffusionRequest($drequest);
$history_table->setHistory($history);
$history_table->loadRevisions();
$phids = $history_table->getRequiredHandlePHIDs();
$handles = $this->loadViewerHandles($phids);
$history_table->setHandles($handles);
if ($show_graph) {
$history_table->setParents($history_results['parents']);
$history_table->setIsHead($offset == 0);
}
$history_panel = new PHUIObjectBoxView();
$history_panel->setHeaderText(pht('History'));
$history_panel->setTable($history_table);
$content[] = $history_panel;
$header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($repository)->setHeader($this->renderPathLinks($drequest, $mode = 'history'));
$actions = $this->buildActionView($drequest);
$properties = $this->buildPropertyView($drequest, $actions);
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history'));
return $this->buildApplicationPage(array($crumbs, $object_box, $content, $pager), array('title' => array(pht('History'), pht('%s Repository', $drequest->getRepository()->getCallsign()))));
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$response = $this->loadDiffusionContext();
if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$pager = id(new PHUIPagerView())->readFromRequest($request);
$params = array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => $pager->getOffset(), 'limit' => $pager->getPageSize() + 1);
if (!$request->getBool('copies')) {
$params['needDirectChanges'] = true;
$params['needChildChanges'] = true;
}
$history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', $params);
$history = DiffusionPathChange::newFromConduit($history_results['pathChanges']);
$history = $pager->sliceResults($history);
$show_graph = !strlen($drequest->getPath());
$content = array();
$history_table = id(new DiffusionHistoryTableView())->setUser($request->getUser())->setDiffusionRequest($drequest)->setHistory($history);
$history_table->loadRevisions();
if ($show_graph) {
$history_table->setParents($history_results['parents']);
$history_table->setIsHead(!$pager->getOffset());
$history_table->setIsTail(!$pager->getHasMorePages());
}
$history_panel = new PHUIObjectBoxView();
$history_panel->setHeaderText(pht('History'));
$history_panel->setTable($history_table);
$content[] = $history_panel;
$header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($repository)->setHeader($this->renderPathLinks($drequest, $mode = 'history'));
$actions = $this->buildActionView($drequest);
$properties = $this->buildPropertyView($drequest, $actions);
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history'));
$pager_box = $this->renderTablePagerBox($pager);
return $this->newPage()->setTitle(array(pht('History'), $repository->getDisplayName()))->setCrumbs($crumbs)->appendChild(array($object_box, $content, $pager_box));
}
示例13: renderExample
public function renderExample()
{
$rows = array(array('make' => 'Honda', 'model' => 'Civic', 'year' => 2004, 'price' => 3199, 'color' => pht('Blue')), array('make' => 'Ford', 'model' => 'Focus', 'year' => 2001, 'price' => 2549, 'color' => pht('Red')), array('make' => 'Toyota', 'model' => 'Camry', 'year' => 2009, 'price' => 4299, 'color' => pht('Black')), array('make' => 'NASA', 'model' => 'Shuttle', 'year' => 1998, 'price' => 1000000000, 'color' => pht('White')));
$request = $this->getRequest();
$orders = array('make', 'model', 'year', 'price');
$sort = $request->getStr('sort');
list($sort, $reverse) = AphrontTableView::parseSort($sort);
if (!in_array($sort, $orders)) {
$sort = 'make';
}
$rows = isort($rows, $sort);
if ($reverse) {
$rows = array_reverse($rows);
}
$table = new AphrontTableView($rows);
$table->setHeaders(array(pht('Make'), pht('Model'), pht('Year'), pht('Price'), pht('Color')));
$table->setColumnClasses(array('', 'wide', 'n', 'n', ''));
$table->makeSortable($request->getRequestURI(), 'sort', $sort, $reverse, $orders);
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Sortable Table of Vehicles'));
$panel->setTable($table);
return $panel;
}
示例14: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $this->getUser();
$editable = PhabricatorEnv::getEnvConfig('account.editable');
$uri = $request->getRequestURI();
$uri->setQueryParams(array());
if ($editable) {
$new = $request->getStr('new');
if ($new) {
return $this->returnNewAddressResponse($request, $uri, $new);
}
$delete = $request->getInt('delete');
if ($delete) {
return $this->returnDeleteAddressResponse($request, $uri, $delete);
}
}
$verify = $request->getInt('verify');
if ($verify) {
return $this->returnVerifyAddressResponse($request, $uri, $verify);
}
$primary = $request->getInt('primary');
if ($primary) {
return $this->returnPrimaryAddressResponse($request, $uri, $primary);
}
$emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID());
$rowc = array();
$rows = array();
foreach ($emails as $email) {
$button_verify = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('verify', $email->getID()), 'sigil' => 'workflow'), pht('Verify'));
$button_make_primary = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('primary', $email->getID()), 'sigil' => 'workflow'), pht('Make Primary'));
$button_remove = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('delete', $email->getID()), 'sigil' => 'workflow'), pht('Remove'));
$button_primary = phutil_tag('a', array('class' => 'button small disabled'), pht('Primary'));
if (!$email->getIsVerified()) {
$action = $button_verify;
} else {
if ($email->getIsPrimary()) {
$action = $button_primary;
} else {
$action = $button_make_primary;
}
}
if ($email->getIsPrimary()) {
$remove = $button_primary;
$rowc[] = 'highlighted';
} else {
$remove = $button_remove;
$rowc[] = null;
}
$rows[] = array($email->getAddress(), $action, $remove);
}
$table = new AphrontTableView($rows);
$table->setHeaders(array(pht('Email'), pht('Status'), pht('Remove')));
$table->setColumnClasses(array('wide', 'action', 'action'));
$table->setRowClasses($rowc);
$table->setColumnVisibility(array(true, true, $editable));
$view = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$header->setHeader(pht('Email Addresses'));
if ($editable) {
$button = new PHUIButtonView();
$button->setText(pht('Add New Address'));
$button->setTag('a');
$button->setHref($uri->alter('new', 'true'));
$button->setIcon('fa-plus');
$button->addSigil('workflow');
$header->addActionLink($button);
}
$view->setHeader($header);
$view->setTable($table);
return $view;
}
示例15: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$user = $request->getUser();
$this->name = $request->getURIData('name');
$query = id(new DiffusionSymbolQuery())->setViewer($user)->setName($this->name);
if ($request->getStr('context')) {
$query->setContext($request->getStr('context'));
}
if ($request->getStr('type')) {
$query->setType($request->getStr('type'));
}
if ($request->getStr('lang')) {
$query->setLanguage($request->getStr('lang'));
}
if ($request->getStr('repositories')) {
$phids = $request->getStr('repositories');
$phids = explode(',', $phids);
$phids = array_filter($phids);
if ($phids) {
$repos = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs($phids)->execute();
$repos = mpull($repos, 'getPHID');
if ($repos) {
$query->withRepositoryPHIDs($repos);
}
}
}
$query->needPaths(true);
$query->needRepositories(true);
$symbols = $query->execute();
$external_query = id(new DiffusionExternalSymbolQuery())->withNames(array($this->name));
if ($request->getStr('context')) {
$external_query->withContexts(array($request->getStr('context')));
}
if ($request->getStr('type')) {
$external_query->withTypes(array($request->getStr('type')));
}
if ($request->getStr('lang')) {
$external_query->withLanguages(array($request->getStr('lang')));
}
$external_sources = id(new PhutilClassMapQuery())->setAncestorClass('DiffusionExternalSymbolsSource')->execute();
$results = array($symbols);
foreach ($external_sources as $source) {
$results[] = $source->executeQuery($external_query);
}
$symbols = array_mergev($results);
if ($request->getBool('jump') && count($symbols) == 1) {
// If this is a clickthrough from Differential, just jump them
// straight to the target if we got a single hit.
$symbol = head($symbols);
return id(new AphrontRedirectResponse())->setIsExternal($symbol->isExternal())->setURI($symbol->getURI());
}
$rows = array();
foreach ($symbols as $symbol) {
$href = $symbol->getURI();
if ($symbol->isExternal()) {
$source = $symbol->getSource();
$location = $symbol->getLocation();
} else {
$repo = $symbol->getRepository();
$file = $symbol->getPath();
$line = $symbol->getLineNumber();
$source = $repo->getMonogram();
$location = $file . ':' . $line;
}
$location = phutil_tag('a', array('href' => $href), $location);
$rows[] = array($symbol->getSymbolType(), $symbol->getSymbolContext(), $symbol->getSymbolName(), $symbol->getSymbolLanguage(), $source, $location);
}
$table = new AphrontTableView($rows);
$table->setHeaders(array(pht('Type'), pht('Context'), pht('Name'), pht('Language'), pht('Source'), pht('Location')));
$table->setColumnClasses(array('', '', 'pri', '', '', ''));
$table->setNoDataString(pht('No matching symbol could be found in any indexed repository.'));
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Similar Symbols'));
$panel->setTable($table);
return $this->buildApplicationPage($panel, array('title' => pht('Find Symbol')));
}