1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-02-18 15:54:28 +01:00

move apps

Merge branch 'master' of ../core

Conflicts:
	files_odfviewer/js/viewer.js
This commit is contained in:
Frank Karlitschek 2012-08-26 17:03:31 +02:00
commit 40dabcfb86
46 changed files with 1480 additions and 0 deletions

33
addBm.php Normal file
View File

@ -0,0 +1,33 @@
<?php
/**
* 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/>.
*
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php');
addBookmark($_GET['url'], '', 'Read-Later');
include 'templates/addBm.php';

37
ajax/addBookmark.php Normal file
View File

@ -0,0 +1,37 @@
<?php
/**
* 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::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php');
$id = addBookmark($_POST['url'], $_POST['title'], $_POST['tags']);
OCP\JSON::success(array('data' => $id));

37
ajax/delBookmark.php Normal file
View File

@ -0,0 +1,37 @@
<?php
/**
* 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/>.
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
OCP\JSON::callCheck();
$id = $_POST['id'];
if (!OC_Bookmarks_Bookmarks::deleteUrl($id)){
OC_JSON::error();
exit();
}
OCP\JSON::success();

90
ajax/editBookmark.php Normal file
View File

@ -0,0 +1,90 @@
<?php
/**
* ownCloud - bookmarks plugin - edit bookmark script
*
* @author Golnaz Nilieh
* @copyright 2011 Golnaz Nilieh <golnaz.nilieh@gmail.com>
*
* 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::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
$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';
} elseif($CONFIG_DBTYPE == 'oci') {
$_ut = '(oracletime - to_date(\'19700101\',\'YYYYMMDD\')) * 86400';
} else {
$_ut = "UNIX_TIMESTAMP()";
}
$bookmark_id = (int)$_POST["id"];
$user_id = OCP\USER::getUser();
//TODO check using CURRENT_TIMESTAMP? prepare already does magic when using now()
$query = OCP\DB::prepare('
UPDATE `*PREFIX*bookmarks`
SET `url` = ?, `title` = ?, `lastmodified` = '.$_ut.'
WHERE `id` = ?
AND `user_id` = ?
');
$params=array(
htmlspecialchars_decode($_POST["url"]),
htmlspecialchars_decode($_POST["title"]),
$bookmark_id,
$user_id,
);
$result = $query->execute($params);
# Abort the operation if bookmark couldn't be set (probably because the user is not allowed to edit this bookmark)
if ($result->numRows() == 0) exit();
# Remove old tags and insert new ones.
$query = OCP\DB::prepare('
DELETE FROM `*PREFIX*bookmarks_tags`
WHERE `bookmark_id` = ?
');
$params=array(
$bookmark_id
);
$query->execute($params);
$query = OCP\DB::prepare('
INSERT INTO `*PREFIX*bookmarks_tags`
(`bookmark_id`, `tag`)
VALUES (?, ?)
');
$tags = explode(' ', urldecode($_POST["tags"]));
foreach ($tags as $tag) {
if(empty($tag)) {
//avoid saving blankspaces
continue;
}
$params = array($bookmark_id, trim($tag));
$query->execute($params);
}

39
ajax/recordClick.php Normal file
View File

@ -0,0 +1,39 @@
<?php
/**
* 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/>.
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks');
$query = OCP\DB::prepare('
UPDATE `*PREFIX*bookmarks`
SET `clickcount` = `clickcount` + 1
WHERE `user_id` = ?
AND `url` LIKE ?
');
$params=array(OCP\USER::getUser(), htmlspecialchars_decode($_POST["url"]));
$bookmarks = $query->execute($params);
header( "HTTP/1.1 204 No Content" );

45
ajax/updateList.php Normal file
View File

@ -0,0 +1,45 @@
<?php
/**
* ownCloud - bookmarks plugin
*
* @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
* @copyright 2012 David Iwanowitsch <david at unclouded dot 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/>.
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks');
//Filter for tag?
$filterTag = isset($_POST['tag']) ? htmlspecialchars_decode($_POST['tag']) : false;
$offset = isset($_POST['page']) ? intval($_POST['page']) * 10 : 0;
$sort = isset($_POST['sort']) ? ($_POST['sort']) : 'bookmarks_sorting_recent';
if($sort == 'bookmarks_sorting_clicks') {
$sqlSortColumn = 'clickcount';
} else {
$sqlSortColumn = 'id';
}
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $filterTag, true);
OCP\JSON::success(array('data' => $bookmarks));

19
appinfo/app.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php';
OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php';
$l = new OC_l10n('bookmarks');
OCP\App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
OCP\App::registerPersonal('bookmarks', 'settings');
OCP\Util::addscript('bookmarks','bookmarksearch');
OC_Search::registerProvider('OC_Search_Provider_Bookmarks');

112
appinfo/database.xml Normal file
View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<name>*dbname*</name>
<create>true</create>
<overwrite>false</overwrite>
<charset>utf8</charset>
<table>
<name>*dbprefix*bookmarks</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<autoincrement>1</autoincrement>
<default>0</default>
<notnull>true</notnull>
<length>4</length>
</field>
<field>
<name>url</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>4096</length>
</field>
<field>
<name>title</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>140</length>
</field>
<field>
<name>user_id</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>public</name>
<type>integer</type>
<default>0</default>
<length>1</length>
</field>
<field>
<name>added</name>
<type>integer</type>
<default></default>
<notnull>false</notnull>
<unsigned>true</unsigned>
<length>4</length>
</field>
<field>
<name>lastmodified</name>
<type>integer</type>
<default></default>
<notnull>false</notnull>
<unsigned>true</unsigned>
<length>4</length>
</field>
<field>
<name>clickcount</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<unsigned>true</unsigned>
<length>4</length>
</field>
<index>
<name>id</name>
<unique>true</unique>
<field>
<name>id</name>
<sorting>descending</sorting>
</field>
</index>
</declaration>
</table>
<table>
<name>*dbprefix*bookmarks_tags</name>
<declaration>
<field>
<name>bookmark_id</name>
<type>integer</type>
<length>64</length>
</field>
<field>
<name>tag</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>255</length>
</field>
<index>
<name>bookmark_tag</name>
<unique>true</unique>
<field>
<name>bookmark_id</name>
<sorting>ascending</sorting>
</field>
<field>
<name>tag</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
</table>
</database>

11
appinfo/info.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<info>
<id>bookmarks</id>
<name>Bookmarks</name>
<description>Bookmark manager for ownCloud</description>
<licence>AGPL</licence>
<author>Arthur Schiwon, Marvin Thomas Rabe</author>
<standalone/>
<require>4</require>
<shipped>true</shipped>
</info>

68
appinfo/migrate.php Normal file
View File

@ -0,0 +1,68 @@
<?php
class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
// Create the xml for the user supplied
function export( ){
$options = array(
'table'=>'bookmarks',
'matchcol'=>'user_id',
'matchval'=>$this->uid,
'idcol'=>'id'
);
$ids = $this->content->copyRows( $options );
$options = array(
'table'=>'bookmarks_tags',
'matchcol'=>'bookmark_id',
'matchval'=>$ids
);
// Export tags
$ids2 = $this->content->copyRows( $options );
// If both returned some ids then they worked
if( is_array( $ids ) && is_array( $ids2 ) )
{
return true;
} else {
return false;
}
}
// Import function for bookmarks
function import( ){
switch( $this->appinfo->version ){
default:
// All versions of the app have had the same db structure, so all can use the same import function
$query = $this->content->prepare( "SELECT * FROM `bookmarks` WHERE `user_id` LIKE ?" );
$results = $query->execute( array( $this->olduid ) );
$idmap = array();
while( $row = $results->fetchRow() ){
// Import each bookmark, saving its id into the map
$query = OCP\DB::prepare( "INSERT INTO `*PREFIX*bookmarks`(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`) VALUES (?, ?, ?, ?, ?, ?)" );
$query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
// Map the id
$idmap[$row['id']] = OCP\DB::insertid();
}
// Now tags
foreach($idmap as $oldid => $newid){
$query = $this->content->prepare( "SELECT * FROM `bookmarks_tags` WHERE `bookmark_id` LIKE ?" );
$results = $query->execute( array( $oldid ) );
while( $row = $results->fetchRow() ){
// Import the tags for this bookmark, using the new bookmark id
$query = OCP\DB::prepare( "INSERT INTO `*PREFIX*bookmarks_tags`(`bookmark_id`, `tag`) VALUES (?, ?)" );
$query->execute( array( $newid, $row['tag'] ) );
}
}
// All done!
break;
}
return true;
}
}
// Load the provider
new OC_Migration_Provider_Bookmarks( 'bookmarks' );

1
appinfo/version Normal file
View File

@ -0,0 +1 @@
0.2

130
bookmarksHelper.php Normal file
View File

@ -0,0 +1,130 @@
<?php
// Source: http://www.php.net/manual/de/function.curl-setopt.php#102121
// This works around a safe_mode/open_basedir restriction
function curl_exec_follow(/*resource*/ $ch, /*int*/ &$maxredirect = null) {
$mr = $maxredirect === null ? 5 : intval($maxredirect);
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $mr > 0);
curl_setopt($ch, CURLOPT_MAXREDIRS, $mr);
} else {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
if ($mr > 0) {
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$rch = curl_copy_handle($ch);
curl_setopt($rch, CURLOPT_HEADER, true);
curl_setopt($rch, CURLOPT_NOBODY, true);
curl_setopt($rch, CURLOPT_FORBID_REUSE, false);
curl_setopt($rch, CURLOPT_RETURNTRANSFER, true);
do {
curl_setopt($rch, CURLOPT_URL, $newurl);
$header = curl_exec($rch);
if (curl_errno($rch)) {
$code = 0;
} else {
$code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
if ($code == 301 || $code == 302) {
preg_match('/Location:(.*?)\n/', $header, $matches);
$newurl = trim(array_pop($matches));
} else {
$code = 0;
}
}
} while ($code && --$mr);
curl_close($rch);
if (!$mr) {
if ($maxredirect === null) {
trigger_error('Too many redirects. When following redirects, libcurl hit the maximum amount.', E_USER_WARNING);
} else {
$maxredirect = 0;
}
return false;
}
curl_setopt($ch, CURLOPT_URL, $newurl);
}
}
return curl_exec($ch);
}
function getURLMetadata($url) {
//allow only http(s) and (s)ftp
$protocols = '/^[hs]{0,1}[tf]{0,1}tp[s]{0,1}\:\/\//i';
//if not (allowed) protocol is given, assume http
if(preg_match($protocols, $url) == 0) {
$url = 'http://' . $url;
}
$metadata['url'] = $url;
if (!function_exists('curl_init')){
return $metadata;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$page = curl_exec_follow($ch);
curl_close($ch);
@preg_match( "/<title>(.*)<\/title>/si", $page, $match );
$metadata['title'] = htmlspecialchars_decode(@$match[1]);
return $metadata;
}
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("
INSERT INTO `*PREFIX*bookmarks`
(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`)
VALUES (?, ?, ?, 0, $_ut, $_ut)
");
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("
INSERT INTO `*PREFIX*bookmarks_tags`
(`bookmark_id`, `tag`)
VALUES (?, ?)
");
$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;
}
}

87
css/bookmarks.css Normal file
View File

@ -0,0 +1,87 @@
#content { overflow: auto; height: 100%; }
#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777; position: relative;}
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; }
#firstrun .button { font-size: 0.7em; }
#firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; }
.bookmarks_headline {
font-size: large;
font-weight: bold;
margin-left: 2em;
padding: 2.5ex 0.5ex;
}
.bookmarks_menu {
margin-left: 1.5em;
padding: 0.5ex;
}
.bookmarks_list {
overflow: auto;
position: fixed;
top: 6.5em;
}
.bookmarks_addBml {
text-decoration: underline;
}
.bookmarks_label {
width: 7em;
display: inline-block;
text-align: right;
}
.bookmarks_input {
width: 8em;
}
.bookmark_actions {
position: absolute;
right: 1em;
top: 0.7em;
display: none;
}
.bookmark_actions span { margin: 0 0.4em; }
.bookmark_actions img { opacity: 0.3; }
.bookmark_actions img:hover { opacity: 1; cursor: pointer; }
.bookmark_single {
position: relative;
padding: 0.5em 1em;
border-bottom: 1px solid #DDD;
-webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms;
}
.bookmark_single:hover {
background-color:#f8f8f8
}
.bookmark_single:hover .bookmark_actions {
display: block;
}
.bookmark_title { font-weight: bold; display: inline-block; margin-right: 0.8em; }
.bookmark_url { display: none; color: #999; }
.bookmark_single:hover .bookmark_url { display: inline; }
.bookmark_tags {
position: absolute;
top: 0.5em;
right: 6em;
text-align: right;
}
.bookmark_tag {
display: inline-block;
color: white;
margin: 0 0.2em;
padding: 0 0.4em;
background-color: #1D2D44;
border-radius: 0.4em;
opacity: 0.2;
}
.bookmark_tag:hover { opacity: 0.5; }
.loading_meta {
display: none;
margin-left: 5px;
}

BIN
img/bookmarks.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

37
index.php Normal file
View File

@ -0,0 +1,37 @@
<?php
/**
* 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/>.
*
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks');
OCP\App::setActiveNavigationEntry( 'bookmarks_index' );
OCP\Util::addscript('bookmarks','bookmarks');
OCP\Util::addStyle('bookmarks', 'bookmarks');
$tmpl = new OCP\Template( 'bookmarks', 'list', 'user' );
$tmpl->printPage();

16
js/addBm.js Normal file
View File

@ -0,0 +1,16 @@
$(document).ready(function() {
$('#bookmark_add_submit').click(addBookmark);
});
function addBookmark(event) {
var url = $('#bookmark_add_url').val();
var tags = $('#bookmark_add_tags').val();
$.ajax({
type: 'POST',
url: 'ajax/addBookmark.php',
data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags),
success: function(data){
window.close();
}
});
}

201
js/bookmarks.js Normal file
View File

@ -0,0 +1,201 @@
var bookmarks_page = 0;
var bookmarks_loading = false;
var bookmarks_sorting = 'bookmarks_sorting_recent';
$(document).ready(function() {
$('#bookmark_add_submit').click(addOrEditBookmark);
$(window).resize(function () {
fillWindow($('.bookmarks_list'));
});
$(window).resize();
$('.bookmarks_list').scroll(updateOnBottom).empty().width($('#content').width());
getBookmarks();
});
function getBookmarks() {
if(bookmarks_loading) {
//have patience :)
return;
}
$.ajax({
type: 'POST',
url: OC.filePath('bookmarks', 'ajax', 'updateList.php'),
data: 'tag=' + encodeURIComponent($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting,
success: function(bookmarks){
if (bookmarks.data.length) {
bookmarks_page += 1;
}
$('.bookmark_link').unbind('click', recordClick);
$('.bookmark_delete').unbind('click', delBookmark);
$('.bookmark_edit').unbind('click', showBookmark);
for(var i in bookmarks.data) {
updateBookmarksList(bookmarks.data[i]);
$("#firstrun").hide();
}
if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show();
}
$('.bookmark_link').click(recordClick);
$('.bookmark_delete').click(delBookmark);
$('.bookmark_edit').click(showBookmark);
bookmarks_loading = false;
if (bookmarks.data.length) {
updateOnBottom()
}
}
});
}
// function addBookmark() {
// Instead of creating editBookmark() function, Converted the one above to
// addOrEditBookmark() to make .js file more compact.
function addOrEditBookmark(event) {
var id = $('#bookmark_add_id').val();
var url = encodeEntities($('#bookmark_add_url').val());
var title = encodeEntities($('#bookmark_add_title').val());
var tags = encodeEntities($('#bookmark_add_tags').val());
$("#firstrun").hide();
if($.trim(url) == '') {
OC.dialogs.alert('A valid bookmark url must be provided', 'Error creating bookmark');
return false;
}
if($.trim(title) == '') {
OC.dialogs.alert('A valid bookmark title must be provided', 'Error creating bookmark');
return false;
}
if (id == 0) {
$.ajax({
type: 'POST',
url: OC.filePath('bookmarks', 'ajax', 'addBookmark.php'),
data: 'url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title) + '&tags=' + encodeURIComponent(tags),
success: function(response){
$('.bookmarks_input').val('');
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
}
});
}
else {
$.ajax({
type: 'POST',
url: OC.filePath('bookmarks', 'ajax', 'editBookmark.php'),
data: 'id=' + id + '&url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title) + '&tags=' + encodeURIComponent(tags),
success: function(){
$('.bookmarks_input').val('');
$('#bookmark_add_id').val('0');
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
}
});
}
}
function delBookmark(event) {
var record = $(this).parent().parent();
$.ajax({
type: 'POST',
url: OC.filePath('bookmarks', 'ajax', 'delBookmark.php'),
data: 'id=' + record.data('id'),
success: function(data){
if (data.status == 'success') {
record.remove();
if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show();
}
}
}
});
}
function showBookmark(event) {
var record = $(this).parent().parent();
$('#bookmark_add_id').val(record.attr('data-id'));
$('#bookmark_add_url').val(record.children('.bookmark_url:first').text());
$('#bookmark_add_title').val(record.children('.bookmark_title:first').text());
$('#bookmark_add_tags').val(record.children('.bookmark_tags:first').text());
if ($('.bookmarks_add').css('display') == 'none') {
$('.bookmarks_add').slideToggle();
}
}
function replaceQueryString(url,param,value) {
var re = new RegExp("([?|&])" + param + "=.*?(&|$)","i");
if (url.match(re))
return url.replace(re,'$1' + param + "=" + value + '$2');
else
return url + '&' + param + "=" + value;
}
function updateBookmarksList(bookmark) {
var tags = encodeEntities(bookmark.tags).split(' ');
var taglist = '';
for ( var i=0, len=tags.length; i<len; ++i ){
if(tags[i] != '')
taglist = taglist + '<a class="bookmark_tag" href="'+replaceQueryString( String(window.location), 'tag', encodeURIComponent(tags[i])) + '">' + tags[i] + '</a> ';
}
if(!hasProtocol(bookmark.url)) {
bookmark.url = 'http://' + bookmark.url;
}
if(bookmark.title == '') bookmark.title = bookmark.url;
$('.bookmarks_list').append(
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
'<p class="bookmark_actions">' +
'<span class="bookmark_edit">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
'</span>' +
'<span class="bookmark_delete">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
'</span>&nbsp;' +
'</p>' +
'<p class="bookmark_title">'+
'<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' +
'</p>' +
'<p class="bookmark_url"><a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.url) + '</a></p>' +
'</div>'
);
if(taglist != '') {
$('div[data-id="'+ bookmark.id +'"]').append('<p class="bookmark_tags">' + taglist + '</p>');
}
}
function updateOnBottom() {
//check wether user is on bottom of the page
var top = $('.bookmarks_list>:last-child').position().top;
var height = $('.bookmarks_list').height();
// use a bit of margin to begin loading before we are really at the
// bottom
if (top < height * 1.2) {
getBookmarks();
}
}
function recordClick(event) {
$.ajax({
type: 'POST',
url: OC.filePath('bookmarks', 'ajax', 'recordClick.php'),
data: 'url=' + encodeURIComponent($(this).attr('href')),
});
}
function encodeEntities(s){
try {
return $('<div/>').text(s).html();
} catch (ex) {
return "";
}
}
function hasProtocol(url) {
var regexp = /(ftp|http|https|sftp)/;
return regexp.test(url);
}

23
js/bookmarksearch.js Normal file
View File

@ -0,0 +1,23 @@
/**
* Copyright (c) 2012 David Iwanowitsch <david at unclouded dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
$(document).ready(function(){
OC.search.customResults['Bookm.'] = function(row,item){
var a=row.find('a');
a.attr('target','_blank');
a.click(recordClick);
}
});
function recordClick(event) {
var jsFileLocation = $('script[src*=bookmarksearch]').attr('src');
jsFileLocation = jsFileLocation.replace('js/bookmarksearch.js', '');
$.ajax({
type: 'POST',
url: jsFileLocation + 'ajax/recordClick.php',
data: 'url=' + encodeURI($(this).attr('href')),
});
}

12
l10n/bg_BG.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Отметки",
"unnamed" => "неозаглавено",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Завлачете това в лентата с отметки на браузъра си и го натискайте, когато искате да отметнете бързо някоя страница:",
"Read later" => "Отмятане",
"Address" => "Адрес",
"Title" => "Заглавие",
"Tags" => "Етикети",
"Save bookmark" => "Запис на отметката",
"You have no bookmarks" => "Нямате отметки",
"Bookmarklet <br />" => "Бутон за отметки <br />"
);

12
l10n/ca.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Adreces d'interès",
"unnamed" => "sense nom",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Arrossegueu-ho al navegador i feu-hi un clic quan volgueu marcar ràpidament una adreça d'interès:",
"Read later" => "Llegeix més tard",
"Address" => "Adreça",
"Title" => "Títol",
"Tags" => "Etiquetes",
"Save bookmark" => "Desa l'adreça d'interès",
"You have no bookmarks" => "No teniu adreces d'interès",
"Bookmarklet <br />" => "Bookmarklet <br />"
);

12
l10n/cs_CZ.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Záložky",
"unnamed" => "nepojmenovaný",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Přetáhněte do Vašeho prohlížeče a kliněte, pokud si přejete rychle uložit stranu do záložek:",
"Read later" => "Přečíst později",
"Address" => "Adresa",
"Title" => "Název",
"Tags" => "Tagy",
"Save bookmark" => "Uložit záložku",
"You have no bookmarks" => "Nemáte žádné záložky",
"Bookmarklet <br />" => "Záložky <br />"
);

12
l10n/de.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Lesezeichen",
"unnamed" => "unbenannt",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Ziehen Sie dies zu Ihren Browser-Lesezeichen und klicken Sie darauf, wenn Sie eine Website schnell den Lesezeichen hinzufügen wollen.",
"Read later" => "Später lesen",
"Address" => "Adresse",
"Title" => "Titel",
"Tags" => "Tags",
"Save bookmark" => "Lesezeichen speichern",
"You have no bookmarks" => "Sie haben keine Lesezeichen",
"Bookmarklet <br />" => "Bookmarklet <br />"
);

12
l10n/el.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Σελιδοδείκτες",
"unnamed" => "ανώνυμο",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Σύρετε αυτό στους σελιδοδείκτες του περιηγητή σας και κάντε κλικ επάνω του, όταν θέλετε να προσθέσετε σύντομα μια ιστοσελίδα ως σελιδοδείκτη:",
"Read later" => "Ανάγνωση αργότερα",
"Address" => "Διεύθυνση",
"Title" => "Τίτλος",
"Tags" => "Ετικέτες",
"Save bookmark" => "Αποθήκευση σελιδοδείκτη",
"You have no bookmarks" => "Δεν έχετε σελιδοδείκτες",
"Bookmarklet <br />" => "Εφαρμογίδιο Σελιδοδεικτών <br />"
);

11
l10n/eo.php Normal file
View File

@ -0,0 +1,11 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Legosignoj",
"unnamed" => "nenomita",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Ŝovu tion ĉi al la legosignoj de via TTT-legilo kaj klaku ĝin, se vi volas rapide legosignigi TTT-paĝon:",
"Read later" => "Legi poste",
"Address" => "Adreso",
"Title" => "Titolo",
"Tags" => "Etikedoj",
"Save bookmark" => "Konservi legosignon",
"You have no bookmarks" => "Vi havas neniun legosignon"
);

12
l10n/es.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Marcadores",
"unnamed" => "sin nombre",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Arrastra desde aquí a los marcadores de tu navegador, y haz clic cuando quieras marcar una página web rápidamente:",
"Read later" => "Leer después",
"Address" => "Dirección",
"Title" => "Título",
"Tags" => "Etiquetas",
"Save bookmark" => "Guardar marcador",
"You have no bookmarks" => "No tienes marcadores",
"Bookmarklet <br />" => "Bookmarklet <br />"
);

10
l10n/et_EE.php Normal file
View File

@ -0,0 +1,10 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Järjehoidjad",
"unnamed" => "nimetu",
"Read later" => "Loe hiljem",
"Address" => "Aadress",
"Title" => "Pealkiri",
"Tags" => "Sildid",
"Save bookmark" => "Salvesta järjehoidja",
"You have no bookmarks" => "Sul pole järjehoidjaid"
);

8
l10n/fa.php Normal file
View File

@ -0,0 +1,8 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "نشانک‌ها",
"unnamed" => "بدون‌نام",
"Address" => "آدرس",
"Title" => "عنوان",
"Save bookmark" => "ذخیره نشانک",
"You have no bookmarks" => "شما هیچ نشانکی ندارید"
);

12
l10n/fi_FI.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Kirjanmerkit",
"unnamed" => "nimetön",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Vedä tämä selaimesi kirjanmerkkipalkkiin ja napsauta sitä, kun haluat lisätä kirjanmerkin nopeasti:",
"Read later" => "Lue myöhemmin",
"Address" => "Osoite",
"Title" => "Otsikko",
"Tags" => "Tunnisteet",
"Save bookmark" => "Tallenna kirjanmerkki",
"You have no bookmarks" => "Sinulla ei ole kirjanmerkkejä",
"Bookmarklet <br />" => "Kirjanmerkitsin <br />"
);

12
l10n/fr.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Favoris",
"unnamed" => "sans titre",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Glissez ceci dans les favoris de votre navigateur, et cliquer dessus lorsque vous souhaitez ajouter la page en cours à vos marques-pages :",
"Read later" => "Lire plus tard",
"Address" => "Adresse",
"Title" => "Titre",
"Tags" => "Étiquettes",
"Save bookmark" => "Sauvegarder le favori",
"You have no bookmarks" => "Vous n'avez aucun favori",
"Bookmarklet <br />" => "Gestionnaire de favoris <br />"
);

12
l10n/it.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Segnalibri",
"unnamed" => "senza nome",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Quando vuoi creare rapidamente un segnalibro, trascinalo sui segnalibri del browser e fai clic su di esso:",
"Read later" => "Leggi dopo",
"Address" => "Indirizzo",
"Title" => "Titolo",
"Tags" => "Tag",
"Save bookmark" => "Salva segnalibro",
"You have no bookmarks" => "Non hai segnalibri",
"Bookmarklet <br />" => "Bookmarklet <br />"
);

3
l10n/lt_LT.php Normal file
View File

@ -0,0 +1,3 @@
<?php $TRANSLATIONS = array(
"unnamed" => "be pavadinimo"
);

12
l10n/nb_NO.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Bokmerker",
"unnamed" => "uten navn",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Dra denne over din nettlesers bokmerker og klikk den, hvis du ønsker å hurtig legge til bokmerke for en nettside",
"Read later" => "Les senere",
"Address" => "Adresse",
"Title" => "Tittel",
"Tags" => "Etikett",
"Save bookmark" => "Lagre bokmerke",
"You have no bookmarks" => "Du har ingen bokmerker",
"Bookmarklet <br />" => "Bokmerke <br />"
);

11
l10n/nl.php Normal file
View File

@ -0,0 +1,11 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Bladwijzers",
"unnamed" => "geen naam",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Sleep dit naar uw browser bladwijzers en klik erop, wanneer u een webpagina snel wilt voorzien van een bladwijzer:",
"Read later" => "Lees later",
"Address" => "Adres",
"Title" => "Titel",
"Tags" => "Tags",
"Save bookmark" => "Bewaar bookmark",
"You have no bookmarks" => "U heeft geen bookmarks"
);

11
l10n/ru.php Normal file
View File

@ -0,0 +1,11 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Закладки",
"unnamed" => "без имени",
"Read later" => "Прочитать позже",
"Address" => "Адрес",
"Title" => "Заголовок",
"Tags" => "Метки",
"Save bookmark" => "Сохранить закладки",
"You have no bookmarks" => "У вас нет закладок",
"Bookmarklet <br />" => "Букмарклет <br />"
);

12
l10n/sl.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Zaznamki",
"unnamed" => "neimenovano",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Povlecite to povezavo med zaznamke v vašem brskalniku in jo, ko želite ustvariti zaznamek trenutne strani, preprosto kliknite:",
"Read later" => "Preberi kasneje",
"Address" => "Naslov",
"Title" => "Ime",
"Tags" => "Oznake",
"Save bookmark" => "Shrani zaznamek",
"You have no bookmarks" => "Nimate zaznamkov",
"Bookmarklet <br />" => "Bookmarklet <br />"
);

12
l10n/sv.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "Bokmärken",
"unnamed" => "namnlös",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Dra till din webbläsares bokmärken och klicka på det när du vill bokmärka en webbsida snabbt:",
"Read later" => "Läs senare",
"Address" => "Adress",
"Title" => "Titel",
"Tags" => "Taggar",
"Save bookmark" => "Spara bokmärke",
"You have no bookmarks" => "Du har inga bokmärken",
"Bookmarklet <br />" => "Skriptbokmärke <br />"
);

12
l10n/th_TH.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "รายการโปรด",
"unnamed" => "ยังไม่มีชื่อ",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "ลากสิ่งนี้ไปไว้ที่รายการโปรดในโปรแกรมบราวเซอร์ของคุณ แล้วคลิกที่นั่น, เมื่อคุณต้องการเก็บหน้าเว็บเพจเข้าไปไว้ในรายการโปรดอย่างรวดเร็ว",
"Read later" => "อ่านภายหลัง",
"Address" => "ที่อยู่",
"Title" => "ชื่อ",
"Tags" => "ป้ายกำกับ",
"Save bookmark" => "บันทึกรายการโปรด",
"You have no bookmarks" => "คุณยังไม่มีรายการโปรด",
"Bookmarklet <br />" => "Bookmarklet <br />"
);

5
l10n/xgettextfiles Normal file
View File

@ -0,0 +1,5 @@
../appinfo/app.php
../lib/search.php
../templates/settings.php
../templates/addBm.php
../templates/list.php

12
l10n/zh_CN.php Normal file
View File

@ -0,0 +1,12 @@
<?php $TRANSLATIONS = array(
"Bookmarks" => "书签",
"unnamed" => "未命名",
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "拖曳此处到您的浏览器书签处,点击可以将网页快速添加到书签中。",
"Read later" => "稍后阅读",
"Address" => "地址",
"Title" => "标题",
"Tags" => "标签",
"Save bookmark" => "保存书签",
"You have no bookmarks" => "您暂无书签",
"Bookmarklet <br />" => "书签应用"
);

147
lib/bookmarks.php Normal file
View File

@ -0,0 +1,147 @@
<?php
/**
* 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/>.
*
*/
/**
* This class manages bookmarks
*/
class OC_Bookmarks_Bookmarks{
/**
* @brief Finds all bookmarks, matching the filter
* @param offset result offset
* @param sqlSortColumn sort result with this column
* @param filter can be: empty -> no filter, a string -> filter this, a string array -> filter for all strings
* @param filterTagOnly if true, filter affacts only tags, else filter affects url, title and tags
* @return void
*/
public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly){
//OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG);
$CONFIG_DBTYPE = OCP\Config::getSystemValue( 'dbtype', 'sqlite' );
$params=array(OCP\USER::getUser());
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
$_gc_separator = ', \' \'';
} else {
$_gc_separator = 'SEPARATOR \' \'';
}
if($filter){
if($CONFIG_DBTYPE == 'pgsql' )
$tagString = 'array_to_string(array_agg(tag), \' \')';
else
$tagString = 'tags';
$sqlFilterTag = 'HAVING ';
if(is_array($filter)){
$first = true;
$filterstring = '';
foreach ($filter as $singleFilter){
$filterstring = $filterstring . ($first?'':' AND ') . $tagString.' LIKE ? ';
$params[] = '%'.$singleFilter.'%';
$first=false;
}
$sqlFilterTag = $sqlFilterTag . $filterstring;
} else{
$sqlFilterTag = $sqlFilterTag .$tagString.' LIKE ? ';
$params[] = '%'.$filter.'%';
}
} else {
$sqlFilterTag = '';
}
if($CONFIG_DBTYPE == 'pgsql' ){
$query = OCP\DB::prepare('
SELECT `id`, `url`, `title`, '.($filterTagOnly?'':'`url` || `title` ||').' array_to_string(array_agg(`tag`), \' \') as `tags`
FROM `*PREFIX*bookmarks`
LEFT JOIN `*PREFIX*bookmarks_tags` ON `*PREFIX*bookmarks`.`id` = `*PREFIX*bookmarks_tags`.`bookmark_id`
WHERE
`*PREFIX*bookmarks`.`user_id` = ?
GROUP BY `id`, `url`, `title`
'.$sqlFilterTag.'
ORDER BY `*PREFIX*bookmarks`.`'.$sqlSortColumn.'` DESC',
10,$offset);
} else {
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' )
$concatFunction = '(url || title || ';
else
$concatFunction = 'Concat(Concat( url, title), ';
$query = OCP\DB::prepare('
SELECT `id`, `url`, `title`, '
.($filterTagOnly?'':$concatFunction).
'CASE WHEN `*PREFIX*bookmarks`.`id` = `*PREFIX*bookmarks_tags`.`bookmark_id`
THEN GROUP_CONCAT( `tag` ' .$_gc_separator. ' )
ELSE \' \'
END '
.($filterTagOnly?'':')').'
AS `tags`
FROM `*PREFIX*bookmarks`
LEFT JOIN `*PREFIX*bookmarks_tags` ON 1=1
WHERE (`*PREFIX*bookmarks`.`id` = `*PREFIX*bookmarks_tags`.`bookmark_id`
OR `*PREFIX*bookmarks`.`id` NOT IN (
SELECT `*PREFIX*bookmarks_tags`.`bookmark_id` FROM `*PREFIX*bookmarks_tags`
)
)
AND `*PREFIX*bookmarks`.`user_id` = ?
GROUP BY `url`
'.$sqlFilterTag.'
ORDER BY `*PREFIX*bookmarks`.`'.$sqlSortColumn.'` DESC',
10, $offset);
}
$bookmarks = $query->execute($params)->fetchAll();
return $bookmarks;
}
public static function deleteUrl($id)
{
$user = OCP\USER::getUser();
$query = OCP\DB::prepare("
SELECT `id` FROM `*PREFIX*bookmarks`
WHERE `id` = ?
AND `user_id` = ?
");
$result = $query->execute(array($id, $user));
$id = $result->fetchOne();
if ($id === false) {
return false;
}
$query = OCP\DB::prepare("
DELETE FROM `*PREFIX*bookmarks`
WHERE `id` = $id
");
$result = $query->execute();
$query = OCP\DB::prepare("
DELETE FROM `*PREFIX*bookmarks_tags`
WHERE `bookmark_id` = $id
");
$result = $query->execute();
return true;
}
}

47
lib/search.php Normal file
View File

@ -0,0 +1,47 @@
<?php
/**
* ownCloud - bookmarks plugin
*
* @author David Iwanowitsch
* @copyright 2012 David Iwanowitsch <david at unclouded dot 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/>.
*
*/
class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
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;
}
}

11
settings.php Normal file
View File

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
$tmpl = new OCP\Template( 'bookmarks', 'settings');
return $tmpl->fetchPage();

11
templates/addBm.php Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Read later - ownCloud</title>
</head>
<body>
<div class="message"><h1>Saved!</h1></div>
<a href="javascript:self.close()" >Close the window</a>
</body>
</html>

View File

@ -0,0 +1,8 @@
<?php
function createBookmarklet() {
$l = OC_L10N::get('bookmarks');
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '</small>'
. '<a class="button bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OCP\Util::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
. $l->t('Read later') . '</a>';
}

26
templates/list.php Normal file
View File

@ -0,0 +1,26 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo OCP\Util::sanitizeHTML($_GET['tag']); ?>" />
<div id="controls">
<input type="hidden" id="bookmark_add_id" value="0" />
<input type="text" id="bookmark_add_url" placeholder="<?php echo $l->t('Address'); ?>" class="bookmarks_input" />
<input type="text" id="bookmark_add_title" placeholder="<?php echo $l->t('Title'); ?>" class="bookmarks_input" />
<input type="text" id="bookmark_add_tags" placeholder="<?php echo $l->t('Tags'); ?>" class="bookmarks_input" />
<input type="submit" value="<?php echo $l->t('Save bookmark'); ?>" id="bookmark_add_submit" />
</div>
<div class="bookmarks_list">
</div>
<div id="firstrun" style="display: none;">
<?php
echo $l->t('You have no bookmarks');
require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php');
createBookmarklet();
?>
</div>

17
templates/settings.php Normal file
View File

@ -0,0 +1,17 @@
<?php
/**
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
?>
<form id="bookmarks">
<fieldset class="personalblock">
<span class="bold"><?php echo $l->t('Bookmarklet <br />');?></span>
<?php
require_once('bookmarklet.php');
createBookmarklet();
?>
</fieldset>
</form>