Merge branch 'master' into calendar

This commit is contained in:
Georg Ehrke 2012-02-02 12:12:48 +01:00
commit 9e5172f75c
12 changed files with 253 additions and 95 deletions

View File

@ -5,6 +5,7 @@
*
* @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
@ -30,71 +31,20 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$params=array(OC_User::getUser());
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
//Filter for tag?
$filterTag = isset($_GET['tag']) ? '%' . htmlspecialchars_decode($_GET['tag']) . '%' : false;
if($filterTag){
$sqlFilterTag = 'HAVING tags LIKE ?';
$params[] = $filterTag;
if($CONFIG_DBTYPE == 'pgsql' ) {
$sqlFilterTag = 'HAVING array_to_string(array_agg(tag), \' \') LIKE ?';
}
} else {
$sqlFilterTag = '';
}
$filterTag = isset($_GET['tag']) ? htmlspecialchars_decode($_GET['tag']) : false;
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent';
if($sort == 'bookmarks_sorting_clicks') {
$sqlSort = 'clickcount DESC';
$sqlSortColumn = 'clickcount';
} else {
$sqlSort = 'id DESC';
$sqlSortColumn = 'id';
}
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
$_gc_separator = ', \' \'';
} else {
$_gc_separator = 'SEPARATOR \' \'';
}
if($CONFIG_DBTYPE == 'pgsql' ){
$params[] = $offset;
$query = OC_DB::prepare('
SELECT id, 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.'.$sqlSort.'
LIMIT 10
OFFSET ?');
} else {
$query = OC_DB::prepare('
SELECT id, url, title,
CASE WHEN *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
THEN GROUP_CONCAT( tag ' .$_gc_separator. ' )
ELSE \' \'
END
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.'.$sqlSort.'
LIMIT '.$offset.', 10');
}
$bookmarks = $query->execute($params)->fetchAll();
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $filterTag, true);
OC_JSON::success(array('data' => $bookmarks));

View File

@ -7,8 +7,13 @@
* See the COPYING-README file.
*/
OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php';
OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' ));
OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OC_Helper::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => 'Bookmarks' ));
$l = new OC_l10n('bookmarks');
OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OC_Helper::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
OC_App::registerPersonal('bookmarks', 'settings');
require_once('apps/bookmarks/lib/search.php');
OC_Util::addScript('bookmarks','bookmarksearch');

View File

