diff --git a/src/application/SemiStructuredDataApplication.php b/src/application/SemiStructuredDataApplication.php index 52884e7..20f0932 100644 --- a/src/application/SemiStructuredDataApplication.php +++ b/src/application/SemiStructuredDataApplication.php @@ -1,65 +1,67 @@ array( - '(?:query/(?P[^/]+)/)?' => + $this->getQueryRoutePattern() => 'SemiStructuredObjectTypeListController', $this->getEditRoutePattern('editclass/') => 'SemiStructuredObjectTypeEditController', + 'type/(?:(?P\d+)/)?' => array( '' => 'SemiStructuredObjectTypeViewController', 'items/' => 'SemiStructuredObjectInstanceListController', - '(?:query/(?P[^/]+)/)?' => 'SemiStructuredObjectInstanceListController', + $this->getQueryRoutePattern() => + 'SemiStructuredObjectInstanceListController', 'archive/' => 'SemiStructuredObjectTypeArchiveController', ), // If the ID field is called `id`, the EditEngine thinks this is // editing an existing object. 'type/(?:(?P\d+)/)?' => array( 'new/' => 'SemiStructuredObjectNewInstanceController', ), $this->getEditRoutePattern('editinstance/') => 'SemiStructuredObjectInstanceEditController', 'instance/(?:(?P\d+)/)?' => 'SemiStructuredObjectInstanceViewController', ), ); } } diff --git a/src/phid/SemiStructuredObjectInstancePHIDType.php b/src/phid/SemiStructuredObjectInstancePHIDType.php index b838e3c..e379250 100644 --- a/src/phid/SemiStructuredObjectInstancePHIDType.php +++ b/src/phid/SemiStructuredObjectInstancePHIDType.php @@ -1,44 +1,47 @@ withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $item = $objects[$phid]; $id = $item->getID(); $class = $item->getClass(); - $handle->setName(pht('%s %d', $class->getName(), $id)); + $handle->setName( + pht("%s\xE2\x96\xB9%s", + $class->getName(), + $item->getName())); $handle->setURI("/semistruct/instance/{$id}/"); } } } diff --git a/src/query/SemiStructuredObjectInstanceSearchEngine.php b/src/query/SemiStructuredObjectInstanceSearchEngine.php index 0b5013c..dbb0b4a 100644 --- a/src/query/SemiStructuredObjectInstanceSearchEngine.php +++ b/src/query/SemiStructuredObjectInstanceSearchEngine.php @@ -1,167 +1,208 @@ 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->withObjectType($this->getObjectType()); } return $query; } protected function buildCustomSearchFields() { $fields = array( ); if ($this->getObjectType()) { $fields[] = id(new SemiStructuredStaticSearchField()) ->setKey('objecttype') ->setLabel(pht('Object Type')) ->setValue($this->getObjectType()->getName()); } return $fields; } protected function getURI($path) { return "/semistruct/type/{$this->getObjectType()->getID()}/{$path}"; } protected function getBuiltinQueryNames() { $names = array(); $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; } +/* -( Export )------------------------------------------------------------ */ + + protected function newExportFields() { + return array( + id(new PhabricatorStringExportField()) + ->setKey('name') + ->setLabel(pht('Name')), + id(new PhabricatorStringExportField()) + ->setKey('description') + ->setLabel(pht('Description')), + id(new PhabricatorStringExportField()) + ->setKey('rawData') + ->setLabel(pht('Raw Data')), + id(new PhabricatorPHIDExportField()) + ->setKey('classPHID') + ->setLabel(pht('Class PHID')), + id(new PhabricatorURIExportField()) + ->setKey('uri') + ->setLabel(pht('URI')), + ); + } + + protected function newExportData(array $instances) { + // $viewer = $this->requireViewer(); + + $export = array(); + foreach ($instances as $instance) { + + $export[] = array( + 'name' => $instance->getName(), + 'uri' => PhabricatorEnv::getProductionURI($instance->getURI()), + 'description' => $instance->getDescription(), + 'classPHID' => $instance->getClassPHID(), + 'rawData' => $instance->getRawData(), + ); + } + + + return $export; + } + }