diff --git a/addBm.php b/addBm.php index 4e72c69d..c4bb305c 100644 --- a/addBm.php +++ b/addBm.php @@ -43,8 +43,8 @@ else{ } -OCP\Util::addscript('bookmarks','tag-it'); -OCP\Util::addscript('bookmarks','addBm'); +OCP\Util::addscript('bookmarks', 'tag-it'); +OCP\Util::addscript('bookmarks', 'addBm'); OCP\Util::addStyle('bookmarks', 'bookmarks'); OCP\Util::addStyle('bookmarks', 'jquery.tagit'); diff --git a/ajax/delTag.php b/ajax/delTag.php index 4ab6d531..f8a9cdfb 100644 --- a/ajax/delTag.php +++ b/ajax/delTag.php @@ -26,8 +26,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); OCP\JSON::checkAppEnabled('bookmarks'); -if(isset($_POST['old_name'])) -{ +if(isset($_POST['old_name'])) { OC_Bookmarks_Bookmarks::deleteTag($_POST['old_name']); OCP\JSON::success(); exit(); diff --git a/ajax/getInfos.php b/ajax/getInfos.php index e164401e..54355e8f 100644 --- a/ajax/getInfos.php +++ b/ajax/getInfos.php @@ -24,12 +24,12 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); -require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'); +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 = getURLMetadata($_GET['url']); $title = isset($datas['title']) ? $datas['title'] : ''; OCP\JSON::success(array('title' => $title)); exit(); diff --git a/ajax/renameTag.php b/ajax/renameTag.php index 8aa6abb6..e25e6c30 100644 --- a/ajax/renameTag.php +++ b/ajax/renameTag.php @@ -30,8 +30,7 @@ $RUNTIME_NOSETUPFS=true; OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); -if(isset($_POST['old_name']) && isset($_POST['new_name']) && $_POST['new_name'] != '') -{ +if(isset($_POST['old_name']) && isset($_POST['new_name']) && $_POST['new_name'] != '') { OC_Bookmarks_Bookmarks::renameTag($_POST['old_name'], $_POST['new_name']); OCP\JSON::success(); exit(); diff --git a/ajax/updateList.php b/ajax/updateList.php index 6deced84..5ddd9869 100644 --- a/ajax/updateList.php +++ b/ajax/updateList.php @@ -25,7 +25,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); -require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'); +require_once OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'; $req_type= isset($_GET['type']) ? $_GET['type'] : 'bookmark'; diff --git a/bookmarksHelper.php b/bookmarksHelper.php index 846613a4..5ffb5087 100644 --- a/bookmarksHelper.php +++ b/bookmarksHelper.php @@ -36,7 +36,10 @@ function curl_exec_follow(/*resource*/ $ch, /*int*/ &$maxredirect = null) { 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); + OCP\Util::writeLog( + 'bookmark', + 'Too many redirects. When following redirects, libcurl hit the maximum amount on bookmark', + OCP\Util::ERROR); } else { $maxredirect = 0; } @@ -72,7 +75,7 @@ function getURLMetadata($url) { } function analyzeTagRequest($line) { - $tags = explode(',',$line); + $tags = explode(',', $line); $filterTag = array(); foreach($tags as $tag){ if(trim($tag) != '') diff --git a/export.php b/export.php index 6ba803ce..ed9d5b21 100644 --- a/export.php +++ b/export.php @@ -22,9 +22,10 @@ Do Not Edit! -->

