本文整理汇总了PHP中Javelin类的典型用法代码示例。如果您正苦于以下问题:PHP Javelin类的具体用法?PHP Javelin怎么用?PHP Javelin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Javelin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderInput
protected function renderInput()
{
$name = $this->getName();
$values = nonempty($this->getValue(), array());
assert_instances_of($values, 'PhabricatorObjectHandle');
if ($this->getID()) {
$id = $this->getID();
} else {
$id = celerity_generate_unique_node_id();
}
$placeholder = null;
if (!strlen($this->placeholder)) {
if ($this->datasource) {
$placeholder = $this->datasource->getPlaceholderText();
}
} else {
$placeholder = $this->placeholder;
}
$template = new AphrontTokenizerTemplateView();
$template->setName($name);
$template->setID($id);
$template->setValue($values);
$username = null;
if ($this->user) {
$username = $this->user->getUsername();
}
$datasource_uri = null;
if ($this->datasource) {
$datasource_uri = $this->datasource->getDatasourceURI();
}
if (!$this->disableBehavior) {
Javelin::initBehavior('aphront-basic-tokenizer', array('id' => $id, 'src' => $datasource_uri, 'value' => mpull($values, 'getFullName', 'getPHID'), 'icons' => mpull($values, 'getIcon', 'getPHID'), 'limit' => $this->limit, 'username' => $username, 'placeholder' => $placeholder));
}
return $template->render();
}
示例2: 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();
}
示例3: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$timer = id(new PhabricatorTimer())->load($this->id);
if (!$timer) {
return new Aphront404Response();
}
require_celerity_resource('phabricator-countdown-css');
$chrome_visible = $request->getBool('chrome', true);
$chrome_new = $chrome_visible ? false : null;
$chrome_link = phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('chrome', $chrome_new), 'class' => 'phabricator-timer-chrome-link'), $chrome_visible ? 'Disable Chrome' : 'Enable Chrome');
$content = '<div class="phabricator-timer">
<h1 class="phabricator-timer-header">' . phutil_escape_html($timer->getTitle()) . ' · ' . phabricator_datetime($timer->getDatePoint(), $user) . '</h1>
<div class="phabricator-timer-pane">
<table class="phabricator-timer-table">
<tr>
<th>Days</th>
<th>Hours</th>
<th>Minutes</th>
<th>Seconds</th>
</tr>
<tr>
<td id="phabricator-timer-days"></td>
<td id="phabricator-timer-hours"></td>
<td id="phabricator-timer-minutes"></td>
<td id="phabricator-timer-seconds"></td>
</table>
</div>' . $chrome_link . '</div>';
Javelin::initBehavior('countdown-timer', array('timestamp' => $timer->getDatepoint()));
$panel = $content;
return $this->buildStandardPageResponse($panel, array('title' => 'Countdown: ' . $timer->getTitle(), 'chrome' => $chrome_visible));
}
示例4: buildMainMenuItems
public function buildMainMenuItems(PhabricatorUser $user, PhabricatorController $controller = null)
{
$application = null;
if ($controller) {
$application = $controller->getCurrentApplication();
}
$items = array();
$help_id = celerity_generate_unique_node_id();
Javelin::initBehavior('aphlict-dropdown', array('bubbleID' => $help_id, 'dropdownID' => 'phabricator-help-menu', 'applicationClass' => __CLASS__, 'local' => true, 'desktop' => true, 'right' => true));
$item = id(new PHUIListItemView())->setIcon('fa-life-ring')->addClass('core-menu-item')->setID($help_id)->setOrder(200);
$hide = true;
if ($application) {
$help_name = pht('%s Help', $application->getName());
$item->setName($help_name)->setHref('/help/documentation/' . get_class($application) . '/')->setAural($help_name);
$help_items = $application->getHelpMenuItems($user);
if ($help_items) {
$hide = false;
}
}
if ($hide) {
$item->setStyle('display: none');
}
$items[] = $item;
return $items;
}
示例5: renderInput
protected function renderInput()
{
$drop_id = celerity_generate_unique_node_id();
Javelin::initBehavior('conpherence-drag-and-drop-photo', array('target' => $drop_id, 'form_pane' => 'conpherence-form', 'upload_uri' => '/file/dropupload/', 'activated_class' => 'conpherence-dialogue-upload-photo'));
require_celerity_resource('conpherence-update-css');
return phutil_tag('div', array('id' => $drop_id, 'class' => 'conpherence-dialogue-drag-photo'), pht('Drag and drop an image here to upload it.'));
}
示例6: buildPropertyView
private function buildPropertyView(PhameBlog $blog)
{
$viewer = $this->getViewer();
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips');
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($blog);
$domain = $blog->getDomain();
if (!$domain) {
$domain = phutil_tag('em', array(), pht('No external domain'));
}
$properties->addProperty(pht('Domain'), $domain);
$feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/'));
$properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri));
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $blog);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process();
$properties->invokeWillRenderEvent();
$description = $blog->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($description);
}
return $properties;
}
示例7: renderThumbnail
private function renderThumbnail(PholioImage $image)
{
$thumbfile = $image->getFile();
$preview_key = PhabricatorFileThumbnailTransform::TRANSFORM_THUMBGRID;
$xform = PhabricatorFileTransform::getTransformByKey($preview_key);
Javelin::initBehavior('phabricator-tooltips');
$attributes = array('class' => 'pholio-mock-thumb-grid-image', 'src' => $thumbfile->getURIForTransform($xform));
if ($image->getFile()->isViewableImage()) {
$dimensions = $xform->getTransformedDimensions($thumbfile);
if ($dimensions) {
list($x, $y) = $dimensions;
$attributes += array('width' => $x, 'height' => $y, 'style' => 'top: ' . floor((100 - $y) / 2) . 'px');
}
} else {
// If this is a PDF or a text file or something, we'll end up using a
// generic thumbnail which is always sized correctly.
$attributes += array('width' => 100, 'height' => 100);
}
$tag = phutil_tag('img', $attributes);
$classes = array('pholio-mock-thumb-grid-item');
if ($image->getIsObsolete()) {
$classes[] = 'pholio-mock-thumb-grid-item-obsolete';
}
$inline_count = null;
if ($image->getInlineComments()) {
$inline_count[] = phutil_tag('span', array('class' => 'pholio-mock-thumb-grid-comment-count'), pht('%s', new PhutilNumber(count($image->getInlineComments()))));
}
return javelin_tag('a', array('sigil' => 'mock-thumbnail has-tooltip', 'class' => implode(' ', $classes), 'href' => '#', 'meta' => array('imageID' => $image->getID(), 'tip' => $image->getName(), 'align' => 'N')), array($tag, $inline_count));
}
示例8: render
public function render()
{
require_celerity_resource('aphront-form-view-css');
Javelin::initBehavior('aphront-form-disable-on-submit');
$layout = id(new AphrontFormLayoutView())->setBackgroundShading(true)->setPadded(true)->appendChild($this->renderDataInputs())->appendChild($this->renderChildren());
return javelin_render_tag('form', array('action' => $this->action, 'method' => $this->method, 'enctype' => $this->encType, 'sigil' => $this->workflow ? 'workflow' : null, 'id' => $this->id), $layout->render());
}
示例9: render
public function render()
{
$viewer = $this->getViewer();
if (!$viewer->isLoggedIn()) {
return null;
}
$instructions_id = 'phabricator-global-drag-and-drop-upload-instructions';
require_celerity_resource('global-drag-and-drop-css');
$hint_text = $this->getHintText();
if (!strlen($hint_text)) {
$hint_text = "⇪ " . pht('Drop Files to Upload');
}
// Use the configured default view policy. Drag and drop uploads use
// a more restrictive view policy if we don't specify a policy explicitly,
// as the more restrictive policy is correct for most drop targets (like
// Pholio uploads and Remarkup text areas).
$view_policy = $this->getViewPolicy();
if ($view_policy === null) {
$view_policy = PhabricatorFile::initializeNewFile()->getViewPolicy();
}
$submit_uri = $this->getSubmitURI();
$done_uri = '/file/query/authored/';
Javelin::initBehavior('global-drag-and-drop', array('ifSupported' => $this->showIfSupportedID, 'instructions' => $instructions_id, 'uploadURI' => '/file/dropupload/', 'submitURI' => $submit_uri, 'browseURI' => $done_uri, 'viewPolicy' => $view_policy, 'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold()));
return phutil_tag('div', array('id' => $instructions_id, 'class' => 'phabricator-global-upload-instructions', 'style' => 'display: none;'), $hint_text);
}
示例10: render
public function render()
{
$content = $this->renderChildren();
if (!$content) {
return null;
}
require_celerity_resource('aphront-list-filter-view-css');
$content = phutil_tag('div', array('class' => 'aphront-list-filter-view-content'), $content);
$classes = array();
$classes[] = 'aphront-list-filter-view';
if ($this->showAction !== null) {
$classes[] = 'aphront-list-filter-view-collapsible';
Javelin::initBehavior('phabricator-reveal-content');
$hide_action_id = celerity_generate_unique_node_id();
$show_action_id = celerity_generate_unique_node_id();
$content_id = celerity_generate_unique_node_id();
$hide_action = javelin_tag('a', array('class' => 'button grey', 'sigil' => 'reveal-content', 'id' => $hide_action_id, 'href' => $this->showHideHref, 'meta' => array('hideIDs' => array($hide_action_id), 'showIDs' => array($content_id, $show_action_id))), $this->showAction);
$content_description = phutil_tag('div', array('class' => 'aphront-list-filter-description'), $this->showHideDescription);
$show_action = javelin_tag('a', array('class' => 'button grey', 'sigil' => 'reveal-content', 'style' => 'display: none;', 'href' => '#', 'id' => $show_action_id, 'meta' => array('hideIDs' => array($content_id, $show_action_id), 'showIDs' => array($hide_action_id))), $this->hideAction);
$reveal_block = phutil_tag('div', array('class' => 'aphront-list-filter-reveal'), array($content_description, $hide_action, $show_action));
$content = array($reveal_block, phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), $content));
}
$content = phutil_tag('div', array('class' => implode(' ', $classes)), $content);
return phutil_tag('div', array('class' => 'aphront-list-filter-wrap'), $content);
}
示例11: render
public function render()
{
require_celerity_resource('phabricator-source-code-view-css');
require_celerity_resource('syntax-highlighting-css');
Javelin::initBehavior('phabricator-oncopy', array());
$line_number = $this->start;
$rows = array();
foreach ($this->lines as $line) {
$hit_limit = $this->limit && $line_number == $this->limit && count($this->lines) != $this->limit;
if ($hit_limit) {
$content_number = '';
$content_line = phutil_tag('span', array('class' => 'c'), pht('...'));
} else {
$content_number = $line_number;
$content_line = $line;
}
$row_attributes = array();
if (isset($this->highlights[$line_number])) {
$row_attributes['class'] = 'phabricator-source-highlight';
}
// TODO: Provide nice links.
$th = phutil_tag('th', array('class' => 'phabricator-source-line', 'style' => 'background-color: #fff;'), $content_number);
$td = phutil_tag('td', array('class' => 'phabricator-source-code'), $content_line);
$rows[] = phutil_tag('tr', $row_attributes, array($th, $td));
if ($hit_limit) {
break;
}
$line_number++;
}
$classes = array();
$classes[] = 'phabricator-source-code-view';
$classes[] = 'remarkup-code';
$classes[] = 'PhabricatorMonospaced';
return phutil_tag('div', array('class' => 'phabricator-source-code-container', 'style' => 'background-color: black; color: white;'), phutil_tag('table', array('class' => implode(' ', $classes), 'style' => 'background-color: black'), phutil_implode_html('', $rows)));
}
示例12: getTagAttributes
protected function getTagAttributes()
{
$classes = array('phui-segment-bar-segment-view');
if ($this->color) {
$classes[] = $this->color;
}
// Convert width to a percentage, and round it up slightly so that bars
// are full if they have, e.g., three segments at 1/3 + 1/3 + 1/3.
$width = 100 * $this->width;
$width = ceil(100 * $width) / 100;
$width = sprintf('%.2f%%', $width);
$left = 100 * $this->position;
$left = floor(100 * $left) / 100;
$left = sprintf('%.2f%%', $left);
$tooltip = $this->tooltip;
if (strlen($tooltip)) {
Javelin::initBehavior('phabricator-tooltips');
$sigil = 'has-tooltip';
$meta = array('tip' => $tooltip, 'align' => 'E');
} else {
$sigil = null;
$meta = null;
}
return array('class' => implode(' ', $classes), 'style' => "left: {$left}; width: {$width};", 'sigil' => $sigil, 'meta' => $meta);
}
示例13: buildTasksTable
/**
* Format the tasks data for display on the page.
*
* @returns PHUIObjectBoxView
*/
public function buildTasksTable()
{
Javelin::initBehavior('tasks-table', array(), 'sprint');
$table = id(new SprintTableView($this->tableData->getRows()))->setHeaders(array(pht('Task'), pht('Epoch Created'), pht('Date Created'), pht('Epoch Updated'), pht('Last Update'), pht('Assigned to'), pht('NumPriority'), pht('Priority'), pht('Points'), pht('Status')))->setTableId('tasks-list')->setClassName('display')->setColumnVisibility(array(true, true, true, true, true, true, true, true, true, true));
$box = id(new PHUIObjectBoxView())->setHeaderText(pht('Tasks in this Sprint'))->setTable($table);
return $box;
}
示例14: render
public function render()
{
require_celerity_resource('differential-changeset-view-css');
require_celerity_resource('syntax-highlighting-css');
if ($this->revisionID) {
$edit = true;
} else {
$edit = false;
}
$changeset = $this->changeset;
$class = 'differential-changeset';
if (!$edit) {
$class .= ' differential-changeset-immutable';
}
$buttons = null;
if ($this->buttons) {
$buttons = '<div class="differential-changeset-buttons">' . implode('', $this->buttons) . '</div>';
}
$id = $this->getID();
if ($this->symbolIndex) {
Javelin::initBehavior('repository-crossreference', array('container' => $id) + $this->symbolIndex);
}
$display_filename = $changeset->getDisplayFilename();
$output = javelin_render_tag('div', array('sigil' => 'differential-changeset', 'meta' => array('left' => $this->changeset->getID(), 'right' => $this->changeset->getID()), 'class' => $class, 'id' => $id), phutil_render_tag('a', array('name' => $changeset->getAnchorName()), '') . $buttons . '<h1>' . phutil_escape_html($display_filename) . '</h1>' . '<div style="clear: both;"></div>' . $this->renderChildren());
return $output;
}
示例15: renderInput
protected function renderInput()
{
$name = $this->getName();
$values = nonempty($this->getValue(), array());
if ($this->getID()) {
$id = $this->getID();
} else {
$id = celerity_generate_unique_node_id();
}
$placeholder = null;
if (!$this->placeholder) {
$placeholder = $this->getDefaultPlaceholder();
}
$template = new AphrontTokenizerTemplateView();
$template->setName($name);
$template->setID($id);
$template->setValue($values);
$username = null;
if ($this->user) {
$username = $this->user->getUsername();
}
if (!$this->disableBehavior) {
Javelin::initBehavior('aphront-basic-tokenizer', array('id' => $id, 'src' => $this->datasource, 'value' => $values, 'limit' => $this->limit, 'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'), 'username' => $username, 'placeholder' => $placeholder));
}
return $template->render();
}