Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2894712
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
6 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/application/SemiStructuredDataApplication.php b/src/application/SemiStructuredDataApplication.php
index cb8a4c7..1838298 100644
--- a/src/application/SemiStructuredDataApplication.php
+++ b/src/application/SemiStructuredDataApplication.php
@@ -1,57 +1,58 @@
<?php
final class SemiStructuredDataApplication extends PhabricatorApplication {
public function getName() {
return pht('Semi-Structured');
}
public function getShortDescription() {
return pht('Work with evolving data sets.');
}
public function getIcon() {
return 'fa-wpforms';
}
public function getBaseURI() {
return '/semistruct/';
}
public function getRemarkupRules() {
// I think I want to use this method to allow classes
// to define user-provided "RemarkupRule" for their instances.
return array(
new SemiStructuredObjectTypeRemarkupRule(),
);
}
public function getRoutes() {
return array(
'/semistruct/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' =>
'SemiStructuredObjectTypeListController',
$this->getEditRoutePattern('editclass/') =>
'SemiStructuredObjectTypeEditController',
'type/(?:(?P<id>\d+)/)?' => array(
'' => 'SemiStructuredObjectTypeViewController',
'items/' => 'SemiStructuredObjectInstanceListController',
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'SemiStructuredObjectInstanceListController',
'archive/' => 'SemiStructuredObjectTypeArchiveController',
),
// If the ID field is called `id`, the EditEngine thinks this is
// editing an existing object.
'type/(?:(?P<typeid>\d+)/)?' => array(
'new/' => 'SemiStructuredObjectNewInstanceController',
),
$this->getEditRoutePattern('editinstance/') =>
'SemiStructuredObjectInstanceEditController',
'instance/(?:(?P<id>\d+)/)?' =>
'SemiStructuredObjectInstanceViewController',
),
);
}
}
diff --git a/src/query/SemiStructuredObjectInstanceSearchEngine.php b/src/query/SemiStructuredObjectInstanceSearchEngine.php
index 3e5fe63..af3f842 100644
--- a/src/query/SemiStructuredObjectInstanceSearchEngine.php
+++ b/src/query/SemiStructuredObjectInstanceSearchEngine.php
@@ -1,166 +1,166 @@
<?php
final class SemiStructuredObjectInstanceSearchEngine
extends PhabricatorApplicationSearchEngine {
private $objectType;
public function setObjectType(SemiStructuredObjectType $object_type) {
$this->objectType = $object_type;
return $this;
}
public function getObjectType() {
return $this->objectType;
}
public function getResultTypeDescription() {
return pht('Object Instances');
}
public function getApplicationClassName() {
return 'SemiStructuredDataApplication';
}
public function newQuery() {
$query = id(new SemiStructuredObjectInstanceQuery());
if ($this->getObjectType()) {
$query->withClassPhids(array($this->getObjectType()->getPHID()));
}
return $query;
}
protected function buildCustomSearchFields() {
return array(
// TODO object class
id(new SemiStructuredStaticSearchField())
->setKey('objecttype')
->setLabel(pht('Object Type'))
->setValue($this->getObjectType()->getName()),
);
}
protected function getURI($path) {
- return '/semistruct/'.$path;
+ return "/semistruct/type/{$this->getObjectType()->getID()}/{$path}";
}
protected function getBuiltinQueryNames() {
$names = array();
- $names['all'] = pht('All object');
+ $names['all'] = pht('All Instances');
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
$viewer = $this->requireViewer();
switch ($query_key) {
case 'all':
return $query;
case 'open':
return $query->setParameter(
'statuses',
array(
SemiStructuredObjectType::STATUS_ACTIVE,
));
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
// TODO type id/phid
// if ($map['statuses']) {
// $query->withStatuses($map['statuses']);
// }
// if ($map['editable'] !== null) {
// $query->withCanEdit($map['editable']);
// }
return $query;
}
protected function getRequiredHandlePHIDsForResultList(
array $objects,
PhabricatorSavedQuery $query) {
return array();
}
public function renderResultsDirectly(array $items) {
return $this->renderResultList(
$items,
new PhabricatorSavedQuery(),
array());
}
protected function renderResultList(
array $items,
PhabricatorSavedQuery $query ,
array $handles) {
$viewer = $this->requireViewer();
if ($items) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($items, 'getPHID'))
->withEdgeTypes(
array(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
));
$edge_query->execute();
}
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($items as $instance) {
$item = id(new PHUIObjectItemView())
->setViewer($viewer)
->setObjectName($instance->getName())
->setHeader($instance->getName())
->setHref($instance->getURI())
->setObject($instance);
$icon = id(new PHUIIconView())
->setIcon($instance->getIcon());
$item->setImageIcon($icon);
$item->setEpoch($instance->getDateModified());
$phid = $instance->getPHID();
$project_phids = $edge_query->getDestinationPHIDs(array($phid));
$project_handles = $viewer->loadHandles($project_phids);
$item->addAttribute(
id(new PHUIHandleTagListView())
->setLimit(4)
->setNoDataString(pht('No Tags'))
->setSlim(true)
->setHandles($project_handles));
$list->addItem($item);
}
$result = new PhabricatorApplicationSearchResultView();
$result->setObjectList($list);
$result->setNoDataString(pht('No objects found.'));
return $result;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 20:20 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1119662
Default Alt Text
(6 KB)
Attached To
Mode
R6 Semi Structured
Attached
Detach File
Event Timeline
Log In to Comment