Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/differential/view/DifferentialAddCommentView.php b/src/applications/differential/view/DifferentialAddCommentView.php
index d9d9d745c1..2f529e42a4 100644
--- a/src/applications/differential/view/DifferentialAddCommentView.php
+++ b/src/applications/differential/view/DifferentialAddCommentView.php
@@ -1,236 +1,235 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class DifferentialAddCommentView extends AphrontView {
private $revision;
private $actions;
private $actionURI;
private $user;
private $draft;
private $auxFields;
private $reviewers = array();
private $ccs = array();
public function setRevision($revision) {
$this->revision = $revision;
return $this;
}
public function setAuxFields(array $aux_fields) {
assert_instances_of($aux_fields, 'DifferentialFieldSpecification');
$this->auxFields = $aux_fields;
return $this;
}
public function setActions(array $actions) {
$this->actions = $actions;
return $this;
}
public function setActionURI($uri) {
$this->actionURI = $uri;
return $this;
}
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function setDraft(PhabricatorDraft $draft = null) {
$this->draft = $draft;
return $this;
}
public function setReviewers(array $names) {
$this->reviewers = $names;
return $this;
}
public function setCCs(array $names) {
$this->ccs = $names;
return $this;
}
private function generateWarningView(
$status,
array $titles,
$id,
$content) {
$warning = new AphrontErrorView();
$warning->setSeverity(AphrontErrorView::SEVERITY_ERROR);
$warning->setID($id);
$warning->appendChild($content);
$warning->setTitle(idx($titles, $status, 'Warning'));
return $warning;
}
public function render() {
require_celerity_resource('differential-revision-add-comment-css');
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$revision = $this->revision;
$action = null;
if ($this->draft) {
$action = idx($this->draft->getMetadata(), 'action');
}
$enable_reviewers = DifferentialAction::allowReviewers($action);
$enable_ccs = ($action == DifferentialAction::ACTION_ADDCCS);
$form = new AphrontFormView();
$form
->setWorkflow(true)
->setUser($this->user)
->setAction($this->actionURI)
->addHiddenInput('revision_id', $revision->getID())
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Action')
->setName('action')
->setValue($action)
->setID('comment-action')
->setOptions($this->actions))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel('Add Reviewers')
->setName('reviewers')
->setControlID('add-reviewers')
->setControlStyle($enable_reviewers ? null : 'display: none')
->setID('add-reviewers-tokenizer')
->setDisableBehavior(true))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel('Add CCs')
->setName('ccs')
->setControlID('add-ccs')
->setControlStyle($enable_ccs ? null : 'display: none')
->setID('add-ccs-tokenizer')
->setDisableBehavior(true))
->appendChild(
id(new PhabricatorRemarkupControl())
->setName('comment')
->setID('comment-content')
->setLabel('Comment')
- ->setEnableDragAndDropFileUploads(true)
->setValue($this->draft ? $this->draft->getDraft() : null))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Clowncopterize'));
Javelin::initBehavior(
'differential-add-reviewers-and-ccs',
array(
'dynamic' => array(
'add-reviewers-tokenizer' => array(
'actions' => array('request_review' => 1, 'add_reviewers' => 1),
'src' => '/typeahead/common/users/',
'value' => $this->reviewers,
'row' => 'add-reviewers',
'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'),
'placeholder' => 'Type a user name...',
),
'add-ccs-tokenizer' => array(
'actions' => array('add_ccs' => 1),
'src' => '/typeahead/common/mailable/',
'value' => $this->ccs,
'row' => 'add-ccs',
'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'),
'placeholder' => 'Type a user or mailing list...',
),
),
'select' => 'comment-action',
));
$diff = $revision->loadActiveDiff();
$warnings = mpull($this->auxFields, 'renderWarningBoxForRevisionAccept');
$lint_warning = null;
$unit_warning = null;
Javelin::initBehavior(
'differential-accept-with-errors',
array(
'select' => 'comment-action',
'warnings' => 'warnings',
));
$rev_id = $revision->getID();
Javelin::initBehavior(
'differential-feedback-preview',
array(
'uri' => '/differential/comment/preview/'.$rev_id.'/',
'preview' => 'comment-preview',
'action' => 'comment-action',
'content' => 'comment-content',
'previewTokenizers' => array(
'reviewers' => 'add-reviewers-tokenizer',
'ccs' => 'add-ccs-tokenizer',
),
'inlineuri' => '/differential/comment/inline/preview/'.$rev_id.'/',
'inline' => 'inline-comment-preview',
));
$panel_view = new AphrontPanelView();
$panel_view->appendChild($form);
$warning_container = '<div id="warnings">';
foreach ($warnings as $warning) {
if ($warning) {
$warning_container .= $warning->render();
}
}
$warning_container .= '</div>';
$panel_view->appendChild($warning_container);
if ($lint_warning) {
$panel_view->appendChild($lint_warning);
}
if ($unit_warning) {
$panel_view->appendChild($unit_warning);
}
$panel_view->setHeader($is_serious ? 'Add Comment' : 'Leap Into Action');
$panel_view->addClass('aphront-panel-accent');
$panel_view->addClass('aphront-panel-flush');
return
id(new PhabricatorAnchorView())
->setAnchorName('comment')
->setNavigationMarker(true)
->render().
'<div class="differential-add-comment-panel">'.
$panel_view->render().
'<div class="aphront-panel-preview aphront-panel-flush">'.
'<div id="comment-preview">'.
'<span class="aphront-panel-preview-loading-text">'.
'Loading comment preview...'.
'</span>'.
'</div>'.
'<div id="inline-comment-preview">'.
'</div>'.
'</div>'.
'</div>';
}
}
diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php
index a986e20e14..1f18b1a74d 100644
--- a/src/applications/phame/controller/post/PhamePostEditController.php
+++ b/src/applications/phame/controller/post/PhamePostEditController.php
@@ -1,424 +1,423 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
final class PhamePostEditController
extends PhameController {
private $phid;
private $isPostEdit;
private $userBlogs;
private $postBlogs;
private $post;
private function setPost(PhamePost $post) {
$this->post = $post;
return $this;
}
private function getPost() {
return $this->post;
}
private function setPostPHID($phid) {
$this->phid = $phid;
return $this;
}
private function getPostPHID() {
return $this->phid;
}
private function setIsPostEdit($is_post_edit) {
$this->isPostEdit = $is_post_edit;
return $this;
}
private function isPostEdit() {
return $this->isPostEdit;
}
private function setUserBlogs(array $blogs) {
assert_instances_of($blogs, 'PhameBlog');
$this->userBlogs = $blogs;
return $this;
}
private function getUserBlogs() {
return $this->userBlogs;
}
private function setPostBlogs(array $blogs) {
assert_instances_of($blogs, 'PhameBlog');
$this->postBlogs = $blogs;
return $this;
}
private function getPostBlogs() {
return $this->postBlogs;
}
protected function getSideNavFilter() {
if ($this->isPostEdit()) {
$post_noun = $this->getPost()->getHumanName();
$filter = $post_noun.'/edit/'.$this->getPostPHID();
} else {
$filter = 'post/new';
}
return $filter;
}
protected function getSideNavExtraPostFilters() {
if ($this->isPostEdit() && !$this->getPost()->isDraft()) {
$filters = array(
array('key' => 'post/edit/'.$this->getPostPHID(),
'name' => 'Edit Post')
);
} else {
$filters = array();
}
return $filters;
}
protected function getSideNavExtraDraftFilters() {
if ($this->isPostEdit() && $this->getPost()->isDraft()) {
$filters = array(
array('key' => 'draft/edit/'.$this->getPostPHID(),
'name' => 'Edit Draft')
);
} else {
$filters = array();
}
return $filters;
}
public function willProcessRequest(array $data) {
$phid = idx($data, 'phid');
$this->setPostPHID($phid);
$this->setIsPostEdit((bool) $phid);
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$e_phame_title = null;
$e_title = null;
$errors = array();
if ($this->isPostEdit()) {
$posts = id(new PhamePostQuery())
->withPHIDs(array($this->getPostPHID()))
->execute();
$post = reset($posts);
if (empty($post)) {
return new Aphront404Response();
}
if ($post->getBloggerPHID() != $user->getPHID()) {
return new Aphront403Response();
}
$post_noun = ucfirst($post->getHumanName());
$cancel_uri = $post->getViewURI($user->getUsername());
$submit_button = 'Save Changes';
$delete_button = javelin_render_tag(
'a',
array(
'href' => $post->getDeleteURI(),
'class' => 'grey button',
'sigil' => 'workflow',
),
'Delete '.$post_noun);
$page_title = 'Edit '.$post_noun;
} else {
$post = id(new PhamePost())
->setBloggerPHID($user->getPHID())
->setVisibility(PhamePost::VISIBILITY_DRAFT);
$cancel_uri = '/phame/draft/';
$submit_button = 'Create Draft';
$delete_button = null;
$page_title = 'Create Draft';
}
$this->setPost($post);
$this->loadEdgesAndBlogs();
if ($request->isFormPost()) {
$saved = true;
$visibility = $request->getInt('visibility');
$comments = $request->getStr('comments_widget');
$data = array('comments_widget' => $comments);
$phame_title = $request->getStr('phame_title');
$phame_title = PhabricatorSlug::normalize($phame_title);
$title = $request->getStr('title');
$post->setTitle($title);
$post->setPhameTitle($phame_title);
$post->setBody($request->getStr('body'));
$post->setVisibility($visibility);
$post->setConfigData($data);
// only publish once...!
if ($visibility == PhamePost::VISIBILITY_PUBLISHED) {
if (!$post->getDatePublished()) {
$post->setDatePublished(time());
}
// this is basically a cast of null to 0 if its a new post
} else if (!$post->getDatePublished()) {
$post->setDatePublished(0);
}
if ($phame_title == '/') {
$errors[] = 'Phame title must be nonempty.';
$e_phame_title = 'Required';
}
if (empty($title)) {
$errors[] = 'Title must be nonempty.';
$e_title = 'Required';
}
$blogs_published = array_keys($this->getPostBlogs());
$blogs_to_publish = array();
$blogs_to_depublish = array();
if ($visibility == PhamePost::VISIBILITY_PUBLISHED) {
$blogs_arr = $request->getArr('blogs');
$blogs_to_publish = array_values($blogs_arr);
$blogs_to_depublish = array_diff($blogs_published,
$blogs_to_publish);
} else {
$blogs_to_depublish = $blogs_published;
}
if (empty($errors)) {
try {
$post->save();
$editor = new PhabricatorEdgeEditor();
$edge_type = PhabricatorEdgeConfig::TYPE_POST_HAS_BLOG;
$editor->setUser($user);
foreach ($blogs_to_publish as $phid) {
$editor->addEdge($post->getPHID(), $edge_type, $phid);
}
foreach ($blogs_to_depublish as $phid) {
$editor->removeEdge($post->getPHID(), $edge_type, $phid);
}
$editor->save();
} catch (AphrontQueryDuplicateKeyException $e) {
$saved = false;
$e_phame_title = 'Not Unique';
$errors[] = 'Another post already uses this slug. '.
'Each post must have a unique slug.';
}
} else {
$saved = false;
}
if ($saved) {
$uri = new PhutilURI($post->getViewURI($user->getUsername()));
$uri->setQueryParam('saved', true);
return id(new AphrontRedirectResponse())
->setURI($uri);
}
}
$panel = new AphrontPanelView();
$panel->setHeader($page_title);
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
if ($delete_button) {
$panel->addButton($delete_button);
}
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Title')
->setName('title')
->setValue($post->getTitle())
->setID('post-title')
->setError($e_title)
)
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Phame Title')
->setName('phame_title')
->setValue(rtrim($post->getPhameTitle(), '/'))
->setID('post-phame-title')
->setCaption('Up to 64 alphanumeric characters '.
'with underscores for spaces. '.
'Formatting is enforced.')
->setError($e_phame_title)
)
->appendChild(
id(new PhabricatorRemarkupControl())
->setLabel('Body')
->setName('body')
->setValue($post->getBody())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
- ->setEnableDragAndDropFileUploads(true)
->setID('post-body')
)
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Visibility')
->setName('visibility')
->setValue($post->getVisibility())
->setOptions(PhamePost::getVisibilityOptionsForSelect())
->setID('post-visibility')
)
->appendChild(
$this->getBlogCheckboxControl($post)
)
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Comments Widget')
->setName('comments_widget')
->setvalue($post->getCommentsWidget())
->setOptions($post->getCommentsWidgetOptionsForSelect())
)
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri)
->setValue($submit_button)
);
$panel->appendChild($form);
$preview_panel =
'<div class="aphront-panel-preview ">
<div class="phame-post-preview-header">
Post Preview
</div>
<div id="post-preview">
<div class="aphront-panel-preview-loading-text">
Loading preview...
</div>
</div>
</div>';
Javelin::initBehavior(
'phame-post-preview',
array(
'preview' => 'post-preview',
'body' => 'post-body',
'title' => 'post-title',
'phame_title' => 'post-phame-title',
'uri' => '/phame/post/preview/',
));
$visibility_data = array(
'select_id' => 'post-visibility',
'current' => $post->getVisibility(),
'published' => PhamePost::VISIBILITY_PUBLISHED,
'draft' => PhamePost::VISIBILITY_DRAFT,
'change_uri' => $post->getChangeVisibilityURI(),
);
$blogs_data = array(
'checkbox_id' => 'post-blogs',
'have_published' => (bool) count($this->getPostBlogs())
);
Javelin::initBehavior(
'phame-post-blogs',
array(
'blogs' => $blogs_data,
'visibility' => $visibility_data,
));
if ($errors) {
$error_view = id(new AphrontErrorView())
->setTitle('Errors saving post.')
->setErrors($errors);
} else {
$error_view = null;
}
$this->setShowSideNav(true);
return $this->buildStandardPageResponse(
array(
$error_view,
$panel,
$preview_panel,
),
array(
'title' => $page_title,
));
}
private function getBlogCheckboxControl(PhamePost $post) {
if ($post->getVisibility() == PhamePost::VISIBILITY_PUBLISHED) {
$control_style = null;
} else {
$control_style = 'display: none';
}
$control = id(new AphrontFormCheckboxControl())
->setLabel('Blogs')
->setControlID('post-blogs')
->setControlStyle($control_style);
$post_blogs = $this->getPostBlogs();
$user_blogs = $this->getUserBlogs();
$all_blogs = $post_blogs + $user_blogs;
$all_blogs = msort($all_blogs, 'getName');
foreach ($all_blogs as $phid => $blog) {
$control->addCheckbox(
'blogs[]',
$blog->getPHID(),
$blog->getName(),
isset($post_blogs[$phid])
);
}
return $control;
}
private function loadEdgesAndBlogs() {
$edge_types = array(PhabricatorEdgeConfig::TYPE_BLOGGER_HAS_BLOG);
$blogger_phid = $this->getRequest()->getUser()->getPHID();
$phids = array($blogger_phid);
if ($this->isPostEdit()) {
$edge_types[] = PhabricatorEdgeConfig::TYPE_POST_HAS_BLOG;
$phids[] = $this->getPostPHID();
}
$edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($phids)
->withEdgeTypes($edge_types)
->execute();
$all_blogs_assoc = array();
foreach ($phids as $phid) {
foreach ($edge_types as $type) {
$all_blogs_assoc += $edges[$phid][$type];
}
}
$blogs = id(new PhameBlogQuery())
->withPHIDs(array_keys($all_blogs_assoc))
->execute();
$blogs = mpull($blogs, null, 'getPHID');
$user_blogs = array_intersect_key(
$blogs,
$edges[$blogger_phid][PhabricatorEdgeConfig::TYPE_BLOGGER_HAS_BLOG]
);
if ($this->isPostEdit()) {
$post_blogs = array_intersect_key(
$blogs,
$edges[$this->getPostPHID()][PhabricatorEdgeConfig::TYPE_POST_HAS_BLOG]
);
} else {
$post_blogs = array();
}
$this->setUserBlogs($user_blogs);
$this->setPostBlogs($post_blogs);
}
}
diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php
index 19b49365ce..adfcbbd8f8 100644
--- a/src/applications/phriction/controller/PhrictionEditController.php
+++ b/src/applications/phriction/controller/PhrictionEditController.php
@@ -1,280 +1,279 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phriction
*/
final class PhrictionEditController
extends PhrictionController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($this->id) {
$document = id(new PhrictionDocument())->load($this->id);
if (!$document) {
return new Aphront404Response();
}
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere(
'documentID = %d AND version = %d',
$document->getID(),
$revert);
if (!$content) {
return new Aphront404Response();
}
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
}
} else {
$slug = $request->getStr('slug');
$slug = PhabricatorSlug::normalize($slug);
if (!$slug) {
return new Aphront404Response();
}
$document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$slug);
if ($document) {
$content = id(new PhrictionContent())->load($document->getContentID());
} else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if (!$project) {
return new Aphront404Response();
}
}
$document = new PhrictionDocument();
$document->setSlug($slug);
$content = new PhrictionContent();
$content->setSlug($slug);
$default_title = PhabricatorSlug::getDefaultTitle($slug);
$content->setTitle($default_title);
}
}
if ($request->getBool('nodraft')) {
$draft = null;
$draft_key = null;
} else {
if ($document->getPHID()) {
$draft_key = $document->getPHID().':'.$content->getVersion();
} else {
$draft_key = 'phriction:'.$content->getSlug();
}
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$draft_key);
}
require_celerity_resource('phriction-document-css');
$e_title = true;
$notes = null;
$errors = array();
if ($request->isFormPost()) {
$title = $request->getStr('title');
$notes = $request->getStr('description');
if (!strlen($title)) {
$e_title = 'Required';
$errors[] = 'Document title is required.';
} else {
$e_title = null;
}
if ($document->getID()) {
if ($content->getTitle() == $title &&
$content->getContent() == $request->getStr('content')) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('No Edits');
$dialog->appendChild(
'<p>You did not make any changes to the document.</p>');
$dialog->addCancelButton($request->getRequestURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
if (!count($errors)) {
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
->setUser($user)
->setTitle($title)
->setContent($request->getStr('content'))
->setDescription($notes);
$editor->save();
if ($draft) {
$draft->delete();
}
$uri = PhrictionDocument::getSlugURI($document->getSlug());
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$error_view = null;
if ($errors) {
$error_view = id(new AphrontErrorView())
->setTitle('Form Errors')
->setErrors($errors);
}
if ($document->getID()) {
$panel_header = 'Edit Phriction Document';
$submit_button = 'Save Changes';
$delete_button = phutil_render_tag(
'a',
array(
'href' => '/phriction/delete/'.$document->getID().'/',
'class' => 'grey button',
),
'Delete Document');
} else {
$panel_header = 'Create New Phriction Document';
$submit_button = 'Create Document';
$delete_button = null;
}
$uri = $document->getSlug();
$uri = PhrictionDocument::getSlugURI($uri);
$uri = PhabricatorEnv::getProductionURI($uri);
$cancel_uri = PhrictionDocument::getSlugURI($document->getSlug());
if ($draft &&
strlen($draft->getDraft()) &&
($draft->getDraft() != $content->getContent())) {
$content_text = $draft->getDraft();
$discard = phutil_render_tag(
'a',
array(
'href' => $request->getRequestURI()->alter('nodraft', true),
),
'discard this draft');
$draft_note = new AphrontErrorView();
$draft_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$draft_note->setTitle('Recovered Draft');
$draft_note->appendChild(
'<p>Showing a saved draft of your edits, you can '.$discard.'.</p>');
} else {
$content_text = $content->getContent();
$draft_note = null;
}
$form = id(new AphrontFormView())
->setUser($user)
->setWorkflow(true)
->setAction($request->getRequestURI()->getPath())
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Title')
->setValue($content->getTitle())
->setError($e_title)
->setName('title'))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('URI')
->setValue($uri))
->appendChild(
id(new PhabricatorRemarkupControl())
->setLabel('Content')
->setValue($content_text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('content')
- ->setID('document-textarea')
- ->setEnableDragAndDropFileUploads(true))
+ ->setID('document-textarea'))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Edit Notes')
->setValue($notes)
->setError(null)
->setName('description'))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri)
->setValue($submit_button));
$panel = id(new AphrontPanelView())
->setWidth(AphrontPanelView::WIDTH_WIDE)
->setHeader($panel_header)
->appendChild($form);
if ($delete_button) {
$panel->addButton($delete_button);
}
$preview_panel =
'<div class="aphront-panel-preview aphront-panel-preview-wide">
<div class="phriction-document-preview-header">
Document Preview
</div>
<div id="document-preview">
<div class="aphront-panel-preview-loading-text">
Loading preview...
</div>
</div>
</div>';
Javelin::initBehavior(
'phriction-document-preview',
array(
'preview' => 'document-preview',
'textarea' => 'document-textarea',
'uri' => '/phriction/preview/?draftkey='.$draft_key,
));
return $this->buildStandardPageResponse(
array(
$draft_note,
$error_view,
$panel,
$preview_panel,
),
array(
'title' => 'Edit Document',
));
}
}
diff --git a/src/applications/ponder/view/PonderAddAnswerView.php b/src/applications/ponder/view/PonderAddAnswerView.php
index 3acbfe1431..3f8992c821 100644
--- a/src/applications/ponder/view/PonderAddAnswerView.php
+++ b/src/applications/ponder/view/PonderAddAnswerView.php
@@ -1,96 +1,95 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PonderAddAnswerView extends AphrontView {
private $question;
private $user;
private $actionURI;
private $draft;
public function setQuestion($question) {
$this->question = $question;
return $this;
}
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function setActionURI($uri) {
$this->actionURI = $uri;
return $this;
}
public function render() {
require_celerity_resource('ponder-core-view-css');
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$question = $this->question;
$header = id(new PhabricatorHeaderView())
->setHeader('Add Answer');
$form = new AphrontFormView();
$form
->setFlexible(true)
->setUser($this->user)
->setAction($this->actionURI)
->setWorkflow(true)
->addHiddenInput('question_id', $question->getID())
->appendChild(
id(new PhabricatorRemarkupControl())
->setName('answer')
->setLabel('Answer')
->setError(true)
- ->setID('answer-content')
- ->setEnableDragAndDropFileUploads(true))
+ ->setID('answer-content'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Make it so.'));
$preview =
'<div class="aphront-panel-flush">'.
'<div id="answer-preview">'.
'<span class="aphront-panel-preview-loading-text">'.
'Loading answer preview...'.
'</span>'.
'</div>'.
'</div>';
Javelin::initBehavior(
'ponder-feedback-preview',
array(
'uri' => '/ponder/answer/preview/',
'content' => 'answer-content',
'preview' => 'answer-preview',
'question_id' => $question->getID()
));
return id(new AphrontNullView())
->appendChild(
array(
$header,
$form,
$preview,
))
->render();
}
}
diff --git a/src/applications/ponder/view/PonderAddCommentView.php b/src/applications/ponder/view/PonderAddCommentView.php
index 83e491726b..3d06c7a8d4 100644
--- a/src/applications/ponder/view/PonderAddCommentView.php
+++ b/src/applications/ponder/view/PonderAddCommentView.php
@@ -1,76 +1,75 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PonderAddCommentView extends AphrontView {
private $target;
private $user;
private $actionURI;
private $questionID;
public function setTarget($target) {
$this->target = $target;
return $this;
}
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function setQuestionID($id) {
$this->questionID = $id;
return $this;
}
public function setActionURI($uri) {
$this->actionURI = $uri;
return $this;
}
public function render() {
require_celerity_resource('ponder-comment-table-css');
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$questionID = $this->questionID;
$target = $this->target;
$form = new AphrontFormView();
$form
->setUser($this->user)
->setAction($this->actionURI)
->setWorkflow(true)
->addHiddenInput('target', $target)
->addHiddenInput('question_id', $questionID)
->appendChild(
id(new AphrontFormTextAreaControl())
- ->setName('content')
- ->setEnableDragAndDropFileUploads(false))
+ ->setName('content'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Editorialize'));
$view = id(new AphrontMoreView())
->setSome(id(new AphrontNullView())->render())
->setMore($form->render())
->setExpandText('Add Comment');
return $view->render();
}
}
diff --git a/src/view/form/control/AphrontFormTextAreaControl.php b/src/view/form/control/AphrontFormTextAreaControl.php
index c237eaaf0b..a20f6acca7 100644
--- a/src/view/form/control/AphrontFormTextAreaControl.php
+++ b/src/view/form/control/AphrontFormTextAreaControl.php
@@ -1,104 +1,85 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @concrete-extensible
*/
class AphrontFormTextAreaControl extends AphrontFormControl {
const HEIGHT_VERY_SHORT = 'very-short';
const HEIGHT_SHORT = 'short';
const HEIGHT_VERY_TALL = 'very-tall';
private $height;
private $readOnly;
private $enableDragAndDropFileUploads;
private $customClass;
public function setHeight($height) {
$this->height = $height;
return $this;
}
public function setReadOnly($read_only) {
$this->readOnly = $read_only;
return $this;
}
protected function getReadOnly() {
return $this->readOnly;
}
protected function getCustomControlClass() {
return 'aphront-form-control-textarea';
}
- public function setEnableDragAndDropFileUploads($enable) {
- $this->enableDragAndDropFileUploads = $enable;
- return $this;
- }
-
public function setCustomClass($custom_class) {
$this->customClass = $custom_class;
return $this;
}
protected function renderInput() {
$height_class = null;
switch ($this->height) {
case self::HEIGHT_VERY_SHORT:
case self::HEIGHT_SHORT:
case self::HEIGHT_VERY_TALL:
$height_class = 'aphront-textarea-'.$this->height;
break;
}
$classes = array();
$classes[] = $height_class;
$classes[] = $this->customClass;
$classes = trim(implode(' ', $classes));
- $id = $this->getID();
- if ($this->enableDragAndDropFileUploads) {
- if (!$id) {
- $id = celerity_generate_unique_node_id();
- }
- Javelin::initBehavior(
- 'aphront-drag-and-drop-textarea',
- array(
- 'target' => $id,
- 'activatedClass' => 'aphront-textarea-drag-and-drop',
- 'uri' => '/file/dropupload/',
- ));
- }
-
return phutil_render_tag(
'textarea',
array(
'name' => $this->getName(),
'disabled' => $this->getDisabled() ? 'disabled' : null,
'readonly' => $this->getReadonly() ? 'readonly' : null,
'class' => $classes,
'style' => $this->getControlStyle(),
- 'id' => $id,
+ 'id' => $this->getID(),
),
phutil_escape_html($this->getValue()));
}
}
diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php
index 3066b1c2bd..8fe9615c76 100644
--- a/src/view/form/control/PhabricatorRemarkupControl.php
+++ b/src/view/form/control/PhabricatorRemarkupControl.php
@@ -1,127 +1,140 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
protected function renderInput() {
+ $id = $this->getID();
+ if (!$id) {
+ $id = celerity_generate_unique_node_id();
+ $this->setID($id);
+ }
+
+ 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'),
),
'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_render_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;
}
$buttons[] = javelin_render_tag(
'a',
array(
'class' => implode(' ', $classes),
'href' => $href,
'sigil' => 'remarkup-assist has-tooltip',
'meta' => $meta,
'mustcapture' => $mustcapture,
'target' => $target,
'tabindex' => -1,
),
phutil_render_tag(
'div',
array(
'class' => 'remarkup-assist autosprite remarkup-assist-'.$action,
),
''));
}
$buttons = phutil_render_tag(
'div',
array(
'class' => 'remarkup-assist-bar',
),
implode('', $buttons));
$this->setCustomClass('remarkup-assist-textarea');
return javelin_render_tag(
'div',
array(
'sigil' => 'remarkup-assist-control',
),
$buttons.
parent::renderInput());
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jul 28, 8:14 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
187465
Default Alt Text
(41 KB)

Event Timeline