diff options
author | Côme BERNIGAUD <come.bernigaud@laposte.net> | 2011-08-25 09:07:02 +0200 |
---|---|---|
committer | Côme BERNIGAUD <come.bernigaud@laposte.net> | 2011-08-25 09:07:02 +0200 |
commit | df560b3d9d513e7b01c95745ae70a2151c2375fc (patch) | |
tree | b23454b6b14704f0a1b8a3c27bc5adda65cef376 | |
parent | 3fbc8973eee869c04c507f549f6388b47ea9134d (diff) | |
parent | 46af991574a3bcec70cb6123f35eb85587d0e0c8 (diff) | |
download | nextcloud-server-df560b3d9d513e7b01c95745ae70a2151c2375fc.tar.gz nextcloud-server-df560b3d9d513e7b01c95745ae70a2151c2375fc.zip |
Merge branch 'master' of git://anongit.kde.org/owncloud
Conflicts:
apps/media/js/collection.js
-rw-r--r-- | apps/bookmarks/addBm.php | 48 | ||||
-rw-r--r-- | apps/bookmarks/ajax/getMeta.php | 20 | ||||
-rw-r--r-- | apps/bookmarks/bookmarksHelper.php | 22 | ||||
-rw-r--r-- | apps/bookmarks/js/addBm.js | 17 | ||||
-rw-r--r-- | apps/bookmarks/templates/addBm.php | 8 | ||||
-rw-r--r-- | apps/bookmarks/templates/list.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/ajax/getitem.php | 13 | ||||
-rw-r--r-- | apps/files_sharing/ajax/share.php | 7 | ||||
-rw-r--r-- | apps/files_sharing/lib_share.php | 9 | ||||
-rw-r--r-- | apps/media/js/collection.js | 2 | ||||
-rw-r--r-- | core/css/styles.css | 8 |
11 files changed, 121 insertions, 34 deletions
diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php new file mode 100644 index 00000000000..d308e8fe605 --- /dev/null +++ b/apps/bookmarks/addBm.php @@ -0,0 +1,48 @@ +<?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/>. +* +*/ + +require_once('../../lib/base.php'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + header( 'Location: '.OC_Helper::linkTo( '', 'index.php' )); + exit(); +} + +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($url)); +$tmpl->assign('TITLE', htmlentities($metadata['title'])); +$tmpl->assign('DESCRIPTION', htmlentities($metadata['description'])); + +$tmpl->printPage();
\ No newline at end of file diff --git a/apps/bookmarks/ajax/getMeta.php b/apps/bookmarks/ajax/getMeta.php index c61c8fb4888..dadf23afd91 100644 --- a/apps/bookmarks/ajax/getMeta.php +++ b/apps/bookmarks/ajax/getMeta.php @@ -35,24 +35,10 @@ if( !OC_User::isLoggedIn()){ exit(); } -$metadata = array(); +// $metadata = array(); -$url = urldecode($_GET["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; -} +require '../bookmarksHelper.php'; -$page = file_get_contents($url); -@preg_match( "/<title>(.*)<\/title>/si", $page, $match ); -$metadata['title'] = htmlentities(strip_tags(@$match[1])); - -$meta = get_meta_tags($url); - -if(array_key_exists('description', $meta)) { - $metadata['description'] = $meta['description']; -} +$metadata = getURLMetadata(urldecode($_GET["url"])); echo json_encode( array( 'status' => 'success', 'data' => $metadata)); diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php new file mode 100644 index 00000000000..be6ac098d0f --- /dev/null +++ b/apps/bookmarks/bookmarksHelper.php @@ -0,0 +1,22 @@ +<?php + +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; + } + + $page = file_get_contents($url); + @preg_match( "/<title>(.*)<\/title>/si", $page, $match ); + $metadata['title'] = htmlentities(strip_tags(@$match[1])); + + $meta = get_meta_tags($url); + + if(array_key_exists('description', $meta)) { + $metadata['description'] = $meta['description']; + } + + return $metadata; +}
\ No newline at end of file diff --git a/apps/bookmarks/js/addBm.js b/apps/bookmarks/js/addBm.js new file mode 100644 index 00000000000..7c914f2338a --- /dev/null +++ b/apps/bookmarks/js/addBm.js @@ -0,0 +1,17 @@ +$(document).ready(function() { + $('#bookmark_add_submit').click(addBookmark); +}); + +function addBookmark(event) { + var url = $('#bookmark_add_url').val(); + var title = $('#bookmark_add_title').val(); + var description = $('#bookmark_add_description').val(); + var tags = $('#bookmark_add_tags').val(); + $.ajax({ + url: 'ajax/addBookmark.php', + data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&description=' + encodeURI(description) + '&tags=' + encodeURI(tags), + success: function(data){ + location.href='index.php'; + } + }); +}
\ No newline at end of file diff --git a/apps/bookmarks/templates/addBm.php b/apps/bookmarks/templates/addBm.php new file mode 100644 index 00000000000..cbc4910e1ae --- /dev/null +++ b/apps/bookmarks/templates/addBm.php @@ -0,0 +1,8 @@ +<div class="bookmarks_addBm"> + <p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<? echo $_['URL']; ?>"/></p> + <p><label class="bookmarks_label">Title</label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<? echo $_['TITLE']; ?>" /></p> + <p><label class="bookmarks_label">Description</label><input type="text" id="bookmark_add_description" class="bookmarks_input" value="<? echo $_['DESCRIPTION']; ?>" /></p> + <p><label class="bookmarks_label">Tags</label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p> + <p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p> + <p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p> +</div>
\ No newline at end of file diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index a9e65b68873..d7d37257a8a 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -2,6 +2,7 @@ <h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? 'Bookmarks with tag: ' . urldecode($_GET["tag"]) : 'All bookmarks'; ?></h2> <div class="bookmarks_menu"> <input type="button" class="bookmarks_addBtn" value="Add Bookmark" /> + <a type="button" class="bookmarks_addBml" href="javascript:var url = encodeURI(location.href);window.open('<?php echo (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . OC_Helper::linkTo('bookmarks', 'addBm.php'); ?>?url='+url, 'owncloud-bookmarks');" title="Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.">Bookmarklet</a> </div> <div class="bookmarks_add"> <p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p> diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php index cdb59b9cd1b..249af6cfa31 100644 --- a/apps/files_sharing/ajax/getitem.php +++ b/apps/files_sharing/ajax/getitem.php @@ -6,17 +6,18 @@ require_once('../lib_share.php'); $userDirectory = "/".OC_User::getUser()."/files"; $source = $userDirectory.$_GET['source']; -$users = OC_Share::getMySharedItem($source); $path = $source; -for ($i = 0; $i < count($users); $i++) { - if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { - $users[$i]['token'] = OC_Share::getTokenFromSource($source); +if ($users = OC_Share::getMySharedItem($source)) { + for ($i = 0; $i < count($users); $i++) { + if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { + $users[$i]['token'] = OC_Share::getTokenFromSource($source); + } } } $source = dirname($source); while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) { - $values = array_values(OC_Share::getMySharedItem($source)); - if (count($values) > 0) { + if ($values = OC_Share::getMySharedItem($source)) { + $values = array_values($values); $parentUsers = array(); for ($i = 0; $i < count($values); $i++) { if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php index cff0acf3323..e672cf02403 100644 --- a/apps/files_sharing/ajax/share.php +++ b/apps/files_sharing/ajax/share.php @@ -13,11 +13,8 @@ foreach ($sources as $source) { if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) { $source = $userDirectory.$source; // If the file doesn't exist, it may be shared with the current user - } else { - $source = OC_Share::getSource($userDirectory.$source); - if (!$source) { - echo "false"; - } + } else if (!$source = OC_Share::getSource($userDirectory.$source)) { + echo "false"; } try { $shared = new OC_Share($source, $uid_shared_with, $permissions); diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index c862f505e42..978847f4a8f 100644 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -176,7 +176,14 @@ class OC_Share { public static function getMySharedItem($source) { $source = self::cleanPath($source); $query = OC_DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?"); - return $query->execute(array($source, OC_User::getUser()))->fetchAll(); + $result = $query->execute(array($source, OC_User::getUser()))->fetchAll(); + if (count($result) > 0) { + return $result; + } else if ($originalSource = self::getSource($source)) { + return $query->execute(array($originalSource, OC_User::getUser()))->fetchAll(); + } else { + return false; + } } /** diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js index 72100927a5f..5c04313d143 100644 --- a/apps/media/js/collection.js +++ b/apps/media/js/collection.js @@ -55,7 +55,7 @@ Collection={ for(var i=0;i<Collection.loadedListeners.length;i++){ Collection.loadedListeners[i](); } - if(Collection.length==0){ + if(data.songs[i].length==0){ $('#scan input.start').val(t('media','Scan Collection')); $('#scan input.start').click(); } diff --git a/core/css/styles.css b/core/css/styles.css index 356de968ea6..faa0ee0b6de 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -32,13 +32,13 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', end /* INPUTS */ input[type="text"], input[type="password"] { cursor:text; } -input, select, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; } +input, select, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; } input[type="text"], input[type="password"] { background:#f8f8f8; color:#555; cursor:text; } -input[type="text"]:hover, input[type="text"]:focus, input[type="password"]:hover, input[type="password"]:focus { background:#fff; color:#333; outline: none;} +input[type="text"]:hover, input[type="text"]:focus, input[type="password"]:hover, input[type="password"]:focus { background:#fff; color:#333; } input[type="submit"], input[type="button"], .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; } -input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, input[type="button"]:focus, .button:hover { background:#fff; color:#333; outline: none;} -input[type="checkbox"] { width:auto; outline: none;} +input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, input[type="button"]:focus, .button:hover { background:#fff; color:#333; } +input[type="checkbox"] { width:auto; } #body-login input { font-size:1.5em; } #body-login input[type="submit"] { float:right; margin-right:.8em; } |