1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-03-21 12:29:14 +01:00

adding space between) and {

This commit is contained in:
Thomas Mueller 2012-09-07 15:21:03 +02:00
parent 412c6ab27d
commit 358910f693
7 changed files with 20 additions and 20 deletions

View File

@ -29,7 +29,7 @@ OCP\JSON::checkAppEnabled('bookmarks');
OCP\JSON::callCheck();
$id = $_POST['id'];
if (!OC_Bookmarks_Bookmarks::deleteUrl($id)){
if (!OC_Bookmarks_Bookmarks::deleteUrl($id)) {
OC_JSON::error();
exit();
}

View File

@ -28,7 +28,7 @@ OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
$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';

View File

@ -2,7 +2,7 @@
class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
// Create the xml for the user supplied
function export( ){
function export( ) {
$options = array(
'table'=>'bookmarks',
'matchcol'=>'user_id',
@ -31,14 +31,14 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
}
// Import function for bookmarks
function import( ){
switch( $this->appinfo->version ){
function import( ) {
switch( $this->appinfo->version ) {
default:
// All versions of the app have had the same db structure, so all can use the same import function
$query = $this->content->prepare( "SELECT * FROM `bookmarks` WHERE `user_id` LIKE ?" );
$results = $query->execute( array( $this->olduid ) );
$idmap = array();
while( $row = $results->fetchRow() ){
while( $row = $results->fetchRow() ) {
// Import each bookmark, saving its id into the map
$query = OCP\DB::prepare( "INSERT INTO `*PREFIX*bookmarks`(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`) VALUES (?, ?, ?, ?, ?, ?)" );
$query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
@ -46,10 +46,10 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
$idmap[$row['id']] = OCP\DB::insertid();
}
// Now tags
foreach($idmap as $oldid => $newid){
foreach($idmap as $oldid => $newid) {
$query = $this->content->prepare( "SELECT * FROM `bookmarks_tags` WHERE `bookmark_id` LIKE ?" );
$results = $query->execute( array( $oldid ) );
while( $row = $results->fetchRow() ){
while( $row = $results->fetchRow() ) {
// Import the tags for this bookmark, using the new bookmark id
$query = OCP\DB::prepare( "INSERT INTO `*PREFIX*bookmarks_tags`(`bookmark_id`, `tag`) VALUES (?, ?)" );
$query->execute( array( $newid, $row['tag'] ) );

View File

@ -56,7 +56,7 @@ function getURLMetadata($url) {
}
$metadata['url'] = $url;
if (!function_exists('curl_init')){
if (!function_exists('curl_init')) {
return $metadata;
}
$ch = curl_init();
@ -73,7 +73,7 @@ function getURLMetadata($url) {
function addBookmark($url, $title, $tags='') {
$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';

View File

@ -33,29 +33,29 @@ class OC_Bookmarks_Bookmarks{
* @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){
public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly) {
//OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG);
$CONFIG_DBTYPE = OCP\Config::getSystemValue( 'dbtype', 'sqlite' );
$params=array(OCP\USER::getUser());
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ) {
$_gc_separator = ', \' \'';
} else {
$_gc_separator = 'SEPARATOR \' \'';
}
if($filter){
if($filter) {
if($CONFIG_DBTYPE == 'pgsql' )
$tagString = 'array_to_string(array_agg(tag), \' \')';
else
$tagString = 'tags';
$sqlFilterTag = 'HAVING ';
if(is_array($filter)){
if(is_array($filter)) {
$first = true;
$filterstring = '';
foreach ($filter as $singleFilter){
foreach ($filter as $singleFilter) {
$filterstring = $filterstring . ($first?'':' AND ') . $tagString.' LIKE ? ';
$params[] = '%'.$singleFilter.'%';
$first=false;
@ -69,7 +69,7 @@ class OC_Bookmarks_Bookmarks{
$sqlFilterTag = '';
}
if($CONFIG_DBTYPE == 'pgsql' ){
if($CONFIG_DBTYPE == 'pgsql' ) {
$query = OCP\DB::prepare('
SELECT `id`, `url`, `title`, '.($filterTagOnly?'':'`url` || `title` ||').' array_to_string(array_agg(`tag`), \' \') as `tags`
FROM `*PREFIX*bookmarks`

View File

@ -21,14 +21,14 @@
*/
class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
function search($query){
function search($query) {
$results=array();
$offset = 0;
$sqlSortColumn = 'id';
$searchquery=array();
if(substr_count($query, ' ') > 0){
if(substr_count($query, ' ') > 0) {
$searchquery = explode(' ', $query);
}else{
$searchquery = $query;
@ -38,7 +38,7 @@ class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false);
// OCP\Util::writeLog('bookmarks', 'found ' .count($bookmarks) ,OCP\Util::DEBUG);
//$l = new OC_l10n('bookmarks'); //resulttype can't be localized, javascript relies on that type
foreach($bookmarks as $bookmark){
foreach($bookmarks as $bookmark) {
$results[]=new OC_Search_Result($bookmark['title'],'', $bookmark['url'],'Bookm.');
}

View File

@ -3,6 +3,6 @@
function createBookmarklet() {
$l = OC_L10N::get('bookmarks');
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '</small>'
. '<a class="button bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OCP\Util::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
. '<a class="button bookmarklet" href="javascript:(function() {var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OCP\Util::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function() {d.focus()},300);})();">'
. $l->t('Read later') . '</a>';
}