Esempio n. 1
0
function addBookmark($url, $title, $tags = '')
{
    $CONFIG_DBTYPE = OCP\Config::getSystemValue("dbtype", "sqlite");
    if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') {
        $_ut = "strftime('%s','now')";
    } elseif ($CONFIG_DBTYPE == 'pgsql') {
        $_ut = 'date_part(\'epoch\',now())::integer';
    } else {
        $_ut = "UNIX_TIMESTAMP()";
    }
    //FIXME: Detect when user adds a known URL
    $query = OCP\DB::prepare("\n\t\tINSERT INTO `*PREFIX*bookmarks`\n\t\t(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`)\n\t\tVALUES (?, ?, ?, 0, {$_ut}, {$_ut})\n\t\t");
    if (empty($title)) {
        $metadata = getURLMetadata($url);
        if (isset($metadata['title'])) {
            // Check for problems fetching the title
            $title = $metadata['title'];
        }
    }
    if (empty($title)) {
        $l = OC_L10N::get('bookmarks');
        $title = $l->t('unnamed');
    }
    $params = array(htmlspecialchars_decode($url), htmlspecialchars_decode($title), OCP\USER::getUser());
    $query->execute($params);
    $b_id = OCP\DB::insertid('*PREFIX*bookmarks');
    if ($b_id !== false) {
        $query = OCP\DB::prepare("\n\t\t\tINSERT INTO `*PREFIX*bookmarks_tags`\n\t\t\t(`bookmark_id`, `tag`)\n\t\t\tVALUES (?, ?)\n\t\t\t");
        $tags = explode(' ', urldecode($tags));
        foreach ($tags as $tag) {
            if (empty($tag)) {
                //avoid saving blankspaces
                continue;
            }
            $params = array($b_id, trim($tag));
            $query->execute($params);
        }
        return $b_id;
    }
}
* @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/>.
* 
*/
require_once '../../lib/base.php';
// Check if we are a user
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
require_once 'bookmarksHelper.php';
OC_App::setActiveNavigationEntry('bookmarks_index');
OC_Util::addScript('bookmarks', 'addBm');
OC_Util::addStyle('bookmarks', 'bookmarks');
$tmpl = new OC_Template('bookmarks', 'addBm', 'user');
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
$metadata = getURLMetadata($url);
$tmpl->assign('URL', htmlentities($metadata['url']));
$tmpl->assign('TITLE', htmlentities($metadata['title']));
$tmpl->printPage();
Esempio n. 3
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 Lesser 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');
require_once OC_App::getAppPath('bookmarks') . '/bookmarksHelper.php';
$req_type = isset($_GET['type']) ? $_GET['type'] : '';
if ($req_type == 'url_info' && $_GET['url']) {
    $datas = getURLMetadata($_GET['url']);
    $title = isset($datas['title']) ? $datas['title'] : '';
    OCP\JSON::success(array('title' => $title));
    exit;
}
OC_JSON::error();
exit;
/**
* 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;
require_once '../../../lib/base.php';
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
// $metadata = array();
require '../bookmarksHelper.php';
$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"]));
OC_JSON::success(array('data' => $metadata));
Esempio n. 5
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;
Esempio n. 6
0
*
* 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/>.
*
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks');
require_once 'bookmarksHelper.php';
// Prep screen if we come from the bookmarklet
$url = '';
if (isset($_GET['url'])) {
    $url = $_GET['url'];
}
if (!isset($_GET['title']) || trim($_GET['title']) == '') {
    $datas = 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'];
}