diff options
-rwxr-xr-x | installer/install.sql | 6 | ||||
-rw-r--r-- | lib/jquery.form.js | 92 | ||||
-rw-r--r-- | lib/jquery.localscroll.js | 18 | ||||
-rw-r--r-- | lib/jquery.scrollTo.js | 22 | ||||
-rw-r--r-- | modules/g2_import/controllers/admin_g2_import.php | 18 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 47 | ||||
-rw-r--r-- | modules/gallery/css/upgrader.css | 117 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 65 | ||||
-rw-r--r-- | modules/gallery/views/upgrader.html.php | 108 |
9 files changed, 269 insertions, 224 deletions
diff --git a/installer/install.sql b/installer/install.sql index a06ef4e7..432aee64 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -208,7 +208,7 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {modules} VALUES (1,1,'gallery',1),(2,1,'user',1),(3,1,'comment',1),(4,1,'organize',1),(5,1,'info',1),(6,1,'rss',1),(7,1,'search',1),(8,1,'slideshow',1),(9,1,'tag',1); +INSERT INTO {modules} VALUES (1,1,'gallery',2),(2,1,'user',1),(3,1,'comment',1),(4,1,'organize',1),(5,1,'info',1),(6,1,'rss',1),(7,1,'search',1),(8,1,'slideshow',1),(9,1,'tag',1); DROP TABLE IF EXISTS {outgoing_translations}; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; @@ -333,6 +333,6 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 beta 1'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>'),(21,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>'),(20,'gallery','date_format','Y-M-d'),(21,'gallery','date_time_format','Y-M-d H:i:s'),(22,'gallery','time_format','H:i:s'),(24,'comment','spam_caught','0'); diff --git a/lib/jquery.form.js b/lib/jquery.form.js index 329d47b9..40fb8b1f 100644 --- a/lib/jquery.form.js +++ b/lib/jquery.form.js @@ -1,14 +1,12 @@ /* * jQuery Form Plugin - * version: 2.17 (06-NOV-2008) + * version: 2.28 (10-MAY-2009) * @requires jQuery v1.2.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html - * - * Revision: $Id$ */ ;(function($) { @@ -55,8 +53,15 @@ $.fn.ajaxSubmit = function(options) { if (typeof options == 'function') options = { success: options }; + var url = $.trim(this.attr('action')); + if (url) { + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; + } + url = url || window.location.href || '' + options = $.extend({ - url: this.attr('action') || window.location.toString(), + url: url, type: this.attr('method') || 'GET' }, options || {}); @@ -81,7 +86,7 @@ $.fn.ajaxSubmit = function(options) { for (var n in options.data) { if(options.data[n] instanceof Array) { for (var k in options.data[n]) - a.push( { name: n, value: options.data[n][k] } ) + a.push( { name: n, value: options.data[n][k] } ); } else a.push( { name: n, value: options.data[n] } ); @@ -136,11 +141,15 @@ $.fn.ajaxSubmit = function(options) { if (files[j]) found = true; + var multipart = false; +// var mp = 'multipart/form-data'; +// multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + // options.iframe allows user to force iframe mode - if (options.iframe || found) { + if (options.iframe || found || multipart) { // hack to fix Safari hang (thanks to Tim Molendijk for this) // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if ($.browser.safari && options.closeKeepAlive) + if (options.closeKeepAlive) $.get(options.closeKeepAlive, fileUpload); else fileUpload(); @@ -156,22 +165,21 @@ $.fn.ajaxSubmit = function(options) { // private function for handling file uploads (hat tip to YAHOO!) function fileUpload() { var form = $form[0]; - /* - if ($(':input[@name=submit]', form).length) { + + /* (this breaks the watermark form uploader, turn it off for now) + if ($(':input[name=submit]', form).length) { alert('Error: Form elements must not be named "submit".'); return; } - */ + */ var opts = $.extend({}, $.ajaxSettings, options); - var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); + var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); var id = 'jqFormIO' + (new Date().getTime()); - var $io = $('<iframe id="' + id + '" name="' + id + '" />'); + var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />'); var io = $io[0]; - if ($.browser.msie || $.browser.opera) - io.src = 'javascript:false;document.write("");'; $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); var xhr = { // mock object @@ -194,9 +202,9 @@ $.fn.ajaxSubmit = function(options) { if (g && ! $.active++) $.event.trigger("ajaxStart"); if (g) $.event.trigger("ajaxSend", [xhr, opts]); - if (s.beforeSend && s.beforeSend(xhr, s) === false) { - s.global && jQuery.active--; - return; + if (s.beforeSend && s.beforeSend(xhr, s) === false) { + s.global && $.active--; + return; } if (xhr.aborted) return; @@ -222,11 +230,13 @@ $.fn.ajaxSubmit = function(options) { setTimeout(function() { // make sure form attrs are set var t = $form.attr('target'), a = $form.attr('action'); - $form.attr({ - target: id, - method: 'POST', - action: opts.url - }); + + // update form attrs in IE friendly way + form.setAttribute('target',id); + if (form.getAttribute('method') != 'POST') + form.setAttribute('method', 'POST'); + if (form.getAttribute('action') != opts.url) + form.setAttribute('action', opts.url); // ie borks in some cases when setting encoding if (! options.skipEncodingOverride) { @@ -256,18 +266,19 @@ $.fn.ajaxSubmit = function(options) { } finally { // reset attrs and remove "extra" input elements - $form.attr('action', a); - t ? $form.attr('target', t) : $form.removeAttr('target'); + form.setAttribute('action',a); + t ? form.setAttribute('target', t) : $form.removeAttr('target'); $(extraInputs).remove(); } }, 10); + var nullCheckFlag = 0; + function cb() { if (cbInvoked++) return; io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false); - var operaHack = 0; var ok = true; try { if (timedOut) throw 'timeout'; @@ -276,10 +287,10 @@ $.fn.ajaxSubmit = function(options) { doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document; - if (doc.body == null && !operaHack && $.browser.opera) { - // In Opera 9.2.x the iframe DOM is not always traversable when - // the onload callback fires so we give Opera 100ms to right itself - operaHack = 1; + if ((doc.body == null || doc.body.innerHTML == '') && !nullCheckFlag) { + // in some browsers (cough, Opera 9.2.x) the iframe DOM is not always traversable when + // the onload callback fires, so we give them a 2nd chance + nullCheckFlag = 1; cbInvoked--; setTimeout(cb, 100); return; @@ -412,8 +423,10 @@ $.fn.formToArray = function(semantic) { if (semantic && form.clk && el.type == "image") { // handle image inputs on the fly when semantic == true - if(!el.disabled && form.clk == el) + if(!el.disabled && form.clk == el) { + a.push({name: n, value: $(el).val()}); a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); + } continue; } @@ -427,13 +440,11 @@ $.fn.formToArray = function(semantic) { } if (!semantic && form.clk) { - // input type=='image' are not found in elements array! handle them here - var inputs = form.getElementsByTagName("input"); - for(var i=0, max=inputs.length; i < max; i++) { - var input = inputs[i]; - var n = input.name; - if(n && !input.disabled && input.type == "image" && form.clk == input) - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); + // input type=='image' are not found in elements array! handle it here + var $input = $(form.clk), input = $input[0], n = input.name; + if (n && !input.disabled && input.type == 'image') { + a.push({name: n, value: $input.val()}); + a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); } } return a; @@ -540,8 +551,9 @@ $.fieldValue = function(el, successful) { for(var i=(one ? index : 0); i < max; i++) { var op = ops[i]; if (op.selected) { - // extra pain for IE... - var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value; + var v = op.value; + if (!v) // extra pain for IE... + v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; if (one) return v; a.push(v); } @@ -598,7 +610,7 @@ $.fn.resetForm = function() { $.fn.enable = function(b) { if (b == undefined) b = true; return this.each(function() { - this.disabled = !b + this.disabled = !b; }); }; diff --git a/lib/jquery.localscroll.js b/lib/jquery.localscroll.js index c4b0f3c1..3f8d64cc 100644 --- a/lib/jquery.localscroll.js +++ b/lib/jquery.localscroll.js @@ -1,9 +1,9 @@ -/** - * jQuery.LocalScroll - Animated scrolling navigation, using anchors. - * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Dual licensed under MIT and GPL. - * Date: 6/3/2008 - * @author Ariel Flesler - * @version 1.2.6 - **/ -;(function($){var g=location.href.replace(/#.*/,''),h=$.localScroll=function(a){$('body').localScroll(a)};h.defaults={duration:1e3,axis:'y',event:'click',stop:1};h.hash=function(a){a=$.extend({},h.defaults,a);a.hash=0;if(location.hash)setTimeout(function(){i(0,location,a)},0)};$.fn.localScroll=function(b){b=$.extend({},h.defaults,b);return(b.persistent||b.lazy)?this.bind(b.event,function(e){var a=$([e.target,e.target.parentNode]).filter(c)[0];a&&i(e,a,b)}):this.find('a,area').filter(c).bind(b.event,function(e){i(e,this,b)}).end().end();function c(){var a=this;return!!a.href&&!!a.hash&&a.href.replace(a.hash,'')==g&&(!b.filter||$(a).is(b.filter))}};function i(e,a,b){var c=a.hash.slice(1),d=document.getElementById(c)||document.getElementsByName(c)[0],f;if(d){e&&e.preventDefault();f=$(b.target||$.scrollTo.window());if(b.lock&&f.is(':animated')||b.onBefore&&b.onBefore.call(a,e,d,f)===!1)return;if(b.stop)f.queue('fx',[]).stop();f.scrollTo(d,b).trigger('notify.serialScroll',[d]);if(b.hash)f.queue(function(){location=a.hash;$(this).dequeue()})}}})(jQuery); +/**
+ * jQuery.LocalScroll - Animated scrolling navigation, using anchors.
+ * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
+ * Dual licensed under MIT and GPL.
+ * Date: 3/11/2009
+ * @author Ariel Flesler
+ * @version 1.2.7
+ **/
+;(function($){var l=location.href.replace(/#.*/,'');var g=$.localScroll=function(a){$('body').localScroll(a)};g.defaults={duration:1e3,axis:'y',event:'click',stop:true,target:window,reset:true};g.hash=function(a){if(location.hash){a=$.extend({},g.defaults,a);a.hash=false;if(a.reset){var e=a.duration;delete a.duration;$(a.target).scrollTo(0,a);a.duration=e}i(0,location,a)}};$.fn.localScroll=function(b){b=$.extend({},g.defaults,b);return b.lazy?this.bind(b.event,function(a){var e=$([a.target,a.target.parentNode]).filter(d)[0];if(e)i(a,e,b)}):this.find('a,area').filter(d).bind(b.event,function(a){i(a,this,b)}).end().end();function d(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,'')==l&&(!b.filter||$(this).is(b.filter))}};function i(a,e,b){var d=e.hash.slice(1),f=document.getElementById(d)||document.getElementsByName(d)[0];if(!f)return;if(a)a.preventDefault();var h=$(b.target);if(b.lock&&h.is(':animated')||b.onBefore&&b.onBefore.call(b,a,f,h)===false)return;if(b.stop)h.stop(true);if(b.hash){var j=f.id==d?'id':'name',k=$('<a> </a>').attr(j,d).css({position:'absolute',top:$(window).scrollTop(),left:$(window).scrollLeft()});f[j]='';$('body').prepend(k);location=e.hash;k.remove();f[j]=d}h.scrollTo(f,b).trigger('notify.serialScroll',[f])}})(jQuery);
\ No newline at end of file diff --git a/lib/jquery.scrollTo.js b/lib/jquery.scrollTo.js index fae1d1db..73a33418 100644 --- a/lib/jquery.scrollTo.js +++ b/lib/jquery.scrollTo.js @@ -1,11 +1,11 @@ -/** - * jQuery.ScrollTo - Easy element scrolling using jQuery. - * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Dual licensed under MIT and GPL. - * Date: 9/11/2008 - * @author Ariel Flesler - * @version 1.4 - * - * http://flesler.blogspot.com/2007/10/jqueryscrollto.html - */ -;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery); +/**
+ * jQuery.ScrollTo - Easy element scrolling using jQuery.
+ * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
+ * Dual licensed under MIT and GPL.
+ * Date: 5/25/2009
+ * @author Ariel Flesler
+ * @version 1.4.2
+ *
+ * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
+ */
+;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
\ No newline at end of file diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 968d97cd..f2969f49 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -44,20 +44,13 @@ class Admin_g2_import_Controller extends Admin_Controller { $form = $this->_get_import_form(); if ($form->validate()) { $embed_path = $form->configure_g2_import->embed_path->value; - $multi_path = $form->configure_g2_import->multi_path->value; - if (!is_file($embed_path) && file_exists("$embed_path/embed.php")) { $embed_path = "$embed_path/embed.php"; } - - if (!empty($multi_path) && !is_file($multi_path) && file_exists("$multi_path/config.php")) { - $multi_path = "$multi_path/embed.php"; - } - if (g2_import::is_valid_embed_path($embed_path, $multi_path)) { + if (g2_import::is_valid_embed_path($embed_path)) { message::success("Gallery 2 path saved."); module::set_var("g2_import", "embed_path", $embed_path); - module::set_var("g2_import", "multi_path", $multi_path); url::redirect("admin/g2_import"); } else { $form->configure_g2_import->embed_path->add_error("invalid", 1); @@ -74,16 +67,11 @@ class Admin_g2_import_Controller extends Admin_Controller { $form = new Forge( "admin/g2_import/save", "", "post", array("id" => "gAdminConfigureG2ImportForm")); $group = $form->group("configure_g2_import")->label(t("Configure Gallery 2 Import")); - $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file (in case of multisite config, use the path to the 'master')")) + $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file")) ->value(module::get_var("g2_import", "embed_path", "")); - - $group->input("multi_path")->label(t("Filesystem path to your Gallery 2 multisite instance config (leave empty if not applicable)")) - ->value(module::get_var("g2_import", "multi_path", "")); - $group->embed_path->error_messages( "invalid", t("The path you entered is not a Gallery 2 installation.")); - $group->submit("")->value(t("Save")); return $form; } -} +}
\ No newline at end of file diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 00e3d31a..2eee564a 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -38,24 +38,22 @@ class g2_import_Core { } $embed_path = module::get_var("g2_import", "embed_path"); - $multi_path = module::get_var("g2_import", "multi_path"); - if (empty($embed_path)) { throw new Exception("@todo G2_IMPORT_NOT_CONFIGURED"); } - g2_import::$init = g2_import::init_embed($embed_path, $multi_path); + g2_import::$init = g2_import::init_embed($embed_path); } - static function is_valid_embed_path($embed_path, $multi_path) { - return file_exists($embed_path) && (empty($multi_path) || file_exists($multi_path)) && g2_import::init_embed($embed_path, $multi_path); + static function is_valid_embed_path($embed_path) { + return file_exists($embed_path) && g2_import::init_embed($embed_path); } /** * Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls. */ - static function init_embed($embed_path, $multi_path) { - if (!is_file($embed_path) && (empty($multi_path) || is_dir($multi_path))) { + static function init_embed($embed_path) { + if (!is_file($embed_path)) { return false; } @@ -72,11 +70,17 @@ class g2_import_Core { @dir::unlink($mod_path); mkdir($mod_path); - $base_dir = dirname($embed_path); - if (!empty($multi_path)) - $config_dir = dirname($multi_path); - else - $config_dir = $base_dir; + $config_dir = dirname($embed_path); + if (filesize($embed_path) > 200) { + // Regular install + $base_dir = $config_dir; + } else { + // Multisite install. Line 2 of embed.php will be something like: + // require('/usr/home/bharat/public_html/gallery2/embed.php'); + $lines = file($embed_path); + preg_match("#require\('(.*)/embed.php'\);#", $lines[2], $matches); + $base_dir = $matches[1]; + } file_put_contents( "$mod_path/embed.php", @@ -108,11 +112,13 @@ class g2_import_Core { array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", - "\$gallery =& new Gallery();"), + "\$gallery =& new Gallery();", + "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '$config_dir');", - "\$gallery =& new G2_Gallery();"), + "\$gallery =& new G2_Gallery();", + "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("$base_dir/bootstrap.inc")))); @@ -576,7 +582,18 @@ class g2_import_Core { return; } - foreach (preg_split("/[,;]/", $keywords) as $keyword) { + // Keywords in G2 are free form. So we don't know what our user used as a separator. Try to + // be smart about it. If we see a comma or a semicolon, expect the keywords to be separated + // by that delimeter. Otherwise, use space as the delimiter. + if (strpos($keywords, ";")) { + $delim = ";"; + } else if (strpos($keywords, ",")) { + $delim = ","; + } else { + $delim = " "; + } + + foreach (preg_split("/$delim/", $keywords) as $keyword) { $keyword = trim($keyword); if ($keyword) { tag::add($item, $keyword); diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css new file mode 100644 index 00000000..6bd16064 --- /dev/null +++ b/modules/gallery/css/upgrader.css @@ -0,0 +1,117 @@ +body { + background: #eee; + font-family: Trebuchet MS; + font-size: 1.1em; +} + +h1 { + font-size: 1.4em; +} + +div#outer { + width: 650px; + background: white; + border: 1px solid #999; + margin: 0 auto; + padding: -10px; +} + +div#inner { + padding: 0 1em 0 1em; + margin: 0px; +} + +div#footer { + border-top: 1px solid #ccc; + margin: 1em; +} + +td.name { + text-align: left; + padding-left: 30px; +} + +td { + text-align: center; + border-bottom: 1px solid #eee; +} + +tr.current td { + color: #999; + font-style: italic; +} + +tr.current td.gallery { + color: #00d; +} + +tr.upgradeable td { + font-weight: bold; +} + +tr.upgradeable td.gallery { + color: #00d; +} + +table { + width: 600px; + margin-bottom: 10px; +} + +p { + font-size: .9em; +} + +ul { + font-size: .9em; + list-style: none; +} + +li { + display: inline; +} + +li:before { + content: "\00BB \0020"; +} + +div.button { + margin: 0 auto; + width: 120px; + text-align: center; + border: 1px solid #999; + background: #eee; +} + +div.button a { + text-decoration: none; +} + +div.button:hover { + background: #ccc; +} + +div#confirmation { + position: absolute; + background: blue; + z-index: 1000; + margin: 10px; + text-align: center; +} + +div#confirmation div { + margin: 2px; + padding: 20px; + border: 2px solid #999; + background: #eee; +} + +.gray_on_done { + opacity: <?= $done ? "0.5" : "1" ?>; +} + +pre { + display: inline; + margin: 0px; + padding: 0px; +} diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b2be63be..cd871c17 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -50,6 +50,18 @@ class gallery_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {incoming_translations} ( + `id` int(9) NOT NULL auto_increment, + `key` char(32) NOT NULL, + `locale` char(10) NOT NULL, + `message` text NOT NULL, + `revision` int(9) DEFAULT NULL, + `translation` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`, `locale`), + KEY `locale_key` (`locale`, `key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {items} ( `id` int(9) NOT NULL auto_increment, `album_cover_item_id` int(9) default NULL, @@ -117,44 +129,24 @@ class gallery_installer { UNIQUE KEY(`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {themes} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - - $db->query("CREATE TABLE {permissions} ( - `id` int(9) NOT NULL auto_increment, - `display_name` varchar(64) default NULL, - `name` varchar(64) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - - $db->query("CREATE TABLE {incoming_translations} ( + $db->query("CREATE TABLE {outgoing_translations} ( `id` int(9) NOT NULL auto_increment, + `base_revision` int(9) DEFAULT NULL, `key` char(32) NOT NULL, `locale` char(10) NOT NULL, `message` text NOT NULL, - `revision` int(9) DEFAULT NULL, `translation` text, PRIMARY KEY (`id`), UNIQUE KEY(`key`, `locale`), KEY `locale_key` (`locale`, `key`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {outgoing_translations} ( + $db->query("CREATE TABLE {permissions} ( `id` int(9) NOT NULL auto_increment, - `base_revision` int(9) DEFAULT NULL, - `key` char(32) NOT NULL, - `locale` char(10) NOT NULL, - `message` text NOT NULL, - `translation` text, + `display_name` varchar(64) default NULL, + `name` varchar(64) default NULL, PRIMARY KEY (`id`), - UNIQUE KEY(`key`, `locale`), - KEY `locale_key` (`locale`, `key`)) + UNIQUE KEY(`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {sessions} ( @@ -179,6 +171,14 @@ class gallery_installer { KEY (`owner_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {themes} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {vars} ( `id` int(9) NOT NULL auto_increment, `module_name` varchar(64) NOT NULL, @@ -248,18 +248,20 @@ class gallery_installer { block_manager::add("dashboard_center", "gallery", "photo_stream"); block_manager::add("dashboard_center", "gallery", "log_entries"); - module::set_version("gallery", 1); + module::set_version("gallery", $version = 1); module::set_var("gallery", "version", "3.0 beta 1"); module::set_var("gallery", "choose_default_tookit", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); - } else if ($version == 1) { + } + + if ($version == 1) { module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); - module::set_version("gallery", 2); + module::set_version("gallery", $version = 2); } } @@ -268,16 +270,15 @@ class gallery_installer { $db->query("DROP TABLE IF EXISTS {access_caches}"); $db->query("DROP TABLE IF EXISTS {access_intents}"); $db->query("DROP TABLE IF EXISTS {graphics_rules}"); + $db->query("DROP TABLE IF EXISTS {incoming_translations}"); $db->query("DROP TABLE IF EXISTS {items}"); $db->query("DROP TABLE IF EXISTS {logs}"); - $db->query("DROP TABLE IF EXISTS {messages}"); $db->query("DROP TABLE IF EXISTS {modules}"); - $db->query("DROP TABLE IF EXISTS {themes}"); - $db->query("DROP TABLE IF EXISTS {incoming_translations}"); $db->query("DROP TABLE IF EXISTS {outgoing_translations}"); $db->query("DROP TABLE IF EXISTS {permissions}"); $db->query("DROP TABLE IF EXISTS {sessions}"); $db->query("DROP TABLE IF EXISTS {tasks}"); + $db->query("DROP TABLE IF EXISTS {themes}"); $db->query("DROP TABLE IF EXISTS {vars}"); foreach (array("albums", "resizes", "thumbs", "uploads", "modules", "logs", "database.php") as $entry) { diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index fa21e196..07792322 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -2,106 +2,10 @@ <html> <head> <title><?= t("Gallery3 Upgrader") ?></title> + <link rel="stylesheet" type="text/css" href="<?= url::file("modules/gallery/css/upgrader.css") ?>" + media="screen,print,projection" /> + <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script> </head> - <style> - body { - background: #eee; - font-family: Trebuchet MS; - font-size: 1.1em; - } - h1 { - font-size: 1.4em; - } - div#outer { - width: 650px; - background: white; - border: 1px solid #999; - margin: 0 auto; - padding: -10px; - } - div#inner { - padding: 0 1em 0 1em; - margin: 0px; - } - div#footer { - border-top: 1px solid #ccc; - margin: 1em; - } - td.name { - text-align: left; - padding-left: 30px; - } - td { - text-align: center; - border-bottom: 1px solid #eee; - } - tr.current td { - color: #999; - font-style: italic; - } - tr.current td.gallery { - color: #00d; - } - tr.upgradeable td { - font-weight: bold; - } - tr.upgradeable td.gallery { - color: #00d; - } - table { - width: 600px; - margin-bottom: 10px; - } - p { - font-size: .9em; - } - ul { - font-size: .9em; - list-style: none; - } - li { - display: inline; - } - li:before { - content: "\00BB \0020"; - } - div.button { - margin: 0 auto; - width: 120px; - text-align: center; - border: 1px solid #999; - background: #eee; - } - div.button a { - text-decoration: none; - } - div.button:hover { - background: #ccc; - } - div#confirmation { - position: fixed; - top: 400px; - left: 325px; - background: blue; - z-index: 1000; - margin: 10px; - text-align: center; - } - div#confirmation div { - margin: 2px; - padding: 20px; - border: 2px solid #999; - background: white; - } - .gray_on_done { - opacity: <?= $done ? "0.5" : "1" ?>; - } - pre { - display: inline; - margin: 0px; - padding: 0px; - } - </style> <body> <div id="outer"> <img src="<?= url::file("modules/gallery/images/gallery.png") ?>" /> @@ -117,6 +21,12 @@ </p> </div> </div> + <script type="text/javascript"> + $(document).ready(function() { + $("#confirmation").css("left", Math.round(($(window).width() - $("#confirmation").width()) / 2)); + $("#confirmation").css("top", Math.round(($(window).height() - $("#confirmation").height()) / 2)); + }); + </script> <? endif ?> <p class="gray_on_done"> <?= t("Welcome to the Gallery upgrader. One click and you're done!") ?> |