function search($query) { $results = array(); $offset = 0; $sqlSortColumn = 'id'; $searchquery = array(); if (substr_count($query, ' ') > 0) { $searchquery = explode(' ', $query); } else { $searchquery = $query; } // OCP\Util::writeLog('bookmarks', 'search ' .$query ,OCP\Util::DEBUG); $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false); // OCP\Util::writeLog('bookmarks', 'found ' .count($bookmarks) ,OCP\Util::DEBUG); //$l = new OC_l10n('bookmarks'); //resulttype can't be localized, javascript relies on that type foreach ($bookmarks as $bookmark) { $results[] = new OC_Search_Result($bookmark['title'], '', $bookmark['url'], 'Bookm.'); } return $results; }
* * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); $req_type = isset($_GET['type']) ? $_GET['type'] : 'bookmark'; if ($req_type == 'rel_tags') { $tags = OC_Bookmarks_Bookmarks::analyzeTagRequest(isset($_GET['tag']) ? $_GET['tag'] : ''); $qtags = OC_Bookmarks_Bookmarks::findTags($tags); OCP\JSON::success(array('data' => $qtags)); } else { // type == bookmark $filterTag = OC_Bookmarks_Bookmarks::analyzeTagRequest(isset($_GET['tag']) ? $_GET['tag'] : ''); $offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0; $sort = isset($_GET['sort']) ? $_GET['sort'] : 'bookmarks_sorting_recent'; if ($sort == 'bookmarks_sorting_clicks') { $sqlSortColumn = 'clickcount'; } else { $sqlSortColumn = 'lastmodified'; } $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $filterTag, true); OCP\JSON::success(array('data' => $bookmarks)); }
return $name; } else { return substr($name, 0, $pos); } } $file = <<<EOT <!DOCTYPE NETSCAPE-Bookmark-file-1> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> <!-- This is an automatically generated file. It will be read and overwritten. Do Not Edit! --> <TITLE>Bookmarks</TITLE> <H1>Bookmarks</H1> <DL><p> EOT; $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1); foreach ($bookmarks as $bm) { $title = $bm['title']; if (trim($title) === '') { $url_parts = parse_url($bm['url']); $title = isset($url_parts['host']) ? getDomainWithoutExt($url_parts['host']) : $bm['url']; } $file .= '<DT><A HREF="' . $bm['url'] . '" TAGS="' . implode(',', $bm['tags']) . '">'; $file .= htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '</A>'; if ($bm['description']) { $file .= '<DD>' . htmlspecialchars($bm['description'], ENT_QUOTES, 'UTF-8'); } $file .= "\n"; } $user_name = trim(OCP\User::getDisplayName()) != '' ? OCP\User::getDisplayName() : OCP\User::getUser(); $export_name = '"ownCloud Bookmarks (' . $user_name . ') (' . date('Y-m-d') . ').html"';
function testAddBM() { $this->assertCount(0, OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1)); OC_Bookmarks_Bookmarks::addBookmark('http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project'); $this->assertCount(1, OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1)); }