EOT; -$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true,-1); +$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks(0, 'id', array(), true, -1); foreach($bookmarks as $bm) { - $file .= '

'.htmlspecialchars($bm['title'], ENT_QUOTES, 'UTF-8').''; + $file .= '
'; + $file .= htmlspecialchars($bm['title'], ENT_QUOTES, 'UTF-8').''; if($bm['description']) $file .= '
'.htmlspecialchars($bm['description'], ENT_QUOTES, 'UTF-8'); } diff --git a/index.php b/index.php index 78ff2877..f5d20c45 100644 --- a/index.php +++ b/index.php @@ -29,13 +29,13 @@ OCP\App::checkAppEnabled('bookmarks'); OCP\App::setActiveNavigationEntry( 'bookmarks_index' ); -OCP\Util::addscript('bookmarks','bookmarks'); +OCP\Util::addscript('bookmarks', 'bookmarks'); OCP\Util::addStyle('bookmarks', 'bookmarks'); -OCP\Util::addscript('bookmarks','addBm'); +OCP\Util::addscript('bookmarks', 'addBm'); -OCP\Util::addscript('bookmarks','tag-it'); -OCP\Util::addscript('bookmarks','js_tpl'); +OCP\Util::addscript('bookmarks', 'tag-it'); +OCP\Util::addscript('bookmarks', 'js_tpl'); OCP\Util::addStyle('bookmarks', 'jquery.tagit'); $qtags = OC_Bookmarks_Bookmarks::findTags(); @@ -55,6 +55,6 @@ $tmpl = new OCP\Template( 'bookmarks', 'list', 'user' ); $tmpl->assign('bookmark', $bm); -$tmpl->assign('req_tag',isset($_GET['tag']) ? $_GET['tag'] : ''); +$tmpl->assign('req_tag', isset($_GET['tag']) ? $_GET['tag'] : ''); $tmpl->assign('tags', json_encode($tags), false); $tmpl->printPage(); diff --git a/lib/bookmarks.php b/lib/bookmarks.php index ef6e81e9..184a0e65 100644 --- a/lib/bookmarks.php +++ b/lib/bookmarks.php @@ -29,14 +29,16 @@ class OC_Bookmarks_Bookmarks{ * @brief Finds all tags for bookmarks */ public static function findTags($filterTags = array(), $offset = 0, $limit = 10){ - //$query = OCP\DB::prepare('SELECT tag, count(*) as nbr from *PREFIX*bookmarks_tags group by tag LIMIT '.$offset.', '.$limit); - $params = array_merge($filterTags,$filterTags); + $params = array_merge($filterTags, $filterTags); array_unshift($params, OCP\USER::getUser()); $not_in = ''; if(!empty($filterTags) ) { - $not_in = ' AND tag not in ('. implode(',',array_fill(0, count($filterTags) ,'?') ) .')'. - str_repeat(" AND exists (select 1 from *PREFIX*bookmarks_tags t2 where t2.bookmark_id = t.bookmark_id and tag = ?) ", count($filterTags)); + $exist_clause = " AND exists (select 1 from *PREFIX*bookmarks_tags + t2 where t2.bookmark_id = t.bookmark_id and tag = ?) "; + + $not_in = ' AND tag not in ('. implode(',', array_fill(0, count($filterTags), '?') ) .')'. + str_repeat($exist_clause, count($filterTags)); } $sql = 'SELECT tag, count(*) as nbr from *PREFIX*bookmarks_tags t '. ' WHERE EXISTS( SELECT 1 from *PREFIX*bookmarks bm where t.bookmark_id = bm.id and user_id = ?) '. @@ -74,7 +76,9 @@ class OC_Bookmarks_Bookmarks{ WHERE user_id = ? "; if($filterTagOnly) { - $sql .= str_repeat(" AND exists (select id from *PREFIX*bookmarks_tags t2 where t2.bookmark_id = b.id and tag = ?) ", count($filters)); + $exist_clause = " AND exists (select id from *PREFIX*bookmarks_tags + t2 where t2.bookmark_id = b.id and tag = ?) "; + $sql .= str_repeat($exist_clause, count($filters)); $params = array_merge($params, $filters); } else { foreach($filters as $filter) { @@ -136,22 +140,22 @@ class OC_Bookmarks_Bookmarks{ $CONFIG_DBTYPE = OCP\Config::getSystemValue( 'dbtype', 'sqlite' ); - if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ + if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ) { // Update tags to the new label unless it already exists a tag like this - $query = OCP\DB::prepare(" - UPDATE OR REPLACE *PREFIX*bookmarks_tags - SET tag = ? - WHERE tag = ? - AND exists( select b.id from *PREFIX*bookmarks b where b.user_id = ? and bookmark_id = b.id) - "); + $query = OCP\DB::prepare(" + UPDATE OR REPLACE *PREFIX*bookmarks_tags + SET tag = ? + WHERE tag = ? + AND exists( select b.id from *PREFIX*bookmarks b where b.user_id = ? and bookmark_id = b.id) + "); - $params=array( - $new, - $old, - $user_id, - ); + $params=array( + $new, + $old, + $user_id, + ); - $result = $query->execute($params); + $result = $query->execute($params); } else { // Remove potentialy duplicated tags @@ -207,7 +211,7 @@ class OC_Bookmarks_Bookmarks{ ); $result = $query->execute($params); - return true; + return $result; } /** @@ -217,7 +221,7 @@ class OC_Bookmarks_Bookmarks{ */ protected static function getNowValue() { $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); - if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ + if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ) { $_ut = "strftime('%s','now')"; } elseif($CONFIG_DBTYPE == 'pgsql') { $_ut = 'date_part(\'epoch\',now())::integer'; @@ -277,7 +281,7 @@ class OC_Bookmarks_Bookmarks{ } /** - * Add a bookmark + * Add a bookmark * @param string $url * @param string $title Name of the bookmark * @param array $tags Simple array of tags to qualify the bookmark (different tags are taken from values) @@ -351,7 +355,6 @@ class OC_Bookmarks_Bookmarks{ $dom->loadHTMLFile($file); $links = $dom->getElementsByTagName('a'); - $things = array(); OCP\DB::beginTransaction(); foreach($links as $link) { @@ -360,10 +363,9 @@ class OC_Bookmarks_Bookmarks{ $tag_str = ''; if($link->hasAttribute("tags")) $tag_str = $link->getAttribute("tags"); - $tags = explode(',' , $tag_str); + $tags = explode(',', $tag_str); self::addBookmark($ref, $title, $tags); - //$things[] = array('title' => $title, 'ref'=>$ref, 'tags' => $tags); } OCP\DB::commit(); return array(); diff --git a/lib/search.php b/lib/search.php index e337f609..a1e30409 100644 --- a/lib/search.php +++ b/lib/search.php @@ -35,7 +35,7 @@ class OC_Search_Provider_Bookmarks extends OC_Search_Provider{ $bookmarks = OC_Bookmarks_Bookmarks::searchBookmarks($search_words); $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'], (string) $l->t('Bookm.')); + $results[]=new OC_Search_Result($bookmark['title'], '', $bookmark['url'], (string) $l->t('Bookm.')); } return $results; diff --git a/settings.php b/settings.php index cc46cd19..626bbc9e 100644 --- a/settings.php +++ b/settings.php @@ -22,8 +22,8 @@ if (isset($_POST['bm_import'])) { $tmpl = new OCP\Template('bookmarks', 'settings'); // Any problems? - if(count($error)){ - $tmpl->assign('error',$error); + if(count($error)) { + $tmpl->assign('error', $error); } return $tmpl->fetchPage(); } else { diff --git a/templates/addBm.php b/templates/addBm.php index e45319a7..171b81c8 100644 --- a/templates/addBm.php +++ b/templates/addBm.php @@ -9,16 +9,22 @@ });

t('Add a bookmark');?>

- +
  • - +
  • - +
  • @@ -30,7 +36,8 @@
  • - +
  • diff --git a/templates/list.php b/templates/list.php index 419db8ac..1d5bd3d7 100644 --- a/templates/list.php +++ b/templates/list.php @@ -19,8 +19,6 @@
    - t('Hide')?> << t('Show')?> >>
    @@ -48,12 +46,13 @@ var fullTags = ; var init_view = ''; var init_sidebar = ''; - var shot_provider = ''; + var shot_provider = ''; //http://api.thumbalizr.com/?width={width}&url={url} @@ -61,16 +60,24 @@

    - " title="t('Edit');?>"> + " + title="t('Edit');?>"> - " title="t('Delete');?>"> + " + title="t('Delete');?>">  

    - <%= encodeEntities(title == '' ? url : title ) %> + + <%= encodeEntities(title == '' ? url : title ) %> + +

    +

    + + <%= encodeEntities(url) %> +

    -

    <%= encodeEntities(url) %>

    <%= formatDate(added_date) %>

    <%= encodeEntities(description)%>

    @@ -81,16 +88,25 @@

    - + +

    +

    +

    -

    t('The address of the page');?>" value="<%= encodeEntities(url)%>"/>

      <% for ( var i = 0; i < tags.length; i++ ) { %>
    • <%=tags[i]%>
    • <% } %>
    -

    -

    +

    + +

    +

    + +

    diff --git a/templates/settings.php b/templates/settings.php index 2544e907..1dd3dd8d 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -24,13 +24,15 @@ t('Import bookmarks');?> -

    +

    +

    t('Export bookmarks');?> -

    t('Export'); ?>

    +

    t('Export'); ?>