diff --git a/resources/sql/patches/071.contentsource.sql b/resources/sql/patches/071.contentsource.sql new file mode 100644 index 0000000000..eae1b7a608 --- /dev/null +++ b/resources/sql/patches/071.contentsource.sql @@ -0,0 +1,5 @@ +ALTER TABLE phabricator_differential.differential_comment + ADD contentSource VARCHAR(255); + +ALTER TABLE phabricator_maniphest.maniphest_transaction + ADD contentSource VARCHAR(255); diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 7ea524bddd..2d93ef3825 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -643,6 +643,17 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/maniphest/behavior-transaction-preview.js', ), + 0 => + array( + 'uri' => '/res/1da00bfe/rsrc/js/javelin/lib/__tests__/URI.js', + 'type' => 'js', + 'requires' => + array( + 0 => 'javelin-uri', + 1 => 'javelin-php-serializer', + ), + 'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js', + ), 'javelin-behavior-owners-path-editor' => array( 'uri' => '/res/9cf78ffc/rsrc/js/application/owners/owners-path-editor.js', @@ -725,17 +736,6 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/projects/projects-resource-editor.js', ), - 0 => - array( - 'uri' => '/res/1da00bfe/rsrc/js/javelin/lib/__tests__/URI.js', - 'type' => 'js', - 'requires' => - array( - 0 => 'javelin-uri', - 1 => 'javelin-php-serializer', - ), - 'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js', - ), 'javelin-behavior-refresh-csrf' => array( 'uri' => '/res/88beba4c/rsrc/js/application/core/behavior-refresh-csrf.js', @@ -1169,6 +1169,15 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/herald/PathTypeahead.js', ), + 'phabricator-content-source-view-css' => + array( + 'uri' => '/res/7147f14c/rsrc/css/application/contentsource/content-source-view.css', + 'type' => 'css', + 'requires' => + array( + ), + 'disk' => '/rsrc/css/application/contentsource/content-source-view.css', + ), 'phabricator-core-buttons-css' => array( 'uri' => '/res/3059cf79/rsrc/css/core/buttons.css', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e30db127a6..ed33b347be 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -344,6 +344,8 @@ phutil_register_library_map(array( 'PhabricatorConduitLogController' => 'applications/conduit/controller/log', 'PhabricatorConduitMethodCallLog' => 'applications/conduit/storage/methodcalllog', 'PhabricatorConduitTokenController' => 'applications/conduit/controller/token', + 'PhabricatorContentSource' => 'applications/metamta/contentsource/source', + 'PhabricatorContentSourceView' => 'applications/metamta/contentsource/view', 'PhabricatorController' => 'applications/base/controller/base', 'PhabricatorCountdownController' => 'applications/countdown/controller/base', 'PhabricatorCountdownDAO' => 'applications/countdown/storage/base', @@ -951,6 +953,7 @@ phutil_register_library_map(array( 'PhabricatorConduitLogController' => 'PhabricatorConduitController', 'PhabricatorConduitMethodCallLog' => 'PhabricatorConduitDAO', 'PhabricatorConduitTokenController' => 'PhabricatorConduitController', + 'PhabricatorContentSourceView' => 'AphrontView', 'PhabricatorController' => 'AphrontController', 'PhabricatorCountdownController' => 'PhabricatorController', 'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO', diff --git a/src/aphront/request/AphrontRequest.php b/src/aphront/request/AphrontRequest.php index 09250a4875..25eb1fb677 100644 --- a/src/aphront/request/AphrontRequest.php +++ b/src/aphront/request/AphrontRequest.php @@ -252,4 +252,8 @@ class AphrontRequest { return $this->isFormPost() && $this->getStr('__dialog__'); } + final public function getRemoteAddr() { + return $_SERVER['REMOTE_ADDR']; + } + } diff --git a/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php b/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php index 428d5ee97b..f123ed3146 100644 --- a/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php +++ b/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php @@ -66,9 +66,14 @@ class ConduitAPI_differential_updaterevision_Method extends ConduitAPIMethod { throw new ConduitException('ERR_COMMITTED'); } + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_CONDUIT, + array()); + $editor = new DifferentialRevisionEditor( $revision, $revision->getAuthorPHID()); + $editor->setContentSource($content_source); $fields = $request->getValue('fields'); $editor->copyFieldsFromConduit($fields); diff --git a/src/applications/conduit/method/differential/updaterevision/__init__.php b/src/applications/conduit/method/differential/updaterevision/__init__.php index 96f0fe8ce3..e139660974 100644 --- a/src/applications/conduit/method/differential/updaterevision/__init__.php +++ b/src/applications/conduit/method/differential/updaterevision/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/revisi phutil_require_module('phabricator', 'applications/differential/editor/revision'); phutil_require_module('phabricator', 'applications/differential/storage/diff'); phutil_require_module('phabricator', 'applications/differential/storage/revision'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/conduit/method/maniphest/createtask/ConduitAPI_maniphest_createtask_Method.php b/src/applications/conduit/method/maniphest/createtask/ConduitAPI_maniphest_createtask_Method.php index 567b16692c..985eccd0a5 100644 --- a/src/applications/conduit/method/maniphest/createtask/ConduitAPI_maniphest_createtask_Method.php +++ b/src/applications/conduit/method/maniphest/createtask/ConduitAPI_maniphest_createtask_Method.php @@ -87,7 +87,12 @@ final class ConduitAPI_maniphest_createtask_Method ); } + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_CONDUIT, + array()); + $template = new ManiphestTransaction(); + $template->setContentSource($content_source); $template->setAuthorPHID($request->getUser()->getPHID()); $transactions = array(); diff --git a/src/applications/conduit/method/maniphest/createtask/__init__.php b/src/applications/conduit/method/maniphest/createtask/__init__.php index 26dcd306c8..06390dfb64 100644 --- a/src/applications/conduit/method/maniphest/createtask/__init__.php +++ b/src/applications/conduit/method/maniphest/createtask/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/transacti phutil_require_module('phabricator', 'applications/maniphest/editor/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phabricator', 'applications/phid/constants'); diff --git a/src/applications/differential/controller/commentsave/DifferentialCommentSaveController.php b/src/applications/differential/controller/commentsave/DifferentialCommentSaveController.php index 6355d44240..9f589951c9 100644 --- a/src/applications/differential/controller/commentsave/DifferentialCommentSaveController.php +++ b/src/applications/differential/controller/commentsave/DifferentialCommentSaveController.php @@ -40,8 +40,15 @@ class DifferentialCommentSaveController extends DifferentialController { $request->getUser()->getPHID(), $action); + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_WEB, + array( + 'ip' => $request->getRemoteAddr(), + )); + $editor ->setMessage($comment) + ->setContentSource($content_source) ->setAttachInlineComments(true) ->setAddCC($action != DifferentialAction::ACTION_RESIGN) ->setAddedReviewers($reviewers) diff --git a/src/applications/differential/controller/commentsave/__init__.php b/src/applications/differential/controller/commentsave/__init__.php index 20dddcc7dc..7392c007a0 100644 --- a/src/applications/differential/controller/commentsave/__init__.php +++ b/src/applications/differential/controller/commentsave/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/differential/controller/base' phutil_require_module('phabricator', 'applications/differential/editor/comment'); phutil_require_module('phabricator', 'applications/differential/storage/revision'); phutil_require_module('phabricator', 'applications/draft/storage/draft'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index 362b3567cb..61e7ca55b5 100644 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -30,6 +30,7 @@ class DifferentialCommentEditor { private $addedCCs = array(); private $parentMessageID; + private $contentSource; public function __construct( DifferentialRevision $revision, @@ -88,6 +89,11 @@ class DifferentialCommentEditor { return $this->addedCCs; } + public function setContentSource(PhabricatorContentSource $content_source) { + $this->contentSource = $content_source; + return $this; + } + public function save() { $revision = $this->revision; $action = $this->action; @@ -320,8 +326,13 @@ class DifferentialCommentEditor { ->setRevisionID($revision->getID()) ->setAction($action) ->setContent((string)$this->message) - ->setMetadata($metadata) - ->save(); + ->setMetadata($metadata); + + if ($this->contentSource) { + $comment->setContentSource($this->contentSource); + } + + $comment->save(); $changesets = array(); if ($inline_comments) { diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index e570881dc8..20a3fab1f9 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -33,6 +33,7 @@ class DifferentialRevisionEditor { protected $silentUpdate; private $auxiliaryFields = array(); + private $contentSource; public function __construct(DifferentialRevision $revision, $actor_phid) { $this->revision = $revision; @@ -108,6 +109,11 @@ class DifferentialRevisionEditor { return $this; } + public function setContentSource(PhabricatorContentSource $content_source) { + $this->contentSource = $content_source; + return $this; + } + public function addDiff(DifferentialDiff $diff, $comments) { if ($diff->getRevisionID() && $diff->getRevisionID() != $this->getRevision()->getID()) { @@ -652,6 +658,11 @@ class DifferentialRevisionEditor { ->setRevisionID($revision_id) ->setContent($this->getComments()) ->setAction('update'); + + if ($this->contentSource) { + $comment->setContentSource($this->contentSource); + } + $comment->save(); return $comment; diff --git a/src/applications/differential/replyhandler/DifferentialReplyHandler.php b/src/applications/differential/replyhandler/DifferentialReplyHandler.php index 516ebd453c..a23b28f50e 100644 --- a/src/applications/differential/replyhandler/DifferentialReplyHandler.php +++ b/src/applications/differential/replyhandler/DifferentialReplyHandler.php @@ -139,6 +139,12 @@ class DifferentialReplyHandler extends PhabricatorMailReplyHandler { // implementation jumps straight into handleAction() and will not have // a PhabricatorMetaMTAReceivedMail object. if ($this->receivedMail) { + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_EMAIL, + array( + 'id' => $this->receivedMail->getID(), + )); + $editor->setContentSource($content_source); $editor->setParentMessageID($this->receivedMail->getMessageID()); } $editor->setMessage($body); diff --git a/src/applications/differential/replyhandler/__init__.php b/src/applications/differential/replyhandler/__init__.php index c857d47389..dcf9ca1d33 100644 --- a/src/applications/differential/replyhandler/__init__.php +++ b/src/applications/differential/replyhandler/__init__.php @@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/action phutil_require_module('phabricator', 'applications/differential/editor/comment'); phutil_require_module('phabricator', 'applications/differential/editor/revision'); phutil_require_module('phabricator', 'applications/differential/mail/exception'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phabricator', 'applications/metamta/replyhandler/base'); phutil_require_module('phabricator', 'infrastructure/env'); diff --git a/src/applications/differential/storage/comment/DifferentialComment.php b/src/applications/differential/storage/comment/DifferentialComment.php index 674ea034f3..bb814240a5 100644 --- a/src/applications/differential/storage/comment/DifferentialComment.php +++ b/src/applications/differential/storage/comment/DifferentialComment.php @@ -27,6 +27,7 @@ class DifferentialComment extends DifferentialDAO { protected $content; protected $cache; protected $metadata = array(); + protected $contentSource; public function getConfiguration() { return array( @@ -36,4 +37,13 @@ class DifferentialComment extends DifferentialDAO { ) + parent::getConfiguration(); } + public function setContentSource(PhabricatorContentSource $content_source) { + $this->contentSource = $content_source->serialize(); + return $this; + } + + public function getContentSource() { + return PhabricatorContentSource::newFromSerialized($this->contentSource); + } + } diff --git a/src/applications/differential/storage/comment/__init__.php b/src/applications/differential/storage/comment/__init__.php index 8f477dca99..dbdbe480a5 100644 --- a/src/applications/differential/storage/comment/__init__.php +++ b/src/applications/differential/storage/comment/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/differential/storage/base'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_source('DifferentialComment.php'); diff --git a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php index 74c7a853c6..64fb56ee0d 100644 --- a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php +++ b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php @@ -94,7 +94,14 @@ final class DifferentialRevisionCommentView extends AphrontView { $date = phabricator_datetime($comment->getDateCreated(), $this->user); } - $info = array($date); + $info = array(); + + $content_source = new PhabricatorContentSourceView(); + $content_source->setContentSource($comment->getContentSource()); + $content_source->setUser($this->user); + $info[] = $content_source->render(); + + $info[] = $date; $comment_anchor = null; $num = $this->commentNumber; @@ -110,7 +117,7 @@ final class DifferentialRevisionCommentView extends AphrontView { $comment_anchor = 'anchor-comment-'.$num; } - $info = implode(' · ', $info); + $info = implode(' · ', array_filter($info)); $author = $this->handles[$comment->getAuthorPHID()]; $author_link = $author->renderLink(); @@ -278,6 +285,7 @@ final class DifferentialRevisionCommentView extends AphrontView { ''. $inline_render. ''. + $content_source->render(). ''); } diff --git a/src/applications/differential/view/revisioncomment/__init__.php b/src/applications/differential/view/revisioncomment/__init__.php index 8dee4bedd6..c09a1245b9 100644 --- a/src/applications/differential/view/revisioncomment/__init__.php +++ b/src/applications/differential/view/revisioncomment/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'aphront/writeguard'); phutil_require_module('phabricator', 'applications/differential/constants/action'); phutil_require_module('phabricator', 'applications/differential/storage/comment'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/view'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'view/base'); diff --git a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php index c181e71998..9181ca03c2 100644 --- a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php @@ -182,8 +182,15 @@ class ManiphestTaskEditController extends ManiphestController { ); } + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_WEB, + array( + 'ip' => $request->getRemoteAddr(), + )); + $template = new ManiphestTransaction(); $template->setAuthorPHID($user->getPHID()); + $template->setContentSource($content_source); $transactions = array(); foreach ($changes as $type => $value) { diff --git a/src/applications/maniphest/controller/taskedit/__init__.php b/src/applications/maniphest/controller/taskedit/__init__.php index 83478c7560..79f39fff09 100644 --- a/src/applications/maniphest/controller/taskedit/__init__.php +++ b/src/applications/maniphest/controller/taskedit/__init__.php @@ -17,6 +17,7 @@ phutil_require_module('phabricator', 'applications/maniphest/editor/transaction' phutil_require_module('phabricator', 'applications/maniphest/extensions/base'); phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); diff --git a/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php b/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php index 0e5aae986e..7d130c5d06 100644 --- a/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php +++ b/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php @@ -219,6 +219,16 @@ class ManiphestTransactionSaveController extends ManiphestController { $transactions[] = $cc_transaction; } + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_WEB, + array( + 'ip' => $request->getRemoteAddr(), + )); + + foreach ($transactions as $transaction) { + $transaction->setContentSource($content_source); + } + $editor = new ManiphestTransactionEditor(); $editor->applyTransactions($task, $transactions); diff --git a/src/applications/maniphest/controller/transactionsave/__init__.php b/src/applications/maniphest/controller/transactionsave/__init__.php index 2967a0a491..43e8b529a3 100644 --- a/src/applications/maniphest/controller/transactionsave/__init__.php +++ b/src/applications/maniphest/controller/transactionsave/__init__.php @@ -17,6 +17,7 @@ phutil_require_module('phabricator', 'applications/maniphest/editor/transaction' phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/markup/engine'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php b/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php index 374da6c953..6bb47a8f8e 100644 --- a/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php +++ b/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php @@ -66,7 +66,14 @@ class ManiphestReplyHandler extends PhabricatorMailReplyHandler { $xactions = array(); + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_EMAIL, + array( + 'id' => $mail->getID(), + )); + $template = new ManiphestTransaction(); + $template->setContentSource($content_source); $template->setAuthorPHID($user->getPHID()); if ($is_new_task) { diff --git a/src/applications/maniphest/replyhandler/__init__.php b/src/applications/maniphest/replyhandler/__init__.php index 376777c40f..0f8e28bc54 100644 --- a/src/applications/maniphest/replyhandler/__init__.php +++ b/src/applications/maniphest/replyhandler/__init__.php @@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/editor/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_module('phabricator', 'applications/metamta/replyhandler/base'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'infrastructure/env'); diff --git a/src/applications/maniphest/storage/transaction/ManiphestTransaction.php b/src/applications/maniphest/storage/transaction/ManiphestTransaction.php index 153e46f375..fbe5ded867 100644 --- a/src/applications/maniphest/storage/transaction/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/transaction/ManiphestTransaction.php @@ -29,6 +29,7 @@ class ManiphestTransaction extends ManiphestDAO { protected $comments; protected $cache; protected $metadata = array(); + protected $contentSource; public function getConfiguration() { return array( @@ -104,5 +105,13 @@ class ManiphestTransaction extends ManiphestDAO { return (bool)strlen(trim($this->getComments())); } + public function setContentSource(PhabricatorContentSource $content_source) { + $this->contentSource = $content_source->serialize(); + return $this; + } + + public function getContentSource() { + return PhabricatorContentSource::newFromSerialized($this->contentSource); + } } diff --git a/src/applications/maniphest/storage/transaction/__init__.php b/src/applications/maniphest/storage/transaction/__init__.php index c4e475868c..f095c1223e 100644 --- a/src/applications/maniphest/storage/transaction/__init__.php +++ b/src/applications/maniphest/storage/transaction/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/storage/base'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/source'); phutil_require_source('ManiphestTransaction.php'); diff --git a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php index e11852f786..61145b902f 100644 --- a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php +++ b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php @@ -202,6 +202,13 @@ class ManiphestTransactionDetailView extends ManiphestView { } $info = array(); + + $source_transaction = nonempty($comment_transaction, $any_transaction); + $content_source = new PhabricatorContentSourceView(); + $content_source->setContentSource($source_transaction->getContentSource()); + $content_source->setUser($this->user); + $info[] = $content_source->render(); + $info[] = $timestamp; $comment_anchor = null; @@ -218,7 +225,8 @@ class ManiphestTransactionDetailView extends ManiphestView { $comment_anchor = 'anchor-comment-'.$num; } - $info = implode(' · ', $info); + + $info = implode(' · ', array_filter($info)); return phutil_render_tag( 'div', diff --git a/src/applications/maniphest/view/transactiondetail/__init__.php b/src/applications/maniphest/view/transactiondetail/__init__.php index b1c34a4630..e47dde0c10 100644 --- a/src/applications/maniphest/view/transactiondetail/__init__.php +++ b/src/applications/maniphest/view/transactiondetail/__init__.php @@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/priority' phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/view/base'); +phutil_require_module('phabricator', 'applications/metamta/contentsource/view'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/env'); diff --git a/src/applications/metamta/contentsource/source/PhabricatorContentSource.php b/src/applications/metamta/contentsource/source/PhabricatorContentSource.php new file mode 100644 index 0000000000..e058dfdb1d --- /dev/null +++ b/src/applications/metamta/contentsource/source/PhabricatorContentSource.php @@ -0,0 +1,75 @@ + + } + + public static function newForSource($source, array $params) { + $obj = new PhabricatorContentSource(); + $obj->source = $source; + $obj->params = $params; + + return $obj; + } + + public static function newFromSerialized($serialized) { + $dict = json_decode($serialized, true); + if (!is_array($dict)) { + $dict = array(); + } + + $obj = new PhabricatorContentSource(); + $obj->source = idx($dict, 'source', self::SOURCE_UNKNOWN); + $obj->params = idx($dict, 'params', array()); + + return $obj; + } + + public function serialize() { + return json_encode(array( + 'source' => $this->getSource(), + 'params' => $this->getParams(), + )); + } + + public function getSource() { + return $this->source; + } + + public function getParams() { + return $this->params; + } + + public function getParam($key, $default = null) { + return idx($this->params, $key, $default); + } + +} diff --git a/src/applications/metamta/contentsource/source/__init__.php b/src/applications/metamta/contentsource/source/__init__.php new file mode 100644 index 0000000000..96cacc81bc --- /dev/null +++ b/src/applications/metamta/contentsource/source/__init__.php @@ -0,0 +1,12 @@ +contentSource = $content_source; + return $this; + } + + public function setUser(PhabricatorUser $user) { + $this->user = $user; + return $this; + } + + + public function render() { + require_celerity_resource('phabricator-content-source-view-css'); + + $type = null; + $map = array( + PhabricatorContentSource::SOURCE_WEB => 'web', + PhabricatorContentSource::SOURCE_CONDUIT => 'conduit', + PhabricatorContentSource::SOURCE_EMAIL => 'email', + PhabricatorContentSource::SOURCE_MOBILE => 'mobile', + PhabricatorContentSource::SOURCE_TABLET => 'tablet', + ); + + $source = $this->contentSource->getSource(); + $type = idx($map, $source, null); + + if (!$type) { + return; + } + + $type_class = 'phabricator-content-source-'.$type; + + return phutil_render_tag( + 'span', + array( + 'class' => "phabricator-content-source-view {$type_class}", + ), + 'Via'); + } + +} diff --git a/src/applications/metamta/contentsource/view/__init__.php b/src/applications/metamta/contentsource/view/__init__.php new file mode 100644 index 0000000000..fbbe1f68c5 --- /dev/null +++ b/src/applications/metamta/contentsource/view/__init__.php @@ -0,0 +1,17 @@ +