コード例 #1
0
    public function doCollection()
    {
        // Document need to contain the minimum require data for each collection
        // Author, title, updated, id, link

        $crit = new ezpContentCriteria();
        $crit->accept[] = ezpContentCriteria::location()->subtree( ezpContentLocation::fetchByNodeId( $this->nodeId ) );

        $retData = array();
        $baseUri = substr( $this->request->protocol, 0, strpos( $this->request->protocol, "-" ) ) . "://{$this->request->host}";

        foreach ( ezpContentRepository::query( $crit ) as $node )
        {
            $retData[] = array(
                "objectName" => $node->name,
                "author" => $node->owner->Name,
                "modified" => $node->dateModified,
                "published" => $node->datePublished,
                "classIdentifier" => $node->classIdentifier,
                "nodeUrl" => $baseUri . $this->getRouter()->generateUrl( 1, array( "nodeId" => $node->locations->node_id ) )
            );
        }

        $result = new ezcMvcResult();
        $result->variables["collection"] = $retData;
        return $result;
    }
コード例 #2
0
ファイル: atom.php プロジェクト: robinmuilwijk/ezpublish
    public function doCollection()
    {
        // Document need to contain the minimum require data for each collection
        // Author, title, updated, id, link

        $crit = new ezpContentCriteria();
        $crit->accept[] = ezpContentCriteria::location()->subtree( ezpContentLocation::fetchByNodeId( $this->nodeId ) );
        $childNodes = ezpContentRepository::query( $crit );


        $result = new ezcMvcResult();

        $retData = array();
        $protIndex = strpos( $this->request->protocol, '-' );
        $baseUri = substr( $this->request->protocol, 0, $protIndex ) . "://{$this->request->host}";
        foreach( $childNodes as $node )
        {
            $childEntry = array(
                            'objectName' => $node->name,
                            'author' => $node->owner->Name,
                            'modified' => $node->dateModified,
                            'published' => $node->datePublished,
                            'classIdentifier' => $node->classIdentifier,
                            'nodeUrl' => $baseUri . $this->getRouter()->generateUrl( 1, array( 'nodeId' => $node->locations->node_id ) ) );
            $retData[] = $childEntry;
        }

        $result->variables['collection'] = $retData;
        return $result;
    }
コード例 #3
0
 public function doListByClass()
 {
     $nodeId = eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode');
     $openDataTools = new OCOpenDataTools();
     $class = $openDataTools->getClass($this->classIdentifier);
     if (!$class instanceof eZContentClass) {
         throw new Exception('La classe non esiste');
     }
     $classIdentifier = $class->attribute('identifier');
     $className = $class->attribute('name');
     $this->setDefaultResponseGroups(array(self::VIEWLIST_RESPONSEGROUP_METADATA));
     $result = new ezpRestMvcResult();
     $crit = new ezpContentCriteria();
     // Location criteria
     // Hmm, the following sequence is too long...
     $crit->accept[] = ezpContentCriteria::location()->subtree(ezpContentLocation::fetchByNodeId($nodeId));
     $crit->accept[] = ezpContentCriteria::depth(20);
     $crit->accept[] = new ezpContentMainNodeOnlyCriteria(true);
     $crit->accept[] = ezpContentCriteria::contentClass()->is($classIdentifier);
     // Limit criteria
     $offset = isset($this->offset) ? $this->offset : 0;
     $limit = isset($this->limit) ? $this->limit : 10;
     $crit->accept[] = ezpContentCriteria::limit()->offset($offset)->limit($limit);
     // Sort criteria
     /*
     if( isset( $this->sortKey ) )
     {
         $sortOrder = isset( $this->sortType ) ? $this->sortType : 'asc';
         $crit->accept[] = ezpContentCriteria::sorting( $this->sortKey, $sortOrder );
     }
     */
     $crit->accept[] = ezpContentCriteria::sorting('published', 'desc');
     $result->variables['nodes'] = ITOpenDataContentModel::getChildrenList($crit, $this->request, $this->getResponseGroups(), $this->getRouter());
     // REST links to children nodes
     // Little dirty since this should belong to the model layer, but I don't want to pass the router nor the full controller to the model
     $contentQueryString = $this->request->getContentQueryString(true);
     for ($i = 0, $iMax = count($result->variables['nodes']); $i < $iMax; ++$i) {
         $linkURI = $this->getRouter()->generateUrl('ezpNode', array('nodeId' => $result->variables['nodes'][$i]['nodeId']));
         $result->variables['nodes'][$i]['link'] = $this->request->getHostURI() . $linkURI . $contentQueryString;
     }
     // Handle Metadata
     if ($this->hasResponseGroup(self::VIEWLIST_RESPONSEGROUP_METADATA)) {
         $childrenCount = ITOpenDataContentModel::getChildrenCount($crit);
         $result->variables['metadata'] = array('count' => $childrenCount, 'rootNodeId' => $nodeId, 'classIdentifier' => $classIdentifier, 'className' => $className, 'limit' => $limit, 'offset' => $offset);
     }
     return $result;
 }
コード例 #4
0
ファイル: content.php プロジェクト: legende91/ez
 /**
  * Counts children of a given node
  * Request :
  *   - GET /api/ezp/content/node/childrenCount
  */
 public function doCountChildren()
 {
     $this->setDefaultResponseGroups(array(self::VIEWLIST_RESPONSEGROUP_METADATA));
     $result = new ezpRestMvcResult();
     if ($this->hasResponseGroup(self::VIEWLIST_RESPONSEGROUP_METADATA)) {
         $crit = new ezpContentCriteria();
         $crit->accept[] = ezpContentCriteria::location()->subtree(ezpContentLocation::fetchByNodeId($this->nodeId));
         $crit->accept[] = ezpContentCriteria::depth(1);
         // Fetch children only
         $childrenCount = ezpRestContentModel::getChildrenCount($crit);
         $result->variables['metadata'] = array('childrenCount' => $childrenCount, 'parentNodeId' => $this->nodeId);
     }
     return $result;
 }
コード例 #5
0
ファイル: content.php プロジェクト: rmiguel/ezp_rest
 public function doList()
 {
     $crit = new ezpContentCriteria();
     // Hmm, the following sequence is too long...
     $crit->accept[] = ezpContentCriteria::location()->subtree(ezpContentLocation::fetchByNodeId($this->nodeId));
     $childNodes = ezpContentRepository::query($crit);
     // Need paging here
     $result = new ezcMvcResult();
     $retData = array();
     // To be moved to URI convenience methods
     $protIndex = strpos($this->request->protocol, '-');
     $baseUri = substr($this->request->protocol, 0, $protIndex) . "://{$this->request->host}";
     foreach ($childNodes as $node) {
         $childEntry = array('objectName' => $node->name, 'classIdentifier' => $node->classIdentifier, 'nodeUrl' => $baseUri . $this->getRouter()->generateUrl(1, array('nodeId' => $node->locations->node_id)));
         $retData[] = $childEntry;
     }
     $result->variables['childNodes'] = $retData;
     return $result;
 }