示例#1
0
 /**
  * Get Collections that fall under this Community
  * Locally implemented as it's specific to Communities
  *
  * @todo: use class constants for link (/hairdressing/api/)
  */
 public function populateCollections()
 {
     $result = Db\Models\MenuLink::where('menu_name', '=', "'primary-links'")->andWhere('p1', '=', ' (select p1 from menu_links where link_path=\'node/' . $this->id . '\') ')->andWhere('depth', '=', 2)->andWhere('hidden', '=', 0)->get();
     foreach ($result->getItems() as $item) {
         $collection = new Collection(array('id' => str_replace('node/', '', $item->link_path), 'name' => $item->link_title, 'handle' => $item->link_path, 'parentCommunity' => $this->id, 'link' => '/hairdressing/api/collection/' . str_replace('node/', '', $item->link_path), 'numberItems' => self::getSiblingsCount($item->mlid, 2, array(3))));
         $collectionList[] = $collection;
     }
     $this->collections = $collectionList;
 }
示例#2
0
文件: Item.php 项目: pdiveris/api_ht
 /**
  * Find and set the parent collection
  */
 public function populateParentCollection()
 {
     $handle = $this->handle;
     /**
      * p2 for immediate parent in Deerupal
      *
      */
     $menuLink = MenuLink::where('mlid', '=', "(select p2 from menu_links where link_path='{$handle}')")->get();
     if ($menuLink->getItems() > 0) {
         $item = $menuLink->getItems()[0];
         $id = str_replace('node/', '', $item->link_path);
         $collection = new \Jisc\api\Service\Hairdressing\Collection(array('id' => $id, 'handle' => $item->link_path, 'link' => self::$servicePoint . '/' . 'collection' . '/' . $id, 'name' => $item->link_title));
         $this->parentCollection = $collection;
     }
 }
示例#3
0
 /**
  * Return all 'valid' handles, i.e. the 'permanent' IDs of all live items
  * This was constructed to support Rob Tice's request for a means to remove stuff form the index
  * since neither HR nor Jorum use the withdrawn flag
  *
  * @return array
  */
 public static function allHandles()
 {
     // set the model
     self::setModel();
     if (self::$model == 'Item') {
         $id = 'nid';
         $statement = Db\Models\Node::where('nid', 'in', " (select replace(link_path, 'node/', '') from menu_links where hidden=0 and menu_name='primary-links' and depth >2 order by plid,p1,p2,p3)");
     } else {
         $id = 'mlid';
         $depth = 0;
         if (self::$model == 'Community') {
             $depth = 1;
         } elseif (self::$model == 'Collection') {
             $depth = 2;
         }
         $statement = Db\Models\MenuLink::where('menu_name', '=', "'primary-links'")->andWhere('depth', '=', $depth)->andWhere('hidden', '=', 0)->andWhere('has_children', '=', 1);
     }
     $columns = array($id);
     $statement->select($columns);
     $result = $statement->get(true);
     $ret = array();
     foreach ($result as $i => $object) {
         $ret[] = 'node/' . $object->{$id};
     }
     return $ret;
 }