Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/view/form/control/AphrontFormDateControl.php b/src/view/form/control/AphrontFormDateControl.php
index 27166c8440..61c470bccf 100644
--- a/src/view/form/control/AphrontFormDateControl.php
+++ b/src/view/form/control/AphrontFormDateControl.php
@@ -1,266 +1,265 @@
<?php
final class AphrontFormDateControl extends AphrontFormControl {
private $initialTime;
private $valueDay;
private $valueMonth;
private $valueYear;
private $valueTime;
const TIME_START_OF_DAY = 'start-of-day';
const TIME_END_OF_DAY = 'end-of-day';
const TIME_START_OF_BUSINESS = 'start-of-business';
const TIME_END_OF_BUSINESS = 'end-of-business';
public function setInitialTime($time) {
$this->initialTime = $time;
return $this;
}
public function readValueFromRequest(AphrontRequest $request) {
$user = $this->user;
if (!$this->user) {
throw new Exception(
"Call setUser() before readValueFromRequest()!");
}
$user_zone = $user->getTimezoneIdentifier();
$zone = new DateTimeZone($user_zone);
$day = $request->getInt($this->getDayInputName());
$month = $request->getInt($this->getMonthInputName());
$year = $request->getInt($this->getYearInputName());
$time = $request->getStr($this->getTimeInputName());
$err = $this->getError();
if ($day || $month || $year || $time) {
$this->valueDay = $day;
$this->valueMonth = $month;
$this->valueYear = $year;
$this->valueTime = $time;
// Assume invalid.
$err = 'Invalid';
try {
$date = new DateTime("{$year}-{$month}-{$day} {$time}", $zone);
$value = $date->format('U');
} catch (Exception $ex) {
$value = null;
}
if ($value) {
$this->setValue($value);
$err = null;
} else {
$this->setValue(null);
}
} else {
// TODO: We could eventually allow these to be customized per install or
// per user or both, but let's wait and see.
switch ($this->initialTime) {
case self::TIME_START_OF_DAY:
default:
$time = '12:00 AM';
break;
case self::TIME_START_OF_BUSINESS:
$time = '9:00 AM';
break;
case self::TIME_END_OF_BUSINESS:
$time = '5:00 PM';
break;
case self::TIME_END_OF_DAY:
$time = '11:59 PM';
break;
}
$today = $this->formatTime(time(), 'Y-m-d');
try {
$date = new DateTime("{$today} {$time}", $zone);
$value = $date->format('U');
} catch (Exception $ex) {
$value = null;
}
if ($value) {
$this->setValue($value);
} else {
$this->setValue(null);
}
}
$this->setError($err);
return $this->getValue();
}
protected function getCustomControlClass() {
return 'aphront-form-control-date';
}
public function setValue($epoch) {
$result = parent::setValue($epoch);
if ($epoch === null) {
return;
}
$readable = $this->formatTime($epoch, 'Y!m!d!g:i A');
$readable = explode('!', $readable, 4);
$this->valueYear = $readable[0];
$this->valueMonth = $readable[1];
$this->valueDay = $readable[2];
$this->valueTime = $readable[3];
return $result;
}
private function getMinYear() {
$cur_year = $this->formatTime(
time(),
'Y');
$val_year = $this->getYearInputValue();
return min($cur_year, $val_year) - 3;
}
private function getMaxYear() {
$cur_year = $this->formatTime(
time(),
'Y');
$val_year = $this->getYearInputValue();
return max($cur_year, $val_year) + 3;
}
private function getDayInputValue() {
return $this->valueDay;
}
private function getMonthInputValue() {
return $this->valueMonth;
}
private function getYearInputValue() {
return $this->valueYear;
}
private function getTimeInputValue() {
return $this->valueTime;
}
private function formatTime($epoch, $fmt) {
return phabricator_format_local_time(
$epoch,
$this->user,
$fmt);
}
private function getDayInputName() {
return $this->getName().'_d';
}
private function getMonthInputName() {
return $this->getName().'_m';
}
private function getYearInputName() {
return $this->getName().'_y';
}
private function getTimeInputName() {
return $this->getName().'_t';
}
protected function renderInput() {
$min_year = $this->getMinYear();
$max_year = $this->getMaxYear();
$days = range(1, 31);
$days = array_fuse($days);
$months = array(
1 => 'Jan',
2 => 'Feb',
3 => 'Mar',
4 => 'Apr',
5 => 'May',
6 => 'Jun',
7 => 'Jul',
8 => 'Aug',
9 => 'Sep',
10 => 'Oct',
11 => 'Nov',
12 => 'Dec',
);
$years = range($this->getMinYear(), $this->getMaxYear());
$years = array_fuse($years);
$days_sel = AphrontFormSelectControl::renderSelectTag(
$this->getDayInputValue(),
$days,
array(
'name' => $this->getDayInputName(),
'sigil' => 'day-input',
));
$months_sel = AphrontFormSelectControl::renderSelectTag(
$this->getMonthInputValue(),
$months,
array(
'name' => $this->getMonthInputName(),
'sigil' => 'month-input',
));
$years_sel = AphrontFormSelectControl::renderSelectTag(
$this->getYearInputValue(),
$years,
array(
'name' => $this->getYearInputName(),
'sigil' => 'year-input',
));
$cal_icon = javelin_tag(
'a',
array(
'href' => '#',
'class' => 'calendar-button',
'sigil' => 'calendar-button',
),
'');
$time_sel = phutil_tag(
'input',
array(
'name' => $this->getTimeInputName(),
'sigil' => 'time-input',
'value' => $this->getTimeInputValue(),
'type' => 'text',
'class' => 'aphront-form-date-time-input',
),
'');
Javelin::initBehavior('fancy-datepicker', array());
- return javelin_render_tag(
+ return javelin_tag(
'div',
array(
'class' => 'aphront-form-date-container',
'sigil' => 'phabricator-date-control',
),
- self::renderSingleView(
- array(
- $days_sel,
- $months_sel,
- $years_sel,
- $cal_icon,
- $time_sel,
- )));
+ array(
+ $days_sel,
+ $months_sel,
+ $years_sel,
+ $cal_icon,
+ $time_sel,
+ ));
}
}
diff --git a/src/view/form/control/AphrontFormSelectControl.php b/src/view/form/control/AphrontFormSelectControl.php
index 9896eedef5..06c0c43e02 100644
--- a/src/view/form/control/AphrontFormSelectControl.php
+++ b/src/view/form/control/AphrontFormSelectControl.php
@@ -1,67 +1,67 @@
<?php
final class AphrontFormSelectControl extends AphrontFormControl {
protected function getCustomControlClass() {
return 'aphront-form-control-select';
}
private $options;
public function setOptions(array $options) {
$this->options = $options;
return $this;
}
public function getOptions() {
return $this->options;
}
protected function renderInput() {
return self::renderSelectTag(
$this->getValue(),
$this->getOptions(),
array(
'name' => $this->getName(),
'disabled' => $this->getDisabled() ? 'disabled' : null,
'id' => $this->getID(),
));
}
public static function renderSelectTag(
$selected,
array $options,
array $attrs = array()) {
$option_tags = self::renderOptions($selected, $options);
- return javelin_render_tag(
+ return javelin_tag(
'select',
$attrs,
- implode("\n", $option_tags));
+ $option_tags);
}
private static function renderOptions($selected, array $options) {
$tags = array();
foreach ($options as $value => $thing) {
if (is_array($thing)) {
$tags[] = phutil_tag(
'optgroup',
array(
'label' => $value,
),
self::renderOptions($selected, $thing));
} else {
$tags[] = phutil_tag(
'option',
array(
'selected' => ($value == $selected) ? 'selected' : null,
'value' => $value,
),
$thing);
}
}
return $tags;
}
}
diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php
index be41fdf655..e1faf1dfb3 100644
--- a/src/view/form/control/PhabricatorRemarkupControl.php
+++ b/src/view/form/control/PhabricatorRemarkupControl.php
@@ -1,154 +1,157 @@
<?php
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
protected function renderInput() {
$id = $this->getID();
if (!$id) {
$id = celerity_generate_unique_node_id();
$this->setID($id);
}
// We need to have this if previews render images, since Ajax can not
// currently ship JS or CSS.
require_celerity_resource('lightbox-attachment-css');
Javelin::initBehavior(
'aphront-drag-and-drop-textarea',
array(
'target' => $id,
'activatedClass' => 'aphront-textarea-drag-and-drop',
'uri' => '/file/dropupload/',
));
Javelin::initBehavior('phabricator-remarkup-assist', array());
Javelin::initBehavior('phabricator-tooltips', array());
$actions = array(
'b' => array(
'tip' => pht('Bold'),
),
'i' => array(
'tip' => pht('Italics'),
),
'tt' => array(
'tip' => pht('Monospaced'),
),
array(
'spacer' => true,
),
'ul' => array(
'tip' => pht('Bulleted List'),
),
'ol' => array(
'tip' => pht('Numbered List'),
),
'code' => array(
'tip' => pht('Code Block'),
),
'table' => array(
'tip' => pht('Table'),
),
array(
'spacer' => true,
),
'meme' => array(
'tip' => pht('Meme'),
),
'help' => array(
'tip' => pht('Help'),
'align' => 'right',
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
),
);
$buttons = array();
foreach ($actions as $action => $spec) {
if (idx($spec, 'spacer')) {
$buttons[] = phutil_tag(
'span',
array(
'class' => 'remarkup-assist-separator',
),
'');
continue;
}
$classes = array();
$classes[] = 'remarkup-assist-button';
if (idx($spec, 'align') == 'right') {
$classes[] = 'remarkup-assist-right';
}
$href = idx($spec, 'href', '#');
if ($href == '#') {
$meta = array('action' => $action);
$mustcapture = true;
$target = null;
} else {
$meta = array();
$mustcapture = null;
$target = '_blank';
}
$tip = idx($spec, 'tip');
if ($tip) {
$meta['tip'] = $tip;
}
require_celerity_resource('sprite-icon-css');
$buttons[] = javelin_tag(
'a',
array(
'class' => implode(' ', $classes),
'href' => $href,
'sigil' => 'remarkup-assist has-tooltip',
'meta' => $meta,
'mustcapture' => $mustcapture,
'target' => $target,
'tabindex' => -1,
),
phutil_tag(
'div',
array(
'class' => 'remarkup-assist sprite-icon remarkup-assist-'.$action,
),
''));
}
$buttons = phutil_tag(
'div',
array(
'class' => 'remarkup-assist-bar',
),
$buttons);
$monospaced_textareas = null;
$monospaced_textareas_class = null;
$user = $this->getUser();
if ($user) {
$monospaced_textareas = $user
->loadPreferences()
->getPreference(
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS);
if ($monospaced_textareas == 'enabled') {
$monospaced_textareas_class = 'PhabricatorMonospaced';
}
}
$this->setCustomClass(
'remarkup-assist-textarea '.$monospaced_textareas_class);
- return javelin_render_tag(
+ return javelin_tag(
'div',
array(
'sigil' => 'remarkup-assist-control',
),
- $buttons.
- parent::renderInput());
+ $this->renderHTMLView(
+ array(
+ $buttons,
+ parent::renderInput(),
+ )));
}
}
diff --git a/src/view/layout/PhabricatorPropertyListView.php b/src/view/layout/PhabricatorPropertyListView.php
index 85c1c2774b..3cedcdbbf9 100644
--- a/src/view/layout/PhabricatorPropertyListView.php
+++ b/src/view/layout/PhabricatorPropertyListView.php
@@ -1,152 +1,152 @@
<?php
final class PhabricatorPropertyListView extends AphrontView {
private $parts = array();
private $hasKeyboardShortcuts;
protected function canAppendChild() {
return false;
}
public function setHasKeyboardShortcuts($has_keyboard_shortcuts) {
$this->hasKeyboardShortcuts = $has_keyboard_shortcuts;
return $this;
}
public function addProperty($key, $value) {
$current = array_pop($this->parts);
if (!$current || $current['type'] != 'property') {
if ($current) {
$this->parts[] = $current;
}
$current = array(
'type' => 'property',
'list' => array(),
);
}
$current['list'][] = array(
'key' => $key,
'value' => $value,
);
$this->parts[] = $current;
return $this;
}
public function addSectionHeader($name) {
$this->parts[] = array(
'type' => 'section',
'name' => $name,
);
return $this;
}
public function addTextContent($content) {
$this->parts[] = array(
'type' => 'text',
'content' => $content,
);
return $this;
}
public function render() {
require_celerity_resource('phabricator-property-list-view-css');
$items = array();
foreach ($this->parts as $part) {
$type = $part['type'];
switch ($type) {
case 'property':
$items[] = $this->renderPropertyPart($part);
break;
case 'section':
$items[] = $this->renderSectionPart($part);
break;
case 'text':
$items[] = $this->renderTextPart($part);
break;
default:
throw new Exception("Unknown part type '{$type}'!");
}
}
- return phutil_render_tag(
+ return phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-view',
),
- $this->renderSingleView($items));
+ $this->renderHTMLView($items));
}
private function renderPropertyPart(array $part) {
$items = array();
foreach ($part['list'] as $spec) {
$key = $spec['key'];
$value = $spec['value'];
$items[] = phutil_tag(
'dt',
array(
'class' => 'phabricator-property-list-key',
),
$key);
$items[] = phutil_tag(
'dd',
array(
'class' => 'phabricator-property-list-value',
),
$this->renderHTMLView($value));
}
$list = phutil_tag(
'dl',
array(
'class' => 'phabricator-property-list-properties',
),
$this->renderHTMLView($items));
$shortcuts = null;
if ($this->hasKeyboardShortcuts) {
$shortcuts =
id(new AphrontKeyboardShortcutsAvailableView())->render();
}
return array(
$shortcuts,
phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-container',
),
array(
$list,
phutil_tag(
'div',
array('class' => 'phabriator-property-list-view-end'),
''),
)));
}
private function renderSectionPart(array $part) {
return phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-section-header',
),
$part['name']);
}
private function renderTextPart(array $part) {
return phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-text-content',
),
$part['content']);
}
}
diff --git a/src/view/widget/AphrontKeyboardShortcutsAvailableView.php b/src/view/widget/AphrontKeyboardShortcutsAvailableView.php
index bfb8850605..a371445664 100644
--- a/src/view/widget/AphrontKeyboardShortcutsAvailableView.php
+++ b/src/view/widget/AphrontKeyboardShortcutsAvailableView.php
@@ -1,12 +1,16 @@
<?php
final class AphrontKeyboardShortcutsAvailableView extends AphrontView {
public function render() {
- return
- '<div class="keyboard-shortcuts-available">'.
- 'Press <strong>?</strong> to show keyboard shortcuts.'.
- '</div>';
+ return phutil_tag(
+ 'div',
+ array(
+ 'class' => 'keyboard-shortcuts-available',
+ ),
+ pht(
+ 'Press %s to show keyboard shortcuts.',
+ phutil_tag('strong', array(), '?')));
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Oct 16, 7:38 AM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
272543
Default Alt Text
(17 KB)

Event Timeline