From: Benjamin Mako Hill Date: Tue, 16 Jul 2019 23:51:54 +0000 (-0700) Subject: Merge remote-tracking branch 'gh-takuya-o/PHP7.0-mysqli' X-Git-Url: https://projects.mako.cc/source/scuttle/commitdiff_plain/a914fa4a9fe3ef4e708e983da8a53edada5e09aa?hp=6b82542171500ea7134f7a4095b79cb781351465 Merge remote-tracking branch 'gh-takuya-o/PHP7.0-mysqli' --- diff --git a/api/posts_all.php b/api/posts_all.php index 4f05d39..747741a 100644 --- a/api/posts_all.php +++ b/api/posts_all.php @@ -8,6 +8,9 @@ require_once 'httpauth.inc.php'; require_once '../header.inc.php'; +// set user as logged in so private bookmarks are exported +$loggedon = true; + $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService'); $userservice =& ServiceFactory::getServiceInstance('UserService'); @@ -42,8 +45,14 @@ foreach($bookmarks['bookmarks'] as $row) { } else { $taglist = 'system:unfiled'; } + // The privacy setting in scuttle is to set bStatus to 2 in the database. + if(trim($row['bStatus']) == '2') { + $shared = "no"; + } else { + $shared = "yes"; + } - echo "\t\r\n"; + echo "\t\r\n"; } echo ''; diff --git a/api/posts_get.php b/api/posts_get.php index d54f86a..2c875ec 100644 --- a/api/posts_get.php +++ b/api/posts_get.php @@ -54,8 +54,14 @@ foreach ($bookmarks['bookmarks'] as $row) { } else { $taglist = 'system:unfiled'; } + // The privacy setting in scuttle is to set bStatus to 2 in database. + if(trim($row['bStatus']) == '2') { + $shared = "no"; + } else { + $shared = "yes"; + } - echo "\t\r\n"; + echo "\t\r\n"; } echo ''; diff --git a/api/posts_recent.php b/api/posts_recent.php index 476eecb..38124d2 100644 --- a/api/posts_recent.php +++ b/api/posts_recent.php @@ -1,3 +1,4 @@ + \r\n"; + echo "\t\r\n"; } echo ''; diff --git a/config.inc.php.example b/config.inc.php.example index 9d52a2f..f690aee 100644 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -64,14 +64,18 @@ $adminemail = 'admin@example.org'; # be considered recent. # defaultOrderBy: The default order in which bookmarks will appear. # Possible values are: -# date_desc - By date of entry descending. -# Latest entry first. (Default) -# date_asc - By date of entry ascending. -# Earliest entry first. -# title_desc - By title, descending alphabetically. -# title_asc - By title, ascending alphabetically. -# url_desc - By URL, descending alphabetically. -# url_asc - By URL, ascending alphabetically. +# date_desc - By date of entry descending. +# Latest entry first. (Default) +# date_asc - By date of entry ascending. +# Earliest entry first. +# mod_date_desc - By modification date descending. +# Latest modified entry first. +# mod_date_asc - By modification date ascending. +# Earliest modified entry first. +# title_desc - By title, descending alphabetically. +# title_asc - By title, ascending alphabetically. +# url_desc - By URL, descending alphabetically. +# url_asc - By URL, ascending alphabetically. # TEMPLATES_DIR: The directory where the template files should be # loaded from (the *.tpl.php files) # root : Set to NULL to autodetect the root url of the website diff --git a/import.php b/import.php index 9f29728..5f0c5ee 100644 --- a/import.php +++ b/import.php @@ -80,6 +80,9 @@ function startElement($parser, $name, $attrs) { case 'TIME': $bDatetime = $attrVal; break; + case 'PRIVATE': + $bStatus = (strcasecmp('yes', $attrVal) == 0) ? 2 : $status ; + break; case 'TAG': $tags = strtolower($attrVal); break; @@ -96,7 +99,7 @@ function startElement($parser, $name, $attrs) { $bDatetime = gmdate('Y-m-d H:i:s'); } - if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $status, $tags, $bDatetime, true, true)) + if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $bStatus, $tags, $bDatetime, true, true)) $tplVars['msg'] = T_('Bookmark imported.'); else $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.'); diff --git a/includes/db/mysql4.php b/includes/db/mysql4.php index 0639518..f074e19 100644 --- a/includes/db/mysql4.php +++ b/includes/db/mysql4.php @@ -44,6 +44,8 @@ class sql_db { if (@mysql_select_db($this->dbname)) { + #Set utf-8 + mysql_query('SET CHARACTER SET utf8', $this->db_connect_id); return $this->db_connect_id; } } diff --git a/includes/jquery-ui-1.8.9.autocomplete.min.js b/includes/jquery-ui-1.8.9.autocomplete.min.js new file mode 100644 index 0000000..3d4ac16 --- /dev/null +++ b/includes/jquery-ui-1.8.9.autocomplete.min.js @@ -0,0 +1,80 @@ +/*! + * jQuery UI 1.8.9 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI + */ +(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, +NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, +"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); +if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, +"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, +d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); +c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+= +a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b), +g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery); +;/* + * jQuery UI Autocomplete 1.8.9 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Autocomplete + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.position.js + */ +(function(d){d.widget("ui.autocomplete",{options:{appendTo:"body",delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,f;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.attr("readonly"))){f=false;var e=d.ui.keyCode; +switch(c.keyCode){case e.PAGE_UP:a._move("previousPage",c);break;case e.PAGE_DOWN:a._move("nextPage",c);break;case e.UP:a._move("previous",c);c.preventDefault();break;case e.DOWN:a._move("next",c);c.preventDefault();break;case e.ENTER:case e.NUMPAD_ENTER:if(a.menu.active){f=true;c.preventDefault()}case e.TAB:if(!a.menu.active)return;a.menu.select(c);break;case e.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!=a.element.val()){a.selectedItem= +null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(f){f=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)};this.menu=d("
    ").addClass("ui-autocomplete").appendTo(d(this.options.appendTo|| +"body",b)[0]).mousedown(function(c){var e=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(g){g.target!==a.element[0]&&g.target!==e&&!d.ui.contains(e,g.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,e){e=e.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:e})&&/^key/.test(c.originalEvent.type)&&a.element.val(e.value)},selected:function(c,e){var g=e.item.data("item.autocomplete"), +h=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=h;setTimeout(function(){a.previous=h;a.selectedItem=g},1)}false!==a._trigger("select",c,{item:g})&&a.element.val(g.value);a.term=a.element.val();a.close(c);a.selectedItem=g},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"); +this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,f;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,e){e(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source=== +"string"){f=this.options.source;this.source=function(c,e){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:f,data:c,dataType:"json",success:function(g,h,i){i===a.xhr&&e(g);a.xhr=null},error:function(g){g===a.xhr&&e([]);a.xhr=null}})}}else this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length").data("item.autocomplete",b).append(d("").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b); +else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(a,b){var f=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return f.test(c.label||c.value||c)})}})})(jQuery); +(function(d){d.widget("ui.menu",{_create:function(){var a=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(b){if(d(b.target).closest(".ui-menu-item a").length){b.preventDefault();a.select(b)}});this.refresh()},refresh:function(){var a=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex", +-1).mouseenter(function(b){a.activate(b,d(this).parent())}).mouseleave(function(){a.deactivate()})},activate:function(a,b){this.deactivate();if(this.hasScroll()){var f=b.offset().top-this.element.offset().top,c=this.element.attr("scrollTop"),e=this.element.height();if(f<0)this.element.attr("scrollTop",c+f);else f>=e&&this.element.attr("scrollTop",c+f-e+b.height())}this.active=b.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",a,{item:b})}, +deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");this._trigger("blur");this.active=null}},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(a,b,f){if(this.active){a=this.active[a+"All"](".ui-menu-item").eq(0); +a.length?this.activate(f,a):this.activate(f,this.element.children(b))}else this.activate(f,this.element.children(b))},nextPage:function(a){if(this.hasScroll())if(!this.active||this.last())this.activate(a,this.element.children(".ui-menu-item:first"));else{var b=this.active.offset().top,f=this.element.height(),c=this.element.children(".ui-menu-item").filter(function(){var e=d(this).offset().top-b-f+d(this).height();return e<10&&e>-10});c.length||(c=this.element.children(".ui-menu-item:last"));this.activate(a, +c)}else this.activate(a,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(a){if(this.hasScroll())if(!this.active||this.first())this.activate(a,this.element.children(".ui-menu-item:last"));else{var b=this.active.offset().top,f=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-b+f-d(this).height();return c<10&&c>-10});result.length||(result=this.element.children(".ui-menu-item:first")); +this.activate(a,result)}else this.activate(a,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height() 0) { if ($row['bDescription'] != '') { echo '
    '. filter($row['bDescription']) ."
    \n"; } - echo '
    '. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."
    \n"; + if ($row['bDatetime'] == $row['bModified']) { + echo '
    '. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."
    \n"; + } else { + echo '
    updated: '. date($GLOBALS['shortdate'], strtotime($row['bModified'])) . ', original: '. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . "" . $cats . $copy . $edit ."
    \n"; + } echo "\n"; } ?> diff --git a/templates/dynamictags.inc.php b/templates/dynamictags.inc.php index b42819e..d7f094a 100644 --- a/templates/dynamictags.inc.php +++ b/templates/dynamictags.inc.php @@ -24,7 +24,8 @@ $userservice =& ServiceFactory::getServiceInstance('UserService'); $logged_on_userid = $userservice->getCurrentUserId(); $userPopularTags =& $tagservice->getPopularTags($logged_on_userid, 25, $logged_on_userid); -$userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175); +$userAllTags =& $tagservice->getPopularTags($logged_on_userid, 10000, $logged_on_userid); +$userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175); $userPopularTagsCount = count($userPopularTags); if ($userPopularTagsCount > 0) { @@ -55,8 +56,8 @@ Array.prototype.remove = function (ele) { function addonload(addition) { var existing = window.onload; window.onload = function () { - existing(); - addition(); + existing; + addition; } } @@ -112,6 +113,67 @@ foreach(array_keys($userPopularTagsCloud) as $key) { document.write(''); document.write('<\/p>'); document.write('<\/div>'); + +var availableTags = [ + +]; +function split( val ) { + return val.split( /,\s*/ ); +} +function extractLast( term ) { + return split( term ).pop(); +} + +$( "#tags" ) + // don't navigate away from the field on tab when selecting an item + .bind( "keydown", function( event ) { + if ( event.keyCode === $.ui.keyCode.TAB && + $( this ).data( "autocomplete" ).menu.active ) { + event.preventDefault(); + } + }) + .autocomplete({ + minLength: 2, + delay: 50, + source: function( request, response ) { + // if the term is >2 in legth delegate back to autocomplete + if (extractLast ( request.term ).length < 3) { + response( [] ); + } else { + response( $.ui.autocomplete.filter( + availableTags, extractLast( request.term ) ) ); + } + }, + focus: function() { + // prevent value inserted on focus + return false; + }, + select: function( event, ui ) { + var terms = split( this.value ); + // remove the current input + terms.pop(); + // add the selected item + var newterm = ui.item.value; + terms.push( newterm ); + + $("#popularTags").children().each(function() { + if (this.innerHTML == newterm) { + this.className = 'selected'; + } + }); + // add placeholder to get the comma-and-space at the end + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } +}); + + - \ No newline at end of file + diff --git a/templates/editbookmark.tpl.php b/templates/editbookmark.tpl.php index 16b56c7..2304134 100644 --- a/templates/editbookmark.tpl.php +++ b/templates/editbookmark.tpl.php @@ -31,7 +31,7 @@ switch ($row['bStatus']) { - + @@ -69,7 +69,7 @@ switch ($row['bStatus']) { @@ -108,4 +108,4 @@ document.write('<\/ul>'); includeTemplate($GLOBALS['bottom_include']); -?> \ No newline at end of file +?> diff --git a/templates/toolbar.inc.php b/templates/toolbar.inc.php index 2eb56ac..023ed3b 100644 --- a/templates/toolbar.inc.php +++ b/templates/toolbar.inc.php @@ -10,6 +10,7 @@ if ($userservice->isLoggedOn()) {
  • +
  • + + @@ -37,7 +39,11 @@ if (isset($_GET['popup'])) { '. $subtitle ."\n"; + echo '

    '. $subtitle; + if (isset($total)) { + echo " (" . $total . ")"; + } + echo "

    \n"; } if (isset($error)) { echo '

    '. $error ."

    \n";