本文整理汇总了PHP中phutil_utf8_shorten函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_utf8_shorten函数的具体用法?PHP phutil_utf8_shorten怎么用?PHP phutil_utf8_shorten使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phutil_utf8_shorten函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: renderValueForRevisionView
public function renderValueForRevisionView()
{
$diff = $this->getDiff();
$ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
$umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
$postponed_count = 0;
$udata = $this->getDiffProperty('arc:unit');
$utail = null;
if ($udata) {
$unit_messages = array();
foreach ($udata as $test) {
$name = idx($test, 'name');
$result = idx($test, 'result');
if ($result != DifferentialUnitTestResult::RESULT_POSTPONED && $result != DifferentialUnitTestResult::RESULT_PASS) {
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$userdata = phutil_utf8_shorten(idx($test, 'userdata'), 512);
$userdata = $engine->markupText($userdata);
$unit_messages[] = '<li>' . '<span class="unit-result-' . phutil_escape_html($result) . '">' . phutil_escape_html(ucwords($result)) . '</span>' . ' ' . phutil_escape_html($name) . '<p>' . $userdata . '</p>' . '</li>';
} else {
if ($result == DifferentialUnitTestResult::RESULT_POSTPONED) {
$postponed_count++;
}
}
}
$uexcuse = $this->getUnitExcuse();
if ($unit_messages) {
$utail = '<div class="differential-unit-block">' . $uexcuse . '<ul>' . implode("\n", $unit_messages) . '</ul>' . '</div>';
}
}
if ($postponed_count > 0 && $diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) {
$umsg = $postponed_count . ' ' . $umsg;
}
return $ustar . ' ' . $umsg . $utail;
}
开发者ID:ramons03,项目名称:phabricator,代码行数:34,代码来源:DifferentialUnitFieldSpecification.php
示例2: fail
private function fail($near, $message)
{
$message = sprintf('%s near: %s', $message, phutil_utf8_shorten($near, 32000));
if ($this->getEngine()->isTextMode()) {
return '(' . $message . ')';
}
return hsprintf('<div style="color: red;">%s</div>', $message);
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:8,代码来源:PhutilRemarkupEngineRemarkupTableBlockRule.php
示例3: getSummary
public function getSummary()
{
$message = $this->getCommitMessage();
$lines = explode("\n", $message);
$summary = head($lines);
$summary = phutil_utf8_shorten($summary, self::SUMMARY_MAX_LENGTH);
return $summary;
}
开发者ID:ramons03,项目名称:phabricator,代码行数:8,代码来源:PhabricatorRepositoryCommitData.php
示例4: testUTF8shorten
public function testUTF8shorten()
{
$inputs = array(array("1erp derp derp", 9, "", "1erp derp"), array("2erp derp derp", 12, "...", "2erp derp..."), array("derpxderpxderp", 12, "...", "derpxderp..."), array("derp♃derpderp", 12, "...", "derp♃derp..."), array("", 12, "...", ""), array("derp", 12, "...", "derp"), array("11111", 5, "2222", "11111"), array("111111", 5, "2222", "12222"), array("D1rp. Derp derp.", 7, "...", "D1rp."), array("D2rp. Derp derp.", 5, "...", "D2rp."), array("D3rp. Derp derp.", 4, "...", "D..."), array("D4rp. Derp derp.", 14, "...", "D4rp. Derp..."), array("D5rpderp, derp derp", 16, "...", "D5rpderp..."), array("D6rpderp, derp derp", 17, "...", "D6rpderp, derp..."), array("Gr͠mpyCatSmiles", 8, "...", "Gr͠mpy..."), array("X͠͠͠Y", 1, "", "X͠͠͠"), array("Derp, supercalafragalisticexpialadoshus", 30, "...", "Derp..."), array("((((((((((", 8, '...', '(((((...'), array('derp', 3, 'quack', 'quack'));
foreach ($inputs as $input) {
list($string, $length, $terminal, $expect) = $input;
$result = phutil_utf8_shorten($string, $length, $terminal);
$this->assertEqual($expect, $result, 'Shortening of ' . $string);
}
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:9,代码来源:PhutilUTF8TestCase.php
示例5: writeAndRead
private function writeAndRead($write, $read)
{
$future = new ExecFuture('cat');
$future->write($write);
$lines = array();
foreach (new LinesOfALargeExecFuture($future) as $line) {
$lines[] = $line;
}
$this->assertEqual($read, $lines, "Write: " . phutil_utf8_shorten($write, 32));
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:10,代码来源:LinesOfALargeExecFutureTestCase.php
示例6: writeAndRead
private function writeAndRead($write, $read, $delimiter = "\n")
{
$tmp = new TempFile();
Filesystem::writeFile($tmp, $write);
$lines = array();
$iterator = id(new LinesOfALargeFile($tmp))->setDelimiter($delimiter);
foreach ($iterator as $n => $line) {
$lines[$n - 1] = $line;
}
$this->assertEqual($read, $lines, "Write: " . phutil_utf8_shorten($write, 32));
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:11,代码来源:LinesOfALargeFileTestCase.php
示例7: flagWasEdited
private static function flagWasEdited($flag, $verb)
{
$color = idx(self::$colorMap, $flag['color'], 'cyan');
$note = $flag['note'];
if ($note) {
// Make sure notes that are long or have line breaks in them or
// whatever don't mess up the formatting.
$note = implode(' ', preg_split('/\\s+/', $note));
$note = ' (' . phutil_utf8_shorten($note, 40, '...') . ')';
}
echo phutil_console_format("<fg:{$color}>%s</fg> flag%s {$verb}!\n", $flag['colorName'], $note);
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:12,代码来源:ArcanistFlagWorkflow.php
示例8: renderView
public function renderView()
{
$data = $this->getStoryData();
$author_phid = $data->getAuthorPHID();
$owner_phid = $data->getValue('ownerPHID');
$task_phid = $data->getValue('taskPHID');
$objects = $this->getObjects();
$action = $data->getValue('action');
$view = new PhabricatorFeedStoryView();
$verb = ManiphestAction::getActionPastTenseVerb($action);
$extra = null;
switch ($action) {
case ManiphestAction::ACTION_ASSIGN:
if ($owner_phid) {
$extra = ' to ' . '<strong>' . $this->getHandle($owner_phid)->renderLink() . '</strong>';
} else {
$verb = 'placed';
$extra = ' up for grabs';
}
break;
}
$title = '<strong>' . $this->getHandle($author_phid)->renderLink() . '</strong>' . " {$verb} task " . '<strong>' . $this->getHandle($task_phid)->renderLink() . '</strong>';
$title .= $extra;
$title .= '.';
$view->setTitle($title);
switch ($action) {
case ManiphestAction::ACTION_CREATE:
$full_size = true;
break;
default:
$full_size = false;
break;
}
$view->setEpoch($data->getEpoch());
if ($full_size) {
if (!empty($objects[$author_phid])) {
$image_phid = $objects[$author_phid]->getProfileImagePHID();
$image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid);
$view->setImage($image_uri);
}
$content = phutil_escape_html(phutil_utf8_shorten($data->getValue('description'), 128));
$content = str_replace("\n", '<br />', $content);
$view->appendChild($content);
} else {
$view->setOneLineStory(true);
}
return $view;
}
开发者ID:netcomtec,项目名称:phabricator,代码行数:48,代码来源:PhabricatorFeedStoryManiphest.php
示例9: testUTF8shorten
public function testUTF8shorten()
{
$inputs = array(array("1erp derp derp", 9, "", "1erp derp"), array("2erp derp derp", 12, "...", "2erp derp..."), array("derpxderpxderp", 12, "...", "derpxderp..."), array("derp♃derpderp", 12, "...", "derp♃derp..."), array("", 12, "...", ""), array("derp", 12, "...", "derp"), array("11111", 5, "2222", "11111"), array("111111", 5, "2222", "12222"), array("D1rp. Derp derp.", 7, "...", "D1rp."), array("D2rp. Derp derp.", 5, "...", "D2rp."), array("D3rp. Derp derp.", 4, "...", "D..."), array("D4rp. Derp derp.", 14, "...", "D4rp. Derp..."), array("D5rpderp, derp derp", 16, "...", "D5rpderp..."), array("D6rpderp, derp derp", 17, "...", "D6rpderp, derp..."), array("Derp, supercalafragalisticexpialadoshus", 30, "...", "Derp..."), array("((((((((((", 8, '...', '(((((...'));
foreach ($inputs as $input) {
list($string, $length, $terminal, $expect) = $input;
$result = phutil_utf8_shorten($string, $length, $terminal);
$this->assertEqual($expect, $result, 'Shortening of ' . $string);
}
try {
phutil_utf8_shorten('derp', 3, 'quack');
$caught = false;
} catch (Exception $ex) {
$caught = true;
}
$this->assertEqual(true, $caught, 'Expect exception for terminal.');
}
开发者ID:relrod,项目名称:libphutil,代码行数:16,代码来源:PhutilUTF8TestCase.php
示例10: processRequest
public function processRequest()
{
$projects = id(new PhabricatorProject())->loadAllWhere('1 = 1 ORDER BY id DESC limit 100');
$project_phids = mpull($projects, 'getPHID');
$profiles = array();
if ($projects) {
$profiles = id(new PhabricatorProjectProfile())->loadAllWhere('projectPHID in (%Ls)', $project_phids);
$profiles = mpull($profiles, null, 'getProjectPHID');
}
$affil_groups = array();
if ($projects) {
$affil_groups = PhabricatorProjectAffiliation::loadAllForProjectPHIDs($project_phids);
}
$author_phids = mpull($projects, 'getAuthorPHID');
$handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles();
$query = id(new ManiphestTaskQuery())->withProjects($project_phids)->withAnyProject(true)->withStatus(ManiphestTaskQuery::STATUS_OPEN)->setLimit(PHP_INT_MAX);
$tasks = $query->execute();
$groups = array();
foreach ($tasks as $task) {
foreach ($task->getProjectPHIDs() as $phid) {
$groups[$phid][] = $task;
}
}
$rows = array();
foreach ($projects as $project) {
$phid = $project->getPHID();
$profile = $profiles[$phid];
$affiliations = $affil_groups[$phid];
$group = idx($groups, $phid, array());
$task_count = count($group);
$population = count($affiliations);
$status = PhabricatorProjectStatus::getNameForStatus($project->getStatus());
$blurb = $profile->getBlurb();
$blurb = phutil_utf8_shorten($blurb, $columns = 100);
$rows[] = array(phutil_escape_html($project->getName()), phutil_escape_html($blurb), $handles[$project->getAuthorPHID()]->renderLink(), phutil_escape_html($population), phutil_escape_html($status), phutil_render_tag('a', array('href' => '/maniphest/view/all/?projects=' . $phid), phutil_escape_html($task_count)), phutil_render_tag('a', array('class' => 'small grey button', 'href' => '/project/view/' . $project->getID() . '/'), 'View Project Profile'));
}
$table = new AphrontTableView($rows);
$table->setHeaders(array('Project', 'Description', 'Mastermind', 'Population', 'Status', 'Open Tasks', ''));
$table->setColumnClasses(array('pri', 'wide', '', 'right', '', 'right', 'action'));
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('Project');
$panel->setCreateButton('Create New Project', '/project/create/');
return $this->buildStandardPageResponse($panel, array('title' => 'Projects'));
}
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:45,代码来源:PhabricatorProjectListController.php
示例11: render
public function render()
{
require_celerity_resource('phabricator-project-tag-css');
$show = array_slice($this->handles, 0, 2);
$tags = array();
foreach ($show as $handle) {
$tags[] = phutil_render_tag('a', array('href' => $handle->getURI(), 'class' => 'phabricator-project-tag'), phutil_escape_html(phutil_utf8_shorten($handle->getName(), 24)));
}
if (count($this->handles) > 2) {
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips');
$all = array();
foreach ($this->handles as $handle) {
$all[] = $handle->getName();
}
$tags[] = javelin_render_tag('span', array('class' => 'phabricator-project-tag', 'sigil' => 'has-tooltip', 'meta' => array('tip' => implode(', ', $all), 'size' => 200)), "…");
}
return implode("\n", $tags);
}
开发者ID:nexeck,项目名称:phabricator,代码行数:19,代码来源:ManiphestTaskProjectsView.php
示例12: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$offset = $request->getInt('offset', 0);
$page_size = 1000;
$pager = new AphrontPagerView();
$request_uri = $request->getRequestURI();
$pager->setURI($request_uri, 'offset');
$pager->setPageSize($page_size);
$pager->setOffset($offset);
$query = new PhabricatorChatLogQuery();
$query->withChannels(array($this->channel));
$logs = $query->executeWithPager($pager);
require_celerity_resource('phabricator-chatlog-css');
$last_author = null;
$last_epoch = null;
$row_idx = 0;
$row_colors = array('normal', 'alternate');
$out = array();
$out[] = '<table class="phabricator-chat-log">';
foreach ($logs as $log) {
$this_author = $log->getAuthor();
$this_epoch = $log->getEpoch();
if ($this_author !== $last_author || $this_epoch - 60 * 5 > $last_epoch) {
++$row_idx;
$out[] = '<tr class="initial ' . $row_colors[$row_idx % 2] . '">';
$out[] = '<td class="timestamp">' . phabricator_datetime($log->getEpoch(), $user) . '</td>';
$author = $log->getAuthor();
$author = phutil_utf8_shorten($author, 18);
$out[] = '<td class="author">' . phutil_escape_html($author) . '</td>';
} else {
$out[] = '<tr class="' . $row_colors[$row_idx % 2] . '">';
$out[] = '<td class="similar" colspan="2"></td>';
}
$out[] = '<td class="message">' . phutil_escape_html($log->getMessage()) . '</td>';
$out[] = '</tr>';
$last_author = $this_author;
$last_epoch = $this_epoch;
}
$out[] = '</table>';
return $this->buildStandardPageResponse(array(implode("\n", $out), $pager), array('title' => 'Channel Log'));
}
开发者ID:ramons03,项目名称:phabricator,代码行数:43,代码来源:PhabricatorChatLogChannelLogController.php
示例13: buildQuestionListView
private function buildQuestionListView(array $questions)
{
assert_instances_of($questions, 'PonderQuestion');
$user = $this->getRequest()->getUser();
$view = new PhabricatorObjectItemListView();
$view->setNoDataString(pht('No matching questions.'));
foreach ($questions as $question) {
$item = new PhabricatorObjectItemView();
$item->setHeader('Q' . $question->getID() . ' ' . $question->getTitle());
$item->setHref('/Q' . $question->getID());
$desc = $question->getContent();
if ($desc) {
$item->addDetail(pht('Description'), phutil_escape_html(phutil_utf8_shorten($desc, 128)));
}
$item->addDetail(pht('Author'), $this->getHandle($question->getAuthorPHID())->renderLink());
$item->addDetail(pht('Votes'), $question->getVoteCount());
$item->addDetail(pht('Answers'), $question->getAnswerCount());
$created = pht('Created %s', phabricator_date($question->getDateCreated(), $user));
$item->addAttribute($created);
$view->addItem($item);
}
return $view;
}
开发者ID:rudimk,项目名称:phabricator,代码行数:23,代码来源:PonderFeedController.php
示例14: buildDisplayRows
//.........这里部分代码省略.........
$color = '#ffd';
// Render as warning.
} else {
$color_ratio = ($blame['epoch'] - $epoch_min) / $epoch_range;
$color_value = 0xf6 * (1.0 - $color_ratio);
$color = sprintf('#%02x%02x%02x', $color_value, 0xf6, $color_value);
}
$display_line['epoch'] = idx($blame, 'epoch');
$display_line['color'] = $color;
$display_line['commit'] = $rev;
if (isset($blame['handle'])) {
$author_link = $blame['handle']->renderLink();
} else {
$author_link = phutil_render_tag('span', array(), phutil_escape_html($blame['author']));
}
$display_line['author'] = $author_link;
$last_rev = $rev;
}
}
if ($line_arr) {
if ($line_number == $line_arr[0]['min']) {
$display_line['target'] = true;
}
foreach ($line_arr as $range) {
if ($line_number >= $range['min'] && $line_number <= $range['max']) {
$display_line['highlighted'] = true;
}
}
}
$display[] = $display_line;
++$line_number;
}
$commits = array_filter(ipull($display, 'commit'));
if ($commits) {
$commits = id(new PhabricatorAuditCommitQuery())->withIdentifiers($drequest->getRepository()->getID(), $commits)->needCommitData(true)->execute();
$commits = mpull($commits, null, 'getCommitIdentifier');
}
$revision_ids = id(new DifferentialRevision())->loadIDsByCommitPHIDs(mpull($commits, 'getPHID'));
$revisions = array();
if ($revision_ids) {
$revisions = id(new DifferentialRevision())->loadAllWhere('id IN (%Ld)', $revision_ids);
}
$request = $this->getRequest();
$user = $request->getUser();
Javelin::initBehavior('phabricator-oncopy', array());
$rows = array();
foreach ($display as $line) {
$line_href = $drequest->generateURI(array('action' => 'browse', 'line' => $line['line'], 'stable' => true));
$blame = array();
if ($line['color']) {
$color = $line['color'];
$before_link = null;
$commit_link = null;
$revision_link = null;
if (idx($line, 'commit')) {
$commit = $line['commit'];
$summary = 'Unknown';
if (idx($commits, $commit)) {
$summary = $commits[$commit]->getCommitData()->getSummary();
}
$tooltip = phabricator_date($line['epoch'], $user) . " · " . $summary;
Javelin::initBehavior('phabricator-tooltips', array());
require_celerity_resource('aphront-tooltip-css');
$commit_link = javelin_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'commit', 'commit' => $line['commit'])), 'sigil' => 'has-tooltip', 'meta' => array('tip' => $tooltip, 'align' => 'E', 'size' => 600)), phutil_escape_html(phutil_utf8_shorten($line['commit'], 9, '')));
$revision_id = null;
if (idx($commits, $commit)) {
$revision_id = idx($revision_ids, $commits[$commit]->getPHID());
}
if ($revision_id) {
$revision = idx($revisions, $revision_id);
if (!$revision) {
$tooltip = '(Invalid revision)';
} else {
$tooltip = phabricator_date($revision->getDateModified(), $user) . " · " . $revision->getTitle();
}
$revision_link = javelin_render_tag('a', array('href' => '/D' . $revision_id, 'sigil' => 'has-tooltip', 'meta' => array('tip' => $tooltip, 'align' => 'E', 'size' => 600)), 'D' . $revision_id);
}
$uri = $line_href->alter('before', $commit);
$before_link = javelin_render_tag('a', array('href' => $uri->setQueryParam('view', 'blame'), 'sigil' => 'has-tooltip', 'meta' => array('tip' => 'Skip Past This Commit', 'align' => 'E', 'size' => 300)), "«");
}
$blame[] = phutil_render_tag('th', array('class' => 'diffusion-blame-link', 'style' => 'background: ' . $color), $before_link);
$blame[] = phutil_render_tag('th', array('class' => 'diffusion-rev-link', 'style' => 'background: ' . $color), $commit_link);
$blame[] = phutil_render_tag('th', array('class' => 'diffusion-rev-link', 'style' => 'background: ' . $color), $revision_link);
$blame[] = phutil_render_tag('th', array('class' => 'diffusion-author-link', 'style' => 'background: ' . $color), idx($line, 'author'));
}
$line_link = phutil_render_tag('a', array('href' => $line_href), phutil_escape_html($line['line']));
$blame[] = javelin_render_tag('th', array('class' => 'diffusion-line-link', 'sigil' => 'diffusion-line-link', 'style' => isset($color) ? 'background: ' . $color : null), $line_link);
Javelin::initBehavior('diffusion-line-linker');
$blame = implode('', $blame);
if ($line['target']) {
Javelin::initBehavior('diffusion-jump-to', array('target' => 'scroll_target'));
$anchor_text = '<a id="scroll_target"></a>';
} else {
$anchor_text = null;
}
$line_text = phutil_render_tag('td', array(), $anchor_text . "" . $line['data']);
$rows[] = phutil_render_tag('tr', array('class' => $line['highlighted'] ? 'highlighted' : null), $blame . $line_text);
}
return $rows;
}
开发者ID:rudimk,项目名称:phabricator,代码行数:101,代码来源:DiffusionBrowseFileController.php
示例15: loadHandles
//.........这里部分代码省略.........
$handle = new PhabricatorObjectHandle();
$handle->setPHID($phid);
$handle->setType($type);
if (empty($projects[$phid])) {
$handle->setName('Unknown Arcanist Project');
} else {
$project = $projects[$phid];
$handle->setName($project->getName());
$handle->setComplete(true);
}
$handles[$phid] = $handle;
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_WIKI:
$document_dao = new PhrictionDocument();
$content_dao = new PhrictionContent();
$conn = $document_dao->establishConnection('r');
$documents = queryfx_all($conn, 'SELECT * FROM %T document JOIN %T content
ON document.contentID = content.id
WHERE document.phid IN (%Ls)', $document_dao->getTableName(), $content_dao->getTableName(), $phids);
$documents = ipull($documents, null, 'phid');
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();
$handle->setPHID($phid);
$handle->setType($type);
if (empty($documents[$phid])) {
$handle->setName('Unknown Document');
} else {
$info = $documents[$phid];
$handle->setName($info['title']);
$handle->setURI(PhrictionDocument::getSlugURI($info['slug']));
$handle->setComplete(true);
}
$handles[$phid] = $handle;
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_QUES:
$questions = id(new PonderQuestionQuery())->withPHIDs($phids)->execute();
$questions = mpull($questions, null, 'getPHID');
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();
$handle->setPHID($phid);
$handle->setType($type);
if (empty($questions[$phid])) {
$handle->setName('Unknown Ponder Question');
} else {
$question = $questions[$phid];
$handle->setName(phutil_utf8_shorten($question->getTitle(), 60));
$handle->setURI(new PhutilURI('Q' . $question->getID()));
$handle->setComplete(true);
}
$handles[$phid] = $handle;
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_PSTE:
$pastes = id(new PhabricatorPasteQuery())->withPHIDs($phids)->setViewer($this->viewer)->execute();
$pastes = mpull($pastes, null, 'getPHID');
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();
$handle->setPHID($phid);
$handle->setType($type);
if (empty($pastes[$phid])) {
$handle->setName('Unknown Paste');
} else {
$paste = $pastes[$phid];
$handle->setName($paste->getTitle());
$handle->setFullName('P' . $paste->getID() . ': ' . $paste->getTitle());
$handle->setURI('/P' . $paste->getID());
$handle->setComplete(true);
}
$handles[$phid] = $handle;
}
break;
default:
$loader = null;
if (isset($external_loaders[$type])) {
$loader = $external_loaders[$type];
} else {
if (isset($external_loaders['*'])) {
$loader = $external_loaders['*'];
}
}
if ($loader) {
$object = newv($loader, array());
$handles += $object->loadHandles($phids);
break;
}
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();
$handle->setType($type);
$handle->setPHID($phid);
$handle->setName('Unknown Object');
$handle->setFullName('An Unknown Object');
$handles[$phid] = $handle;
}
break;
}
}
return $handles;
}
开发者ID:neoxen,项目名称:phabricator,代码行数:101,代码来源:PhabricatorObjectHandleData.php
示例16: render
public function render()
{
$user = $this->user;
if (!$user) {
throw new Exception("Call setUser() before render()-ing this view.");
}
$local = $this->localCommits;
if (!$local) {
return null;
}
require_celerity_resource('differential-local-commits-view-css');
$has_tree = false;
$has_local = false;
foreach ($local as $commit) {
if (idx($commit, 'tree')) {
$has_tree = true;
}
if (idx($commit, 'local')) {
$has_local = true;
}
}
$rows = array();
foreach ($local as $commit) {
$row = array();
if (idx($commit, 'commit')) {
$commit_hash = substr($commit['commit'], 0, 16);
} else {
if (isset($commit['rev'])) {
$commit_hash = substr($commit['rev'], 0, 16);
} else {
$commit_hash = null;
}
}
$row[] = '<td>' . phutil_escape_html($commit_hash) . '</td>';
if ($has_tree) {
$tree = idx($commit, 'tree');
$tree = substr($tree, 0, 16);
$row[] = '<td>' . phutil_escape_html($tree) . '</td>';
}
if ($has_local) {
$local_rev = idx($commit, 'local', null);
$row[] = '<td>' . phutil_escape_html($local_rev) . '</td>';
}
$parents = idx($commit, 'parents', array());
foreach ($parents as $k => $parent) {
if (is_array($parent)) {
$parent = idx($parent, 'rev');
}
$parents[$k] = phutil_escape_html(substr($parent, 0, 16));
}
$parents = implode('<br />', $parents);
$row[] = '<td>' . $parents . '</td>';
$author = nonempty(idx($commit, 'user'), idx($commit, 'author'));
$row[] = '<td>' . phutil_escape_html($author) . '</td>';
$message = idx($commit, 'message');
$summary = idx($commit, 'summary');
$summary = phutil_utf8_shorten($summary, 80);
$view = new AphrontMoreView();
$view->setSome(phutil_escape_html($summary));
if ($message && trim($summary) != trim($message)) {
$view->setMore(nl2br(phutil_escape_html($message)));
}
$row[] = phutil_render_tag('td', array('class' => 'summary'), $view->render());
$date = nonempty(idx($commit, 'date'), idx($commit, 'time'));
if ($date) {
$date = phabricator_datetime($date, $user);
}
$row[] = '<td>' . $date . '</td>';
$rows[] = '<tr>' . implode('', $row) . '</tr>';
}
$headers = array();
$headers[] = '<th>Commit</th>';
if ($has_tree) {
$headers[] = '<th>Tree</th>';
}
if ($has_local) {
$headers[] = '<th>Local</th>';
}
$headers[] = '<th>Parents</th>';
$headers[] = '<th>Author</th>';
$headers[] = '<th>Summary</th>';
$headers[] = '<th>Date</th>';
$headers = '<tr>' . implode('', $headers) . '</tr>';
return '<div class="differential-panel">' . '<h1>Local Commits</h1>' . '<table class="differential-local-commits-table">' . $headers . implode("\n", $rows) . '</table>' . '</div>';
}
开发者ID:nexeck,项目名称:phabricator,代码行数:85,代码来源:DifferentialLocalCommitsView.php
示例17: getCommitMessageFromUser
/**
* @task message
*/
private function getCommitMessageFromUser()
{
$conduit = $this->getConduit();
$template = null;
if (!$this->getArgument('verbatim')) {
$saved = $this->readScratchFile('create-message');
if ($saved) {
$where = $this->getReadableScratchFilePath('create-message');
$preview = explode("\n", $saved);
$preview = array_shift($preview);
$preview = trim($preview);
$preview = phutil_utf8_shorten($preview, 64);
if ($preview) {
$preview = "Message begins:\n\n {$preview}\n\n";
} else {
$preview = null;
}
echo "You have a saved revision message in '{$where}'.\n" . "{$preview}" . "You can use this message, or discard it.";
$use = phutil_console_confirm("Do you want to use this message?", $default_no = false);
if ($use) {
$template = $saved;
} else {
$this->removeScratchFile('create-message');
}
}
}
$template_is_default = false;
$notes = array();
$included = array();
list($fields, $notes, $included) = $this->getDefaultCreateFields();
if ($template) {
$fields = array();
$notes = array();
} else {
if (!$fields) {
$template_is_default = true;
}
if ($notes) {
$commit = head($this->getRepositoryAPI()->getLocalCommitInformation());
$template = $commit['message'];
} else {
$template = $conduit->callMethodSynchronous('differential.getcommitmessage', array('revision_id' => null, 'edit' => 'create', 'fields' => $fields));
}
}
if ($included) {
foreach ($included as $k => $commit) {
$included[$k] = ' ' . $commit;
}
$in_branch = '';
if (!$this->isRawDiffSource()) {
$in_branch = ' in branch ' . $this->getRepositoryAPI()->getBranchName();
}
$included = array_merge(array("", "Included commits{$in_branch}:", ""), $included, array(""));
} else {
$included = array('');
}
$issues = array_merge(array('NEW DIFFERENTIAL REVISION', 'Describe the changes in this new revision.'), $included, array('arc could not identify any existing revision in your working copy.', 'If you intended to update an existing revision, use:', '', ' $ arc diff --update <revision>'));
if ($notes) {
$issues = array_merge($issues, array(''), $notes);
}
$done = false;
$first = true;
while (!$done) {
$template = rtrim($template, "\r\n") . "\n\n";
foreach ($issues as $issue) {
$template .= '# ' . $issue . "\n";
}
$template .= "\n";
if ($first && $this->getArgument('verbatim') && !$template_is_default) {
$new_template = $template;
} else {
$new_template = $this->newInteractiveEditor($template)->setName('new-commit')->editInteractively();
}
$first = false;
if ($template_is_default && $new_template == $template) {
throw new ArcanistUsageException("Template not edited.");
}
$template = ArcanistCommentRemover::removeComments($new_template);
$wrote = $this->writeScratchFile('create-message', $template);
$where = $this->getReadableScratchFilePath('create-message');
try {
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($template);
$message->pullDataFromConduit($conduit);
$this->validateCommitMessage($message);
$done = true;
} catch (ArcanistDifferentialCommitMessageParserException $ex) {
echo "Commit message has errors:\n\n";
$issues = array('Resolve these errors:');
foreach ($ex->getParserErrors() as $error) {
echo phutil_console_wrap("- " . $error . "\n", 6);
$issues[] = ' - ' . $error;
}
echo "\n";
echo "You must resolve these errors to continue.";
$again = phutil_console_confirm("Do you want to edit the message?", $default_no = false);
if ($again) {
// Keep going.
//.........这里部分代码省略.........
开发者ID:rafikk,项目名称:arcanist,代码行数:101,代码来源:ArcanistDiffWorkflow.php
示例18: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$project = id(new PhabricatorProject())->load($this->id);
if (!$project) {
return new Aphront404Response();
}
$profile = $project->loadProfile();
if (!$profile) {
$profile = new PhabricatorProjectProfile();
}
$src_phid = $profile->getProfileImagePHID();
if (!$src_phid) {
$src_phid = $user->getProfileImagePHID();
}
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
if ($file) {
$picture = $file->getBestURI();
} else {
$picture = null;
}
$members = mpull($project->loadAffiliations(), null, 'getUserPHID');
$nav_view = new AphrontSideNavFilterView();
$uri = new PhutilURI('/project/view/' . $project->getID() . '/');
$nav_view->setBaseURI($uri);
$external_arrow = "↗";
$tasks_uri = '/maniphest/view/all/?projects=' . $project->getPHID();
$slug = PhabricatorSlug::normalize($project->getName());
$phriction_uri = '/w/projects/' . $slug;
$edit_uri = '/project/edit/' . $project->getID() . '/';
$nav_view->addFilter('dashboard', 'Dashboard');
$nav_view->addSpacer();
$nav_view->addFilter('feed', 'Feed');
$nav_view->addFilter(null, 'Tasks ' . $external_arrow, $tasks_uri);
$nav_view->addFilter(null, 'Wiki ' . $external_arrow, $phriction_uri);
$nav_view->addFilter('people', 'People');
$nav_view->addFilter('about', 'About');
$nav_view->addSpacer();
$nav_view->addFilter(null, "Edit Project…", $edit_uri);
$this->page = $nav_view->selectFilter($this->page, 'dashboard');
require_celerity_resource('phabricator-profile-css');
switch ($this->page) {
case 'dashboard':
$content = $this->renderTasksPage($project, $profile);
$query = new PhabricatorFeedQuery();
$query->setFilterPHIDs(array($project->getPHID()));
$stories = $query->execute();
$content .= $this->renderStories($stories);
break;
case 'about':
$content = $this->renderAboutPage($project, $profile);
break;
case 'people':
$content = $this->renderPeoplePage($project, $profile);
break;
case 'feed':
$content = $this->renderFeedPage($project, $profile);
break;
default:
throw new Exception("Unimplemented filter '{$this->page}'.");
}
$content = '<div style="padding: 1em;">' . $content . '</div>';
$nav_view->appendChild($content);
$header = new PhabricatorProfileHeaderView();
$header->setName($project->getName());
$header->setDescription(phutil_utf8_shorten($profile->getBlurb(), 1024));
$header->setProfilePicture($picture);
$action = null;
if (empty($members[$user->getPHID()])) {
$action = phabricator_render_form($user, array('action' => '/project/update/' . $project->getID() . '/join/', 'method' => 'post'), phutil_render_tag('button', array('class' => 'green'), 'Join Project'));
} else {
$action = javelin_render_tag('a', array('href' => '/project/update/' . $project->getID() . '/leave/', 'sigil' => 'workflow', 'class' => 'grey button'), 'Leave Project...');
}
$header->addAction($action);
$header->appendChild($nav_view);
return $this->buildStandardPageResponse($header, array('title'
|
请发表评论