Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/pholio/controller/PholioController.php b/src/applications/pholio/controller/PholioController.php
index e738ae7cf0..b91a6c1989 100644
--- a/src/applications/pholio/controller/PholioController.php
+++ b/src/applications/pholio/controller/PholioController.php
@@ -1,22 +1,40 @@
<?php
/**
* @group pholio
*/
abstract class PholioController extends PhabricatorController {
- public function buildSideNav() {
+ public function buildSideNav($filter = null, $for_app = false) {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
- $nav->addLabel('Create');
- $nav->addFilter('new', pht('Create Mock'));
-
$nav->addLabel('Mocks');
$nav->addFilter('view/all', pht('All Mocks'));
+ if ($for_app) {
+ $nav->addFilter('new/', pht('Create Mock'));
+ }
+
return $nav;
}
+ public function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+
+ $crumbs->addAction(
+ id(new PhabricatorMenuItemView())
+ ->setName(pht('Create Mock'))
+ ->setHref($this->getApplicationURI('new/'))
+ ->setIcon('create'));
+
+ return $crumbs;
+ }
+
+ public function buildApplicationMenu() {
+ return $this->buildSideNav(null, true)->getMenu();
+ }
+
+
}
diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php
index cfc1da1022..ae577497c2 100644
--- a/src/applications/pholio/controller/PholioMockEditController.php
+++ b/src/applications/pholio/controller/PholioMockEditController.php
@@ -1,217 +1,218 @@
<?php
/**
* @group pholio
*/
final class PholioMockEditController extends PholioController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($this->id) {
$mock = id(new PholioMockQuery())
->setViewer($user)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->withIDs(array($this->id))
->executeOne();
if (!$mock) {
return new Aphront404Response();
}
$title = pht('Edit Mock');
$is_new = false;
} else {
$mock = new PholioMock();
$mock->setAuthorPHID($user->getPHID());
$mock->setViewPolicy(PhabricatorPolicies::POLICY_USER);
$title = pht('Create Mock');
$is_new = true;
}
$e_name = true;
$e_images = true;
$errors = array();
$v_name = $mock->getName();
$v_desc = $mock->getDescription();
$v_view = $mock->getViewPolicy();
if ($request->isFormPost()) {
$xactions = array();
$type_name = PholioTransactionType::TYPE_NAME;
$type_desc = PholioTransactionType::TYPE_DESCRIPTION;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$v_name = $request->getStr('name');
$v_desc = $request->getStr('description');
$v_view = $request->getStr('can_view');
$xactions[$type_name] = $v_name;
$xactions[$type_desc] = $v_desc;
$xactions[$type_view] = $v_view;
if (!strlen($request->getStr('name'))) {
$e_name = 'Required';
$errors[] = pht('You must name the mock.');
}
$images = array();
if ($is_new) {
// TODO: Make this transactional and allow edits?
$files = array();
$file_phids = $request->getArr('file_phids');
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
->setViewer($user)
->withPHIDs($file_phids)
->execute();
}
if (!$files) {
- $e_images = 'Required';
+ $e_images = pht('Required');
$errors[] = pht('You must add at least one image to the mock.');
} else {
$mock->setCoverPHID(head($files)->getPHID());
}
$sequence = 0;
foreach ($files as $file) {
$image = new PholioImage();
$image->setFilePHID($file->getPHID());
$image->setSequence($sequence++);
$images[] = $image;
}
}
if (!$errors) {
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_WEB,
array(
'ip' => $request->getRemoteAddr(),
));
foreach ($xactions as $type => $value) {
$xactions[$type] = id(new PholioTransaction())
->setTransactionType($type)
->setNewValue($value);
}
$mock->openTransaction();
$editor = id(new PholioMockEditor())
->setContentSource($content_source)
->setContinueOnNoEffect(true)
->setActor($user);
$xactions = $editor->applyTransactions($mock, $xactions);
if ($images) {
foreach ($images as $image) {
// TODO: Move into editor?
$image->setMockID($mock->getID());
$image->save();
}
}
$mock->saveTransaction();
return id(new AphrontRedirectResponse())
->setURI('/M'.$mock->getID());
}
}
if ($errors) {
$error_view = id(new AphrontErrorView())
->setTitle(pht('Form Errors'))
->setErrors($errors);
} else {
$error_view = null;
}
if ($this->id) {
$submit = id(new AphrontFormSubmitControl())
->addCancelButton('/M'.$this->id)
->setValue(pht('Save'));
} else {
$submit = id(new AphrontFormSubmitControl())
->addCancelButton($this->getApplicationURI())
->setValue(pht('Create'));
}
$policies = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($mock)
->execute();
// NOTE: Make this show up correctly on the rendered form.
$mock->setViewPolicy($v_view);
$form = id(new AphrontFormView())
->setUser($user)
->setFlexible(true)
->appendChild(
id(new AphrontFormTextControl())
->setName('name')
->setValue($v_name)
->setLabel(pht('Name'))
->setError($e_name))
->appendChild(
id(new PhabricatorRemarkupControl())
->setName('description')
->setValue($v_desc)
->setLabel(pht('Description'))
->setUser($user))
->appendChild(
id(new AphrontFormDragAndDropUploadControl($request))
->setName('file_phids')
->setLabel(pht('Images'))
->setError($e_images))
->appendChild(
id(new AphrontFormPolicyControl())
->setUser($user)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicyObject($mock)
->setPolicies($policies)
->setName('can_view'))
->appendChild($submit);
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$content = array(
$header,
$error_view,
$form,
);
$nav = $this->buildSideNav();
$nav->selectFilter(null);
$nav->appendChild($content);
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
+ 'device' => true,
));
}
}
diff --git a/src/applications/pholio/controller/PholioMockListController.php b/src/applications/pholio/controller/PholioMockListController.php
index 2e5a4351d5..eeaaf65382 100644
--- a/src/applications/pholio/controller/PholioMockListController.php
+++ b/src/applications/pholio/controller/PholioMockListController.php
@@ -1,65 +1,70 @@
<?php
/**
* @group pholio
*/
final class PholioMockListController extends PholioController {
private $view;
public function willProcessRequest(array $data) {
$this->view = idx($data, 'view');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$query = id(new PholioMockQuery())
->setViewer($user)
->needCoverFiles(true);
$nav = $this->buildSideNav();
$filter = $nav->selectFilter('view/'.$this->view, 'view/all');
switch ($filter) {
case 'view/all':
default:
- $title = 'All Mocks';
+ $title = pht('All Mocks');
break;
}
$pager = new AphrontCursorPagerView();
$pager->readFromRequest($request);
$mocks = $query->executeWithCursorPager($pager);
$board = new PhabricatorPinboardView();
foreach ($mocks as $mock) {
$board->addItem(
id(new PhabricatorPinboardItemView())
->setHeader($mock->getName())
->setURI('/M'.$mock->getID())
->setImageURI($mock->getCoverFile()->getThumb220x165URI())
->setImageSize(220, 165));
}
- $header = id(new PhabricatorHeaderView())
- ->setHeader($title);
-
$content = array(
- $header,
$board,
$pager,
);
$nav->appendChild($content);
+ $crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName($title)
+ ->setHref($this->getApplicationURI())
+ );
+ $nav->setCrumbs($crumbs);
+
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
+ 'device' => true,
));
}
}
diff --git a/src/applications/pholio/controller/PholioMockViewController.php b/src/applications/pholio/controller/PholioMockViewController.php
index 927e03cdd1..d8dc11e27a 100644
--- a/src/applications/pholio/controller/PholioMockViewController.php
+++ b/src/applications/pholio/controller/PholioMockViewController.php
@@ -1,197 +1,204 @@
<?php
/**
* @group pholio
*/
final class PholioMockViewController extends PholioController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$mock = id(new PholioMockQuery())
->setViewer($user)
->withIDs(array($this->id))
->needImages(true)
->needCoverFiles(true)
->executeOne();
if (!$mock) {
return new Aphront404Response();
}
$xactions = id(new PholioTransactionQuery())
->setViewer($user)
->withObjectPHIDs(array($mock->getPHID()))
->execute();
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$mock->getPHID());
$phids = array();
$phids[] = $mock->getAuthorPHID();
foreach ($subscribers as $subscriber) {
$phids[] = $subscriber;
}
$this->loadHandles($phids);
$engine = id(new PhabricatorMarkupEngine())
->setViewer($user);
$engine->addObject($mock, PholioMock::MARKUP_FIELD_DESCRIPTION);
foreach ($xactions as $xaction) {
if ($xaction->getComment()) {
$engine->addObject(
$xaction->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
}
$engine->process();
$title = 'M'.$mock->getID().' '.$mock->getName();
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$actions = $this->buildActionView($mock);
$properties = $this->buildPropertyView($mock, $engine, $subscribers);
require_celerity_resource('pholio-css');
$output = new PholioMockImagesView();
$output->setMock($mock);
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($this->getRequest()->getUser())
->setTransactions($xactions)
->setMarkupEngine($engine);
$add_comment = $this->buildAddCommentView($mock);
+ $crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName($title)
+ ->setHref($this->getApplicationURI().'M'.$this->id)
+ );
+
$content = array(
+ $crumbs,
$header,
$actions,
$properties,
$output->render(),
$xaction_view,
$add_comment,
);
-
return $this->buildApplicationPage(
$content,
array(
'title' => $title,
'device' => true,
));
}
private function buildActionView(PholioMock $mock) {
$user = $this->getRequest()->getUser();
$actions = id(new PhabricatorActionListView())
->setUser($user)
->setObject($mock);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$mock,
PhabricatorPolicyCapability::CAN_EDIT);
$actions->addAction(
id(new PhabricatorActionView())
->setIcon('edit')
->setName(pht('Edit Mock'))
->setHref($this->getApplicationURI('/edit/'.$mock->getID()))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
return $actions;
}
private function buildPropertyView(
PholioMock $mock,
PhabricatorMarkupEngine $engine,
array $subscribers) {
$user = $this->getRequest()->getUser();
$properties = id(new PhabricatorPropertyListView())
->setUser($user)
->setObject($mock);
$properties->addProperty(
pht('Author'),
$this->getHandle($mock->getAuthorPHID())->renderLink());
$properties->addProperty(
pht('Created'),
phabricator_datetime($mock->getDateCreated(), $user));
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
$user,
$mock);
$properties->addProperty(
pht('Visible To'),
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
if ($subscribers) {
$sub_view = array();
foreach ($subscribers as $subscriber) {
$sub_view[] = $this->getHandle($subscriber)->renderLink();
}
$sub_view = phutil_implode_html(', ', $sub_view);
} else {
$sub_view = phutil_tag('em', array(), pht('None'));
}
$properties->addProperty(
pht('Subscribers'),
$sub_view);
$properties->invokeWillRenderEvent();
$properties->addTextContent(
$engine->getOutput($mock, PholioMock::MARKUP_FIELD_DESCRIPTION));
return $properties;
}
private function buildAddCommentView(PholioMock $mock) {
$user = $this->getRequest()->getUser();
$draft = PhabricatorDraft::newFromUserAndKey($user, $mock->getPHID());
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$title = $is_serious
? pht('Add Comment')
: pht('History Beckons');
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$button_name = $is_serious
? pht('Add Comment')
: pht('Answer The Call');
$form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($user)
->setDraft($draft)
->setSubmitButtonName($button_name)
->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'));
return array(
$header,
$form,
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Aug 14, 2:07 PM (1 d, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
202290
Default Alt Text
(15 KB)

Event Timeline