function testFindTags()
 {
     // 		$uid=uniqid();
     $this->assertEquals(OC_Bookmarks_Bookmarks::findTags(), array());
     OC_Bookmarks_Bookmarks::addBookmark('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)), OC_Bookmarks_Bookmarks::findTags());
 }
Beispiel #2
0
 function search($query)
 {
     $l = OC_L10N::get('bookmarks');
     $results = array();
     $search_words = array();
     if (substr_count($query, ' ') > 0) {
         $search_words = explode(' ', $query);
     } else {
         $search_words = $query;
     }
     $bookmarks = OC_Bookmarks_Bookmarks::searchBookmarks($search_words);
     $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['title'], $bookmark['url'], (string) $l->t('Bookm.'), null);
     }
     return $results;
 }
 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;
 }
Beispiel #4
0
<?php

// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
$l = new OC_l10n('bookmarks');
if (empty($_FILES)) {
    OCP\Util::writeLog('bookmarks', "No file provided for import", \OCP\Util::WARN);
    $error[] = $l->t('No file provided for import');
} elseif (isset($_FILES['bm_import'])) {
    $file = $_FILES['bm_import']['tmp_name'];
    if ($_FILES['bm_import']['type'] == 'text/html') {
        $error = OC_Bookmarks_Bookmarks::importFile($file);
        if (empty($errors)) {
            OCP\JSON::success();
            //force charset as not set by OC_JSON
            header('Content-Type: application/json; charset=utf-8');
            exit;
        }
    } else {
        $error[] = $l->t('Unsupported file type for import');
    }
}
OC_JSON::error(array('data' => $error));
//force charset as not set by OC_JSON
header('Content-Type: application/json; charset=utf-8');
exit;
Beispiel #5
0
* 
* 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));
}
/**
* ownCloud - bookmarks plugin
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* 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 Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
//no apps or filesystem
$RUNTIME_NOSETUPFS = true;
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks');
$id = $_POST['id'];
if (!OC_Bookmarks_Bookmarks::deleteUrl($id)) {
    OC_JSON::error();
    exit;
}
OCP\JSON::success();
Beispiel #7
0
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks');
// Prep screen if we come from the bookmarklet
$url = '';
if (isset($_GET['url'])) {
    $url = $_GET['url'];
}
if (!isset($_GET['title']) || trim($_GET['title']) == '') {
    $datas = OC_Bookmarks_Bookmarks::getURLMetadata($url);
    $title = isset($datas['title']) ? $datas['title'] : '';
} else {
    $title = $_GET['title'];
}
OCP\Util::addscript('bookmarks/3rdparty', 'tag-it');
OCP\Util::addscript('bookmarks', 'addBm');
OCP\Util::addStyle('bookmarks', 'bookmarks');
OCP\Util::addStyle('bookmarks/3rdparty', 'jquery.tagit');
$bm = array('title' => $title, 'url' => $url, 'tags' => array(), 'desc' => '', 'is_public' => 0);
//Find All Tags
$qtags = OC_Bookmarks_Bookmarks::findTags(array(), 0, 400);
$tags = array();
foreach ($qtags as $tag) {
    $tags[] = $tag['tag'];
}
$tmpl = new OCP\Template('bookmarks', 'addBm', 'base');
$tmpl->assign('requesttoken', OC_Util::callRegister());
$tmpl->assign('bookmark', $bm);
$tmpl->assign('tags', json_encode($tags));
$tmpl->printPage();
Beispiel #8
0
        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"';
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* 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 Lesser General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
//no apps or filesystem
$RUNTIME_NOSETUPFS = true;
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
if (isset($_POST['old_name']) && isset($_POST['new_name']) && $_POST['new_name'] != '') {
    OC_Bookmarks_Bookmarks::renameTag($_POST['old_name'], $_POST['new_name']);
    OCP\JSON::success();
    exit;
}
OC_JSON::error();
exit;
Beispiel #10
0
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
// Check if it is a valid URL
if (filter_var($_POST['url'], FILTER_VALIDATE_URL) === FALSE) {
    OC_JSON::error();
    exit;
}
// If we go the dialog form submit
if (isset($_POST['url'])) {
    $title = isset($_POST['title']) ? $_POST['title'] : '';
    $tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
    $pub = isset($_POST['is_public']) ? true : false;
    if (isset($_POST['record_id']) && is_numeric($_POST['record_id'])) {
        //EDIT
        $id = OC_Bookmarks_Bookmarks::editBookmark($_POST['record_id'], $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
    } else {
        if (isset($_POST['from_own'])) {
            $datas = OC_Bookmarks_Bookmarks::getURLMetadata($_POST['url']);
            if (isset($datas['title'])) {
                $title = $datas['title'];
            }
        }
        $id = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub);
    }
    $bm = OC_Bookmarks_Bookmarks::findOneBookmark($id);
    OCP\JSON::success(array('item' => $bm));
    exit;
}
OC_JSON::error();
exit;
Beispiel #11
0
* 
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
require_once OC_App::getAppPath('bookmarks') . '/bookmarksHelper.php';
// If we go the dialog form submit
if (isset($_POST['url'])) {
    $title = '';
    $tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
    $pub = isset($_POST['is_public']) ? true : false;
    if (isset($_POST['record_id']) && is_numeric($_POST['record_id'])) {
        //EDIT
        $bm = $_POST['record_id'];
        OC_Bookmarks_Bookmarks::editBookmark($bm, $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
        $title = $_POST['title'];
    } else {
        if (isset($_POST['from_own'])) {
            $datas = getURLMetadata($_POST['url']);
            if (isset($datas['title'])) {
                $title = $datas['title'];
            }
        }
        $bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub);
    }
    OCP\JSON::success(array('id' => $bm, 'title' => $title));
    exit;
}
OC_JSON::error();
exit;
Beispiel #12
0
/**
* ownCloud - bookmarks plugin
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* 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::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
if (isset($_POST['old_name'])) {
    OC_Bookmarks_Bookmarks::deleteTag($_POST['old_name']);
    OCP\JSON::success();
    exit;
}
OC_JSON::error();
exit;
Beispiel #13
0
/**
* ownCloud - bookmarks plugin
*
* @author Brice Maron
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* 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'] : '';
if ($req_type == 'url_info' && $_GET['url']) {
    $datas = OC_Bookmarks_Bookmarks::getURLMetadata($_GET['url']);
    $title = isset($datas['title']) ? $datas['title'] : '';
    OCP\JSON::success(array('title' => $title));
    exit;
}
OC_JSON::error();
exit;