mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-01-31 01:52:11 +01:00
Merge branch 'master' into gallery
This commit is contained in:
commit
67e48c92d0
@ -27,15 +27,13 @@
|
|||||||
OCP\User::checkLoggedIn();
|
OCP\User::checkLoggedIn();
|
||||||
OCP\App::checkAppEnabled('bookmarks');
|
OCP\App::checkAppEnabled('bookmarks');
|
||||||
|
|
||||||
require_once 'bookmarksHelper.php';
|
|
||||||
|
|
||||||
// Prep screen if we come from the bookmarklet
|
// Prep screen if we come from the bookmarklet
|
||||||
$url ='';
|
$url ='';
|
||||||
if(isset($_GET['url'])) {
|
if(isset($_GET['url'])) {
|
||||||
$url = $_GET['url'];
|
$url = $_GET['url'];
|
||||||
}
|
}
|
||||||
if(!isset($_GET['title']) || trim($_GET['title']) == '') {
|
if(!isset($_GET['title']) || trim($_GET['title']) == '') {
|
||||||
$datas = getURLMetadata($url);
|
$datas = OC_Bookmarks_Bookmarks::getURLMetadata($url);
|
||||||
$title = isset($datas['title']) ? $datas['title'] : '';
|
$title = isset($datas['title']) ? $datas['title'] : '';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
<?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));
|
|
@ -26,7 +26,6 @@ OCP\JSON::checkLoggedIn();
|
|||||||
OCP\JSON::callCheck();
|
OCP\JSON::callCheck();
|
||||||
|
|
||||||
OCP\JSON::checkAppEnabled('bookmarks');
|
OCP\JSON::checkAppEnabled('bookmarks');
|
||||||
require_once OC_App::getAppPath('bookmarks').'/bookmarksHelper.php';
|
|
||||||
|
|
||||||
// If we go the dialog form submit
|
// If we go the dialog form submit
|
||||||
if(isset($_POST['url'])) {
|
if(isset($_POST['url'])) {
|
||||||
@ -41,7 +40,7 @@ if(isset($_POST['url'])) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(isset($_POST['from_own'])) {
|
if(isset($_POST['from_own'])) {
|
||||||
$datas = getURLMetadata($_POST['url']);
|
$datas = OC_Bookmarks_Bookmarks::getURLMetadata($_POST['url']);
|
||||||
if(isset($datas['title'])) $title = $datas['title'];
|
if(isset($datas['title'])) $title = $datas['title'];
|
||||||
}
|
}
|
||||||
$bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub);
|
$bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub);
|
||||||
|
@ -24,12 +24,10 @@
|
|||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::checkAppEnabled('bookmarks');
|
OCP\JSON::checkAppEnabled('bookmarks');
|
||||||
|
|
||||||
require_once OC_App::getAppPath('bookmarks').'/bookmarksHelper.php';
|
|
||||||
|
|
||||||
$req_type=isset($_GET['type']) ? $_GET['type'] : '';
|
$req_type=isset($_GET['type']) ? $_GET['type'] : '';
|
||||||
|
|
||||||
if($req_type == 'url_info' && $_GET['url']) {
|
if($req_type == 'url_info' && $_GET['url']) {
|
||||||
$datas = getURLMetadata($_GET['url']);
|
$datas = OC_Bookmarks_Bookmarks::getURLMetadata($_GET['url']);
|
||||||
$title = isset($datas['title']) ? $datas['title'] : '';
|
$title = isset($datas['title']) ? $datas['title'] : '';
|
||||||
OCP\JSON::success(array('title' => $title));
|
OCP\JSON::success(array('title' => $title));
|
||||||
exit();
|
exit();
|
||||||
|
@ -25,18 +25,17 @@
|
|||||||
// Check if we are a user
|
// Check if we are a user
|
||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::checkAppEnabled('bookmarks');
|
OCP\JSON::checkAppEnabled('bookmarks');
|
||||||
require_once OC_App::getAppPath('bookmarks').'/bookmarksHelper.php';
|
|
||||||
|
|
||||||
$req_type= isset($_GET['type']) ? $_GET['type'] : 'bookmark';
|
$req_type= isset($_GET['type']) ? $_GET['type'] : 'bookmark';
|
||||||
|
|
||||||
if($req_type == 'rel_tags') {
|
if($req_type == 'rel_tags') {
|
||||||
$tags = analyzeTagRequest(isset($_GET['tag']) ? $_GET['tag'] : '');
|
$tags = OC_Bookmarks_Bookmarks::analyzeTagRequest(isset($_GET['tag']) ? $_GET['tag'] : '');
|
||||||
$qtags = OC_Bookmarks_Bookmarks::findTags($tags);
|
$qtags = OC_Bookmarks_Bookmarks::findTags($tags);
|
||||||
OCP\JSON::success(array('data' => $qtags));
|
OCP\JSON::success(array('data' => $qtags));
|
||||||
|
|
||||||
}
|
}
|
||||||
else { // type == bookmark
|
else { // type == bookmark
|
||||||
$filterTag = analyzeTagRequest(isset($_GET['tag']) ? $_GET['tag'] : '');
|
$filterTag = OC_Bookmarks_Bookmarks::analyzeTagRequest(isset($_GET['tag']) ? $_GET['tag'] : '');
|
||||||
|
|
||||||
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
|
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
|
||||||
|
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
<?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($ch, CURLOPT_USERAGENT, "Owncloud Bookmark Crawl");
|
|
||||||
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) {
|
|
||||||
OCP\Util::writeLog(
|
|
||||||
'bookmark',
|
|
||||||
'Too many redirects. When following redirects, libcurl hit the maximum amount on bookmark',
|
|
||||||
OCP\Util::ERROR);
|
|
||||||
} 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>/sUi", $page, $match );
|
|
||||||
$metadata['title'] = htmlspecialchars_decode(@$match[1]);
|
|
||||||
return $metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
function analyzeTagRequest($line) {
|
|
||||||
$tags = explode(',', $line);
|
|
||||||
$filterTag = array();
|
|
||||||
foreach($tags as $tag){
|
|
||||||
if(trim($tag) != '')
|
|
||||||
$filterTag[] = trim($tag);
|
|
||||||
}
|
|
||||||
return $filterTag;
|
|
||||||
}
|
|
@ -113,7 +113,7 @@ input.disabled, input.disabled:hover, input.disabled:focus {
|
|||||||
|
|
||||||
.bookmark_tags {
|
.bookmark_tags {
|
||||||
left:25%;
|
left:25%;
|
||||||
position: absolute;
|
position: relative;
|
||||||
}
|
}
|
||||||
.bookmark_tag {
|
.bookmark_tag {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<?php $TRANSLATIONS = array(
|
<?php $TRANSLATIONS = array(
|
||||||
|
"Unsupported file type for import" => "Ikke understøttet filtype til import",
|
||||||
"Bookmarks" => "Bogmærker",
|
"Bookmarks" => "Bogmærker",
|
||||||
"Tags" => "Mærker",
|
"Tags" => "Mærker",
|
||||||
|
"Filter by tag" => "Filtrer efter tag",
|
||||||
"Edit bookmark" => "Rediger bogmærker",
|
"Edit bookmark" => "Rediger bogmærker",
|
||||||
"Are you sure you want to remove this tag from every entry?" => "Er du sikker på at du vil fjerne dette flag fra alle poster?",
|
"Are you sure you want to remove this tag from every entry?" => "Er du sikker på at du vil fjerne dette flag fra alle poster?",
|
||||||
"Warning" => "Advarsel",
|
"Warning" => "Advarsel",
|
||||||
|
"Import completed successfully." => "Importer fuldført.",
|
||||||
|
"Uploading..." => "Uploader...",
|
||||||
"Bookm." => "Bogm.",
|
"Bookm." => "Bogm.",
|
||||||
"Add a bookmark" => "Tilføj bogmærke",
|
"Add a bookmark" => "Tilføj bogmærke",
|
||||||
"Close" => "Luk",
|
"Close" => "Luk",
|
||||||
@ -21,6 +25,9 @@
|
|||||||
"Related Tags" => "Relaterede Tags",
|
"Related Tags" => "Relaterede Tags",
|
||||||
"Settings" => "Indstillinger",
|
"Settings" => "Indstillinger",
|
||||||
"You have no bookmarks" => "Du har ingen bogmærker",
|
"You have no bookmarks" => "Du har ingen bogmærker",
|
||||||
|
"You can also try to import a bookmark file" => "Du kan også prøve at importere en bogmærke-fil",
|
||||||
|
"Bookmarklet" => "Bookmarklet",
|
||||||
|
"Export & Import" => "Eksport & import",
|
||||||
"Export" => "Exporter",
|
"Export" => "Exporter",
|
||||||
"Import" => "Importer"
|
"Import" => "Importer"
|
||||||
);
|
);
|
||||||
|
16
l10n/mk.php
16
l10n/mk.php
@ -1,13 +1,29 @@
|
|||||||
<?php $TRANSLATIONS = array(
|
<?php $TRANSLATIONS = array(
|
||||||
|
"Unsupported file type for import" => "Неподржнан тип на датотека за внес",
|
||||||
|
"Bookmarks" => "Обележувачи",
|
||||||
|
"Edit bookmark" => "Уреди обележувач",
|
||||||
"Warning" => "Предупредување",
|
"Warning" => "Предупредување",
|
||||||
|
"Import completed successfully." => "Увозот заврши успешно",
|
||||||
|
"Uploading..." => "Подигнувам...",
|
||||||
|
"Bookm." => "Обел.",
|
||||||
|
"Add a bookmark" => "Додади обележувач",
|
||||||
"Close" => "Затвои",
|
"Close" => "Затвои",
|
||||||
|
"The title of the page" => "Насловот на страницата",
|
||||||
|
"The address of the page" => "Адресата на страницата",
|
||||||
|
"Description of the page" => "Опис на страницата",
|
||||||
"Save" => "Сними",
|
"Save" => "Сними",
|
||||||
"Delete" => "Избриши",
|
"Delete" => "Избриши",
|
||||||
"Edit" => "Уреди",
|
"Edit" => "Уреди",
|
||||||
"Cancel" => "Откажи",
|
"Cancel" => "Откажи",
|
||||||
|
"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Повлечете го ова во папката со обележувачи во Вашиот прелистувач и кликнете го кога сакате брзо да направите обележувач:",
|
||||||
|
"Read later" => "Читај подоцна",
|
||||||
"Address" => "Адреса",
|
"Address" => "Адреса",
|
||||||
"Add" => "Додади",
|
"Add" => "Додади",
|
||||||
"Settings" => "Параметри",
|
"Settings" => "Параметри",
|
||||||
|
"You have no bookmarks" => "Немате обележувачи",
|
||||||
|
"You can also try to import a bookmark file" => "Можете да се обидете да внесете датотека со обележувачи",
|
||||||
|
"Bookmarklet" => "Обележувач",
|
||||||
|
"Export & Import" => "Извези и увези",
|
||||||
"Export" => "Извези",
|
"Export" => "Извези",
|
||||||
"Import" => "Внеси"
|
"Import" => "Внеси"
|
||||||
);
|
);
|
||||||
|
@ -375,4 +375,35 @@ class OC_Bookmarks_Bookmarks{
|
|||||||
OCP\DB::commit();
|
OCP\DB::commit();
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static 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;
|
||||||
|
}
|
||||||
|
$page = OC_Util::getUrlContent($url);
|
||||||
|
if($page) {
|
||||||
|
if(preg_match( "/<title>(.*)<\/title>/sUi", $page, $match ) !== false)
|
||||||
|
$metadata['title'] = htmlspecialchars_decode($match[1]);
|
||||||
|
}
|
||||||
|
return $metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function analyzeTagRequest($line) {
|
||||||
|
$tags = explode(',', $line);
|
||||||
|
$filterTag = array();
|
||||||
|
foreach($tags as $tag){
|
||||||
|
if(trim($tag) != '')
|
||||||
|
$filterTag[] = trim($tag);
|
||||||
|
}
|
||||||
|
return $filterTag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user