本文整理汇总了PHP中hsprintf函数的典型用法代码示例。如果您正苦于以下问题:PHP hsprintf函数的具体用法?PHP hsprintf怎么用?PHP hsprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hsprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderValueForRevisionView
public function renderValueForRevisionView()
{
$diff = $this->getDiff();
$path_changesets = mpull($diff->loadChangesets(), 'getId', 'getFilename');
$lstar = DifferentialRevisionUpdateHistoryView::renderDiffLintStar($diff);
$lmsg = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff);
$ldata = $this->getDiffProperty('arc:lint');
$ltail = null;
if ($ldata) {
$ldata = igroup($ldata, 'path');
$lint_messages = array();
foreach ($ldata as $path => $messages) {
$message_markup = array();
foreach ($messages as $message) {
$path = idx($message, 'path');
$line = idx($message, 'line');
$code = idx($message, 'code');
$severity = idx($message, 'severity');
$name = idx($message, 'name');
$description = idx($message, 'description');
$line_link = phutil_escape_html($line);
if (isset($path_changesets[$path])) {
// TODO: Create standalone links for large diffs. Logic is in
// DifferentialDiffTableOfContentsView::renderChangesetLink().
$line_link = phutil_render_tag('a', array('href' => '#C' . $path_changesets[$path] . 'NL' . $line), $line_link);
}
$message_markup[] = hsprintf('<li>' . '<span class="lint-severity-%s">%s</span> (%s) %s ' . 'at line ' . $line_link . '<p>%s</p>' . '</li>', $severity, ucwords($severity), $code, $name, $description);
}
$lint_messages[] = '<li class="lint-file-block">' . 'Lint for <strong>' . phutil_escape_html($path) . '</strong>' . '<ul>' . implode("\n", $message_markup) . '</ul>' . '</li>';
}
$lexcuse = $this->getLintExcuse();
$ltail = '<div class="differential-lint-block">' . $lexcuse . '<ul>' . implode("\n", $lint_messages) . '</ul>' . '</div>';
}
return $lstar . ' ' . $lmsg . $ltail;
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getUser();
$file = PhabricatorFile::initializeNewFile();
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$view_policy = $request->getStr('viewPolicy');
if (!$request->getFileExists('file')) {
$e_file = pht('Required');
$errors[] = pht('You must select a file to upload.');
} else {
$file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'isExplicitUpload' => true));
}
if (!$errors) {
return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
}
$file->setViewPolicy($view_policy);
}
$support_id = celerity_generate_unique_node_id();
$instructions = id(new AphrontFormMarkupControl())->setControlID($support_id)->setControlStyle('display: none')->setValue(hsprintf('<br /><br /><strong>%s</strong> %s<br /><br />', pht('Drag and Drop:'), pht('You can also upload files by dragging and dropping them from your ' . 'desktop onto this page or the Phabricator home page.')));
$policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($file)->execute();
$form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setLabel(pht('File'))->setName('file')->setError($e_file))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name'))->setName('name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setCapability(PhabricatorPolicyCapability::CAN_VIEW)->setPolicyObject($file)->setPolicies($policies)->setName('viewPolicy'))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Upload'))->addCancelButton('/file/'))->appendChild($instructions);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Upload'), $request->getRequestURI());
$crumbs->setBorder(true);
$title = pht('Upload File');
$global_upload = id(new PhabricatorGlobalUploadTargetView())->setUser($viewer)->setShowIfSupportedID($support_id);
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('File'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
$header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-upload');
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $global_upload));
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例3: render
public function render()
{
$right_button = $desc = '';
$hidden_inputs = array();
foreach ($this->hidden as $inp) {
list($key, $value) = $inp;
$hidden_inputs[] = phutil_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
if ($this->rightButton) {
$right_button = phutil_tag('div', array('style' => 'float: right;'), $this->rightButton);
}
if ($this->description) {
$desc = phutil_tag('p', array(), $this->description);
if ($right_button) {
$desc = hsprintf('%s<div style="clear: both;"></div>', $desc);
}
}
$div_attributes = $this->divAttributes;
$classes = array('aphront-form-inset');
if (isset($div_attributes['class'])) {
$classes[] = $div_attributes['class'];
}
$div_attributes['class'] = implode(' ', $classes);
$content = $hidden_inputs;
$content[] = $right_button;
$content[] = $desc;
if ($this->title != '') {
array_unshift($content, phutil_tag('h1', array(), $this->title));
}
if ($this->content) {
$content[] = $this->content;
}
$content = array_merge($content, $this->renderChildren());
return phutil_tag('div', $div_attributes, $content);
}
示例4: markupHyperlinkUngreedy
protected function markupHyperlinkUngreedy($matches)
{
$match = $matches[1];
$tail = null;
$trailing = null;
if (preg_match('/[;,.:!?]+$/', $match, $trailing)) {
$tail = $trailing[0];
$match = substr($match, 0, -strlen($tail));
}
// If there's a closing paren at the end but no balancing open paren in
// the URL, don't link the close paren. This is an attempt to gracefully
// handle the two common paren cases, Wikipedia links and English language
// parentheticals, e.g.:
//
// http://en.wikipedia.org/wiki/Noun_(disambiguation)
// (see also http://www.example.com)
//
// We could apply a craftier heuristic here which tries to actually balance
// the parens, but this is probably sufficient.
if (preg_match('/\\)$/', $match) && !preg_match('/\\(/', $match)) {
$tail = ')' . $tail;
$match = substr($match, 0, -1);
}
return hsprintf('%s%s', $this->markupHyperlink(array(null, $match)), $tail);
}
示例5: renderTransactionInfo
private function renderTransactionInfo()
{
$info = array();
if ($this->contentSource) {
$content_source = new PhabricatorContentSourceView();
$content_source->setContentSource($this->contentSource);
$content_source->setUser($this->user);
$source = $content_source->render();
if ($source) {
$info[] = $source;
}
}
if ($this->isPreview) {
$info[] = 'PREVIEW';
} else {
if ($this->epoch) {
$info[] = phabricator_datetime($this->epoch, $this->user);
}
}
if ($this->anchorName) {
Javelin::initBehavior('phabricator-watch-anchor');
$anchor = id(new PhabricatorAnchorView())->setAnchorName($this->anchorName)->render();
$info[] = hsprintf('%s%s', $anchor, phutil_tag('a', array('href' => '#' . $this->anchorName), $this->anchorText));
}
$info = phutil_implode_html(" · ", $info);
return phutil_tag('span', array('class' => 'phabricator-transaction-info'), $info);
}
示例6: testSingleVariant
public function testSingleVariant()
{
$translator = $this->newTranslator('en_US');
// In this translation, we have no alternatives for the first conversion.
$translator->setTranslations(array('Run the command %s %d time(s).' => array(array('Run the command %s once.', 'Run the command %s %d times.'))));
$this->assertEqual('Run the command <tt>ls</tt> 123 times.', (string) $translator->translate('Run the command %s %d time(s).', hsprintf('<tt>%s</tt>', 'ls'), 123));
}
示例7: getHead
protected function getHead()
{
$framebust = null;
if (!$this->getFrameable()) {
$framebust = '(top == self) || top.location.replace(self.location.href);';
}
$viewport_tag = null;
if ($this->getDeviceReady()) {
$viewport_tag = phutil_tag('meta', array('name' => 'viewport', 'content' => 'width=device-width, ' . 'initial-scale=1, ' . 'maximum-scale=1'));
}
$mask_icon = phutil_tag('link', array('rel' => 'mask-icon', 'color' => '#3D4B67', 'href' => celerity_get_resource_uri('/rsrc/favicons/mask-icon.svg')));
$icon_tag_76 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-76x76.png')));
$icon_tag_120 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '120x120', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-120x120.png')));
$icon_tag_152 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '152x152', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-152x152.png')));
$favicon_tag = phutil_tag('link', array('id' => 'favicon', 'rel' => 'shortcut icon', 'href' => celerity_get_resource_uri('/rsrc/favicons/favicon.ico')));
$referrer_tag = phutil_tag('meta', array('name' => 'referrer', 'content' => 'never'));
$response = CelerityAPI::getStaticResourceResponse();
if ($this->getRequest()) {
$viewer = $this->getRequest()->getViewer();
if ($viewer) {
$postprocessor_key = $viewer->getUserSetting(PhabricatorAccessibilitySetting::SETTINGKEY);
if (strlen($postprocessor_key)) {
$response->setPostProcessorKey($postprocessor_key);
}
}
}
$developer = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
return hsprintf('%s%s%s%s%s%s%s%s%s', $viewport_tag, $mask_icon, $icon_tag_76, $icon_tag_120, $icon_tag_152, $favicon_tag, $referrer_tag, CelerityStaticResourceResponse::renderInlineScript($framebust . jsprintf('window.__DEV__=%d;', $developer ? 1 : 0)), $response->renderResourcesOfType('css'));
}
示例8: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$object = id(new PhabricatorObjectQuery())->withPHIDs(array($request->getURIData('phid')))->setViewer($viewer)->executeOne();
if (!$object) {
return new Aphront404Response();
}
if (!$object instanceof PhabricatorApplicationTransactionInterface) {
return new Aphront404Response();
}
$template = $object->getApplicationTransactionTemplate();
$queries = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorApplicationTransactionQuery')->execute();
$object_query = null;
foreach ($queries as $query) {
if ($query->getTemplateApplicationTransaction() == $template) {
$object_query = $query;
break;
}
}
if (!$object_query) {
return new Aphront404Response();
}
$timeline = $this->buildTransactionTimeline($object, $query);
$phui_timeline = $timeline->buildPHUITimelineView($with_hiding = false);
$phui_timeline->setShouldAddSpacers(false);
$events = $phui_timeline->buildEvents();
return id(new AphrontAjaxResponse())->setContent(array('timeline' => hsprintf('%s', $events)));
}
开发者ID:patelhardik,项目名称:phabricator,代码行数:28,代码来源:PhabricatorApplicationTransactionShowOlderController.php
示例9: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$query = id(new PhabricatorNotificationQuery())->setViewer($user)->withUserPHIDs(array($user->getPHID()))->setLimit(15);
$stories = $query->execute();
$clear_ui_class = 'phabricator-notification-clear-all';
$clear_uri = id(new PhutilURI('/notification/clear/'));
if ($stories) {
$builder = new PhabricatorNotificationBuilder($stories);
$notifications_view = $builder->buildView();
$content = $notifications_view->render();
$clear_uri->setQueryParam('chronoKey', head($stories)->getChronologicalKey());
} else {
$content = phutil_tag_div('phabricator-notification no-notifications', pht('You have no notifications.'));
$clear_ui_class .= ' disabled';
}
$clear_ui = javelin_tag('a', array('sigil' => 'workflow', 'href' => (string) $clear_uri, 'class' => $clear_ui_class), pht('Mark All Read'));
$notifications_link = phutil_tag('a', array('href' => '/notification/'), pht('Notifications'));
if (PhabricatorEnv::getEnvConfig('notification.enabled')) {
$connection_status = new PhabricatorNotificationStatusView();
} else {
$connection_status = phutil_tag('a', array('href' => PhabricatorEnv::getDoclink('Notifications User Guide: Setup and Configuration')), pht('Notification Server not enabled.'));
}
$connection_ui = phutil_tag('div', array('class' => 'phabricator-notification-footer'), $connection_status);
$header = phutil_tag('div', array('class' => 'phabricator-notification-header'), array($notifications_link, $clear_ui));
$content = hsprintf('%s%s%s', $header, $content, $connection_ui);
$unread_count = id(new PhabricatorFeedStoryNotification())->countUnread($user);
$json = array('content' => $content, 'number' => (int) $unread_count);
return id(new AphrontAjaxResponse())->setContent($json);
}
示例10: render
public function render()
{
require_celerity_resource('pholio-edit-css');
$image = $this->image;
$file = $image->getFile();
$phid = $file->getPHID();
$replaces_phid = $this->replacesPHID;
$remove = $this->renderRemoveElement();
$title = id(new AphrontFormTextControl())->setName('title_' . $phid)->setValue($image->getName())->setSigil('image-title')->setLabel(pht('Title'));
$description = id(new PhabricatorRemarkupControl())->setName('description_' . $phid)->setValue($image->getDescription())->setSigil('image-description')->setLabel(pht('Description'));
$thumb_frame = phutil_tag('div', array('class' => 'pholio-thumb-frame', 'style' => 'background-image: url(' . $file->getThumb280x210URI() . ');'));
$handle = javelin_tag('div', array('class' => 'pholio-drag-handle', 'sigil' => 'pholio-drag-handle'));
$content = hsprintf('<div class="pholio-thumb-box">
<div class="pholio-thumb-title">
%s
<div class="pholio-thumb-name">%s</div>
</div>
%s
</div>
<div class="pholio-image-details">
%s
%s
</div>', $remove, $file->getName(), $thumb_frame, $title, $description);
$input = phutil_tag('input', array('type' => 'hidden', 'name' => 'file_phids[]', 'value' => $phid));
$replaces_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'replaces[' . $replaces_phid . ']', 'value' => $phid));
return javelin_tag('div', array('class' => 'pholio-uploaded-image', 'sigil' => 'pholio-drop-image', 'meta' => array('filePHID' => $file->getPHID(), 'replacesPHID' => $replaces_phid)), array($handle, $content, $input, $replaces_input));
}
示例11: renderExample
public function renderExample()
{
$request = $this->getRequest();
$user = $request->getUser();
$action = id(new PHUIListItemView())->setName(pht('Actions'))->setType(PHUIListItemView::TYPE_LABEL);
$action1 = id(new PHUIListItemView())->setName(pht('Edit Document'))->setHref('#')->setIcon('fa-edit')->setType(PHUIListItemView::TYPE_LINK);
$action2 = id(new PHUIListItemView())->setName(pht('Move Document'))->setHref('#')->setIcon('fa-arrows')->setType(PHUIListItemView::TYPE_LINK);
$action3 = id(new PHUIListItemView())->setName(pht('Delete Document'))->setHref('#')->setIcon('fa-times')->setType(PHUIListItemView::TYPE_LINK);
$action4 = id(new PHUIListItemView())->setName(pht('View History'))->setHref('#')->setIcon('fa-list')->setType(PHUIListItemView::TYPE_LINK);
$action5 = id(new PHUIListItemView())->setName(pht('Subscribe'))->setHref('#')->setIcon('fa-plus-circle')->setType(PHUIListItemView::TYPE_LINK);
$divider = id(new PHUIListItemView())->setType(PHUIListItemView::TYPE_DIVIDER);
$header = id(new PHUIHeaderView())->setHeader(pht('Installation'));
$label1 = id(new PHUIListItemView())->setName(pht('Getting Started'))->setType(PHUIListItemView::TYPE_LABEL);
$label2 = id(new PHUIListItemView())->setName(pht('Documentation'))->setType(PHUIListItemView::TYPE_LABEL);
$item1 = id(new PHUIListItemView())->setName(pht('Installation'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$item2 = id(new PHUIListItemView())->setName(pht('Webserver Config'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$item3 = id(new PHUIListItemView())->setName(pht('Adding Users'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$item4 = id(new PHUIListItemView())->setName(pht('Debugging'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$sidenav = id(new PHUIListView())->setType(PHUIListView::SIDENAV_LIST)->addMenuItem($action)->addMenuItem($action1)->addMenuItem($action2)->addMenuItem($action3)->addMenuItem($action4)->addMenuItem($action5)->addMenuItem($divider)->addMenuItem($label1)->addMenuItem($item1)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4)->addMenuItem($label2)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4)->addMenuItem($item1);
$home = id(new PHUIListItemView())->setIcon('fa-home')->setHref('#')->setType(PHUIListItemView::TYPE_ICON);
$item1 = id(new PHUIListItemView())->setName(pht('Installation'))->setHref('#')->setSelected(true)->setType(PHUIListItemView::TYPE_LINK);
$item2 = id(new PHUIListItemView())->setName(pht('Webserver Config'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$item3 = id(new PHUIListItemView())->setName(pht('Adding Users'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$item4 = id(new PHUIListItemView())->setName(pht('Debugging'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
$topnav = id(new PHUIListView())->setType(PHUIListView::NAVBAR_LIST)->addMenuItem($home)->addMenuItem($item1)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4);
$document = hsprintf('<p class="pl">Lorem ipsum dolor sit amet, consectetur adipisicing, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>');
$content = new PHUIDocumentView();
$content->setBook(pht('Book or Project Name'), pht('Article'));
$content->setHeader($header);
$content->setFluid(true);
$content->setTopNav($topnav);
$content->setSidenav($sidenav);
$content->appendChild($document);
return $content;
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$engine = new PhabricatorSetupEngine();
$response = $engine->execute();
if ($response) {
return $response;
}
$issues = $engine->getIssues();
$unresolved_count = count($engine->getUnresolvedIssues());
if ($issues) {
require_celerity_resource('phabricator-notification-menu-css');
$items = array();
foreach ($issues as $issue) {
$classes = array();
$classes[] = 'phabricator-notification';
if ($issue->getIsIgnored()) {
$classes[] = 'phabricator-notification-read';
} else {
$classes[] = 'phabricator-notification-unread';
}
$uri = '/config/issue/' . $issue->getIssueKey() . '/';
$title = $issue->getName();
$summary = $issue->getSummary();
$items[] = javelin_tag('div', array('class' => implode(' ', $classes), 'sigil' => 'notification', 'meta' => array('href' => $uri)), $title);
}
$content = phutil_tag_div('setup-issue-menu', $items);
} else {
$content = phutil_tag_div('phabricator-notification no-notifications', pht('You have no unresolved setup issues.'));
}
$content = hsprintf('<div class="phabricator-notification-header">%s</div>' . '%s', phutil_tag('a', array('href' => '/config/issue/'), pht('Unresolved Setup Issues')), $content);
$json = array('content' => $content, 'number' => (int) $unresolved_count);
return id(new AphrontAjaxResponse())->setContent($json);
}
示例13: renderPropertyViewValue
public function renderPropertyViewValue(array $handles)
{
$requested_object = $this->getObject()->getRequestedObject();
if (!$requested_object instanceof DifferentialRevision) {
return null;
}
$diff_rev = $requested_object;
$diffs = $diff_rev->loadRelatives(new DifferentialDiff(), 'revisionID', 'getID', 'creationMethod <> "commit"');
$all_changesets = array();
$most_recent_changesets = null;
foreach ($diffs as $diff) {
$changesets = $diff->loadRelatives(new DifferentialChangeset(), 'diffID');
$all_changesets += $changesets;
$most_recent_changesets = $changesets;
}
// The score is based on all changesets for all versions of this diff
$all_changes = $this->countLinesAndPaths($all_changesets);
$points = self::LINES_WEIGHT * $all_changes['code']['lines'] + self::PATHS_WEIGHT * count($all_changes['code']['paths']);
// The blurb is just based on the most recent version of the diff
$mr_changes = $this->countLinesAndPaths($most_recent_changesets);
$test_tag = '';
if ($mr_changes['tests']['paths']) {
Javelin::initBehavior('phabricator-tooltips');
require_celerity_resource('aphront-tooltip-css');
$test_blurb = pht('%d line(s)', $mr_changes['tests']['lines']) . ' and ' . pht('%d path(s)', count($mr_changes['tests']['paths'])) . " contain changes to test code:\n";
foreach ($mr_changes['tests']['paths'] as $mr_test_path) {
$test_blurb .= pht("%s\n", $mr_test_path);
}
$test_tag = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $test_blurb, 'align' => 'E', 'size' => 'auto'), 'style' => ''), ' + tests');
}
$blurb = hsprintf('%s%s.', pht('%d line(s)', $mr_changes['code']['lines']) . ' and ' . pht('%d path(s)', count($mr_changes['code']['paths'])) . ' over ' . pht('%d diff(s)', count($diffs)), $test_tag);
return id(new AphrontProgressBarView())->setValue($points)->setMax(self::MAX_POINTS)->setCaption($blurb)->render();
}
示例14: getHead
protected function getHead()
{
$framebust = null;
if (!$this->getFrameable()) {
$framebust = '(top == self) || top.location.replace(self.location.href);';
}
$viewport_tag = null;
if ($this->getDeviceReady()) {
$viewport_tag = phutil_tag('meta', array('name' => 'viewport', 'content' => 'width=device-width, ' . 'initial-scale=1, ' . 'maximum-scale=1'));
}
$icon_tag_76 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-76x76.png')));
$icon_tag_120 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '120x120', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-120x120.png')));
$icon_tag_152 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '152x152', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-152x152.png')));
$apple_tag = phutil_tag('meta', array('name' => 'apple-mobile-web-app-status-bar-style', 'content' => 'black-translucent'));
$referrer_tag = phutil_tag('meta', array('name' => 'referrer', 'content' => 'never'));
$response = CelerityAPI::getStaticResourceResponse();
if ($this->getRequest()) {
$viewer = $this->getRequest()->getViewer();
if ($viewer) {
$postprocessor_key = $viewer->getPreference(PhabricatorUserPreferences::PREFERENCE_RESOURCE_POSTPROCESSOR);
if (strlen($postprocessor_key)) {
$response->setPostProcessorKey($postprocessor_key);
}
}
}
$developer = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
return hsprintf('%s%s%s%s%s%s%s%s', $viewport_tag, $icon_tag_76, $icon_tag_120, $icon_tag_152, $apple_tag, $referrer_tag, CelerityStaticResourceResponse::renderInlineScript($framebust . jsprintf('window.__DEV__=%d;', $developer ? 1 : 0)), $response->renderResourcesOfType('css'));
}
示例15: render
public function render()
{
require_celerity_resource('pholio-edit-css');
$image = $this->image;
$file = $image->getFile();
$phid = $file->getPHID();
$replaces_phid = $this->replacesPHID;
$remove = $this->renderRemoveElement();
$title = id(new AphrontFormTextControl())->setName('title_' . $phid)->setValue($image->getName())->setSigil('image-title')->setLabel(pht('Title'));
$description = id(new PhabricatorRemarkupControl())->setUser($this->getUser())->setName('description_' . $phid)->setValue($image->getDescription())->setSigil('image-description')->setLabel(pht('Description'));
$xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PINBOARD);
$thumbnail_uri = $file->getURIForTransform($xform);
$thumb_img = javelin_tag('img', array('class' => 'pholio-thumb-img', 'src' => $thumbnail_uri, 'sigil' => 'pholio-uploaded-thumb'));
$thumb_frame = phutil_tag('div', array('class' => 'pholio-thumb-frame'), $thumb_img);
$handle = javelin_tag('div', array('class' => 'pholio-drag-handle', 'sigil' => 'pholio-drag-handle'));
$content = hsprintf('<div class="pholio-thumb-box">
<div class="pholio-thumb-title">
%s
<div class="pholio-thumb-name">%s</div>
</div>
%s
</div>
<div class="pholio-image-details">
%s
%s
</div>', $remove, $file->getName(), $thumb_frame, $title, $description);
$input = phutil_tag('input', array('type' => 'hidden', 'name' => 'file_phids[]', 'value' => $phid));
$replaces_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'replaces[' . $replaces_phid . ']', 'value' => $phid));
return javelin_tag('div', array('class' => 'pholio-uploaded-image', 'sigil' => 'pholio-drop-image', 'meta' => array('filePHID' => $file->getPHID(), 'replacesPHID' => $replaces_phid)), array($handle, $content, $input, $replaces_input));
}