function testFindTags()
 {
     $this->cleanDB();
     $this->assertEquals(Bookmarks::findTags($this->userid, $this->db), array());
     Bookmarks::addBookmark($this->userid, $this->db, 'http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project');
     $this->assertEquals(array(0 => array('tag' => 'cloud', 'nbr' => 1), 1 => array('tag' => 'oc', 'nbr' => 1)), Bookmarks::findTags($this->userid, $this->db));
 }
示例#2
0
 /**
  * @NoAdminRequired
  */
 public function fullTags()
 {
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     $qtags = Bookmarks::findTags($this->userId, $this->db, array(), 0, 400);
     $tags = array();
     foreach ($qtags as $tag) {
         $tags[] = $tag['tag'];
     }
     return new JSONResponse($tags);
 }
 /**
  * @NoAdminRequired
  */
 public function getBookmarks($type = "bookmark", $tag = '', $page = 0, $sort = "bookmarks_sorting_recent")
 {
     if ($type == 'rel_tags') {
         $tags = Bookmarks::analyzeTagRequest($tag);
         $qtags = Bookmarks::findTags($this->userId, $this->db, $tags);
         return new JSONResponse(array('data' => $qtags, 'status' => 'success'));
     } else {
         // type == bookmark
         $filterTag = Bookmarks::analyzeTagRequest($tag);
         $offset = $page * 10;
         if ($sort == 'bookmarks_sorting_clicks') {
             $sqlSortColumn = 'clickcount';
         } else {
             $sqlSortColumn = 'lastmodified';
         }
         $bookmarks = Bookmarks::findBookmarks($this->userId, $this->db, $offset, $sqlSortColumn, $filterTag, true);
         return new JSONResponse(array('data' => $bookmarks, 'status' => 'success'));
     }
 }