@ -18,7 +18,7 @@
}
.bookmarks_list {
margin-top: 45px;
margin-top: 36px;
}
.bookmarks_addBml {
@ -36,42 +36,49 @@
}
.bookmark_actions {
position: absolute;
right: 1em;
top: 0.7em;
display: none;
font-size: smaller;
color: #666;
padding-left: 4em;
}
.bookmark_actions span:hover {
cursor: pointer;
text-decoration: underline;
}
.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: #EAEAEA;
background-color:#f8f8f8
}
.bookmark_single:hover .bookmark_actions {
display: block;
}
.bookmark_title {
font-size: larger;
color: blue;
text-decoration: underline;
.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_url {
color: green;
}
.bookmark_tag {
color: #ff3333;
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;

View File

@ -85,10 +85,10 @@ function addOrEditBookmark(event) {
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('.bookmarks_list').prepend(
'<div class="bookmark_single" data-id="' + bookmark_id + '" >' +
'<p class="bookmark_actions"><span class="bookmark_delete"><img src="img/delete.png" title="Delete"></span>&nbsp;<span class="bookmark_edit"><img src="img/edit.png" title="Edit"></span></p>' +
'<p class="bookmark_title"><a href="' + url + '" target="_blank" class="bookmark_link">' + title + '</a></p>' +
'<p class="bookmark_url">' + url + '</p>' +
'<p class="bookmark_tags">' + tagshtml + '</p>' +
'<p class="bookmark_actions"><span class="bookmark_delete">Delete</span>&nbsp;<span class="bookmark_edit">Edit</span></p>' +
'<p class="bookmark_url">' + url + '</p>' +
'</div>'
);
}
@ -146,19 +146,22 @@ function updateBookmarksList(bookmark) {
var tags = encodeEntities(bookmark.tags).split(' ');
var taglist = '';
for ( var i=0, len=tags.length; i<len; ++i ){
taglist = taglist + '<a class="bookmark_tag" href="?tag=' + encodeURI(tags[i]) + '">' + tags[i] + '</a> ';
if(tags[i] != '')
taglist = taglist + '<a class="bookmark_tag" href="?tag=' + encodeURI(tags[i]) + '">' + tags[i] + '</a> ';
}
if(!hasProtocol(bookmark.url)) {
bookmark.url = 'http://' + bookmark.url;
}
$('.bookmarks_list').append(
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
'<p class="bookmark_actions"><span class="bookmark_delete"><img src="img/delete.png" title="Delete"></span>&nbsp;<span class="bookmark_edit"><img src="img/edit.png" title="Edit"></span></p>' +
'<p class="bookmark_title"><a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a></p>' +
'<p class="bookmark_url">' + encodeEntities(bookmark.url) + '</p>' +
'<p class="bookmark_tags">' + taglist + '</p>' +
'<p class="bookmark_actions"><span class="bookmark_delete">Delete</span>&nbsp;<span class="bookmark_edit">Edit</span></p>' +
'</div>'
);
if(taglist != '') {
$('div[data-id="'+ bookmark.id +'"]').append('<p class="bookmark_tags">' + taglist + '</p>');
}
}
function updateOnBottom() {
@ -178,7 +181,6 @@ function recordClick(event) {
function encodeEntities(s){
try {
return $('<div/>').text(s).html();
} catch (ex) {
return "";
}

View File

@ -0,0 +1,22 @@
/**
* 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({
url: jsFileLocation + 'ajax/recordClick.php',
data: 'url=' + encodeURI($(this).attr('href')),
});
}

View File

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

View File

@ -0,0 +1,117 @@
<?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){
//OC_Log::write('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OC_Log::DEBUG);
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
$params=array(OC_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 = OC_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
LIMIT 10
OFFSET '. $offset);
} else {
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' )
$concatFunction = '(url || title || ';
else
$concatFunction = 'Concat(Concat( url, title), ';
$query = OC_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
LIMIT '.$offset.', 10');
}
$bookmarks = $query->execute($params)->fetchAll();
return $bookmarks;
}
}
?>

View File

@ -0,0 +1,50 @@
<?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;
}
// OC_Log::write('bookmarks', 'search ' .$query ,OC_Log::DEBUG);
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false);
// OC_Log::write('bookmarks', 'found ' .count($bookmarks) ,OC_Log::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;
}
}
new OC_Search_Provider_Bookmarks();
?>

View File

@ -46,14 +46,14 @@ Albums={
var a = Albums.albums[i];
var local=$(displayTemplate);
local.attr('data-album',a.name);
$(".gallery_album_decoration a.rename", local).click(function(name,event){
$(".gallery_album_decoration a.rename", local).bind('click', {name: a.name},function(event){
event.preventDefault();
galleryRename(name);
}.bind(null,a.name));
$(".gallery_album_decoration a.remove", local).click(function(name,event){
galleryRename(event.data.name);
});
$(".gallery_album_decoration a.remove", local).bind('click', {name: a.name},function(event){
event.preventDefault();
galleryRemove(name);
}.bind(null,a.name));
galleryRemove(a.data.name);
});
$("a.view", local).attr('href','?view='+a.name);
$('h1',local).text(a.name);
$(".gallery_album_cover", local).attr('title',a.name);

View File

@ -27,7 +27,8 @@
.file_upload_start { opacity:0; filter:alpha(opacity=0); z-index:1; position:absolute; left:0; top:0; width:100%; cursor:pointer;}
.file_upload_filename.active { border-bottom-right-radius:0 }
.file_upload_filename { z-index:100; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; padding:.3em; }
.file_upload_filename { position: relative; z-index:100; padding-left: 0.8em; padding-right: 0.8em; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; }
.file_upload_filename img { position: absolute; top: 0.4em; left: 0.4em; }
.file_upload_form, .file_upload_wrapper, .file_upload_start, .file_upload_filename, #file_upload_submit { cursor:pointer; }

View File

@ -3,13 +3,10 @@
<?php if (!isset($_['readonly']) || !$_['readonly']):?>
<div class="actions">
<div id='new' class='button'>
<a>
<?php echo $l->t('New');?>
</a>
<a><?php echo $l->t('New');?></a>
<ul class="popup popupTop">
<li style="background-image:url('<?php echo mimetype_icon('text/plain') ?>')" data-type='file'><p><?php echo $l->t('Text file');?></p></li>
<li style="background-image:url('<?php echo mimetype_icon('dir') ?>')" data-type='folder'><p><?php echo $l->t('Folder');?></p></li>
<!-- <li style="background-image:url('<?php echo mimetype_icon('dir') ?>')" data-type='web'><p><?php echo $l->t('From the web');?></p></li> -->
</ul>
</div>
<div class="file_upload_wrapper svg">
@ -17,7 +14,7 @@
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_['uploadMaxFilesize'] ?>" id="max_upload">
<input type="hidden" class="max_human_file_size" value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
<input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
<button class="file_upload_filename"><img class='svg action' alt="Upload" src="<?php echo image_path("core", "actions/upload.svg"); ?>" /></button>
<button class="file_upload_filename">&nbsp;<img class='svg action' alt="Upload" src="<?php echo image_path("core", "actions/upload.svg"); ?>" /></button>
<input class="file_upload_start" type="file" name='files[]'/>
<a href="#" class="file_upload_button_wrapper" onclick="return false;" title="<?php echo $l->t('Upload'); echo ' max. '.$_['uploadMaxHumanFilesize'] ?>"></a>
<iframe name="file_upload_target_1" class='file_upload_target' src=""></iframe>

View File

@ -23,8 +23,10 @@ $relative=round(($used/$total)*10000)/100;
$email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email','');
$lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', 'en' );
$lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
$languageCodes=OC_L10N::findAvailableLanguages();
sort ($languageCodes);
//put the current language in the front
unset($languageCodes[array_search($lang,$languageCodes)]);
array_unshift($languageCodes,$lang);