Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890622
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
11 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/controller/instance/SemiStructuredObjectInstanceViewController.php b/src/controller/instance/SemiStructuredObjectInstanceViewController.php
index 1663420..ff1cdfc 100644
--- a/src/controller/instance/SemiStructuredObjectInstanceViewController.php
+++ b/src/controller/instance/SemiStructuredObjectInstanceViewController.php
@@ -1,96 +1,103 @@
<?php
final class SemiStructuredObjectInstanceViewController
extends SemiStructuredObjectInstanceController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$object = id(new SemiStructuredObjectInstanceQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$object) {
return new Aphront404Response();
}
$this->setObject($object);
+ $object_type = $object->getClass();
$crumbs = $this->buildApplicationCrumbs();
- $title = "AN OBJ";// $object_type->getName();
+ $title = pht(
+ "%s: %d %s",
+ $object_type->getName(),
+ $object->getID(),
+ $object->getName());
$header = $this->buildHeaderView();
$curtain = $this->buildCurtain();
$details = $this->buildDetailsView();
// $timeline = $this->buildTransactionTimeline(
// $object_type,
// new PhabricatorBadgesTransactionQuery()); /// TODO
$timeline = null;
$comment_view = id(new SemiStructuredObjectInstanceEditEngine())
->setViewer($viewer)
->buildEditEngineCommentView($object);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$timeline,
$comment_view,
))
- ->addPropertySection(pht('Description'), $details);
+ ->addPropertySection(pht('Details'), $details);
$navigation = $this->buildSideNavView('view');
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(array($object->getPHID()))
->setNavigation($navigation)
->appendChild($view);
}
private function buildDetailsView() {
$viewer = $this->getViewer();
$object = $this->getObject();
$view = id(new PHUIPropertyListView())
->setUser($viewer);
-/* $description = $object_type->getDescription();
- if (strlen($description)) {
- $view->addTextContent(
- new PHUIRemarkupView($viewer, $description));
- }
-*/
+ $content = $object->getRawData();
+ $content = id(new PhutilJSON())
+ ->encodeFormatted(json_decode($content));
+
+ $view->addProperty(
+ pht('Unstructured content'),
+ phutil_tag('pre', array(), $content));
+
return $view;
}
private function buildCurtain() {
$viewer = $this->getViewer();
$object = $this->getObject();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$object,
PhabricatorPolicyCapability::CAN_EDIT);
$id = $object->getID();
$edit_uri = $this->getApplicationURI("/editinstance/{$id}/");
$curtain = $this->newCurtainView($object);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Instance'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
->setHref($edit_uri));
return $curtain;
}
}
diff --git a/src/editor/SemiStructuredObjectInstanceEditEngine.php b/src/editor/SemiStructuredObjectInstanceEditEngine.php
index 7997473..ffd2a13 100644
--- a/src/editor/SemiStructuredObjectInstanceEditEngine.php
+++ b/src/editor/SemiStructuredObjectInstanceEditEngine.php
@@ -1,120 +1,124 @@
<?php
final class SemiStructuredObjectInstanceEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'sst:objectinstance';
private $objectType;
public function isEngineConfigurable() {
return false;
}
public function getEngineName() {
return pht('Object Instance');
}
public function getSummaryHeader() {
return pht('Edit Object Instance');
}
public function getSummaryText() {
return pht('This engine is used to modify object instances.');
}
public function getEngineApplicationClass() {
return 'SemiStructuredDataApplication';
}
public function setObjectType(SemiStructuredObjectType $object_type) {
$this->objectType = $object_type;
return $this;
}
protected function newEditableObject() {
$viewer = $this->getViewer();
return SemiStructuredObjectInstance::initializeNewObjectInstance(
$viewer,
$this->objectType);
}
protected function newObjectQuery() {
return new SemiStructuredObjectInstanceQuery();
}
protected function getObjectCreateTitleText($object) {
return pht('Create Object Instance');
}
protected function getObjectCreateButtonText($object) {
return pht('Create Object Instance');
}
protected function getObjectCreateCancelURI($object) {
// TODO if objjec has link to class - go to that class
return '/semistructured/';
}
protected function getEditorURI() {
return $this->getApplication()->getApplicationURI('editobject/');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Object: %d', $object->getID());
}
protected function getObjectEditShortText($object) {
return pht('Edit Object');
}
protected function getObjectCreateShortText() {
return pht('Create Object Instance');
}
protected function getObjectName() {
return pht('Object Instance');
}
protected function getObjectViewURI($object) {
return $object->getURI();
}
protected function buildCustomEditFields($object) {
$fields = array(
-// TODO is this the best edit field?
+ id(id(new PhabricatorStaticEditField())
+ ->setKey('objecttype')
+ ->setLabel(pht("Object Type"))
+ ->setValue($object->getClass()->getName())),
id(new PhabricatorIntEditField())
->setKey('classID')
->setLabel(pht('Object Type'))
->setDescription(pht('Type of the object.'))
->setConduitDescription(pht('Set type of object.'))
->setIsHidden(true)
->setTransactionType(
SemiStructuredObjectInstanceClassTransaction::TRANSACTIONTYPE)
->setIsRequired(true)
->setValue($object->getClassID()),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Name of the object.'))
->setConduitDescription(pht('Rename the object.'))
->setConduitTypeDescription(pht('New object name.'))
->setTransactionType(
SemiStructuredObjectInstanceNameTransaction::TRANSACTIONTYPE)
->setValue($object->getName()),
id(new PhabricatorTextAreaEditField())
->setKey('rawdata')
- ->setLabel(pht('Raw data'))
+ ->setLabel(pht('Unstructured content'))
->setDescription(pht('Object unstructured data (JSON).'))
->setConduitTypeDescription(pht('Object body (JSON).'))
->setMonospaced(true)
+ ->setIsRequired(true)
->setTransactionType(
SemiStructuredObjectInstanceRawDataTransaction::TRANSACTIONTYPE)
->setValue($object->getRawData()),
);
return $fields;
}
}
diff --git a/src/storage/SemiStructuredObjectInstance.php b/src/storage/SemiStructuredObjectInstance.php
index 0b8de71..eaf7a56 100644
--- a/src/storage/SemiStructuredObjectInstance.php
+++ b/src/storage/SemiStructuredObjectInstance.php
@@ -1,142 +1,142 @@
<?php
final class SemiStructuredObjectInstance extends SemiStructuredDAO
implements
PhabricatorPolicyInterface,
PhabricatorApplicationTransactionInterface,
// PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface,
// PhabricatorConduitResultInterface,
PhabricatorDestructibleInterface {
protected $classID;
protected $status;
protected $name;
protected $rawData;
// description?
// comments?
const STATUS_ACTIVE = 'active';
const STATUS_ARCHIVED = 'archived';
private $class = self::ATTACHABLE;
public static function initializeNewObjectInstance(
PhabricatorUser $actor,
SemiStructuredObjectType $object_class = null) {
$object = id(new self())
// ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) // TODO take policies from class?
// ->setEditPolicy($actor->getPHID())
->setStatus(self::STATUS_ACTIVE);
if ($object_class !== null) {
$object
->setClassID($object_class->getID())
->attachClass($object_class);
}
return $object;
}
public function attachClass(
SemiStructuredObjectType $object_class = null) {
$this->class = $object_class;
return $this;
}
public function getClass() {
return $this->assertAttached($this->class);
}
public function getURI() {
return urisprintf('/semistruct/instance/%d/', $this->getID());
}
public function getIcon() {
// TODO
return 'fa-google';
}
public static function getStatusNameMap() {
return array(
+ // TODO remove this
self::STATUS_ACTIVE => pht('Active'),
self::STATUS_ARCHIVED => pht('Archived'),
);
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'sort255',
- 'status' => 'text32',
- 'rawData' => 'text',
+ 'rawData' => 'text', // TODO maybe it should be marked as "json"?
),
self::CONFIG_KEY_SCHEMA => array(
'classID' => array(
'columns' => array('classID'),
),
),
) + parent::getConfiguration();
}
public function getPHIDType() {
return SemiStructuredObjectInstancePHIDType::TYPECONST;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new SemiStructuredObjectInstanceTransactionEditor();
}
public function getApplicationTransactionTemplate() {
return new SemiStructuredObjectInstanceTransaction();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
return;
switch ($capability) {
// TODO
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy();
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return true;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 13:52 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1119474
Default Alt Text
(11 KB)
Attached To
Mode
R6 Semi Structured
Attached
Detach File
Event Timeline
Log In to Comment