diff --git a/addBm.php b/addBm.php index f2b44426..cd53e55a 100644 --- a/addBm.php +++ b/addBm.php @@ -27,15 +27,13 @@ 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); + $datas = OC_Bookmarks_Bookmarks::getURLMetadata($url); $title = isset($datas['title']) ? $datas['title'] : ''; } else{ diff --git a/ajax/addBookmark.php b/ajax/addBookmark.php deleted file mode 100644 index 37e97108..00000000 --- a/ajax/addBookmark.php +++ /dev/null @@ -1,37 +0,0 @@ -. -* -*/ - -//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)); diff --git a/ajax/editBookmark.php b/ajax/editBookmark.php index 12c2364c..bf213172 100644 --- a/ajax/editBookmark.php +++ b/ajax/editBookmark.php @@ -26,7 +26,6 @@ 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'])) { @@ -41,7 +40,7 @@ if(isset($_POST['url'])) { } else { if(isset($_POST['from_own'])) { - $datas = getURLMetadata($_POST['url']); + $datas = OC_Bookmarks_Bookmarks::getURLMetadata($_POST['url']); if(isset($datas['title'])) $title = $datas['title']; } $bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub); diff --git a/ajax/getInfos.php b/ajax/getInfos.php index 54355e8f..f2e8496c 100644 --- a/ajax/getInfos.php +++ b/ajax/getInfos.php @@ -24,12 +24,10 @@ 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']); + $datas = OC_Bookmarks_Bookmarks::getURLMetadata($_GET['url']); $title = isset($datas['title']) ? $datas['title'] : ''; OCP\JSON::success(array('title' => $title)); exit(); diff --git a/ajax/updateList.php b/ajax/updateList.php index 5ddd9869..7dadb73f 100644 --- a/ajax/updateList.php +++ b/ajax/updateList.php @@ -25,18 +25,17 @@ // 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'] : 'bookmark'; 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); OCP\JSON::success(array('data' => $qtags)); } 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; diff --git a/bookmarksHelper.php b/bookmarksHelper.php deleted file mode 100644 index 5ffb5087..00000000 --- a/bookmarksHelper.php +++ /dev/null @@ -1,85 +0,0 @@ - 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>/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; -} diff --git a/css/bookmarks.css b/css/bookmarks.css index 9ce32db2..3ef77972 100644 --- a/css/bookmarks.css +++ b/css/bookmarks.css @@ -112,8 +112,8 @@ input.disabled, input.disabled:hover, input.disabled:focus { } .bookmark_tags { - left:25%; - position: absolute; + left:25%; + position: relative; } .bookmark_tag { display: inline-block; diff --git a/l10n/da.php b/l10n/da.php index 6ded3bb0..895861bd 100644 --- a/l10n/da.php +++ b/l10n/da.php @@ -1,9 +1,13 @@ <?php $TRANSLATIONS = array( +"Unsupported file type for import" => "Ikke understøttet filtype til import", "Bookmarks" => "Bogmærker", "Tags" => "Mærker", +"Filter by tag" => "Filtrer efter tag", "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?", "Warning" => "Advarsel", +"Import completed successfully." => "Importer fuldført.", +"Uploading..." => "Uploader...", "Bookm." => "Bogm.", "Add a bookmark" => "Tilføj bogmærke", "Close" => "Luk", @@ -21,6 +25,9 @@ "Related Tags" => "Relaterede Tags", "Settings" => "Indstillinger", "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", "Import" => "Importer" ); diff --git a/l10n/mk.php b/l10n/mk.php index d47ff9b8..8695ad33 100644 --- a/l10n/mk.php +++ b/l10n/mk.php @@ -1,13 +1,29 @@ <?php $TRANSLATIONS = array( +"Unsupported file type for import" => "Неподржнан тип на датотека за внес", +"Bookmarks" => "Обележувачи", +"Edit bookmark" => "Уреди обележувач", "Warning" => "Предупредување", +"Import completed successfully." => "Увозот заврши успешно", +"Uploading..." => "Подигнувам...", +"Bookm." => "Обел.", +"Add a bookmark" => "Додади обележувач", "Close" => "Затвои", +"The title of the page" => "Насловот на страницата", +"The address of the page" => "Адресата на страницата", +"Description of the page" => "Опис на страницата", "Save" => "Сними", "Delete" => "Избриши", "Edit" => "Уреди", "Cancel" => "Откажи", +"Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:" => "Повлечете го ова во папката со обележувачи во Вашиот прелистувач и кликнете го кога сакате брзо да направите обележувач:", +"Read later" => "Читај подоцна", "Address" => "Адреса", "Add" => "Додади", "Settings" => "Параметри", +"You have no bookmarks" => "Немате обележувачи", +"You can also try to import a bookmark file" => "Можете да се обидете да внесете датотека со обележувачи", +"Bookmarklet" => "Обележувач", +"Export & Import" => "Извези и увези", "Export" => "Извези", "Import" => "Внеси" ); diff --git a/lib/bookmarks.php b/lib/bookmarks.php index fc2f2311..be868334 100644 --- a/lib/bookmarks.php +++ b/lib/bookmarks.php @@ -375,4 +375,35 @@ class OC_Bookmarks_Bookmarks{ OCP\DB::commit(); 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; + } } +