Index: trunk/extensions/uniwiki/MooTools12core/MooTools12core.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:MooTools_1.2_Core |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined('MEDIAWIKI')) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +$wgExtensionCredits['other'][] = array( |
| 12 | + 'name' => "MooTools12core", |
| 13 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 14 | + 'description' => "Adds mootools-1.2-core-yc.js to each page" |
| 15 | +); |
| 16 | + |
| 17 | + |
| 18 | +$wgHooks['BeforePageDisplay'][] = "UW_MooTools12core_addJS"; |
| 19 | +function UW_MooTools12core_addJS($out) { |
| 20 | + global $wgScriptPath; |
| 21 | + $src = "$wgScriptPath/extensions/uniwiki/MooTools12core/mootools-1.2-core-yc.js"; |
| 22 | + $out->addScript("<script type='text/javascript' src='$src'></script>"); |
| 23 | + return true; |
| 24 | +} |
| 25 | + |
Index: trunk/extensions/uniwiki/MooTools12core/mootools-1.2-core-yc.js |
— | — | @@ -0,0 +1,341 @@ |
| 2 | +//MooTools, <http://mootools.net>, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, <http://mad4milk.net>, MIT Style License. |
| 3 | + |
| 4 | +var MooTools={version:"1.2.0",build:""};var Native=function(J){J=J||{};var F=J.afterImplement||function(){};var G=J.generics;G=(G!==false);var H=J.legacy; |
| 5 | +var E=J.initialize;var B=J.protect;var A=J.name;var C=E||H;C.constructor=Native;C.$family={name:"native"};if(H&&E){C.prototype=H.prototype;}C.prototype.constructor=C; |
| 6 | +if(A){var D=A.toLowerCase();C.prototype.$family={name:D};Native.typize(C,D);}var I=function(M,K,N,L){if(!B||L||!M.prototype[K]){M.prototype[K]=N;}if(G){Native.genericize(M,K,B); |
| 7 | +}F.call(M,K,N);return M;};C.implement=function(L,K,N){if(typeof L=="string"){return I(this,L,K,N);}for(var M in L){I(this,M,L[M],K);}return this;};C.alias=function(M,K,N){if(typeof M=="string"){M=this.prototype[M]; |
| 8 | +if(M){I(this,K,M,N);}}else{for(var L in M){this.alias(L,M[L],K);}}return this;};return C;};Native.implement=function(D,C){for(var B=0,A=D.length;B<A;B++){D[B].implement(C); |
| 9 | +}};Native.genericize=function(B,C,A){if((!A||!B[C])&&typeof B.prototype[C]=="function"){B[C]=function(){var D=Array.prototype.slice.call(arguments);return B.prototype[C].apply(D.shift(),D); |
| 10 | +};}};Native.typize=function(A,B){if(!A.type){A.type=function(C){return($type(C)===B);};}};Native.alias=function(E,B,A,F){for(var D=0,C=E.length;D<C;D++){E[D].alias(B,A,F); |
| 11 | +}};(function(B){for(var A in B){Native.typize(B[A],A);}})({"boolean":Boolean,"native":Native,object:Object});(function(B){for(var A in B){new Native({name:A,initialize:B[A],protect:true}); |
| 12 | +}})({String:String,Function:Function,Number:Number,Array:Array,RegExp:RegExp,Date:Date});(function(B,A){for(var C=A.length;C--;C){Native.genericize(B,A[C],true); |
| 13 | +}return arguments.callee;})(Array,["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","toString","valueOf","indexOf","lastIndexOf"])(String,["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase","valueOf"]); |
| 14 | +function $chk(A){return !!(A||A===0);}function $clear(A){clearTimeout(A);clearInterval(A);return null;}function $defined(A){return(A!=undefined);}function $empty(){}function $arguments(A){return function(){return arguments[A]; |
| 15 | +};}function $lambda(A){return(typeof A=="function")?A:function(){return A;};}function $extend(C,A){for(var B in (A||{})){C[B]=A[B];}return C;}function $unlink(C){var B; |
| 16 | +switch($type(C)){case"object":B={};for(var E in C){B[E]=$unlink(C[E]);}break;case"hash":B=$unlink(C.getClean());break;case"array":B=[];for(var D=0,A=C.length; |
| 17 | +D<A;D++){B[D]=$unlink(C[D]);}break;default:return C;}return B;}function $merge(){var E={};for(var D=0,A=arguments.length;D<A;D++){var B=arguments[D];if($type(B)!="object"){continue; |
| 18 | +}for(var C in B){var G=B[C],F=E[C];E[C]=(F&&$type(G)=="object"&&$type(F)=="object")?$merge(F,G):$unlink(G);}}return E;}function $pick(){for(var B=0,A=arguments.length; |
| 19 | +B<A;B++){if(arguments[B]!=undefined){return arguments[B];}}return null;}function $random(B,A){return Math.floor(Math.random()*(A-B+1)+B);}function $splat(B){var A=$type(B); |
| 20 | +return(A)?((A!="array"&&A!="arguments")?[B]:B):[];}var $time=Date.now||function(){return new Date().getTime();};function $try(){for(var B=0,A=arguments.length; |
| 21 | +B<A;B++){try{return arguments[B]();}catch(C){}}return null;}function $type(A){if(A==undefined){return false;}if(A.$family){return(A.$family.name=="number"&&!isFinite(A))?false:A.$family.name; |
| 22 | +}if(A.nodeName){switch(A.nodeType){case 1:return"element";case 3:return(/\S/).test(A.nodeValue)?"textnode":"whitespace";}}else{if(typeof A.length=="number"){if(A.callee){return"arguments"; |
| 23 | +}else{if(A.item){return"collection";}}}}return typeof A;}var Hash=new Native({name:"Hash",initialize:function(A){if($type(A)=="hash"){A=$unlink(A.getClean()); |
| 24 | +}for(var B in A){this[B]=A[B];}return this;}});Hash.implement({getLength:function(){var B=0;for(var A in this){if(this.hasOwnProperty(A)){B++;}}return B; |
| 25 | +},forEach:function(B,C){for(var A in this){if(this.hasOwnProperty(A)){B.call(C,this[A],A,this);}}},getClean:function(){var B={};for(var A in this){if(this.hasOwnProperty(A)){B[A]=this[A]; |
| 26 | +}}return B;}});Hash.alias("forEach","each");function $H(A){return new Hash(A);}Array.implement({forEach:function(C,D){for(var B=0,A=this.length;B<A;B++){C.call(D,this[B],B,this); |
| 27 | +}}});Array.alias("forEach","each");function $A(C){if(C.item){var D=[];for(var B=0,A=C.length;B<A;B++){D[B]=C[B];}return D;}return Array.prototype.slice.call(C); |
| 28 | +}function $each(C,B,D){var A=$type(C);((A=="arguments"||A=="collection"||A=="array")?Array:Hash).each(C,B,D);}var Browser=new Hash({Engine:{name:"unknown",version:""},Platform:{name:(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase()},Features:{xpath:!!(document.evaluate),air:!!(window.runtime)},Plugins:{}}); |
| 29 | +if(window.opera){Browser.Engine={name:"presto",version:(document.getElementsByClassName)?950:925};}else{if(window.ActiveXObject){Browser.Engine={name:"trident",version:(window.XMLHttpRequest)?5:4}; |
| 30 | +}else{if(!navigator.taintEnabled){Browser.Engine={name:"webkit",version:(Browser.Features.xpath)?420:419};}else{if(document.getBoxObjectFor!=null){Browser.Engine={name:"gecko",version:(document.getElementsByClassName)?19:18}; |
| 31 | +}}}}Browser.Engine[Browser.Engine.name]=Browser.Engine[Browser.Engine.name+Browser.Engine.version]=true;if(window.orientation!=undefined){Browser.Platform.name="ipod"; |
| 32 | +}Browser.Platform[Browser.Platform.name]=true;Browser.Request=function(){return $try(function(){return new XMLHttpRequest();},function(){return new ActiveXObject("MSXML2.XMLHTTP"); |
| 33 | +});};Browser.Features.xhr=!!(Browser.Request());Browser.Plugins.Flash=(function(){var A=($try(function(){return navigator.plugins["Shockwave Flash"].description; |
| 34 | +},function(){return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version");})||"0 r0").match(/\d+/g);return{version:parseInt(A[0]||0+"."+A[1]||0),build:parseInt(A[2]||0)}; |
| 35 | +})();function $exec(B){if(!B){return B;}if(window.execScript){window.execScript(B);}else{var A=document.createElement("script");A.setAttribute("type","text/javascript"); |
| 36 | +A.text=B;document.head.appendChild(A);document.head.removeChild(A);}return B;}Native.UID=1;var $uid=(Browser.Engine.trident)?function(A){return(A.uid||(A.uid=[Native.UID++]))[0]; |
| 37 | +}:function(A){return A.uid||(A.uid=Native.UID++);};var Window=new Native({name:"Window",legacy:(Browser.Engine.trident)?null:window.Window,initialize:function(A){$uid(A); |
| 38 | +if(!A.Element){A.Element=$empty;if(Browser.Engine.webkit){A.document.createElement("iframe");}A.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{}; |
| 39 | +}return $extend(A,Window.Prototype);},afterImplement:function(B,A){window[B]=Window.Prototype[B]=A;}});Window.Prototype={$family:{name:"window"}};new Window(window); |
| 40 | +var Document=new Native({name:"Document",legacy:(Browser.Engine.trident)?null:window.Document,initialize:function(A){$uid(A);A.head=A.getElementsByTagName("head")[0]; |
| 41 | +A.html=A.getElementsByTagName("html")[0];A.window=A.defaultView||A.parentWindow;if(Browser.Engine.trident4){$try(function(){A.execCommand("BackgroundImageCache",false,true); |
| 42 | +});}return $extend(A,Document.Prototype);},afterImplement:function(B,A){document[B]=Document.Prototype[B]=A;}});Document.Prototype={$family:{name:"document"}}; |
| 43 | +new Document(document);Array.implement({every:function(C,D){for(var B=0,A=this.length;B<A;B++){if(!C.call(D,this[B],B,this)){return false;}}return true; |
| 44 | +},filter:function(D,E){var C=[];for(var B=0,A=this.length;B<A;B++){if(D.call(E,this[B],B,this)){C.push(this[B]);}}return C;},clean:function(){return this.filter($defined); |
| 45 | +},indexOf:function(C,D){var A=this.length;for(var B=(D<0)?Math.max(0,A+D):D||0;B<A;B++){if(this[B]===C){return B;}}return -1;},map:function(D,E){var C=[]; |
| 46 | +for(var B=0,A=this.length;B<A;B++){C[B]=D.call(E,this[B],B,this);}return C;},some:function(C,D){for(var B=0,A=this.length;B<A;B++){if(C.call(D,this[B],B,this)){return true; |
| 47 | +}}return false;},associate:function(C){var D={},B=Math.min(this.length,C.length);for(var A=0;A<B;A++){D[C[A]]=this[A];}return D;},link:function(C){var A={}; |
| 48 | +for(var E=0,B=this.length;E<B;E++){for(var D in C){if(C[D](this[E])){A[D]=this[E];delete C[D];break;}}}return A;},contains:function(A,B){return this.indexOf(A,B)!=-1; |
| 49 | +},extend:function(C){for(var B=0,A=C.length;B<A;B++){this.push(C[B]);}return this;},getLast:function(){return(this.length)?this[this.length-1]:null;},getRandom:function(){return(this.length)?this[$random(0,this.length-1)]:null; |
| 50 | +},include:function(A){if(!this.contains(A)){this.push(A);}return this;},combine:function(C){for(var B=0,A=C.length;B<A;B++){this.include(C[B]);}return this; |
| 51 | +},erase:function(B){for(var A=this.length;A--;A){if(this[A]===B){this.splice(A,1);}}return this;},empty:function(){this.length=0;return this;},flatten:function(){var D=[]; |
| 52 | +for(var B=0,A=this.length;B<A;B++){var C=$type(this[B]);if(!C){continue;}D=D.concat((C=="array"||C=="collection"||C=="arguments")?Array.flatten(this[B]):this[B]); |
| 53 | +}return D;},hexToRgb:function(B){if(this.length!=3){return null;}var A=this.map(function(C){if(C.length==1){C+=C;}return C.toInt(16);});return(B)?A:"rgb("+A+")"; |
| 54 | +},rgbToHex:function(D){if(this.length<3){return null;}if(this.length==4&&this[3]==0&&!D){return"transparent";}var B=[];for(var A=0;A<3;A++){var C=(this[A]-0).toString(16); |
| 55 | +B.push((C.length==1)?"0"+C:C);}return(D)?B:"#"+B.join("");}});Function.implement({extend:function(A){for(var B in A){this[B]=A[B];}return this;},create:function(B){var A=this; |
| 56 | +B=B||{};return function(D){var C=B.arguments;C=(C!=undefined)?$splat(C):Array.slice(arguments,(B.event)?1:0);if(B.event){C=[D||window.event].extend(C); |
| 57 | +}var E=function(){return A.apply(B.bind||null,C);};if(B.delay){return setTimeout(E,B.delay);}if(B.periodical){return setInterval(E,B.periodical);}if(B.attempt){return $try(E); |
| 58 | +}return E();};},pass:function(A,B){return this.create({arguments:A,bind:B});},attempt:function(A,B){return this.create({arguments:A,bind:B,attempt:true})(); |
| 59 | +},bind:function(B,A){return this.create({bind:B,arguments:A});},bindWithEvent:function(B,A){return this.create({bind:B,event:true,arguments:A});},delay:function(B,C,A){return this.create({delay:B,bind:C,arguments:A})(); |
| 60 | +},periodical:function(A,C,B){return this.create({periodical:A,bind:C,arguments:B})();},run:function(A,B){return this.apply(B,$splat(A));}});Number.implement({limit:function(B,A){return Math.min(A,Math.max(B,this)); |
| 61 | +},round:function(A){A=Math.pow(10,A||0);return Math.round(this*A)/A;},times:function(B,C){for(var A=0;A<this;A++){B.call(C,A,this);}},toFloat:function(){return parseFloat(this); |
| 62 | +},toInt:function(A){return parseInt(this,A||10);}});Number.alias("times","each");(function(B){var A={};B.each(function(C){if(!Number[C]){A[C]=function(){return Math[C].apply(null,[this].concat($A(arguments))); |
| 63 | +};}});Number.implement(A);})(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);String.implement({test:function(A,B){return((typeof A=="string")?new RegExp(A,B):A).test(this); |
| 64 | +},contains:function(A,B){return(B)?(B+this+B).indexOf(B+A+B)>-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim(); |
| 65 | +},camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase()); |
| 66 | +});},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1"); |
| 67 | +},toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); |
| 68 | +return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A=""; |
| 69 | +var C=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){A+=arguments[1]+"\n";return"";});if(B===true){$exec(A);}else{if($type(B)=="function"){B(A,C); |
| 70 | +}}return C;},substitute:function(A,B){return this.replace(B||(/\\?\{([^}]+)\}/g),function(D,C){if(D.charAt(0)=="\\"){return D.slice(1);}return(A[C]!=undefined)?A[C]:""; |
| 71 | +});}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(B){for(var A in this){if(this.hasOwnProperty(A)&&this[A]===B){return A;}}return null; |
| 72 | +},hasValue:function(A){return(Hash.keyOf(this,A)!==null);},extend:function(A){Hash.each(A,function(C,B){Hash.set(this,B,C);},this);return this;},combine:function(A){Hash.each(A,function(C,B){Hash.include(this,B,C); |
| 73 | +},this);return this;},erase:function(A){if(this.hasOwnProperty(A)){delete this[A];}return this;},get:function(A){return(this.hasOwnProperty(A))?this[A]:null; |
| 74 | +},set:function(A,B){if(!this[A]||this.hasOwnProperty(A)){this[A]=B;}return this;},empty:function(){Hash.each(this,function(B,A){delete this[A];},this); |
| 75 | +return this;},include:function(B,C){var A=this[B];if(A==undefined){this[B]=C;}return this;},map:function(B,C){var A=new Hash;Hash.each(this,function(E,D){A.set(D,B.call(C,E,D,this)); |
| 76 | +},this);return A;},filter:function(B,C){var A=new Hash;Hash.each(this,function(E,D){if(B.call(C,E,D,this)){A.set(D,E);}},this);return A;},every:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&!B.call(C,this[A],A)){return false; |
| 77 | +}}return true;},some:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&B.call(C,this[A],A)){return true;}}return false;},getKeys:function(){var A=[]; |
| 78 | +Hash.each(this,function(C,B){A.push(B);});return A;},getValues:function(){var A=[];Hash.each(this,function(B){A.push(B);});return A;},toQueryString:function(A){var B=[]; |
| 79 | +Hash.each(this,function(F,E){if(A){E=A+"["+E+"]";}var D;switch($type(F)){case"object":D=Hash.toQueryString(F,E);break;case"array":var C={};F.each(function(H,G){C[G]=H; |
| 80 | +});D=Hash.toQueryString(C,E);break;default:D=E+"="+encodeURIComponent(F);}if(F!=undefined){B.push(D);}});return B.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"}); |
| 81 | +var Event=new Native({name:"Event",initialize:function(A,F){F=F||window;var K=F.document;A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type; |
| 82 | +var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.test(/key/)){var B=A.which||A.keyCode;var M=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111; |
| 83 | +if(D>0&&D<13){M="f"+D;}}M=M||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){K=(!K.compatMode||K.compatMode=="CSS1Compat")?K.html:K.body; |
| 84 | +var I={x:A.pageX||A.clientX+K.scrollLeft,y:A.pageY||A.clientY+K.scrollTop};var C={x:(A.pageX)?A.pageX-F.pageXOffset:A.clientX,y:(A.pageY)?A.pageY-F.pageYOffset:A.clientY}; |
| 85 | +if(J.match(/DOMMouseScroll|mousewheel/)){var H=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}var E=(A.which==3)||(A.button==2);var L=null;if(J.match(/over|out/)){switch(J){case"mouseover":L=A.relatedTarget||A.fromElement; |
| 86 | +break;case"mouseout":L=A.relatedTarget||A.toElement;}if(!(function(){while(L&&L.nodeType==3){L=L.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){L=false; |
| 87 | +}}}}return $extend(this,{event:A,type:J,page:I,client:C,rightClick:E,wheel:H,relatedTarget:L,target:G,code:B,key:M,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey}); |
| 88 | +}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); |
| 89 | +},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); |
| 90 | +}else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(E){for(var D in this){this[D]=$unlink(this[D]); |
| 91 | +}for(var F in Class.Mutators){if(!this[F]){continue;}Class.Mutators[F](this,this[F]);delete this[F];}this.constructor=A;if(E===$empty){return this;}var C=(this.initialize)?this.initialize.apply(this,arguments):this; |
| 92 | +if(this.options&&this.options.initialize){this.options.initialize.call(this);}return C;};$extend(A,this);A.constructor=Class;A.prototype=B;return A;}}); |
| 93 | +Class.implement({implement:function(){Class.Mutators.Implements(this.prototype,Array.slice(arguments));return this;}});Class.Mutators={Implements:function(A,B){$splat(B).each(function(C){$extend(A,($type(C)=="class")?new C($empty):C); |
| 94 | +});},Extends:function(self,klass){var instance=new klass($empty);delete instance.parent;delete instance.parentOf;for(var key in instance){var current=self[key],previous=instance[key]; |
| 95 | +if(current==undefined){self[key]=previous;continue;}var ctype=$type(current),ptype=$type(previous);if(ctype!=ptype){continue;}switch(ctype){case"function":if(!arguments.callee.caller){self[key]=eval("("+String(current).replace(/\bthis\.parent\(\s*(\))?/g,function(full,close){return"arguments.callee._parent_.call(this"+(close||", "); |
| 96 | +})+")");}self[key]._parent_=previous;break;case"object":self[key]=$merge(previous,current);}}self.parent=function(){return arguments.callee.caller._parent_.apply(this,arguments); |
| 97 | +};self.parentOf=function(descendant){return descendant._parent_.apply(this,Array.slice(arguments,1));};}};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments); |
| 98 | +return this;},callChain:function(){return(this.$chain&&this.$chain.length)?this.$chain.shift().apply(this,arguments):false;},clearChain:function(){if(this.$chain){this.$chain.empty(); |
| 99 | +}return this;}});var Events=new Class({addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){this.$events=this.$events||{};this.$events[C]=this.$events[C]||[]; |
| 100 | +this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){C=Events.removeOn(C); |
| 101 | +if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,"arguments":B})();},this);return this;},removeEvent:function(B,A){B=Events.removeOn(B); |
| 102 | +if(!this.$events||!this.$events[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){for(var D in this.$events){if(C&&C!=D){continue; |
| 103 | +}var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]);}}return this;}});Events.removeOn=function(A){return A.replace(/^on([A-Z])/,function(B,C){return C.toLowerCase(); |
| 104 | +});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue; |
| 105 | +}this.addEvent(A,this.options[A]);delete this.options[A];}return this;}});Document.implement({newElement:function(A,B){if(Browser.Engine.trident&&B){["name","type","checked"].each(function(C){if(!B[C]){return ; |
| 106 | +}A+=" "+C+'="'+B[C]+'"';if(C!="checked"){delete B[C];}});A="<"+A+">";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A); |
| 107 | +},getDocument:function(){return this;},getWindow:function(){return this.defaultView||this.parentWindow;},purge:function(){var C=this.getElementsByTagName("*"); |
| 108 | +for(var B=0,A=C.length;B<A;B++){Browser.freeMem(C[B]);}}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(A,B){var C=Element.Constructors.get(A); |
| 109 | +if(C){return C(B);}if(typeof A=="string"){return document.newElement(A,B);}return $(A).set(B);},afterImplement:function(A,B){if(!Array[A]){Elements.implement(A,Elements.multi(A)); |
| 110 | +}Element.Prototype[A]=B;}});Element.Prototype={$family:{name:"element"}};Element.Constructors=new Hash;var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){var E=Array.link(arguments,{properties:Object.type,iframe:$defined}); |
| 111 | +var C=E.properties||{};var B=$(E.iframe)||false;var D=C.onload||$empty;delete C.onload;C.id=C.name=$pick(C.id,C.name,B.id,B.name,"IFrame_"+$time());B=new Element(B||"iframe",C); |
| 112 | +var A=function(){var F=$try(function(){return B.contentWindow.location.host;});if(F&&F==window.location.host){var H=new Window(B.contentWindow);var G=new Document(B.contentWindow.document); |
| 113 | +$extend(H.Element.prototype,Element.Prototype);}D.call(B.contentWindow,B.contentWindow.document);};(!window.frames[C.id])?B.addListener("load",A):A();return B; |
| 114 | +}});var Elements=new Native({initialize:function(F,B){B=$extend({ddup:true,cash:true},B);F=F||[];if(B.ddup||B.cash){var G={},E=[];for(var C=0,A=F.length; |
| 115 | +C<A;C++){var D=$.element(F[C],!B.cash);if(B.ddup){if(G[D.uid]){continue;}G[D.uid]=true;}E.push(D);}F=E;}return(B.cash)?$extend(F,this):F;}});Elements.implement({filter:function(A,B){if(!A){return this; |
| 116 | +}return new Elements(Array.filter(this,(typeof A=="string")?function(C){return C.match(A);}:A,B));}});Elements.multi=function(A){return function(){var B=[]; |
| 117 | +var F=true;for(var D=0,C=this.length;D<C;D++){var E=this[D][A].apply(this[D],arguments);B.push(E);if(F){F=($type(E)=="element");}}return(F)?new Elements(B):B; |
| 118 | +};};Window.implement({$:function(B,C){if(B&&B.$family&&B.uid){return B;}var A=$type(B);return($[A])?$[A](B,C,this.document):null;},$$:function(A){if(arguments.length==1&&typeof A=="string"){return this.document.getElements(A); |
| 119 | +}var F=[];var C=Array.flatten(arguments);for(var D=0,B=C.length;D<B;D++){var E=C[D];switch($type(E)){case"element":E=[E];break;case"string":E=this.document.getElements(E,true); |
| 120 | +break;default:E=false;}if(E){F.extend(E);}}return new Elements(F);},getDocument:function(){return this.document;},getWindow:function(){return this;}}); |
| 121 | +$.string=function(C,B,A){C=A.getElementById(C);return(C)?$.element(C,B):null;};$.element=function(A,D){$uid(A);if(!D&&!A.$family&&!(/^object|embed$/i).test(A.tagName)){var B=Element.Prototype; |
| 122 | +for(var C in B){A[C]=B[C];}}return A;};$.object=function(B,C,A){if(B.toElement){return $.element(B.toElement(A),C);}return null;};$.textnode=$.whitespace=$.window=$.document=$arguments(0); |
| 123 | +Native.implement([Element,Document],{getElement:function(A,B){return $(this.getElements(A,true)[0]||null,B);},getElements:function(A,D){A=A.split(","); |
| 124 | +var C=[];var B=(A.length>1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D}); |
| 125 | +}});Element.Storage={get:function(A){return(this[A]||(this[A]={}));}};Element.Inserters=new Hash({before:function(B,A){if(A.parentNode){A.parentNode.insertBefore(B,A); |
| 126 | +}},after:function(B,A){if(!A.parentNode){return ;}var C=A.nextSibling;(C)?A.parentNode.insertBefore(B,C):A.parentNode.appendChild(B);},bottom:function(B,A){A.appendChild(B); |
| 127 | +},top:function(B,A){var C=A.firstChild;(C)?A.insertBefore(B,C):A.appendChild(B);}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(C,B){var A=B.capitalize(); |
| 128 | +Element.implement("inject"+A,function(D){C(this,$(D,true));return this;});Element.implement("grab"+A,function(D){C($(D,true),this);return this;});});Element.implement({getDocument:function(){return this.ownerDocument; |
| 129 | +},getWindow:function(){return this.ownerDocument.getWindow();},getElementById:function(D,C){var B=this.ownerDocument.getElementById(D);if(!B){return null; |
| 130 | +}for(var A=B.parentNode;A!=this;A=A.parentNode){if(!A){return null;}}return $.element(B,C);},set:function(D,B){switch($type(D)){case"object":for(var C in D){this.set(C,D[C]); |
| 131 | +}break;case"string":var A=Element.Properties.get(D);(A&&A.set)?A.set.apply(this,Array.slice(arguments,1)):this.setProperty(D,B);}return this;},get:function(B){var A=Element.Properties.get(B); |
| 132 | +return(A&&A.get)?A.get.apply(this,Array.slice(arguments,1)):this.getProperty(B);},erase:function(B){var A=Element.Properties.get(B);(A&&A.erase)?A.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(B); |
| 133 | +return this;},match:function(A){return(!A||Element.get(this,"tag")==A);},inject:function(B,A){Element.Inserters.get(A||"bottom")(this,$(B,true));return this; |
| 134 | +},wraps:function(B,A){B=$(B,true);return this.replaces(B).grab(B,A);},grab:function(B,A){Element.Inserters.get(A||"bottom")($(B,true),this);return this; |
| 135 | +},appendText:function(B,A){return this.grab(this.getDocument().newTextNode(B),A);},adopt:function(){Array.flatten(arguments).each(function(A){A=$(A,true); |
| 136 | +if(A){this.appendChild(A);}},this);return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},clone:function(D,C){switch($type(this)){case"element":var H={}; |
| 137 | +for(var G=0,E=this.attributes.length;G<E;G++){var B=this.attributes[G],L=B.nodeName.toLowerCase();if(Browser.Engine.trident&&(/input/i).test(this.tagName)&&(/width|height/).test(L)){continue; |
| 138 | +}var K=(L=="style"&&this.style)?this.style.cssText:B.nodeValue;if(!$chk(K)||L=="uid"||(L=="id"&&!C)){continue;}if(K!="inherit"&&["string","number"].contains($type(K))){H[L]=K; |
| 139 | +}}var J=new Element(this.nodeName.toLowerCase(),H);if(D!==false){for(var I=0,F=this.childNodes.length;I<F;I++){var A=Element.clone(this.childNodes[I],true,C); |
| 140 | +if(A){J.grab(A);}}}return J;case"textnode":return document.newTextNode(this.nodeValue);}return null;},replaces:function(A){A=$(A,true);A.parentNode.replaceChild(this,A); |
| 141 | +return this;},hasClass:function(A){return this.className.contains(A," ");},addClass:function(A){if(!this.hasClass(A)){this.className=(this.className+" "+A).clean(); |
| 142 | +}return this;},removeClass:function(A){this.className=this.className.replace(new RegExp("(^|\\s)"+A+"(?:\\s|$)"),"$1").clean();return this;},toggleClass:function(A){return this.hasClass(A)?this.removeClass(A):this.addClass(A); |
| 143 | +},getComputedStyle:function(B){if(this.currentStyle){return this.currentStyle[B.camelCase()];}var A=this.getWindow().getComputedStyle(this,null);return(A)?A.getPropertyValue([B.hyphenate()]):null; |
| 144 | +},empty:function(){$A(this.childNodes).each(function(A){Browser.freeMem(A);Element.empty(A);Element.dispose(A);},this);return this;},destroy:function(){Browser.freeMem(this.empty().dispose()); |
| 145 | +return null;},getSelected:function(){return new Elements($A(this.options).filter(function(A){return A.selected;}));},toQueryString:function(){var A=[]; |
| 146 | +this.getElements("input, select, textarea").each(function(B){if(!B.name||B.disabled){return ;}var C=(B.tagName.toLowerCase()=="select")?Element.getSelected(B).map(function(D){return D.value; |
| 147 | +}):((B.type=="radio"||B.type=="checkbox")&&!B.checked)?null:B.value;$splat(C).each(function(D){if(D){A.push(B.name+"="+encodeURIComponent(D));}});});return A.join("&"); |
| 148 | +},getProperty:function(C){var B=Element.Attributes,A=B.Props[C];var D=(A)?this[A]:this.getAttribute(C,2);return(B.Bools[C])?!!D:(A)?D:D||null;},getProperties:function(){var A=$A(arguments); |
| 149 | +return A.map(function(B){return this.getProperty(B);},this).associate(A);},setProperty:function(D,E){var C=Element.Attributes,B=C.Props[D],A=$defined(E); |
| 150 | +if(B&&C.Bools[D]){E=(E||!A)?true:false;}else{if(!A){return this.removeProperty(D);}}(B)?this[B]=E:this.setAttribute(D,E);return this;},setProperties:function(A){for(var B in A){this.setProperty(B,A[B]); |
| 151 | +}return this;},removeProperty:function(D){var C=Element.Attributes,B=C.Props[D],A=(B&&C.Bools[D]);(B)?this[B]=(A)?false:"":this.removeAttribute(D);return this; |
| 152 | +},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this;}});(function(){var A=function(D,B,I,C,F,H){var E=D[I||B];var G=[]; |
| 153 | +while(E){if(E.nodeType==1&&(!C||Element.match(E,C))){G.push(E);if(!F){break;}}E=E[B];}return(F)?new Elements(G,{ddup:false,cash:!H}):$(G[0],H);};Element.implement({getPrevious:function(B,C){return A(this,"previousSibling",null,B,false,C); |
| 154 | +},getAllPrevious:function(B,C){return A(this,"previousSibling",null,B,true,C);},getNext:function(B,C){return A(this,"nextSibling",null,B,false,C);},getAllNext:function(B,C){return A(this,"nextSibling",null,B,true,C); |
| 155 | +},getFirst:function(B,C){return A(this,"nextSibling","firstChild",B,false,C);},getLast:function(B,C){return A(this,"previousSibling","lastChild",B,false,C); |
| 156 | +},getParent:function(B,C){return A(this,"parentNode",null,B,false,C);},getParents:function(B,C){return A(this,"parentNode",null,B,true,C);},getChildren:function(B,C){return A(this,"nextSibling","firstChild",B,true,C); |
| 157 | +},hasChild:function(B){B=$(B,true);return(!!B&&$A(this.getElementsByTagName(B.tagName)).contains(B));}});})();Element.Properties=new Hash;Element.Properties.style={set:function(A){this.style.cssText=A; |
| 158 | +},get:function(){return this.style.cssText;},erase:function(){this.style.cssText="";}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase(); |
| 159 | +}};Element.Properties.href={get:function(){return(!this.href)?null:this.href.replace(new RegExp("^"+document.location.protocol+"//"+document.location.host),""); |
| 160 | +}};Element.Properties.html={set:function(){return this.innerHTML=Array.flatten(arguments).join("");}};Native.implement([Element,Window,Document],{addListener:function(B,A){if(this.addEventListener){this.addEventListener(B,A,false); |
| 161 | +}else{this.attachEvent("on"+B,A);}return this;},removeListener:function(B,A){if(this.removeEventListener){this.removeEventListener(B,A,false);}else{this.detachEvent("on"+B,A); |
| 162 | +}return this;},retrieve:function(B,A){var D=Element.Storage.get(this.uid);var C=D[B];if($defined(A)&&!$defined(C)){C=D[B]=A;}return $pick(C);},store:function(B,A){var C=Element.Storage.get(this.uid); |
| 163 | +C[B]=A;return this;},eliminate:function(A){var B=Element.Storage.get(this.uid);delete B[A];return this;}});Element.Attributes=new Hash({Props:{html:"innerHTML","class":"className","for":"htmlFor",text:(Browser.Engine.trident)?"innerText":"textContent"},Bools:["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"],Camels:["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]}); |
| 164 | +Browser.freeMem=function(A){if(!A){return ;}if(Browser.Engine.trident&&(/object/i).test(A.tagName)){for(var B in A){if(typeof A[B]=="function"){A[B]=$empty; |
| 165 | +}}Element.dispose(A);}if(A.uid&&A.removeEvents){A.removeEvents();}};(function(B){var C=B.Bools,A=B.Camels;B.Bools=C=C.associate(C);Hash.extend(Hash.combine(B.Props,C),A.associate(A.map(function(D){return D.toLowerCase(); |
| 166 | +})));B.erase("Camels");})(Element.Attributes);window.addListener("unload",function(){window.removeListener("unload",arguments.callee);document.purge(); |
| 167 | +if(Browser.Engine.trident){CollectGarbage();}});Element.Properties.events={set:function(A){this.addEvents(A);}};Native.implement([Element,Window,Document],{addEvent:function(E,G){var H=this.retrieve("events",{}); |
| 168 | +H[E]=H[E]||{keys:[],values:[]};if(H[E].keys.contains(G)){return this;}H[E].keys.push(G);var F=E,A=Element.Events.get(E),C=G,I=this;if(A){if(A.onAdd){A.onAdd.call(this,G); |
| 169 | +}if(A.condition){C=function(J){if(A.condition.call(this,J)){return G.call(this,J);}return false;};}F=A.base||F;}var D=function(){return G.call(I);};var B=Element.NativeEvents[F]||0; |
| 170 | +if(B){if(B==2){D=function(J){J=new Event(J,I.getWindow());if(C.call(I,J)===false){J.stop();}};}this.addListener(F,D);}H[E].values.push(D);return this;},removeEvent:function(D,C){var B=this.retrieve("events"); |
| 171 | +if(!B||!B[D]){return this;}var G=B[D].keys.indexOf(C);if(G==-1){return this;}var A=B[D].keys.splice(G,1)[0];var F=B[D].values.splice(G,1)[0];var E=Element.Events.get(D); |
| 172 | +if(E){if(E.onRemove){E.onRemove.call(this,C);}D=E.base||D;}return(Element.NativeEvents[D])?this.removeListener(D,F):this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]); |
| 173 | +}return this;},removeEvents:function(B){var A=this.retrieve("events");if(!A){return this;}if(!B){for(var C in A){this.removeEvents(C);}A=null;}else{if(A[B]){while(A[B].keys[0]){this.removeEvent(B,A[B].keys[0]); |
| 174 | +}A[B]=null;}}return this;},fireEvent:function(D,B,A){var C=this.retrieve("events");if(!C||!C[D]){return this;}C[D].keys.each(function(E){E.create({bind:this,delay:A,"arguments":B})(); |
| 175 | +},this);return this;},cloneEvents:function(D,A){D=$(D);var C=D.retrieve("events");if(!C){return this;}if(!A){for(var B in C){this.cloneEvents(D,B);}}else{if(C[A]){C[A].keys.each(function(E){this.addEvent(A,E); |
| 176 | +},this);}}return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1}; |
| 177 | +(function(){var A=function(B){var C=B.relatedTarget;if(C==undefined){return true;}if(C===false){return false;}return($type(this)!="document"&&C!=this&&C.prefix!="xul"&&!this.hasChild(C)); |
| 178 | +};Element.Events=new Hash({mouseenter:{base:"mouseover",condition:A},mouseleave:{base:"mouseout",condition:A},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}}); |
| 179 | +})();Element.Properties.styles={set:function(A){this.setStyles(A);}};Element.Properties.opacity={set:function(A,B){if(!B){if(A==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden"; |
| 180 | +}}else{if(this.style.visibility!="visible"){this.style.visibility="visible";}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(Browser.Engine.trident){this.style.filter=(A==1)?"":"alpha(opacity="+A*100+")"; |
| 181 | +}this.style.opacity=A;this.store("opacity",A);},get:function(){return this.retrieve("opacity",1);}};Element.implement({setOpacity:function(A){return this.set("opacity",A,true); |
| 182 | +},getOpacity:function(){return this.get("opacity");},setStyle:function(B,A){switch(B){case"opacity":return this.set("opacity",parseFloat(A));case"float":B=(Browser.Engine.trident)?"styleFloat":"cssFloat"; |
| 183 | +}B=B.camelCase();if($type(A)!="string"){var C=(Element.Styles.get(B)||"@").split(" ");A=$splat(A).map(function(E,D){if(!C[D]){return"";}return($type(E)=="number")?C[D].replace("@",Math.round(E)):E; |
| 184 | +}).join(" ");}else{if(A==String(Number(A))){A=Math.round(A);}}this.style[B]=A;return this;},getStyle:function(G){switch(G){case"opacity":return this.get("opacity"); |
| 185 | +case"float":G=(Browser.Engine.trident)?"styleFloat":"cssFloat";}G=G.camelCase();var A=this.style[G];if(!$chk(A)){A=[];for(var F in Element.ShortStyles){if(G!=F){continue; |
| 186 | +}for(var E in Element.ShortStyles[F]){A.push(this.getStyle(E));}return A.join(" ");}A=this.getComputedStyle(G);}if(A){A=String(A);var C=A.match(/rgba?\([\d\s,]+\)/); |
| 187 | +if(C){A=A.replace(C[0],C[0].rgbToHex());}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(A)))){if(G.test(/^(height|width)$/)){var B=(G=="width")?["left","right"]:["top","bottom"],D=0; |
| 188 | +B.each(function(H){D+=this.getStyle("border-"+H+"-width").toInt()+this.getStyle("padding-"+H).toInt();},this);return this["offset"+G.capitalize()]-D+"px"; |
| 189 | +}if(Browser.Engine.presto&&String(A).test("px")){return A;}if(G.test(/(border(.+)Width|margin|padding)/)){return"0px";}}return A;},setStyles:function(B){for(var A in B){this.setStyle(A,B[A]); |
| 190 | +}return this;},getStyles:function(){var A={};Array.each(arguments,function(B){A[B]=this.getStyle(B);},this);return A;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"}); |
| 191 | +Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(G){var F=Element.ShortStyles; |
| 192 | +var B=Element.Styles;["margin","padding"].each(function(H){var I=H+G;F[H][I]=B[I]="@px";});var E="border"+G;F.border[E]=B[E]="@px @ rgb(@, @, @)";var D=E+"Width",A=E+"Style",C=E+"Color"; |
| 193 | +F[E]={};F.borderWidth[D]=F[E][D]=B[D]="@px";F.borderStyle[A]=F[E][A]=B[A]="@";F.borderColor[C]=F[E][C]=B[C]="rgb(@, @, @)";});(function(){Element.implement({scrollTo:function(H,I){if(B(this)){this.getWindow().scrollTo(H,I); |
| 194 | +}else{this.scrollLeft=H;this.scrollTop=I;}return this;},getSize:function(){if(B(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight}; |
| 195 | +},getScrollSize:function(){if(B(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(B(this)){return this.getWindow().getScroll(); |
| 196 | +}return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var I=this,H={x:0,y:0};while(I&&!B(I)){H.x+=I.scrollLeft;H.y+=I.scrollTop;I=I.parentNode; |
| 197 | +}return H;},getOffsetParent:function(){var H=this;if(B(H)){return null;}if(!Browser.Engine.trident){return H.offsetParent;}while((H=H.parentNode)&&!B(H)){if(D(H,"position")!="static"){return H; |
| 198 | +}}return null;},getOffsets:function(){var I=this,H={x:0,y:0};if(B(this)){return H;}while(I&&!B(I)){H.x+=I.offsetLeft;H.y+=I.offsetTop;if(Browser.Engine.gecko){if(!F(I)){H.x+=C(I); |
| 199 | +H.y+=G(I);}var J=I.parentNode;if(J&&D(J,"overflow")!="visible"){H.x+=C(J);H.y+=G(J);}}else{if(I!=this&&(Browser.Engine.trident||Browser.Engine.webkit)){H.x+=C(I); |
| 200 | +H.y+=G(I);}}I=I.offsetParent;if(Browser.Engine.trident){while(I&&!I.currentStyle.hasLayout){I=I.offsetParent;}}}if(Browser.Engine.gecko&&!F(this)){H.x-=C(this); |
| 201 | +H.y-=G(this);}return H;},getPosition:function(K){if(B(this)){return{x:0,y:0};}var L=this.getOffsets(),I=this.getScrolls();var H={x:L.x-I.x,y:L.y-I.y};var J=(K&&(K=$(K)))?K.getPosition():{x:0,y:0}; |
| 202 | +return{x:H.x-J.x,y:H.y-J.y};},getCoordinates:function(J){if(B(this)){return this.getWindow().getCoordinates();}var H=this.getPosition(J),I=this.getSize(); |
| 203 | +var K={left:H.x,top:H.y,width:I.x,height:I.y};K.right=K.left+K.width;K.bottom=K.top+K.height;return K;},computePosition:function(H){return{left:H.x-E(this,"margin-left"),top:H.y-E(this,"margin-top")}; |
| 204 | +},position:function(H){return this.setStyles(this.computePosition(H));}});Native.implement([Document,Window],{getSize:function(){var I=this.getWindow(); |
| 205 | +if(Browser.Engine.presto||Browser.Engine.webkit){return{x:I.innerWidth,y:I.innerHeight};}var H=A(this);return{x:H.clientWidth,y:H.clientHeight};},getScroll:function(){var I=this.getWindow(); |
| 206 | +var H=A(this);return{x:I.pageXOffset||H.scrollLeft,y:I.pageYOffset||H.scrollTop};},getScrollSize:function(){var I=A(this);var H=this.getSize();return{x:Math.max(I.scrollWidth,H.x),y:Math.max(I.scrollHeight,H.y)}; |
| 207 | +},getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var H=this.getSize();return{top:0,left:0,bottom:H.y,right:H.x,height:H.y,width:H.x}; |
| 208 | +}});var D=Element.getComputedStyle;function E(H,I){return D(H,I).toInt()||0;}function F(H){return D(H,"-moz-box-sizing")=="border-box";}function G(H){return E(H,"border-top-width"); |
| 209 | +}function C(H){return E(H,"border-left-width");}function B(H){return(/^(?:body|html)$/i).test(H.tagName);}function A(H){var I=H.getDocument();return(!I.compatMode||I.compatMode=="CSS1Compat")?I.html:I.body; |
| 210 | +}})();Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y; |
| 211 | +},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x; |
| 212 | +},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Document,Element],{getElements:function(H,G){H=H.split(","); |
| 213 | +var C,E={};for(var D=0,B=H.length;D<B;D++){var A=H[D],F=Selectors.Utils.search(this,A,E);if(D!=0&&F.item){F=$A(F);}C=(D==0)?F:(C.item)?$A(C).concat(F):C.concat(F); |
| 214 | +}return new Elements(C,{ddup:(H.length>1),cash:!G});}});Element.implement({match:function(B){if(!B){return true;}var D=Selectors.Utils.parseTagAndID(B); |
| 215 | +var A=D[0],E=D[1];if(!Selectors.Filters.byID(this,E)||!Selectors.Filters.byTag(this,A)){return false;}var C=Selectors.Utils.parseSelector(B);return(C)?Selectors.Utils.filter(this,C,{}):true; |
| 216 | +}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)["']?(.*?)["']?)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)}; |
| 217 | +Selectors.Utils={chk:function(B,C){if(!C){return true;}var A=$uid(B);if(!C[A]){return C[A]=true;}return false;},parseNthArgument:function(F){if(Selectors.Cache.nth[F]){return Selectors.Cache.nth[F]; |
| 218 | +}var C=F.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!C){return false;}var E=parseInt(C[1]);var B=(E||E===0)?E:1;var D=C[2]||false;var A=parseInt(C[3])||0; |
| 219 | +if(B!=0){A--;while(A<1){A+=B;}while(A>=B){A-=B;}}else{B=A;D="index";}switch(D){case"n":C={a:B,b:A,special:"n"};break;case"odd":C={a:2,b:0,special:"n"}; |
| 220 | +break;case"even":C={a:2,b:1,special:"n"};break;case"first":C={a:0,special:"index"};break;case"last":C={special:"last-child"};break;case"only":C={special:"only-child"}; |
| 221 | +break;default:C={a:(B-1),special:"index"};}return Selectors.Cache.nth[F]=C;},parseSelector:function(E){if(Selectors.Cache.parsed[E]){return Selectors.Cache.parsed[E]; |
| 222 | +}var D,H={classes:[],pseudos:[],attributes:[]};while((D=Selectors.RegExps.combined.exec(E))){var I=D[1],G=D[2],F=D[3],B=D[4],C=D[5],J=D[6];if(I){H.classes.push(I); |
| 223 | +}else{if(C){var A=Selectors.Pseudo.get(C);if(A){H.pseudos.push({parser:A,argument:J});}else{H.attributes.push({name:C,operator:"=",value:J});}}else{if(G){H.attributes.push({name:G,operator:F,value:B}); |
| 224 | +}}}}if(!H.classes.length){delete H.classes;}if(!H.attributes.length){delete H.attributes;}if(!H.pseudos.length){delete H.pseudos;}if(!H.classes&&!H.attributes&&!H.pseudos){H=null; |
| 225 | +}return Selectors.Cache.parsed[E]=H;},parseTagAndID:function(B){var A=B.match(Selectors.RegExps.tag);var C=B.match(Selectors.RegExps.id);return[(A)?A[1]:"*",(C)?C[1]:false]; |
| 226 | +},filter:function(F,C,E){var D;if(C.classes){for(D=C.classes.length;D--;D){var G=C.classes[D];if(!Selectors.Filters.byClass(F,G)){return false;}}}if(C.attributes){for(D=C.attributes.length; |
| 227 | +D--;D){var B=C.attributes[D];if(!Selectors.Filters.byAttribute(F,B.name,B.operator,B.value)){return false;}}}if(C.pseudos){for(D=C.pseudos.length;D--;D){var A=C.pseudos[D]; |
| 228 | +if(!Selectors.Filters.byPseudo(F,A.parser,A.argument,E)){return false;}}}return true;},getByTagAndID:function(B,A,D){if(D){var C=(B.getElementById)?B.getElementById(D,true):Element.getElementById(B,D,true); |
| 229 | +return(C&&Selectors.Filters.byTag(C,A))?[C]:[];}else{return B.getElementsByTagName(A);}},search:function(J,I,O){var B=[];var C=I.trim().replace(Selectors.RegExps.splitter,function(Z,Y,X){B.push(Y); |
| 230 | +return":)"+X;}).split(":)");var K,F,E,V;for(var U=0,Q=C.length;U<Q;U++){var T=C[U];if(U==0&&Selectors.RegExps.quick.test(T)){K=J.getElementsByTagName(T); |
| 231 | +continue;}var A=B[U-1];var L=Selectors.Utils.parseTagAndID(T);var W=L[0],M=L[1];if(U==0){K=Selectors.Utils.getByTagAndID(J,W,M);}else{var D={},H=[];for(var S=0,R=K.length; |
| 232 | +S<R;S++){H=Selectors.Getters[A](H,K[S],W,M,D);}K=H;}var G=Selectors.Utils.parseSelector(T);if(G){E=[];for(var P=0,N=K.length;P<N;P++){V=K[P];if(Selectors.Utils.filter(V,G,O)){E.push(V); |
| 233 | +}}K=E;}}return K;}};Selectors.Getters={" ":function(H,G,I,A,E){var D=Selectors.Utils.getByTagAndID(G,I,A);for(var C=0,B=D.length;C<B;C++){var F=D[C];if(Selectors.Utils.chk(F,E)){H.push(F); |
| 234 | +}}return H;},">":function(H,G,I,A,F){var C=Selectors.Utils.getByTagAndID(G,I,A);for(var E=0,D=C.length;E<D;E++){var B=C[E];if(B.parentNode==G&&Selectors.Utils.chk(B,F)){H.push(B); |
| 235 | +}}return H;},"+":function(C,B,A,E,D){while((B=B.nextSibling)){if(B.nodeType==1){if(Selectors.Utils.chk(B,D)&&Selectors.Filters.byTag(B,A)&&Selectors.Filters.byID(B,E)){C.push(B); |
| 236 | +}break;}}return C;},"~":function(C,B,A,E,D){while((B=B.nextSibling)){if(B.nodeType==1){if(!Selectors.Utils.chk(B,D)){break;}if(Selectors.Filters.byTag(B,A)&&Selectors.Filters.byID(B,E)){C.push(B); |
| 237 | +}}}return C;}};Selectors.Filters={byTag:function(B,A){return(A=="*"||(B.tagName&&B.tagName.toLowerCase()==A));},byID:function(A,B){return(!B||(A.id&&A.id==B)); |
| 238 | +},byClass:function(B,A){return(B.className&&B.className.contains(A," "));},byPseudo:function(A,D,C,B){return D.call(A,C,B);},byAttribute:function(C,D,B,E){var A=Element.prototype.getProperty.call(C,D); |
| 239 | +if(!A){return false;}if(!B||E==undefined){return true;}switch(B){case"=":return(A==E);case"*=":return(A.contains(E));case"^=":return(A.substr(0,E.length)==E); |
| 240 | +case"$=":return(A.substr(A.length-E.length)==E);case"!=":return(A!=E);case"~=":return A.contains(E," ");case"|=":return A.contains(E,"-");}return false; |
| 241 | +}};Selectors.Pseudo=new Hash({empty:function(){return !(this.innerText||this.textContent||"").length;},not:function(A){return !Element.match(this,A);},contains:function(A){return(this.innerText||this.textContent||"").contains(A); |
| 242 | +},"first-child":function(){return Selectors.Pseudo.index.call(this,0);},"last-child":function(){var A=this;while((A=A.nextSibling)){if(A.nodeType==1){return false; |
| 243 | +}}return true;},"only-child":function(){var B=this;while((B=B.previousSibling)){if(B.nodeType==1){return false;}}var A=this;while((A=A.nextSibling)){if(A.nodeType==1){return false; |
| 244 | +}}return true;},"nth-child":function(G,E){G=(G==undefined)?"n":G;var C=Selectors.Utils.parseNthArgument(G);if(C.special!="n"){return Selectors.Pseudo[C.special].call(this,C.a,E); |
| 245 | +}var F=0;E.positions=E.positions||{};var D=$uid(this);if(!E.positions[D]){var B=this;while((B=B.previousSibling)){if(B.nodeType!=1){continue;}F++;var A=E.positions[$uid(B)]; |
| 246 | +if(A!=undefined){F=A+F;break;}}E.positions[D]=F;}return(E.positions[D]%C.a==C.b);},index:function(A){var B=this,C=0;while((B=B.previousSibling)){if(B.nodeType==1&&++C>A){return false; |
| 247 | +}}return(C==A);},even:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n+1",A);},odd:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n",A); |
| 248 | +}});Element.Events.domready={onAdd:function(A){if(Browser.loaded){A.call(this);}}};(function(){var B=function(){if(Browser.loaded){return ;}Browser.loaded=true; |
| 249 | +window.fireEvent("domready");document.fireEvent("domready");};switch(Browser.Engine.name){case"webkit":(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50); |
| 250 | +})();break;case"trident":var A=document.createElement("div");(function(){($try(function(){A.doScroll("left");return $(A).inject(document.body).set("html","temp").dispose(); |
| 251 | +}))?B():arguments.callee.delay(50);})();break;default:window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}})();var JSON=new Hash({encode:function(B){switch($type(B)){case"string":return'"'+B.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"'; |
| 252 | +case"array":return"["+String(B.map(JSON.encode).filter($defined))+"]";case"object":case"hash":var A=[];Hash.each(B,function(E,D){var C=JSON.encode(E);if(C){A.push(JSON.encode(D)+":"+C); |
| 253 | +}});return"{"+A+"}";case"number":case"boolean":return String(B);case false:return"null";}return null;},$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},$replaceChars:function(A){return JSON.$specialChars[A]||"\\u00"+Math.floor(A.charCodeAt()/16).toString(16)+(A.charCodeAt()%16).toString(16); |
| 254 | +},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null; |
| 255 | +}return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(B,A){this.key=B; |
| 256 | +this.setOptions(A);},write:function(B){B=encodeURIComponent(B);if(this.options.domain){B+="; domain="+this.options.domain;}if(this.options.path){B+="; path="+this.options.path; |
| 257 | +}if(this.options.duration){var A=new Date();A.setTime(A.getTime()+this.options.duration*24*60*60*1000);B+="; expires="+A.toGMTString();}if(this.options.secure){B+="; secure"; |
| 258 | +}this.options.document.cookie=this.key+"="+B;return this;},read:function(){var A=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); |
| 259 | +return(A)?decodeURIComponent(A[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(B,C,A){return new Cookie(B,A).write(C); |
| 260 | +};Cookie.read=function(A){return new Cookie(A).read();};Cookie.dispose=function(B,A){return new Cookie(B,A).dispose();};var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:"high",allowScriptAccess:"always",wMode:"transparent",swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object; |
| 261 | +},initialize:function(L,M){this.instance="Swiff_"+$time();this.setOptions(M);M=this.options;var B=this.id=M.id||this.instance;var A=$(M.container);Swiff.CallBacks[this.instance]={}; |
| 262 | +var E=M.params,G=M.vars,F=M.callBacks;var H=$extend({height:M.height,width:M.width},M.properties);var K=this;for(var D in F){Swiff.CallBacks[this.instance][D]=(function(N){return function(){return N.apply(K.object,arguments); |
| 263 | +};})(F[D]);G[D]="Swiff.CallBacks."+this.instance+"."+D;}E.flashVars=Hash.toQueryString(G);if(Browser.Engine.trident){H.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; |
| 264 | +E.movie=L;}else{H.type="application/x-shockwave-flash";H.data=L;}var J='<object id="'+B+'"';for(var I in H){J+=" "+I+'="'+H[I]+'"';}J+=">";for(var C in E){if(E[C]){J+='<param name="'+C+'" value="'+E[C]+'" />'; |
| 265 | +}}J+="</object>";this.object=((A)?A.empty():new Element("div")).set("html",J).firstChild;},replaces:function(A){A=$(A,true);A.parentNode.replaceChild(this.toElement(),A); |
| 266 | +return this;},inject:function(A){$(A,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments)); |
| 267 | +}});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction('<invoke name="'+fn+'" returntype="javascript">'+__flash__argumentsToXML(arguments,2)+"</invoke>"); |
| 268 | +return eval(rs);};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore",transition:function(A){return -(Math.cos(Math.PI*A)-1)/2; |
| 269 | +}},initialize:function(A){this.subject=this.subject||this;this.setOptions(A);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt(); |
| 270 | +var B=this.options.wait;if(B===false){this.options.link="cancel";}},step:function(){var A=$time();if(A<this.time+this.options.duration){var B=this.options.transition((A-this.time)/this.options.duration); |
| 271 | +this.set(this.compute(this.from,this.to,B));}else{this.set(this.compute(this.from,this.to,1));this.complete();}},set:function(A){return A;},compute:function(C,B,A){return Fx.compute(C,B,A); |
| 272 | +},check:function(A){if(!this.timer){return true;}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1))); |
| 273 | +return false;}return false;},start:function(B,A){if(!this.check(arguments.callee,B,A)){return this;}this.from=B;this.to=A;this.time=0;this.startTimer(); |
| 274 | +this.onStart();return this;},complete:function(){if(this.stopTimer()){this.onComplete();}return this;},cancel:function(){if(this.stopTimer()){this.onCancel(); |
| 275 | +}return this;},onStart:function(){this.fireEvent("start",this.subject);},onComplete:function(){this.fireEvent("complete",this.subject);if(!this.callChain()){this.fireEvent("chainComplete",this.subject); |
| 276 | +}},onCancel:function(){this.fireEvent("cancel",this.subject).clearChain();},pause:function(){this.stopTimer();return this;},resume:function(){this.startTimer(); |
| 277 | +return this;},stopTimer:function(){if(!this.timer){return false;}this.time=$time()-this.time;this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer){return false; |
| 278 | +}this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true;}});Fx.compute=function(C,B,A){return(B-C)*A+C; |
| 279 | +};Fx.Durations={"short":250,normal:500,"long":1000};Fx.CSS=new Class({Extends:Fx,prepare:function(D,E,B){B=$splat(B);var C=B[1];if(!$chk(C)){B[1]=B[0]; |
| 280 | +B[0]=D.getStyle(E);}var A=B.map(this.parse);return{from:A[0],to:A[1]};},parse:function(A){A=$lambda(A)();A=(typeof A=="string")?A.split(" "):$splat(A); |
| 281 | +return A.map(function(C){C=String(C);var B=false;Fx.CSS.Parsers.each(function(F,E){if(B){return ;}var D=F.parse(C);if($chk(D)){B={value:D,parser:F};}}); |
| 282 | +B=B||{value:C,parser:Fx.CSS.Parsers.String};return B;});},compute:function(D,C,B){var A=[];(Math.min(D.length,C.length)).times(function(E){A.push({value:D[E].parser.compute(D[E].value,C[E].value,B),parser:D[E].parser}); |
| 283 | +});A.$family={name:"fx:css:value"};return A;},serve:function(C,B){if($type(C)!="fx:css:value"){C=this.parse(C);}var A=[];C.each(function(D){A=A.concat(D.parser.serve(D.value,B)); |
| 284 | +});return A;},render:function(A,D,C,B){A.setStyle(D,this.serve(C,B));},search:function(A){if(Fx.CSS.Cache[A]){return Fx.CSS.Cache[A];}var B={};Array.each(document.styleSheets,function(E,D){var C=E.href; |
| 285 | +if(C&&C.contains("://")&&!C.contains(document.domain)){return ;}var F=E.rules||E.cssRules;Array.each(F,function(I,G){if(!I.style){return ;}var H=(I.selectorText)?I.selectorText.replace(/^\w+/,function(J){return J.toLowerCase(); |
| 286 | +}):null;if(!H||!H.test("^"+A+"$")){return ;}Element.Styles.each(function(K,J){if(!I.style[J]||Element.ShortStyles[J]){return ;}K=String(I.style[J]);B[J]=(K.test(/^rgb/))?K.rgbToHex():K; |
| 287 | +});});});return Fx.CSS.Cache[A]=B;}});Fx.CSS.Cache={};Fx.CSS.Parsers=new Hash({Color:{parse:function(A){if(A.match(/^#[0-9a-f]{3,6}$/i)){return A.hexToRgb(true); |
| 288 | +}return((A=A.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[A[1],A[2],A[3]]:false;},compute:function(C,B,A){return C.map(function(E,D){return Math.round(Fx.compute(C[D],B[D],A)); |
| 289 | +});},serve:function(A){return A.map(Number);}},Number:{parse:parseFloat,compute:Fx.compute,serve:function(B,A){return(A)?B+A:B;}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}}); |
| 290 | +Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(B,A){this.element=this.subject=$(B);this.parent(A);},set:function(B,A){if(arguments.length==1){A=B; |
| 291 | +B=this.property||this.options.property;}this.render(this.element,B,A,this.options.unit);return this;},start:function(C,E,D){if(!this.check(arguments.callee,C,E,D)){return this; |
| 292 | +}var B=Array.flatten(arguments);this.property=this.options.property||B.shift();var A=this.prepare(this.element,this.property,B);return this.parent(A.from,A.to); |
| 293 | +}});Element.Properties.tween={set:function(A){var B=this.retrieve("tween");if(B){B.cancel();}return this.eliminate("tween").store("tween:options",$extend({link:"cancel"},A)); |
| 294 | +},get:function(A){if(A||!this.retrieve("tween")){if(A||!this.retrieve("tween:options")){this.set("tween",A);}this.store("tween",new Fx.Tween(this,this.retrieve("tween:options"))); |
| 295 | +}return this.retrieve("tween");}};Element.implement({tween:function(A,C,B){this.get("tween").start(arguments);return this;},fade:function(C){var E=this.get("tween"),D="opacity",A; |
| 296 | +C=$pick(C,"toggle");switch(C){case"in":E.start(D,1);break;case"out":E.start(D,0);break;case"show":E.set(D,1);break;case"hide":E.set(D,0);break;case"toggle":var B=this.retrieve("fade:flag",this.get("opacity")==1); |
| 297 | +E.start(D,(B)?0:1);this.store("fade:flag",!B);A=true;break;default:E.start(D,arguments);}if(!A){this.eliminate("fade:flag");}return this;},highlight:function(C,A){if(!A){A=this.retrieve("highlight:original",this.getStyle("background-color")); |
| 298 | +A=(A=="transparent")?"#fff":A;}var B=this.get("tween");B.start("background-color",C||"#ffff88",A).chain(function(){this.setStyle("background-color",this.retrieve("highlight:original")); |
| 299 | +B.callChain();}.bind(this));return this;}});Fx.Morph=new Class({Extends:Fx.CSS,initialize:function(B,A){this.element=this.subject=$(B);this.parent(A);},set:function(A){if(typeof A=="string"){A=this.search(A); |
| 300 | +}for(var B in A){this.render(this.element,B,A[B],this.options.unit);}return this;},compute:function(E,D,C){var A={};for(var B in E){A[B]=this.parent(E[B],D[B],C); |
| 301 | +}return A;},start:function(B){if(!this.check(arguments.callee,B)){return this;}if(typeof B=="string"){B=this.search(B);}var E={},D={};for(var C in B){var A=this.prepare(this.element,C,B[C]); |
| 302 | +E[C]=A.from;D[C]=A.to;}return this.parent(E,D);}});Element.Properties.morph={set:function(A){var B=this.retrieve("morph");if(B){B.cancel();}return this.eliminate("morph").store("morph:options",$extend({link:"cancel"},A)); |
| 303 | +},get:function(A){if(A||!this.retrieve("morph")){if(A||!this.retrieve("morph:options")){this.set("morph",A);}this.store("morph",new Fx.Morph(this,this.retrieve("morph:options"))); |
| 304 | +}return this.retrieve("morph");}};Element.implement({morph:function(A){this.get("morph").start(A);return this;}});(function(){var A=Fx.prototype.initialize; |
| 305 | +Fx.prototype.initialize=function(B){A.call(this,B);var C=this.options.transition;if(typeof C=="string"&&(C=C.split(":"))){var D=Fx.Transitions;D=D[C[0]]||D[C[0].capitalize()]; |
| 306 | +if(C[1]){D=D["ease"+C[1].capitalize()+(C[2]?C[2].capitalize():"")];}this.options.transition=D;}};})();Fx.Transition=function(B,A){A=$splat(A);return $extend(B,{easeIn:function(C){return B(C,A); |
| 307 | +},easeOut:function(C){return 1-B(1-C,A);},easeInOut:function(C){return(C<=0.5)?B(2*C,A)/2:(2-B(2*(1-C),A))/2;}});};Fx.Transitions=new Hash({linear:$arguments(0)}); |
| 308 | +Fx.Transitions.extend=function(A){for(var B in A){Fx.Transitions[B]=new Fx.Transition(A[B]);}};Fx.Transitions.extend({Pow:function(B,A){return Math.pow(B,A[0]||6); |
| 309 | +},Expo:function(A){return Math.pow(2,8*(A-1));},Circ:function(A){return 1-Math.sin(Math.acos(A));},Sine:function(A){return 1-Math.sin((1-A)*Math.PI/2); |
| 310 | +},Back:function(B,A){A=A[0]||1.618;return Math.pow(B,2)*((A+1)*B-A);},Bounce:function(D){var C;for(var B=0,A=1;1;B+=A,A/=2){if(D>=(7-4*B)/11){C=-Math.pow((11-6*B-11*D)/4,2)+A*A; |
| 311 | +break;}}return C;},Elastic:function(B,A){return Math.pow(2,10*--B)*Math.cos(20*B*Math.PI*(A[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(B,A){Fx.Transitions[B]=new Fx.Transition(function(C){return Math.pow(C,[A+2]); |
| 312 | +});});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(A){this.xhr=new Browser.Request(); |
| 313 | +this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ; |
| 314 | +}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; |
| 315 | +this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300)); |
| 316 | +},processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts); |
| 317 | +},success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); |
| 318 | +},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B); |
| 319 | +return this;},getHeader:function(A){return $try(function(){return this.xhr.getResponseHeader(A);}.bind(this));},check:function(A){if(!this.running){return true; |
| 320 | +}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));return false;}return false; |
| 321 | +},send:function(I){if(!this.check(arguments.callee,I)){return this;}this.running=true;var G=$type(I);if(G=="string"||G=="element"){I={data:I};}var D=this.options; |
| 322 | +I=$extend({data:D.data,url:D.url,method:D.method},I);var E=I.data,B=I.url,A=I.method;switch($type(E)){case"element":E=$(E).toQueryString();break;case"object":case"hash":E=Hash.toQueryString(E); |
| 323 | +}if(this.options.format){var H="format="+this.options.format;E=(E)?H+"&"+E:H;}if(this.options.emulation&&["put","delete"].contains(A)){var F="_method="+A; |
| 324 | +E=(E)?F+"&"+E:F;A="post";}if(this.options.urlEncoded&&A=="post"){var C=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+C); |
| 325 | +}if(E&&A=="get"){B=B+(B.contains("?")?"&":"?")+E;E=null;}this.xhr.open(A.toUpperCase(),B,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this); |
| 326 | +this.headers.each(function(K,J){if(!$try(function(){this.xhr.setRequestHeader(J,K);return true;}.bind(this))){this.fireEvent("exception",[J,K]);}},this); |
| 327 | +this.fireEvent("request");this.xhr.send(E);if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this; |
| 328 | +}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var A={}; |
| 329 | +["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(B){A[B]=function(){var C=Array.link(arguments,{url:String.type,data:$defined}); |
| 330 | +return this.send($extend(C,{method:B.toLowerCase()}));};});Request.implement(A);})();Element.Properties.send={set:function(A){var B=this.retrieve("send"); |
| 331 | +if(B){B.cancel();}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},A)); |
| 332 | +},get:function(A){if(A||!this.retrieve("send")){if(A||!this.retrieve("send:options")){this.set("send",A);}this.store("send",new Request(this.retrieve("send:options"))); |
| 333 | +}return this.retrieve("send");}};Element.implement({send:function(A){var B=this.get("send");B.send({data:this,url:A||B.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,evalScripts:true,filter:false},processHTML:function(C){var B=C.match(/<body[^>]*>([\s\S]*?)<\/body>/i); |
| 334 | +C=(B)?B[1]:C;var A=new Element("div");return $try(function(){var D="<root>"+C+"</root>",G;if(Browser.Engine.trident){G=new ActiveXObject("Microsoft.XMLDOM"); |
| 335 | +G.async=false;G.loadXML(D);}else{G=new DOMParser().parseFromString(D,"text/xml");}D=G.getElementsByTagName("root")[0];for(var F=0,E=D.childNodes.length; |
| 336 | +F<E;F++){var H=Element.clone(D.childNodes[F],true,true);if(H){A.grab(H);}}return A;})||A.set("html",C);},success:function(D){var C=this.options,B=this.response; |
| 337 | +B.html=D.stripScripts(function(E){B.javascript=E;});var A=this.processHTML(B.html);B.tree=A.childNodes;B.elements=A.getElements("*");if(C.filter){B.tree=B.elements.filter(C.filter); |
| 338 | +}if(C.update){$(C.update).empty().adopt(B.tree);}if(C.evalScripts){$exec(B.javascript);}this.onSuccess(B.tree,B.elements,B.html,B.javascript);}});Element.Properties.load={set:function(A){var B=this.retrieve("load"); |
| 339 | +if(B){send.cancel();}return this.eliminate("load").store("load:options",$extend({data:this,link:"cancel",update:this,method:"get"},A));},get:function(A){if(A||!this.retrieve("load")){if(A||!this.retrieve("load:options")){this.set("load",A); |
| 340 | +}this.store("load",new Request.HTML(this.retrieve("load:options")));}return this.retrieve("load");}};Element.implement({load:function(){this.get("load").send(Array.link(arguments,{data:Object.type,url:String.type})); |
| 341 | +return this;}});Request.JSON=new Class({Extends:Request,options:{secure:true},initialize:function(A){this.parent(A);this.headers.extend({Accept:"application/json","X-Request":"JSON"}); |
| 342 | +},success:function(A){this.response.json=JSON.decode(A,this.options.secure);this.onSuccess(this.response.json,A);}}); |
Index: trunk/extensions/uniwiki/CatBoxAtTop/CatBoxAtTop.php |
— | — | @@ -0,0 +1,54 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Category_Box_at_Top |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +$wgExtensionCredits['other'][] = array( |
| 14 | + 'name' => "Uniwiki Category Box at Top", |
| 15 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 16 | + 'description' => "Adds a category box to the top right of articles" |
| 17 | +); |
| 18 | + |
| 19 | + |
| 20 | +/* ---- HOOKS ---- */ |
| 21 | + |
| 22 | +$wgHooks['BeforePageDisplay'][] = "UW_CatBoxAtTop_CSS"; |
| 23 | +function UW_CatBoxAtTop_CSS (&$out) { |
| 24 | + global $wgScriptPath; |
| 25 | + $href = "$wgScriptPath/extensions/uniwiki/CatBoxAtTop/style.css"; |
| 26 | + $out->addScript ("<link rel='stylesheet' href='$href' />"); |
| 27 | + return true; |
| 28 | +} |
| 29 | + |
| 30 | +$wgHooks['OutputPageBeforeHTML'][] = "UW_CatBoxAtTop_Rejig"; |
| 31 | +function UW_CatBoxAtTop_Rejig (&$out, &$text) { |
| 32 | + global $wgVersion; |
| 33 | + |
| 34 | + // no categories = no box |
| 35 | + if (!$out->mCategoryLinks) |
| 36 | + return true; |
| 37 | + |
| 38 | + /* add a category box to the top of the output, |
| 39 | + * to be dropped into the top right via CSS */ |
| 40 | + $catbox = "<div id=\"catbox\"><div>\n"; |
| 41 | + $catbox .= "<h5>Categories</h5><ul>\n"; |
| 42 | + $catlinks = array(); |
| 43 | + if ($wgVersion == '1.13.0') { |
| 44 | + $catlinks = $out->mCategoryLinks['normal']; |
| 45 | + } else { |
| 46 | + $catlinks = $out->mCategoryLinks; |
| 47 | + } |
| 48 | + foreach ($catlinks as $cat) |
| 49 | + $catbox .= "<li>$cat</li>\n"; |
| 50 | + $catbox .= "</ul></div></div>\n"; |
| 51 | + |
| 52 | + $text = $catbox.$text; |
| 53 | + return true; |
| 54 | +} |
| 55 | + |
Index: trunk/extensions/uniwiki/CatBoxAtTop/style.css |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +/* vim: noet ts=4 sw=4 |
| 3 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Category_Box_at_Top |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | + |
| 7 | +/* hide the table of contents |
| 8 | + * THIS IS A TEMPORARY HACK! */ |
| 9 | +#bodyContent #toc { |
| 10 | + display: none; } |
| 11 | + |
| 12 | +/* move the catbox to the right, and |
| 13 | + * float, to wrap surrounding content */ |
| 14 | +#catbox { |
| 15 | + float: right; |
| 16 | + width: 10em; |
| 17 | + padding-bottom: 1em; |
| 18 | + |
| 19 | + /*margin-left: 1em;*/ |
| 20 | + border-left: 1em solid #fff; |
| 21 | +} |
| 22 | + |
| 23 | + #catbox div { |
| 24 | + border: 1px solid #aaa; |
| 25 | + background: #fff; |
| 26 | + } |
| 27 | + |
| 28 | + #catbox h5 { |
| 29 | + text-align: center; |
| 30 | + padding: 0.25em 1em; |
| 31 | + border-bottom: 1px solid #aaa; |
| 32 | + background: #eee; |
| 33 | + margin-bottom: 0; |
| 34 | + } |
| 35 | + |
| 36 | + #catbox ul { |
| 37 | + margin: 0; |
| 38 | + padding: 0.25em 0.5em; |
| 39 | + } |
| 40 | + |
| 41 | + #catbox li { |
| 42 | + margin: 0; |
| 43 | + display: block; |
| 44 | + line-height: 1.8; |
| 45 | + list-style-image: none; |
| 46 | + } |
| 47 | + |
| 48 | + /*#catbox li a { |
| 49 | + display: block; |
| 50 | + padding: 0.25em 0.5em; |
| 51 | + border-bottom: 1px solid #eee; |
| 52 | + }*/ |
| 53 | + |
Index: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.i18n.php |
— | — | @@ -0,0 +1,30 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Auto_Create_Category_Pages |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +$wgAutoCreateCategoryPagesMessages = array(); |
| 12 | +$wgAutoCreateCategoryPagesMessages['en'] = array( |
| 13 | + 'accp_stub' => "This is a category page. It lists all of the pages in category \"$1\" as well as all subcategories of category \"$1\" if any exist.", |
| 14 | + 'accp_createdby' => "Created automatically by the AutoCreateCategoryPage extension." |
| 15 | +); |
| 16 | + |
| 17 | +$wgAutoCreateCategoryPagesMessages['es'] = array( |
| 18 | + 'accp_stub' => "Esta es una página de categorÃas. Aquà se enumeran todas las páginas en la categorÃa \"$1\" asà como todas las subcategorÃas en la categorÃa \"$1\" si las hubiere.", |
| 19 | + 'accp_createdby' => "Creado automáticamente por la extensión AutoCreateCategoryPe." |
| 20 | +); |
| 21 | + |
| 22 | +$wgAutoCreateCategoryPagesMessages['de'] = array( |
| 23 | + 'accp_stub' => "Dies ist eine Kategorie Übersicht. Es listet alle Seiten in der Kategorie \"$1\" sowie alle Unterkategorien der Kategorie \"$1\" wenn sie existiert.", |
| 24 | + 'accp_createdby' => "Erstellt automatisch von der AutoCreateCategoryPage Erweiterung" |
| 25 | +); |
| 26 | + |
| 27 | +$wgAutoCreateCategoryPagesMessages['pt-br'] = array( |
| 28 | + 'accp_stub' => "Esta é uma página de categoria. Ela lista todas as páginas da categoria \"$1\", bem como todas as subcategorias da categoria \"$1\", se existirem.", |
| 29 | + 'accp_createdby' => "Gerada automaticamente pela extensão AutoCreateCategoryPag." |
| 30 | +); |
| 31 | + |
Index: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.php |
— | — | @@ -0,0 +1,85 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Auto_Create_Category_Pages |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined('MEDIAWIKI')) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +$wgExtensionCredits['other'][] = array( |
| 14 | + 'name' => "AutoCreateCategoryPages", |
| 15 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 16 | + 'description' => "Create stub Category pages automatically" |
| 17 | +); |
| 18 | + |
| 19 | + |
| 20 | +/* ---- INTERNATIONALIZATION ---- */ |
| 21 | + |
| 22 | +require_once ("AutoCreateCategoryPages.i18n.php"); |
| 23 | +$wgExtensionFunctions[] = "AutoCreateCategoryPages_i18n"; |
| 24 | + |
| 25 | +function AutoCreateCategoryPages_i18n() { |
| 26 | + // add this extension's messages to the message cache |
| 27 | + global $wgMessageCache, $wgAutoCreateCategoryPagesMessages; |
| 28 | + foreach ($wgAutoCreateCategoryPagesMessages as $lang => $messages) |
| 29 | + $wgMessageCache->addMessages ($messages, $lang); |
| 30 | +} |
| 31 | + |
| 32 | + |
| 33 | +/* ---- HOOKS ---- */ |
| 34 | + |
| 35 | +$wgHooks['ArticleSaveComplete'][] = "UW_AutoCreateCategoryPages_Save"; |
| 36 | +function UW_AutoCreateCategoryPages_Save (&$article, &$user, &$text, &$summary, &$minoredit, |
| 37 | + &$watchthis, &$sectionanchor, &$flags, $revision) { |
| 38 | + global $wgDBprefix; |
| 39 | + |
| 40 | + /* after the page is saved, get all the categories |
| 41 | + * and see if they exists as "proper" pages; if not |
| 42 | + * then create a simple page for them automatically */ |
| 43 | + |
| 44 | + // extract the categories on this page |
| 45 | + $regex = "/\[\[category:(.+?)(?:\|.*)?\]\]/i"; |
| 46 | + preg_match_all ($regex, $text, $matches); |
| 47 | + |
| 48 | + // array of the categories on the page (in db form) |
| 49 | + $on_page = array(); |
| 50 | + foreach ($matches[1] as $cat) |
| 51 | + $on_page[] = Title::newFromText ($cat)->getDBkey(); |
| 52 | + |
| 53 | + // array of the categories in the db |
| 54 | + $db = wfGetDB (DB_MASTER); |
| 55 | + $results = $db->resultObject ($db->query( |
| 56 | + "select distinct page_title from {$wgDBprefix}page " . |
| 57 | + "where page_namespace = '".NS_CATEGORY."'")); |
| 58 | + |
| 59 | + $in_db = array(); |
| 60 | + while ($r = $results->next()) |
| 61 | + $in_db[] = $r->page_title; |
| 62 | + |
| 63 | + /* loop through the categories in the page and |
| 64 | + * see if they already exist as a category page */ |
| 65 | + foreach ($on_page as $db_key) { |
| 66 | + if (!in_array( $db_key, $in_db)) { |
| 67 | + |
| 68 | + // if it doesn't exist, then create it here |
| 69 | + $page_title = Title::newFromDBkey ($db_key)->getText(); |
| 70 | + $stub = wfMsg ("accp_stub", $page_title); |
| 71 | + $summary = wfMsg ("accp_createdby"); |
| 72 | + $article = new Article (Title::newFromDBkey("Category:$db_key")); |
| 73 | + |
| 74 | + try { |
| 75 | + $article->doEdit ($stub, $summary, EDIT_NEW & EDIT_SUPPRESS_RC); |
| 76 | + |
| 77 | + } catch (MWException $e) { |
| 78 | + /* fail silently... |
| 79 | + * todo: what can go wrong here? */ |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + return true; |
| 85 | +} |
| 86 | + |
Index: trunk/extensions/uniwiki/.uniwiki.settings |
— | — | @@ -0,0 +1,16 @@ |
| 2 | + |
| 3 | +# uniwiki |
| 4 | +# ======= |
| 5 | +\$wgLogo = \"\$wgScriptPath/extensions/uniwiki/uniwiki.png\"; |
| 6 | +\$uw = \"\$IP/extensions/uniwiki\"; |
| 7 | +require_once(\"\$uw/CssHooks/CssHooks.php\"); |
| 8 | +require_once(\"\$uw/Javascript/Javascript.php\"); |
| 9 | +require_once(\"\$uw/MooTools12core/MooTools12core.php\"); |
| 10 | +require_once(\"\$uw/AutoCreateCategoryPages/AutoCreateCategoryPages.php\"); |
| 11 | +require_once(\"\$uw/GenericEditPage/GenericEditPage.php\"); |
| 12 | +require_once(\"\$uw/CatBoxAtTop/CatBoxAtTop.php\"); |
| 13 | +require_once(\"\$uw/Layouts/Layouts.php\"); |
| 14 | +require_once(\"\$uw/Authors/Authors.php\"); |
| 15 | +require_once(\"\$uw/CustomToolbar/CustomToolbar.php\"); |
| 16 | +require_once(\"\$uw/CreatePage/CreatePage.php\"); |
| 17 | + |
Index: trunk/extensions/uniwiki/CssHooks/CssHooks.php |
— | — | @@ -0,0 +1,63 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_CSS_Hooks |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +$wgExtensionCredits['other'][] = array( |
| 14 | + 'name' => "Uniwiki CSS Hooks", |
| 15 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 16 | + 'description' => "Add some CSS hooks to the HTML output of articles, for better styling" |
| 17 | +); |
| 18 | + |
| 19 | + |
| 20 | +/* ---- HOOKS ---- */ |
| 21 | + |
| 22 | +$wgHooks['OutputPageBeforeHTML'][] = 'UW_CssHooks_AddHooks'; |
| 23 | +function UW_CssHooks_AddHooks (&$out, &$text) { |
| 24 | + global $wgRequest; |
| 25 | + |
| 26 | + // break the page into sections via their <h2>s |
| 27 | + $sections = preg_split ("/(<a name=\".+?\"><\/a><h2>.+?<\/h2>)/", |
| 28 | + $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 29 | + |
| 30 | + // remove the first empty section |
| 31 | + if ($sections[0] == "") |
| 32 | + array_shift ($sections); |
| 33 | + |
| 34 | + $index = 0; |
| 35 | + $output = ''; |
| 36 | + $div_open = false; |
| 37 | + for ($i=0; $i<count ($sections); $i++) { |
| 38 | + |
| 39 | + /* is this block of text a header? (check for mw-headline |
| 40 | + * to only include actual section headers, and dodge toc) */ |
| 41 | + if (substr ($sections[$i], 0, 7) == "<a name") { |
| 42 | + if (strstr ($sections[$i], "<span class=\"mw-headline\">") !== false) { |
| 43 | + $index++; |
| 44 | + |
| 45 | + /* close current section div, if one exists, |
| 46 | + * and always open a new one with hooks */ |
| 47 | + if ($div_open) $output .= "</div>"; |
| 48 | + $output .= "<div class=\"uw-section sect-$index\">"; |
| 49 | + $div_open = true; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + // re-add the original text |
| 54 | + $output .= $sections[$i]; |
| 55 | + |
| 56 | + // close the last section, if one is open |
| 57 | + if (($i==count ($sections)-1) && $div_open) |
| 58 | + $output .= "</div>"; |
| 59 | + } |
| 60 | + |
| 61 | + $text = $output; |
| 62 | + return true; |
| 63 | +} |
| 64 | + |
Index: trunk/extensions/uniwiki/CustomToolbar/CustomToolbar.php |
— | — | @@ -0,0 +1,316 @@ |
| 2 | +<?php |
| 3 | +# Copyright (C) 2008 Mark Johnston and Adam Mckaig |
| 4 | +# |
| 5 | +# This program is free software; you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License as published by |
| 7 | +# the Free Software Foundation; either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# This program is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License along |
| 16 | +# with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | +# |
| 19 | +# http://www.gnu.org/licenses/gpl-3.0.html |
| 20 | + |
| 21 | +if (!defined('MEDIAWIKI')) |
| 22 | + die(); |
| 23 | + |
| 24 | +$wgExtensionCredits['other'][] = array( |
| 25 | + 'name' => 'CustomToolbar', |
| 26 | + 'author' => 'Mark Johnston, Adam Mckaig, Evan Wheeler', |
| 27 | + 'version' => '0.1', |
| 28 | + 'description' => 'Extension to build an extensible toolbar for MediaWiki.' |
| 29 | +); |
| 30 | + |
| 31 | +/* ---- INTERNATIONALIZATION ---- */ |
| 32 | + |
| 33 | +require_once( 'CustomToolbar.i18n.php' ); |
| 34 | + |
| 35 | +// add the internationalization function to the list |
| 36 | +global $wgExtensionFunctions; |
| 37 | +$wgExtensionFunctions[] = 'CustomToolbar_i18n'; |
| 38 | + |
| 39 | +//add file extensions for acceptable images and attachments |
| 40 | +global $wgFileExtensions; |
| 41 | +$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'ogg', 'mp3', 'wav', 'doc', 'xls', 'csv', 'bmp', 'ppt', 'pdf', 'txt', 'rm', 'mov', 'avi' ); |
| 42 | + |
| 43 | +//these will get thumbnails and image links |
| 44 | +$ct_uploadable_images = array('png', 'gif', 'jpg', 'jpeg' ); |
| 45 | +//these will get media links |
| 46 | +$ct_uploadable_attachments = array('ogg', 'mp3', 'wav', 'doc', 'xls', 'csv', 'bmp', 'ppt', 'pdf', 'txt', 'rm', 'mov', 'avi' ); |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +function CustomToolbar_i18n() { |
| 51 | + // add this extension's messages to the message cache |
| 52 | + global $wgMessageCache, $wgCustomToolbarMessages; |
| 53 | + foreach( $wgCustomToolbarMessages as $lang => $messages ) |
| 54 | + $wgMessageCache->addMessages($messages, $lang); |
| 55 | +} |
| 56 | + |
| 57 | + |
| 58 | +$wgHooks['EditPage::showEditForm:initial'][] = "CustomToolbar_turnOffToolbar"; |
| 59 | +function CustomToolbar_turnOffToolbar() { |
| 60 | + global $wgUser, $wgHooks; |
| 61 | + |
| 62 | + /* if the user has the edit toolbar turned on, then turn |
| 63 | + * it off (to hide the ugly toolbar), and add the BeforePageDisplay |
| 64 | + * hook, too attach our replacement */ |
| 65 | + if($wgUser->getOption('showtoolbar')) { |
| 66 | + $wgUser->setOption('showtoolbar', false); |
| 67 | + $wgHooks['BeforePageDisplay'][] = 'CustomToolbar_addAssets'; |
| 68 | + } |
| 69 | + |
| 70 | + return true; |
| 71 | +} |
| 72 | + |
| 73 | +function CustomToolbar_addAssets(&$out) { |
| 74 | + global $wgScriptPath, $wgCustomToolbarMessages, $wgLanguageCode; |
| 75 | + |
| 76 | + /* add all messages for the current lang by iterating the |
| 77 | + * global array, and converting it into a javascript hash */ |
| 78 | + $js = "Uniwiki.i18n.add({\n"; |
| 79 | + foreach ($wgCustomToolbarMessages[$wgLanguageCode] as $key => $str) { |
| 80 | + $js .= "\t'".$key."': \"".$str."\",\n"; |
| 81 | + } |
| 82 | + |
| 83 | + // chop off last comma + newline, for IE |
| 84 | + $js = substr($js,0,strlen($js)-2)."})"; |
| 85 | + $out->addInlineScript($js); |
| 86 | + |
| 87 | + $path = "$wgScriptPath/extensions/uniwiki/CustomToolbar"; |
| 88 | + $out->addScript("<script type='text/javascript' src='$path/Element.Forms.js'></script>\n"); |
| 89 | + $out->addScript("<script type='text/javascript' src='$path/CustomToolbar.js'></script>\n"); |
| 90 | + $out->addScript("<style type='text/css'>@import '$path/style.css';</style>\n"); |
| 91 | + return true; |
| 92 | + |
| 93 | +} |
| 94 | + |
| 95 | +$wgExtensionFunctions[] = 'wfCustomToolbarUploadForm'; |
| 96 | +function wfCustomToolbarUploadForm() { |
| 97 | + $file = "extensions/uniwiki/CustomToolbar/CustomToolbar.php"; |
| 98 | + SpecialPage::AddPage( |
| 99 | + new UnlistedSpecialPage('CustomToolbarUpload', '', false, $file) |
| 100 | + ); |
| 101 | +} |
| 102 | + |
| 103 | +function wfSpecialCustomToolbarUpload() { |
| 104 | + global $wgRequest; |
| 105 | + $form = new CustomToolbarUploadForm($wgRequest); |
| 106 | + $form->execute(); |
| 107 | +} |
| 108 | + |
| 109 | +$wgHooks['UploadComplete'][] = array('CustomToolbarUploadForm::showSuccess'); |
| 110 | +//XX TODO investigate FileUpload hook for attachment purposes |
| 111 | +//$wgHooks['FileUpload'][] = array('CustomToolbarUploadForm::showSuccess', 'attachment'); |
| 112 | +if ($wgVersion == '1.13.0') { |
| 113 | + require_once('includes/specials/SpecialUpload.php'); |
| 114 | +} else { |
| 115 | + require_once('includes/SpecialUpload.php'); |
| 116 | +} |
| 117 | +class CustomToolbarUploadForm extends UploadForm { |
| 118 | + /* Some code poached from Travis Derouin's <travis@wikihow.com> |
| 119 | + * UploadPopup extension |
| 120 | + */ |
| 121 | + var $mType, $mSection, $mCaption; |
| 122 | + |
| 123 | + function CustomToolbarUploadForm(&$request) { |
| 124 | + $this->mType = $request->getVal('type'); |
| 125 | + $this->mCaption = $request->getText('wpCaption'); |
| 126 | + $this->mSection = $request->getVal('section'); |
| 127 | + UploadForm::UploadForm(&$request); |
| 128 | + } |
| 129 | + |
| 130 | + function execute() { |
| 131 | + // override MW's UploadForm with only the bits we want |
| 132 | + global $wgOut, $wgStylePath; |
| 133 | + $wgOut->setArticleBodyOnly(true); |
| 134 | + $wgOut->addHTML(" |
| 135 | + <html> |
| 136 | + <head> |
| 137 | + <title>". wfMsg('ct_upload', $this->mType) . " </title> |
| 138 | + </head> |
| 139 | + <body>"); |
| 140 | + $wgOut->addHTML("<h2>". wfMsg('ct_upload', $this->mType) . " </h2>"); |
| 141 | + UploadForm::execute(); |
| 142 | + $wgOut->addHTML(" |
| 143 | + </body> |
| 144 | + </html>"); |
| 145 | + } |
| 146 | + |
| 147 | + function mainUploadForm( $msg = '') { |
| 148 | + global $wgOut, $wgScriptPath, $wgStylePath; |
| 149 | + if ( '' != $msg ) { |
| 150 | + $sub = wfMsgHtml( 'uploaderror' ); |
| 151 | + $wgOut->addHTML( "<h2>{$sub}</h2>\n" . |
| 152 | + "<span class='error'>{$msg}</span>\n" ); |
| 153 | + } |
| 154 | + |
| 155 | + $source_filename = wfMsg('ct_select', $this->mType); |
| 156 | + $destination_filename = wfMsgHtml( 'destfilename' ); |
| 157 | + $caption = $this->mType == 'image' ? wfMsg('ct_caption') : wfMsg('ct_link'); |
| 158 | + $linkname = wfMsg('ct_link'); |
| 159 | + $submit = wfMsg('ct_submit'); |
| 160 | + |
| 161 | + $upload_button = wfMsgHtml( 'uploadbtn' ); |
| 162 | + $cancel_button = wfMsg('cancel'); |
| 163 | + |
| 164 | + $titleObj = Title::makeTitle( NS_SPECIAL, 'CustomToolbarUpload' ); |
| 165 | + $action = $titleObj->escapeLocalURL(); |
| 166 | + |
| 167 | + $encDestFile = htmlspecialchars( $this->mDestFile ); |
| 168 | + |
| 169 | + $icon_path = "{$wgScriptPath}/extensions/uniwiki/CustomToolbar/images/numbers/"; |
| 170 | + /* The following form contains a strange hack for passing the section index id |
| 171 | + * through the upload function so we know where to insert the file tag. |
| 172 | + * This info is passed as wpDestFileWarningAck and retrieved from the returned, |
| 173 | + * uploaded object as $image->mDestWarningAck (see includes/SpecialUpload.php) |
| 174 | + * This parameter doesn't seem to be used for anything other than raising warnings, |
| 175 | + * all of which we are ignoring ... for better or for worse |
| 176 | + */ |
| 177 | + $wgOut->addHTML( " |
| 178 | + <form id='upload' name='uploadform' method='post' enctype='multipart/form-data' action=\"$action\" '> |
| 179 | + <table border='0'> |
| 180 | + <tr> |
| 181 | + <td align='left'><img src='{$icon_path}1.png' alt='1.' /> |
| 182 | + <label for='wpUploadFile'>{$source_filename}:</label></td> |
| 183 | + <td align='left'> |
| 184 | + <input type='file' name='wpUploadFile' id='wpUploadFile' " |
| 185 | + . ($this->mDestFile?"":"onchange=\"opener.Uniwiki.CustomToolbar.fillDestFilename(document.getElementById('wpUploadFile').value, document.getElementById('wpDestFile') )\" ") . "size='40' /> |
| 186 | + </td> |
| 187 | + </tr> |
| 188 | + <tr> |
| 189 | + <td align='left'><img src='{$icon_path}2.png' alt='2.' /> |
| 190 | + <label for='wpCaption'>{$caption}:</label></td> |
| 191 | + <td align='left'> |
| 192 | + <input type='text' name=\"wpCaption\" size='40'\"/> |
| 193 | + </td> |
| 194 | + </tr> |
| 195 | + <td align='left'><img src='{$icon_path}3.png' alt='3.' /> |
| 196 | + <label for='wpUpload'>{$submit}</label></td> |
| 197 | + <td align='left'><input type='submit' name='wpUpload' value=\"{$upload_button}\" /> |
| 198 | + <input type='button' name='wpCancel' onclick='window.close()' value=\"{$cancel_button}\"/></td> |
| 199 | + <tr> |
| 200 | + <td></td> |
| 201 | + <td> |
| 202 | + <input type='hidden' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' checked/> |
| 203 | + <input type='hidden' name='wpDestFileWarningAck' id='wpDestFileWarningAck' value='{$this->mSection}'/> |
| 204 | + <input type='hidden' name='wpDestFile' id='wpDestFile' /> |
| 205 | + </td> |
| 206 | + </tr> |
| 207 | + </table> |
| 208 | + </form> |
| 209 | + "); |
| 210 | + } |
| 211 | + |
| 212 | + function showSuccess(&$file) { |
| 213 | + global $wgOut, $ct_uploadable_images, $ct_uploadable_attachments; |
| 214 | + |
| 215 | + //styles copied from monobook/main.css |
| 216 | + //modified to not float the whole preview to the right |
| 217 | + $wgOut->addHTML(" |
| 218 | + <style> |
| 219 | + /* thumbnails */ |
| 220 | + div.thumb { |
| 221 | + margin-bottom: .5em; |
| 222 | + border-style: solid; |
| 223 | + border-color: white; |
| 224 | + width: auto; |
| 225 | + } |
| 226 | + div.thumbinner { |
| 227 | + border: 1px solid #ccc; |
| 228 | + padding: 3px !important; |
| 229 | + background-color: #f9f9f9; |
| 230 | + font-size: 94%; |
| 231 | + text-align: center; |
| 232 | + overflow: hidden; |
| 233 | + } |
| 234 | + html .thumbimage { |
| 235 | + border: 1px solid #ccc; |
| 236 | + } |
| 237 | + html .thumbcaption { |
| 238 | + border: none; |
| 239 | + text-align: left; |
| 240 | + line-height: 1.4em; |
| 241 | + padding: 3px !important; |
| 242 | + font-size: 94%; |
| 243 | + } |
| 244 | + div.magnify { |
| 245 | + float: right; |
| 246 | + border: none !important; |
| 247 | + background: none !important; |
| 248 | + } |
| 249 | + div.magnify a, div.magnify img { |
| 250 | + display: block; |
| 251 | + border: none !important; |
| 252 | + background: none !important; |
| 253 | + } |
| 254 | + div.tright { |
| 255 | + border-width: .5em 0 .8em 1.4em; |
| 256 | + } |
| 257 | + div.tleft { |
| 258 | + margin-right: .5em; |
| 259 | + border-width: .5em 1.4em .8em 0; |
| 260 | + } |
| 261 | + img.thumbborder { |
| 262 | + border: 1px solid #dddddd; |
| 263 | + } |
| 264 | + .hiddenStructure { |
| 265 | + display: none; |
| 266 | + } |
| 267 | + </style> |
| 268 | + "); |
| 269 | + $wgOut->redirect(''); |
| 270 | + $wgOut->addHTML("<h2>" . wfMsg('ct_success') . "</h2>"); |
| 271 | + |
| 272 | + //make wiki markup for the file |
| 273 | + $ext = explode('.', $file->mDestName ); |
| 274 | + $extension = $ext[count( $ext ) - 1]; |
| 275 | + if (in_array($extension, $ct_uploadable_images )){ |
| 276 | + $file_link = '[[' . 'Image:' . $file->mDestName . '|thumb|' . $file->mCaption . ']]'; |
| 277 | + } |
| 278 | + elseif (in_array($extension, $ct_uploadable_attachments )){ |
| 279 | + $file_link = '[[' . 'Media:' . $file->mDestName . '|' . $file->mCaption . ']]'; |
| 280 | + } |
| 281 | + |
| 282 | + $titleObj = Title::makeTitle( NS_SPECIAL, 'CustomToolbarUpload' ); |
| 283 | + //insert the wiki markup in the appropriate section |
| 284 | + //or the classic-mode textarea if we are in classic-mode |
| 285 | + if($file->mDestWarningAck != 'wpTextbox1'){ |
| 286 | + $insertion = 'opener.Uniwiki.CustomToolbar.insertIntoSection(section, file_link)'; |
| 287 | + }else{ |
| 288 | + $insertion = 'opener.Uniwiki.CustomToolbar.insertIntoClassic(file_link)'; |
| 289 | + } |
| 290 | + $wgOut->addHTML( " |
| 291 | + <script type='text/javascript'> |
| 292 | + var file_link = \"{$file_link}\"; |
| 293 | + var caption = \"{$file->mCaption}\"; |
| 294 | + var section =\"{$file->mDestWarningAck}\"; |
| 295 | + {$insertion}; |
| 296 | + </script> |
| 297 | + "); |
| 298 | + |
| 299 | + //show a thumbnail of the image as it will appear on the page |
| 300 | + $wgOut->addWikiText($file_link); |
| 301 | + $wgOut->addHTML(" |
| 302 | + <a href='#' onclick='window.close()'>" . wfMsg('ct_close') . "</a> |
| 303 | + </div> |
| 304 | + "); |
| 305 | + /* The UploadComplete hook is placed before the usual MW redirection |
| 306 | + * that follows a successful upload, so in order to show our success |
| 307 | + * page and insert the markup, we dump this output and kill the process |
| 308 | + * to avoid redirection to the file's page. |
| 309 | + */ |
| 310 | + print($wgOut->output()); |
| 311 | + exit; |
| 312 | + } |
| 313 | + |
| 314 | + //XX TODO make a prettier error page |
| 315 | + //function showError() { |
| 316 | + //} |
| 317 | +} |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/internal.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/internal.png |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 318 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/horizontal-line.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/horizontal-line.png |
___________________________________________________________________ |
Added: svn:mime-type |
2 | 319 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/user.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/user.png |
___________________________________________________________________ |
Added: svn:mime-type |
3 | 320 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/bold.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/bold.png |
___________________________________________________________________ |
Added: svn:mime-type |
4 | 321 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/nowiki.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/nowiki.png |
___________________________________________________________________ |
Added: svn:mime-type |
5 | 322 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/audio.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/audio.png |
___________________________________________________________________ |
Added: svn:mime-type |
6 | 323 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/external.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/external.png |
___________________________________________________________________ |
Added: svn:mime-type |
7 | 324 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/image.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/image.png |
___________________________________________________________________ |
Added: svn:mime-type |
8 | 325 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/default.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/default.png |
___________________________________________________________________ |
Added: svn:mime-type |
9 | 326 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/italic.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/italic.png |
___________________________________________________________________ |
Added: svn:mime-type |
10 | 327 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/video.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/video.png |
___________________________________________________________________ |
Added: svn:mime-type |
11 | 328 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/attachment.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/attachment.png |
___________________________________________________________________ |
Added: svn:mime-type |
12 | 329 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/22/math.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/22/math.png |
___________________________________________________________________ |
Added: svn:mime-type |
13 | 330 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/default.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/default.png |
___________________________________________________________________ |
Added: svn:mime-type |
14 | 331 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/italic.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/italic.png |
___________________________________________________________________ |
Added: svn:mime-type |
15 | 332 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/video.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/video.png |
___________________________________________________________________ |
Added: svn:mime-type |
16 | 333 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/attachment.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/attachment.png |
___________________________________________________________________ |
Added: svn:mime-type |
17 | 334 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/math.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/math.png |
___________________________________________________________________ |
Added: svn:mime-type |
18 | 335 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/internal.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/internal.png |
___________________________________________________________________ |
Added: svn:mime-type |
19 | 336 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/horizontal-line.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/horizontal-line.png |
___________________________________________________________________ |
Added: svn:mime-type |
20 | 337 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/user.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/user.png |
___________________________________________________________________ |
Added: svn:mime-type |
21 | 338 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/bold.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/bold.png |
___________________________________________________________________ |
Added: svn:mime-type |
22 | 339 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/nowiki.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/nowiki.png |
___________________________________________________________________ |
Added: svn:mime-type |
23 | 340 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/audio.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/audio.png |
___________________________________________________________________ |
Added: svn:mime-type |
24 | 341 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/external.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/external.png |
___________________________________________________________________ |
Added: svn:mime-type |
25 | 342 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/16/image.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/16/image.png |
___________________________________________________________________ |
Added: svn:mime-type |
26 | 343 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/numbers/5.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/numbers/5.png |
___________________________________________________________________ |
Added: svn:mime-type |
27 | 344 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/numbers/1.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/numbers/1.png |
___________________________________________________________________ |
Added: svn:mime-type |
28 | 345 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/numbers/2.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/numbers/2.png |
___________________________________________________________________ |
Added: svn:mime-type |
29 | 346 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/numbers/3.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/numbers/3.png |
___________________________________________________________________ |
Added: svn:mime-type |
30 | 347 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/images/numbers/4.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/CustomToolbar/images/numbers/4.png |
___________________________________________________________________ |
Added: svn:mime-type |
31 | 348 | + application/octet-stream |
Index: trunk/extensions/uniwiki/CustomToolbar/style.css |
— | — | @@ -0,0 +1,56 @@ |
| 2 | +.editor-wrap { |
| 3 | + /* make the editor wrapper look like a regular |
| 4 | + * text area, to make the toolbar look as if |
| 5 | + * if is nested within it */ |
| 6 | + border: 2px inset buttonface; |
| 7 | + zoom: 1; |
| 8 | +} |
| 9 | + |
| 10 | + .editor-wrap .toolbar { |
| 11 | + background: #F4F4F4; |
| 12 | + color: #888; |
| 13 | + padding: 1px; |
| 14 | + overflow: auto; |
| 15 | + display: inline-block; |
| 16 | + margin-bottom: 0.5em; |
| 17 | + border-bottom: 1px solid #CCC; |
| 18 | + width: 100%; |
| 19 | + } |
| 20 | + |
| 21 | + .editor-wrap .toolbar .button { |
| 22 | + cursor: pointer; |
| 23 | + float: left; |
| 24 | + line-height: 16px; |
| 25 | + padding: 4px 6px 2px 24px; |
| 26 | + font-size: 8pt; |
| 27 | + border: 1px solid #f4f4f4; |
| 28 | + background: url("images/16/default.png") no-repeat 4px 50%; |
| 29 | + } |
| 30 | + |
| 31 | + .editor-wrap .toolbar .button:hover, |
| 32 | + .editor-wrap .toolbar .button.hover { |
| 33 | + background-color: white; |
| 34 | + border: 1px solid #aaa; |
| 35 | + color: #000; |
| 36 | + } |
| 37 | + |
| 38 | + .editor-wrap .toolbar .but-bold { background-image: url("images/16/bold.png"); } |
| 39 | + .editor-wrap .toolbar .but-italic { background-image: url("images/16/italic.png"); } |
| 40 | + .editor-wrap .toolbar .but-internal { background-image: url("images/16/internal.png"); } |
| 41 | + .editor-wrap .toolbar .but-external { background-image: url("images/16/external.png"); } |
| 42 | + .editor-wrap .toolbar .but-image { background-image: url("images/16/image.png"); } |
| 43 | + .editor-wrap .toolbar .but-attachment { background-image: url("images/16/attachment.png"); } |
| 44 | + .editor-wrap .toolbar .but-horizontal-line { background-image: url("images/16/horizontal-line.png"); } |
| 45 | + .editor-wrap .toolbar .but-nowiki { background-image: url("images/16/nowiki.png"); } |
| 46 | + .editor-wrap .toolbar .but-math { background-image: url("images/16/math.png"); } |
| 47 | + .editor-wrap .toolbar .but-user { background-image: url("images/16/user.png"); } |
| 48 | + |
| 49 | + .editor-wrap textarea { |
| 50 | + padding: 0; |
| 51 | + width: 100%; |
| 52 | + border: 0; |
| 53 | + } |
| 54 | + |
| 55 | +.edit-generic .editor-wrap { display: none; } |
| 56 | +.edit-generic .generic-editor .editor-wrap { display: block; } |
| 57 | + |
Index: trunk/extensions/uniwiki/CustomToolbar/CustomToolbar.js |
— | — | @@ -0,0 +1,271 @@ |
| 2 | +Uniwiki.CustomToolbar = { |
| 3 | + |
| 4 | + /* other plugins may add more buttons here, |
| 5 | + * which will automatically be included */ |
| 6 | + Buttons: { |
| 7 | + 'bold': { |
| 8 | + 'key': "b", |
| 9 | + 'open': "'''", |
| 10 | + 'close': "'''", |
| 11 | + 'sample': wfMsg('ct_bold_sample'), |
| 12 | + 'tip': [wfMsg('ct_bold_tip_ins'), wfMsg('ct_bold_tip_wrap')], |
| 13 | + 'caption': wfMsg('ct_bold_caption') |
| 14 | + }, |
| 15 | + 'italic': { |
| 16 | + 'key': "i", |
| 17 | + 'open': "''", |
| 18 | + 'close': "''", |
| 19 | + 'sample': wfMsg('ct_italic_sample'), |
| 20 | + 'tip': [wfMsg('ct_italic_tip_ins'), wfMsg('ct_italic_tip_wrap')], |
| 21 | + 'caption': wfMsg('ct_italic_caption') |
| 22 | + }, |
| 23 | + 'internal': { |
| 24 | + 'key': "l", |
| 25 | + 'open': "[[", |
| 26 | + 'close': "]]", |
| 27 | + 'sample': wfMsg('ct_internal_sample'), |
| 28 | + 'tip': [wfMsg('ct_internal_tip_ins'), wfMsg('ct_internal_tip_wrap')], |
| 29 | + 'caption': wfMsg('ct_internal_caption') |
| 30 | + }, |
| 31 | + 'external': { |
| 32 | + 'key': "e", |
| 33 | + 'open': "[", |
| 34 | + 'close': "]", |
| 35 | + 'sample': wfMsg('ct_external_sample'), |
| 36 | + 'tip': [wfMsg('ct_external_tip_ins'), wfMsg('ct_external_tip_wrap')], |
| 37 | + 'caption': wfMsg('ct_external_caption') |
| 38 | + }, |
| 39 | + 'image': { |
| 40 | + 'key': "u", |
| 41 | + 'caption': wfMsg('ct_image_caption'), |
| 42 | + 'tip': wfMsg('ct_image_tip'), |
| 43 | + 'func': function(textarea) { |
| 44 | + |
| 45 | + /* Unless we are in the classic-mode textbox, |
| 46 | + * pass the section id number so that we know |
| 47 | + * where to add the image back into the page |
| 48 | + * (the name of the textarea will always match |
| 49 | + * the id of the section) */ |
| 50 | + if (textarea.name == "wpTextbox1") var section = textarea.name; |
| 51 | + else var section = textarea.name.replace(/\D/g, ''); |
| 52 | + |
| 53 | + /* open the upload form in a popup window |
| 54 | + * (this shold be moved to an iframe) */ |
| 55 | + popup = open( |
| 56 | + wgServer + wgScript + "/Special:CustomToolbarUpload?type=image§ion=" + section, |
| 57 | + null, "scrollbars=yes, status=no, width=600, height=400" |
| 58 | + ); |
| 59 | + |
| 60 | + /* check if the popup window wasn't blocked; if |
| 61 | + * it was, then display a notice to let the user |
| 62 | + * know that we didn't set them up the bomb */ |
| 63 | + if (popup != null && popup.opener != null) popup.opener = self; |
| 64 | + else alert (wfMsg('ct_popupblocked')); |
| 65 | + } |
| 66 | + }, |
| 67 | + 'attachment': { |
| 68 | + 'key': "a", |
| 69 | + 'caption': wfMsg('ct_attachment_caption'), |
| 70 | + 'tip': wfMsg('ct_attachment_tip'), |
| 71 | + 'func': function(textarea) { |
| 72 | + |
| 73 | + /* Unless we are in the classic-mode textbox, |
| 74 | + * pass the section id number so that we know |
| 75 | + * where to add the image back into the page |
| 76 | + * (the name of the textarea will always match |
| 77 | + * the id of the section) */ |
| 78 | + if (textarea.name == "wpTextbox1") var section = textarea.name; |
| 79 | + else var section = textarea.name.replace(/\D/g, ''); |
| 80 | + |
| 81 | + /* open the upload form in a popup window |
| 82 | + * (this shold be moved to an iframe) */ |
| 83 | + popup = open( |
| 84 | + wgServer + wgScript + "/Special:CustomToolbarUpload?type=attachment§ion=" + section, |
| 85 | + null, "scrollbars=no, status=no, width=600, height=400" |
| 86 | + ); |
| 87 | + |
| 88 | + /* check if the popup window wasn't blocked; if |
| 89 | + * it was, then display a notice to let the user |
| 90 | + * know that we didn't set them up the bomb */ |
| 91 | + if (popup != null && popup.opener != null) popup.opener = self; |
| 92 | + else alert (wfMsg('ct_popupblocked')); |
| 93 | + } |
| 94 | + }, |
| 95 | + 'user': { |
| 96 | + 'key': "u", |
| 97 | + 'open': "[[" + wfMsg('ct_user_user') + ":", |
| 98 | + 'close': "]]", |
| 99 | + 'sample': wfMsg('ct_user_sample'), |
| 100 | + 'tip': wfMsg('ct_user_tip'), |
| 101 | + 'caption': wfMsg('ct_user_caption'), |
| 102 | + }, |
| 103 | + 'math': { |
| 104 | + 'key': "m", |
| 105 | + 'open': "<math>", |
| 106 | + 'close': "</math>", |
| 107 | + 'sample': wfMsg('ct_math_sample'), |
| 108 | + 'tip': [wfMsg('ct_math_tip_ins'), wfMsg('ct_math_tip_wrap')], |
| 109 | + 'caption': wfMsg('ct_math_caption'), |
| 110 | + 'advanced': true |
| 111 | + }, |
| 112 | + 'nowiki': { |
| 113 | + 'key': "n", |
| 114 | + 'open': "<nowiki>", |
| 115 | + 'close': "</nowiki>", |
| 116 | + 'sample': wfMsg('ct_nowiki_sample'), |
| 117 | + 'tip': [wfMsg('ct_nowiki_tip_ins'), wfMsg('ct_nowiki_tip_wrap')], |
| 118 | + 'caption': wfMsg('ct_nowiki_caption'), |
| 119 | + 'advanced': true |
| 120 | + }, |
| 121 | + 'horizontal-line': { |
| 122 | + 'key': "-", |
| 123 | + 'open': "\n----\n", |
| 124 | + 'close': "", |
| 125 | + 'sample': "", |
| 126 | + 'tip': wfMsg('ct_horizontal_tip'), |
| 127 | + 'caption': wfMsg('ct_horizontal_caption'), |
| 128 | + 'advanced': true |
| 129 | + } |
| 130 | + }, |
| 131 | + |
| 132 | + attach: function(elements, advanced) { |
| 133 | + var buttons = $H(Uniwiki.CustomToolbar.Buttons); |
| 134 | + |
| 135 | + /* accept either an array of elements, |
| 136 | + * or a single element (which we will |
| 137 | + * just bundle into a temp array */ |
| 138 | + if ($type(elements) != "array") |
| 139 | + elements = [elements]; |
| 140 | + |
| 141 | + // iterate elements, to add a toolbar to each |
| 142 | + elements.each (function (txta) { |
| 143 | + var wrapper = new Element ("div", { 'class': "editor-wrap" }); |
| 144 | + var toolbar = new Element ("div", { 'class': "toolbar" }); |
| 145 | + |
| 146 | + // create and append the buttons |
| 147 | + buttons.each (function (button,name) { |
| 148 | + |
| 149 | + /* only add this button if this button is NOT |
| 150 | + * advanced-only, or this txta is advanced */ |
| 151 | + if (advanced || !button.advanced) { |
| 152 | + var div = new Element("div", { |
| 153 | + 'class': "button but-" + name, |
| 154 | + 'html': (button.caption || name) |
| 155 | + }).inject(toolbar); |
| 156 | + var func = null; |
| 157 | + |
| 158 | + /* if this button has its own click handler, |
| 159 | + * then attach it, and pass it a reference to |
| 160 | + * the textarea which it will insert stuff into */ |
| 161 | + if (button.func) { |
| 162 | + func = function() { button.func(txta); } |
| 163 | + |
| 164 | + /* otherwise, the button will just be wrapping |
| 165 | + * selected text in wiki markup, which is the |
| 166 | + * same function every time */ |
| 167 | + } else { |
| 168 | + func = function() { |
| 169 | + /* either wrap up the current selection |
| 170 | + * in the wiki tags, or insert the wrapped |
| 171 | + * sample, using the wonderful CNET forms |
| 172 | + * extension to MooTools */ |
| 173 | + txta.insertAroundCursor({ |
| 174 | + 'before': button.open, |
| 175 | + 'after': button.close, |
| 176 | + 'defaultMiddle': button.sample |
| 177 | + }, true); |
| 178 | + } |
| 179 | + } |
| 180 | + div.addEvent ("click", func); |
| 181 | + |
| 182 | + // if this button has a hotkey, we will append it to the tooltip |
| 183 | + var suffix = button.key ? (" [ctrl-" + button.key + "]") : ""; |
| 184 | + |
| 185 | + /* add the static tooltip to the button, or if a dual- |
| 186 | + * tool-tip were provided ([0] = no selection, [1] = |
| 187 | + * text is selected), add the event to facilitate */ |
| 188 | + if ($type(button.tip) == "array") { |
| 189 | + div.addEvent ("mouseover", function() { |
| 190 | + if (txta.getSelectedText().length) div.title = button.tip[1] + suffix; |
| 191 | + else div.title = button.tip[0] + suffix; |
| 192 | + }); |
| 193 | + } else if(button.tip) |
| 194 | + div.title = button.tip + suffix; |
| 195 | + |
| 196 | + /* if this button has a hotkey, then store it in the div, |
| 197 | + * so we can iterate them later on, in txta.keypress */ |
| 198 | + if (button.key) div.store('key', button.key); |
| 199 | + } |
| 200 | + }); |
| 201 | + |
| 202 | + wrapper.inject(txta, "before"); |
| 203 | + toolbar.inject(wrapper); |
| 204 | + txta.inject(wrapper); |
| 205 | + |
| 206 | + /* when a key is pressed, check the hotkeys of |
| 207 | + * each button, and trigger one if relevent |
| 208 | + * (eg, ctrl+b = bold) */ |
| 209 | + txta.addEvent('keypress', function(e) { |
| 210 | + if (!e.control) return true; |
| 211 | + |
| 212 | + // find all of the buttons relevant to this txta |
| 213 | + var my_buttons = e.target.getParent().getElements(".button"); |
| 214 | + |
| 215 | + var found = false; |
| 216 | + my_buttons.each (function(button) { |
| 217 | + if(button.retrieve("key") == e.key) { |
| 218 | + button.fireEvent("click"); |
| 219 | + found = true; |
| 220 | + |
| 221 | + /* switch the button to it's hover |
| 222 | + * state for a very short time, to |
| 223 | + * show the user what just happened */ |
| 224 | + button.addClass("hover"); |
| 225 | + (function() { button.removeClass("hover"); }).delay(250); |
| 226 | + } |
| 227 | + }); |
| 228 | + |
| 229 | + /* if we did something, then prevent the event from |
| 230 | + * bubbling, to cancel browser behaviours (ctrl+b |
| 231 | + * opens the bookmarks sidebar in mozilla, etc) */ |
| 232 | + if (found) e.stop(); |
| 233 | + }); |
| 234 | + }); |
| 235 | + }, |
| 236 | + insertIntoSection: function(index, text){ |
| 237 | + var txta = $$("#section-"+ index + " textarea")[0]; |
| 238 | + txta.insertAtCursor(text, true); |
| 239 | + }, |
| 240 | + insertIntoClassic: function(text){ |
| 241 | + var txta = $$("#wpTextbox1")[0]; |
| 242 | + txta.insertAtCursor(text, true); |
| 243 | + }, |
| 244 | + /* function poached from skins/common/upload.js |
| 245 | + * and modified to take the path and values |
| 246 | + * rather than getElementById-ing them */ |
| 247 | + fillDestFilename: function(path, destFile) { |
| 248 | + // Find trailing part |
| 249 | + var slash = path.lastIndexOf('/'); |
| 250 | + var backslash = path.lastIndexOf('\\\\'); |
| 251 | + var fname; |
| 252 | + if (slash == -1 && backslash == -1) { |
| 253 | + fname = path; |
| 254 | + } else if (slash > backslash) { |
| 255 | + fname = path.substring(slash+1, 10000); |
| 256 | + } else { |
| 257 | + fname = path.substring(backslash+1, 10000); |
| 258 | + } |
| 259 | + // Capitalise first letter and replace spaces by underscores |
| 260 | + fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_'); |
| 261 | + // Output result |
| 262 | + destFile.value = fname; |
| 263 | + } |
| 264 | +}; |
| 265 | + |
| 266 | +/* add the toolbar to all textareas (including the |
| 267 | + * advanced editor, in advanced mode) ASAP */ |
| 268 | +window.addEvent('domready', function() { |
| 269 | + Uniwiki.CustomToolbar.attach($$(".generic-editor textarea.editor")); |
| 270 | + Uniwiki.CustomToolbar.attach($$("#wpTextbox1"), true); |
| 271 | +}); |
| 272 | + |
Index: trunk/extensions/uniwiki/CustomToolbar/Element.Forms.js |
— | — | @@ -0,0 +1,157 @@ |
| 2 | +/* |
| 3 | +Script: Element.Forms.js |
| 4 | + Extends the Element native object to include methods useful in managing inputs. |
| 5 | + |
| 6 | +License: |
| 7 | + http://clientside.cnet.com/wiki/cnet-libraries#license |
| 8 | +*/ |
| 9 | +Element.implement({ |
| 10 | + tidy: function(){ |
| 11 | + try { |
| 12 | + this.set('value', this.get('value').tidy()); |
| 13 | + }catch(e){dbug.log('element.tidy error: %o', e);} |
| 14 | + }, |
| 15 | + getTextInRange: function(start, end) { |
| 16 | + return this.get('value').substring(start, end); |
| 17 | + }, |
| 18 | + getSelectedText: function() { |
| 19 | + if(Browser.Engine.trident) return document.selection.createRange().text; |
| 20 | + return this.get('value').substring(this.getSelectionStart(), this.getSelectionEnd()); |
| 21 | + }, |
| 22 | + getBookmarkOffset: function() { |
| 23 | + if(Browser.Engine.trident) { |
| 24 | + var tmp_range = this.createTextRange(); |
| 25 | + tmp_range.move("character", 0); |
| 26 | + return tmp_range.getBookmark().charCodeAt(2); |
| 27 | + } else return null; |
| 28 | + }, |
| 29 | + getSelectionStart: function() { |
| 30 | + if(Browser.Engine.trident) { |
| 31 | + this.focus(); |
| 32 | + var range = document.selection.createRange(); |
| 33 | + if (range.compareEndPoints("StartToEnd", range) != 0) range.collapse(true); |
| 34 | + return range.getBookmark().charCodeAt(2) - this.getBookmarkOffset(); |
| 35 | + } |
| 36 | + return this.selectionStart; |
| 37 | + }, |
| 38 | + getSelectionEnd: function() { |
| 39 | + if(Browser.Engine.trident) { |
| 40 | + var range = document.selection.createRange(); |
| 41 | + if (range.compareEndPoints("StartToEnd", range) != 0) range.collapse(false); |
| 42 | + return range.getBookmark().charCodeAt(2) - this.getBookmarkOffset(); |
| 43 | + } |
| 44 | + return this.selectionEnd; |
| 45 | + }, |
| 46 | + getSelectedRange: function() { |
| 47 | + return { |
| 48 | + start: this.getSelectionStart(), |
| 49 | + end: this.getSelectionEnd() |
| 50 | + } |
| 51 | + }, |
| 52 | + setCaretPosition: function(pos) { |
| 53 | + if(pos == 'end') pos = this.get('value').length; |
| 54 | + this.selectRange(pos, pos); |
| 55 | + return this; |
| 56 | + }, |
| 57 | + getCaretPosition: function() { |
| 58 | + return this.getSelectedRange().start; |
| 59 | + }, |
| 60 | + selectRange: function(start, end) { |
| 61 | + this.focus(); |
| 62 | + if(Browser.Engine.trident) { |
| 63 | + var range = this.createTextRange(); |
| 64 | + range.collapse(true); |
| 65 | + range.moveStart('character', start); |
| 66 | + range.moveEnd('character', end - start); |
| 67 | + range.select(); |
| 68 | + return this; |
| 69 | + } |
| 70 | + this.setSelectionRange(start, end); |
| 71 | + return this; |
| 72 | + }, |
| 73 | + insertAtCursor: function(value, select) { |
| 74 | + var start = this.getSelectionStart(); |
| 75 | + var end = this.getSelectionEnd(); |
| 76 | + this.set('value', this.get('value').substring(0, start) + value + this.get('value').substring(end, this.get('value').length)); |
| 77 | + if($pick(select, true)) this.selectRange(start, start + value.length); |
| 78 | + else this.setCaretPosition(start + value.length); |
| 79 | + return this; |
| 80 | + }, |
| 81 | + insertAroundCursor: function(options, select) { |
| 82 | + options = $merge({ |
| 83 | + before: '', |
| 84 | + defaultMiddle: 'SOMETHING HERE', |
| 85 | + after: '' |
| 86 | + }, options); |
| 87 | + value = this.getSelectedText() || options.defaultMiddle; |
| 88 | + var start = this.getSelectionStart(); |
| 89 | + var end = this.getSelectionEnd(); |
| 90 | + if(start == end) { |
| 91 | + var text = this.get('value'); |
| 92 | + this.set('value', text.substring(0, start) + options.before + value + options.after + text.substring(end, text.length)); |
| 93 | + this.selectRange(start + options.before.length, end + options.before.length + value.length); |
| 94 | + text = null; |
| 95 | + } else { |
| 96 | + text = this.get('value').substring(start, end); |
| 97 | + this.set('value', this.get('value').substring(0, start) + options.before + text + options.after + this.get('value').substring(end, this.get('value').length)); |
| 98 | + var selStart = start + options.before.length; |
| 99 | + if($pick(select, true)) this.selectRange(selStart, selStart + text.length); |
| 100 | + else this.setCaretPosition(selStart + text.length); |
| 101 | + } |
| 102 | + return this; |
| 103 | + } |
| 104 | +}); |
| 105 | + |
| 106 | + |
| 107 | +Element.Properties.inputValue = { |
| 108 | + |
| 109 | + get: function(){ |
| 110 | + switch(this.get('tag')) { |
| 111 | + case 'select': |
| 112 | + vals = this.getSelected().map(function(op){ return $pick(op.get('value'),op.get('text')) }); |
| 113 | + return this.get('multiple')?vals:vals[0]; |
| 114 | + case 'input': |
| 115 | + if(['radio','checkbox'].contains(this.get('type'))) |
| 116 | + return this.get('checked')?this.get('name'):false; |
| 117 | + default: |
| 118 | + return this.get('value'); |
| 119 | + } |
| 120 | + }, |
| 121 | + |
| 122 | + set: function(value){ |
| 123 | + switch(this.get('tag')){ |
| 124 | + case 'select': |
| 125 | + this.getElements('option').each(function(op){ |
| 126 | + op.set('selected', $splat(value).contains($pick(op.get('value'), op.get('text')))); |
| 127 | + }); |
| 128 | + break; |
| 129 | + case 'input': |
| 130 | + if (['radio','checkbox'].contains(this.get('type'))) { |
| 131 | + this.set('checked', $type(value)=="boolean"?value:$splat(value).contains(this.get('name'))); |
| 132 | + break; |
| 133 | + } |
| 134 | + default: |
| 135 | + this.set('value', value); |
| 136 | + } |
| 137 | + return this; |
| 138 | + }, |
| 139 | + |
| 140 | + erase: function() { |
| 141 | + switch(this.get('tag')) { |
| 142 | + case 'select': |
| 143 | + this.getElements('option').each(function(op) { |
| 144 | + op.set('selected', false); |
| 145 | + }); |
| 146 | + break; |
| 147 | + case 'input': |
| 148 | + if (['radio','checkbox'].contains(this.get('type'))) { |
| 149 | + this.set('checked', false); |
| 150 | + break; |
| 151 | + } |
| 152 | + default: |
| 153 | + this.set('value', ''); |
| 154 | + } |
| 155 | + return this; |
| 156 | + } |
| 157 | + |
| 158 | +}; |
Index: trunk/extensions/uniwiki/CustomToolbar/CustomToolbar.i18n.php |
— | — | @@ -0,0 +1,216 @@ |
| 2 | +<?php |
| 3 | +/* Internationalisation file for CustomToolbar extension. |
| 4 | + */ |
| 5 | + |
| 6 | +$wgCustomToolbarMessages = array(); |
| 7 | + |
| 8 | +$wgCustomToolbarMessages['en'] = array( |
| 9 | + 'ct_bold_sample' => "Bold text", |
| 10 | + 'ct_bold_tip_ins' => "Insert bold text", |
| 11 | + 'ct_bold_tip_wrap' => "Make this text bold", |
| 12 | + 'ct_bold_caption' => "Bold", |
| 13 | + |
| 14 | + 'ct_italic_sample' => "Italic text", |
| 15 | + 'ct_italic_tip_ins' => "Insert italic text", |
| 16 | + 'ct_italic_tip_wrap' => "Make this text italic", |
| 17 | + 'ct_italic_caption' => "Italic", |
| 18 | + |
| 19 | + 'ct_internal_sample' => "PageName", |
| 20 | + 'ct_internal_tip_ins' => "Insert an internal link", |
| 21 | + 'ct_internal_tip_wrap' => "Make this text an internal link", |
| 22 | + 'ct_internal_caption' => "Internal Link", |
| 23 | + |
| 24 | + 'ct_external_sample' => "http://example.com", |
| 25 | + 'ct_external_tip_ins' => "Insert an external link", |
| 26 | + 'ct_external_tip_wrap' => "Make this text an external link", |
| 27 | + 'ct_external_caption' => "External Link", |
| 28 | + |
| 29 | + 'ct_image_tip' => "Insert an image", |
| 30 | + 'ct_image_caption' => "Add Image", |
| 31 | + |
| 32 | + 'ct_attachment_tip' => "Insert an attachment", |
| 33 | + 'ct_attachment_caption' => "Add Attachment", |
| 34 | + |
| 35 | + 'ct_math_sample' => "Insert LaTeX formula here", |
| 36 | + 'ct_math_tip_ins' => "Insert mathematical formula (LaTeX)", |
| 37 | + 'ct_math_tip_wrap' => "Make this text a mathematical formula (LaTeX)", |
| 38 | + 'ct_math_caption' => "Formula", |
| 39 | + |
| 40 | + 'ct_nowiki_sample' => "Insert non-formatted text here", |
| 41 | + 'ct_nowiki_tip_ins' => "Ignore wiki formatting", |
| 42 | + 'ct_nowiki_tip_wrap' => "Ignore wiki formattting for this text", |
| 43 | + 'ct_nowiki_caption' => "No Wiki", |
| 44 | + |
| 45 | + 'ct_horizontal_tip' => "Insert a horizontal line (use sparingly)", |
| 46 | + 'ct_horizontal_caption' => "Horizontal Line", |
| 47 | + |
| 48 | + 'ct_upload' => "Upload $1", |
| 49 | + 'ct_select' => "Select $1 to upload", |
| 50 | + 'ct_caption' => "Add caption (optional)", |
| 51 | + 'ct_link' => "Add link name (optional)", |
| 52 | + 'ct_submit' => "Go!", |
| 53 | + 'ct_close' => "Close window", |
| 54 | + 'ct_success' => "File upload successful!", |
| 55 | + 'ct_popupblocked' => "The upload popup was prevented from opening. Please check your popup blocker.", |
| 56 | + |
| 57 | + 'ct_user_user' => "User", |
| 58 | + 'ct_user_tip' => "Insert a link to a user page", |
| 59 | + 'ct_user_caption' => "User Link", |
| 60 | + 'ct_user_sample' => "Username" |
| 61 | +); |
| 62 | + |
| 63 | +$wgCustomToolbarMessages['es'] = array( |
| 64 | + 'ct_bold_sample' => "Texto en negrita", |
| 65 | + 'ct_bold_tip_ins' => "Insertar texto en negrita", |
| 66 | + 'ct_bold_tip_wrap' => "Convertir este texto en negrita ", |
| 67 | + 'ct_bold_caption' => "Negrita", |
| 68 | + |
| 69 | + 'ct_italic_sample' => "Texto en cursiva", |
| 70 | + 'ct_italic_tip_ins' => "Insertar texto en cursiva", |
| 71 | + 'ct_italic_tip_wrap' => "Convertir este texto en cursiva ", |
| 72 | + 'ct_italic_caption' => "Cursiva", |
| 73 | + |
| 74 | + 'ct_internal_sample' => "Título del enlace", |
| 75 | + 'ct_internal_tip_ins' => "Insertar un enlace interno", |
| 76 | + 'ct_internal_tip_wrap' => "Convertir este texto en un enlace interno", |
| 77 | + 'ct_internal_caption' => "Enlace interno", |
| 78 | + |
| 79 | + 'ct_external_sample' => "http://ejemplo.com", |
| 80 | + 'ct_external_tip_ins' => "Insertar un enlace externo", |
| 81 | + 'ct_external_tip_wrap' => "Convertir este texto en un enlace externo", |
| 82 | + 'ct_external_caption' => "Enlace externo", |
| 83 | + |
| 84 | + 'ct_image_tip' => "Insertar una imagen", |
| 85 | + 'ct_image_caption' => "Agregar imagen", |
| 86 | + |
| 87 | + 'ct_attachment_tip' => "Insertar un archivo adjunto", |
| 88 | + 'ct_attachment_caption' => "Agregar archivo adjunto", |
| 89 | + |
| 90 | + 'ct_math_sample' => "Insertar la fórmula LaTeX aquí", |
| 91 | + 'ct_math_tip_ins' => "Insertar la fórmula matemática (LaTeX)", |
| 92 | + 'ct_math_tip_wrap' => "Convertir este texto en una fórmula matemática (LaTeX)", |
| 93 | + 'ct_math_caption' => "Fórmula", |
| 94 | + |
| 95 | + 'ct_nowiki_sample' => "Insertar aquí el texto no formateado", |
| 96 | + 'ct_nowiki_tip_ins' => "Ignorar el formato wiki", |
| 97 | + 'ct_nowiki_tip_wrap' => "Ignorar el formato wiki para este texto", |
| 98 | + 'ct_nowiki_caption' => "Sin Wiki", |
| 99 | + |
| 100 | + 'ct_horizontal_tip' => "Insertar una línea horizontal (utilizar con moderación)", |
| 101 | + 'ct_horizontal_caption' => "Línea Horizontal", |
| 102 | + |
| 103 | + 'ct_upload' => "Subir $1", |
| 104 | + 'ct_select' => "Seleccionar $1 para subirlo", |
| 105 | + 'ct_caption' => "Agregar un subtítulo (opcional)", |
| 106 | + 'ct_link' => "Agregar el nombre del enlace (opcional)", |
| 107 | + 'ct_submit' => "¡Ir!", |
| 108 | + 'ct_close' => "Cerrar la ventana ", |
| 109 | + 'ct_success' => "¡El archivo se subió con éxito!", |
| 110 | + 'ct_popupblocked' => "No se pudo abrir la ventana para subir el archivo. Revise su bloqueador de ventanas emergentes." |
| 111 | +); |
| 112 | + |
| 113 | +$wgCustomToolbarMessages['de'] = array( |
| 114 | + 'ct_bold_sample' => "Fetter Text", |
| 115 | + 'ct_bold_tip_ins' => "Fetten Text einfügen", |
| 116 | + 'ct_bold_tip_wrap' => "Diesen Text fett markieren", |
| 117 | + 'ct_bold_caption' => "Fett", |
| 118 | + |
| 119 | + 'ct_italic_sample' => "Kursiver Text", |
| 120 | + 'ct_italic_tip_ins' => "Kursiven Text einfügen", |
| 121 | + 'ct_italic_tip_wrap' => "Diesen Text kursiv markieren", |
| 122 | + 'ct_italic_caption' => "Kursiv", |
| 123 | + |
| 124 | + 'ct_internal_sample' => "Seitenname", |
| 125 | + 'ct_internal_tip_ins' => "Einen internen Link einfügen", |
| 126 | + 'ct_internal_tip_wrap' => "Diesen Text in einen internen Link umwandeln", |
| 127 | + 'ct_internal_caption' => "Interner Link", |
| 128 | + |
| 129 | + 'ct_external_sample' => "http://beispiel.de", |
| 130 | + 'ct_external_tip_ins' => "Einen externen Link einfügen", |
| 131 | + 'ct_external_tip_wrap' => "Diesen Text in einen externen Link umwandeln", |
| 132 | + 'ct_external_caption' => "Externer Link", |
| 133 | + |
| 134 | + 'ct_image_tip' => "Ein Bild einfügen", |
| 135 | + 'ct_image_caption' => "Bild einfügen", |
| 136 | + |
| 137 | + 'ct_attachment_tip' => "Eine Anlage einfuegen", |
| 138 | + 'ct_attachment_caption' => "Eine Anlage anfuegen", |
| 139 | + |
| 140 | + 'ct_math_sample' => "Hier LaTeX Formel einfügen", |
| 141 | + 'ct_math_tip_ins' => "Hier mathematische Formel einfügen (LaTeX)", |
| 142 | + 'ct_math_tip_wrap' => "Diesen Text in eine mathematische Formel umwandeln (LaTeX)", |
| 143 | + 'ct_math_caption' => "Formel", |
| 144 | + |
| 145 | + 'ct_nowiki_sample' => "Hier unformatierten Text eingeben", |
| 146 | + 'ct_nowiki_tip_ins' => "Ignoriere wiki Formatierung", |
| 147 | + 'ct_nowiki_tip_wrap' => "Ignoriere wiki Formatierung für diesen Text", |
| 148 | + 'ct_nowiki_caption' => "Keine Wiki", |
| 149 | + |
| 150 | + 'ct_horizontal_tip' => "Eine waagrechte Linie einfügen (nicht alzu oft verwenden)", |
| 151 | + 'ct_horizontal_caption' => "Waagrechte Linie", |
| 152 | + |
| 153 | + 'ct_upload' => "Hochladen $1", |
| 154 | + 'ct_select' => "Wähle $1 zum hochladen.", |
| 155 | + 'ct_caption' => "Beschriftung einfügen (optional)", |
| 156 | + 'ct_link' => "Link benennen (optional)", |
| 157 | + 'ct_submit' => "Go!", |
| 158 | + 'ct_close' => "Fenster schliessen", |
| 159 | + 'ct_success' => "Datei erfolgreich hochgeladen!", |
| 160 | + 'ct_popupblocked' => "Das Hochladen-Popup wurde am Öffnen gehindert. Bitte überprüfe Deinen Popup-Blocker.", |
| 161 | + |
| 162 | + 'ct_user_user' => "Benutzer", |
| 163 | + 'ct_user_tip' => "Einen Link zu der Seite eines Freundes einfügen", |
| 164 | + 'ct_user_caption' => "Einen Link zu einem Freund einfügen", |
| 165 | + 'ct_user_sample' => "Benutzername" |
| 166 | +); |
| 167 | + |
| 168 | +$wgCustomToolbarMessages['pt-br'] = array( |
| 169 | + 'ct_bold_sample' => "Texto em negrito", |
| 170 | + 'ct_bold_tip_ins' => "Digitar texto em negrito", |
| 171 | + 'ct_bold_tip_wrap' => "Colocar este texto em negrito", |
| 172 | + 'ct_bold_caption' => "Negrito", |
| 173 | + |
| 174 | + 'ct_italic_sample' => "Texto em itálico", |
| 175 | + 'ct_italic_tip_ins' => "Digitar texto em itálico", |
| 176 | + 'ct_italic_tip_wrap' => "Colocar este texto em itálico", |
| 177 | + 'ct_italic_caption' => "Itálico", |
| 178 | + |
| 179 | + 'ct_internal_sample' => "Título do link", |
| 180 | + 'ct_internal_tip_ins' => "Inserir um link interno", |
| 181 | + 'ct_internal_tip_wrap' => "Transformar este texto em link interno", |
| 182 | + 'ct_internal_caption' => "Link Interno", |
| 183 | + |
| 184 | + 'ct_external_sample' => "http://exemplo.com", |
| 185 | + 'ct_external_tip_ins' => "Incluir um link externo", |
| 186 | + 'ct_external_tip_wrap' => "Transformar este texto em link externo", |
| 187 | + 'ct_external_caption' => "Link Externo", |
| 188 | + |
| 189 | + 'ct_image_tip' => "Carregar uma imagem", |
| 190 | + 'ct_image_caption' => "Adicionar uma Imagem", |
| 191 | + |
| 192 | + 'ct_attachment_tip' => "Incluir um anexo", |
| 193 | + 'ct_attachment_caption' => "Adicionar um Anexo", |
| 194 | + |
| 195 | + 'ct_math_sample' => "Incluir fórmula LaTeX aqui", |
| 196 | + 'ct_math_tip_ins' => "Incluir fórmula matemática (LaTeX)", |
| 197 | + 'ct_math_tip_wrap' => "Transformar este texto em fórmula matemática (LaTeX)", |
| 198 | + 'ct_math_caption' => "Fórmula", |
| 199 | + |
| 200 | + 'ct_nowiki_sample' => "Inserir aqui o texto não formatado", |
| 201 | + 'ct_nowiki_tip_ins' => "Ignorar a formatação wiki", |
| 202 | + 'ct_nowiki_tip_wrap' => "Ignorar a formatação wiki neste texto", |
| 203 | + 'ct_nowiki_caption' => "Sem wiki", |
| 204 | + |
| 205 | + 'ct_horizontal_tip' => "Incluir uma linha horizontal (use com moderação)", |
| 206 | + 'ct_horizontal_caption' => "Linha Horizontal", |
| 207 | + |
| 208 | + 'ct_upload' => "Carregar $1", |
| 209 | + 'ct_select' => "Selecionar $1 para carregar o arquivo", |
| 210 | + 'ct_caption' => "Incluir uma explicação (opcional)", |
| 211 | + 'ct_link' => "Incluir um nome para o link (opcional)", |
| 212 | + 'ct_submit' => "Salvar", |
| 213 | + 'ct_close' => "Fechar a janela", |
| 214 | + 'ct_success' => "O arquivo foi carregado com sucesso!", |
| 215 | + 'ct_popupblocked' => "O pop-up para carregar o arquivo foi bloqueado. Verifique o seu bloqueador de pop-ups." |
| 216 | +); |
| 217 | + |
Index: trunk/extensions/uniwiki/FormatSearch/FormatSearch.php |
— | — | @@ -0,0 +1,26 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | +if (!defined("MEDIAWIKI")) |
| 7 | + die(); |
| 8 | + |
| 9 | + |
| 10 | +/* ---- CREDITS ---- */ |
| 11 | + |
| 12 | +$wgExtensionCredits['other'][] = array( |
| 13 | + 'name' => "Uniwiki Format Search", |
| 14 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 15 | + 'description' => "Minor changes to clean up the search results page" |
| 16 | +); |
| 17 | + |
| 18 | + |
| 19 | +/* ---- HOOKS ---- */ |
| 20 | + |
| 21 | +$wgHooks['BeforePageDisplay'][] = "UW_FormatSearch_CSS"; |
| 22 | +function UW_FormatSearch_CSS (&$out) { |
| 23 | + global $wgScriptPath; |
| 24 | + $href = "$wgScriptPath/extensions/uniwiki/FormatSearch/style.css"; |
| 25 | + $out->addScript ("<link rel='stylesheet' href='$href' />"); |
| 26 | + return true; |
| 27 | +} |
Index: trunk/extensions/uniwiki/FormatSearch/style.css |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +/* vim: noet ts=4 sw=4 |
| 3 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 4 | + |
| 5 | +/* hide the extra search result data */ |
| 6 | +.mw-search-result-data { |
| 7 | + display: none; |
| 8 | +} |
| 9 | + |
| 10 | +/* hide the advanced search form */ |
| 11 | +#powersearch { |
| 12 | + display: none; |
| 13 | +} |
| 14 | + |
| 15 | +/* hide the search at the top */ |
| 16 | +#search { |
| 17 | + display: none; |
| 18 | +} |
Index: trunk/extensions/uniwiki/GenericEditPage/GenericEditPage.i18n.php |
— | — | @@ -0,0 +1,90 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Generic_Edit_Page |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +$wgGenericEditPageMessages = array(); |
| 12 | +$wgGenericEditPageMessages['en'] = array( |
| 13 | + 'gep_emailsubject' => "[$1] Category suggestion: $2", |
| 14 | + 'gep_emailbody' => "User '$1' suggested category '$2' for site '$3'.\n", |
| 15 | + 'gep_emailfailure' => "Sorry, your suggestion could not be processed.", |
| 16 | + 'gep_emailsuccess' => "Thanks for suggesting the category: $1.", |
| 17 | + 'gep_categories' => "Categories", |
| 18 | + 'gep_addcategory' => "Add a Category", |
| 19 | + 'gep_addcategorybutton' => "Add", |
| 20 | + 'gep_suggestcategory' => "Suggest a Category", |
| 21 | + 'gep_suggestcategorybutton' => "Submit", |
| 22 | + 'gep_sections' => "Sections", |
| 23 | + 'gep_sectionnotdisabled' => "This section cannot be disabled", |
| 24 | + 'gep_addsection' => "Add a Section", |
| 25 | + 'gep_addsectionbutton' => "Add", |
| 26 | + 'gep_classicmode' => "Classic Mode", |
| 27 | + 'gep_genericmode' => "Generic Mode", |
| 28 | + 'gep_nosectioninstructions' => "There are no sections on this page. Add some using the tools on the right.", |
| 29 | + 'gep_nocategories' => "Please select at least one category before saving" |
| 30 | +); |
| 31 | + |
| 32 | +$wgGenericEditPageMessages['es'] = array( |
| 33 | + 'gep_emailsubject' => "Sugerencia de categoría de [$1]: $2", |
| 34 | + 'gep_emailbody' => "El usuario '$1' sugirió la categoría '$2' para el sitio '$3'.\n", |
| 35 | + 'gep_emailfailure' => "No fue posible procesar su sugerencia.", |
| 36 | + 'gep_emailsuccess' => "Gracias por sugerir la categoría: $1.", |
| 37 | + 'gep_categories' => "Categorías", |
| 38 | + 'gep_addcategory' => "Agregar una Categoría", |
| 39 | + 'gep_addcategorybutton' => "Agregar", |
| 40 | + 'gep_suggestcategory' => "Sugerir una Categoría", |
| 41 | + 'gep_suggestcategorybutton' => "Enviar", |
| 42 | + 'gep_sections' => "Secciones", |
| 43 | + 'gep_sectionnotdisabled' => "Esta sección no se puede desactivar", |
| 44 | + 'gep_addsection' => "Agregar una Sección", |
| 45 | + 'gep_addsectionbutton' => "Agregar", |
| 46 | + 'gep_classicmode' => "Modo Clásico", |
| 47 | + 'gep_genericmode' => "Modo Genérico", |
| 48 | + 'gep_nosectioninstructions' => "No hay secciones en esta página. Agrega algunas secciones utilizando las herramientas a la derecha.", |
| 49 | + 'gep_nocategories' => "Selecciona por lo menos una categoría antes de guardar" |
| 50 | +); |
| 51 | + |
| 52 | +$wgGenericEditPageMessages['de'] = array( |
| 53 | + 'gep_emailsubject' => "[$1] Vorschlag Kategorie: $2", |
| 54 | + 'gep_emailbody' => "User '$1' hat die Kategorie '$2' für die Seite '$3'. ausgewählt\n", |
| 55 | + 'gep_emailfailure' => "Leider, konnte Deine Änderung nicht verarbeitet werden.", |
| 56 | + 'gep_emailsuccess' => "Danke für den Vorschlag der Kategorie: $1.", |
| 57 | + 'gep_categories' => "Kategorien", |
| 58 | + 'gep_addcategory' => "Eine Kategorie einfügen", |
| 59 | + 'gep_addcategorybutton' => "Einfügen", |
| 60 | + 'gep_suggestcategory' => "Eine Kategorie vorschlagen", |
| 61 | + 'gep_suggestcategorybutton' => "Senden", |
| 62 | + 'gep_sections' => "Abschnitte", |
| 63 | + 'gep_sectionnotdisabled' => "Dieser Abschnitt kann nicht aufgehoben werden", |
| 64 | + 'gep_addsection' => "Einen Abschnitt einfügen", |
| 65 | + 'gep_addsectionbutton' => "Einfügen", |
| 66 | + 'gep_classicmode' => "Normaler Modus", |
| 67 | + 'gep_genericmode' => "Genereller Modus", |
| 68 | + 'gep_nosectioninstructions' => "Diese Seite hat keine Abschnitte. Gib ein paar ein mit den Werkzeugen an der rechten Seite.", |
| 69 | + 'gep_nocategories' => "Bitte vor Abspeichern, mindestens eine Kategorie aussuchen" |
| 70 | +); |
| 71 | + |
| 72 | +$wgGenericEditPageMessages['pt-br'] = array( |
| 73 | + 'gep_emailsubject' => "Sugestão de categoria de [$1] : $2", |
| 74 | + 'gep_emailbody' => "O usuário '$1' sugeriu a categoria '$2' para o site '$3'.\n", |
| 75 | + 'gep_emailfailure' => "Não foi possível processar a sua sugestão.", |
| 76 | + 'gep_emailsuccess' => "Obrigado por sugerir essa categoria: $1.", |
| 77 | + 'gep_categories' => "Categorias", |
| 78 | + 'gep_addcategory' => "Adicionar uma Categoria", |
| 79 | + 'gep_addcategorybutton' => "Adicionar", |
| 80 | + 'gep_suggestcategory' => "Sugerir uma Categoria", |
| 81 | + 'gep_suggestcategorybutton' => "Encaminhar", |
| 82 | + 'gep_sections' => "Seções", |
| 83 | + 'gep_sectionnotdisabled' => "Esta seção não pode ser desativada", |
| 84 | + 'gep_addsection' => "Adicionar uma Seção", |
| 85 | + 'gep_addsectionbutton' => "Acrescentar", |
| 86 | + 'gep_classicmode' => "Modo Clássico", |
| 87 | + 'gep_genericmode' => "Modo Genérico", |
| 88 | + 'gep_nosectioninstructions' => "Não há seções nesta página. Use as ferramentas à direita para incluir algumas seções.", |
| 89 | + 'gep_nocategories' => "Selecione, no mínimo, uma categoria antes de salvar" |
| 90 | +); |
| 91 | + |
Index: trunk/extensions/uniwiki/GenericEditPage/GenericEditPage.php |
— | — | @@ -0,0 +1,772 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Generic_Edit_Page |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined('MEDIAWIKI')) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +$wgExtensionCredits['other'][] = array( |
| 14 | + 'name' => "Uniwiki Generic Edit Page", |
| 15 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 16 | + 'description' => "Suppliments the edit page with something more usable" |
| 17 | +); |
| 18 | + |
| 19 | + |
| 20 | +/* ---- CONFIGURABLE OPTIONS ---- */ |
| 21 | + |
| 22 | +$wgSectionBox = true; |
| 23 | +$wgCategoryBox = true; |
| 24 | +$wgAddSection = true; |
| 25 | +$wgAddCategory = true; |
| 26 | +$wgSuggestCategory = false; |
| 27 | +$wgSuggestCategoryRecipient = $wgEmergencyContact; |
| 28 | +$wgUseCategoryPage = false; |
| 29 | +$wgCategoryPage = "MediaWiki:Editpagetags"; |
| 30 | +$wgRequireCategory = false; |
| 31 | +$wgGenericEditPageWhiteList = array(NS_MAIN); |
| 32 | + |
| 33 | +/* not configurable. in fact, |
| 34 | + * it's a big ugly hack */ |
| 35 | +$wgSwitchMode = false; |
| 36 | + |
| 37 | + |
| 38 | +/* ---- INTERNATIONALIZATION ---- */ |
| 39 | + |
| 40 | +require_once ("GenericEditPage.i18n.php"); |
| 41 | +$wgExtensionFunctions[] = "UW_GenericEditPage_i18n"; |
| 42 | + |
| 43 | +function UW_GenericEditPage_i18n() { |
| 44 | + // add this extension's messages to the message cache |
| 45 | + global $wgMessageCache, $wgGenericEditPageMessages; |
| 46 | + foreach ($wgGenericEditPageMessages as $lang => $messages) |
| 47 | + $wgMessageCache->addMessages ($messages, $lang); |
| 48 | +} |
| 49 | + |
| 50 | + |
| 51 | +/* ---- HOOKS ---- */ |
| 52 | + |
| 53 | +$wgHooks['BeforePageDisplay'][] = "UW_GenericEditPage_addJS"; |
| 54 | +function UW_GenericEditPage_addJS($out) { |
| 55 | + global $wgScriptPath; |
| 56 | + $src = "$wgScriptPath/extensions/uniwiki/GenericEditPage/GenericEditPage.js"; |
| 57 | + $out->addScript ("<script type='text/javascript' src='$src'></script>"); |
| 58 | + $href = "$wgScriptPath/extensions/uniwiki/GenericEditPage/global.css"; |
| 59 | + $out->addScript ("<link rel='stylesheet' href='$href' />"); |
| 60 | + return true; |
| 61 | +} |
| 62 | + |
| 63 | +$wgAjaxExportList[] = "UW_GenericEditPage_emailSuggestion"; |
| 64 | +function UW_GenericEditPage_emailSuggestion ($category) { |
| 65 | + global $wgSuggestCategoryRecipient, $wgEmergencyContact, $wgSitename, $wgUser; |
| 66 | + require_once ("UserMailer.php"); |
| 67 | + |
| 68 | + $from = new MailAddress ($wgEmergencyContact); |
| 69 | + $to = new MailAddress ($wgSuggestCategoryRecipient); |
| 70 | + $subj = wfMsg ("gep_emailsubject", $wgSitename, $category); |
| 71 | + $body = wfMsg ("gep_emailbody", $wgUser->getName(), $category, $wgSitename); |
| 72 | + |
| 73 | + // attempt to send the notification |
| 74 | + $result = userMailer ($to, $from, $subj, $body); |
| 75 | + |
| 76 | + /* send a message back to the client, to let them |
| 77 | + * know if the suggestion was successfully sent (or not) */ |
| 78 | + return WikiError::isError ($result) |
| 79 | + ? wfMsg ('gep_emailfailure') |
| 80 | + : wfMsg ('gep_emailsuccess', $category); |
| 81 | +} |
| 82 | + |
| 83 | +function UW_GenericEditPage_extractLayout (&$text) { |
| 84 | + /* match all layout tags (in case, some how, multiple |
| 85 | + * tags have ended up in the wiki markup). only the |
| 86 | + * first tag will be used, but all will be removed */ |
| 87 | + $re = "/\n*<layout\s+name=\"(.+)\"\s+\/>/"; |
| 88 | + preg_match_all ($re, $text, $matches); |
| 89 | + $text = preg_replace ($re, "", $text); |
| 90 | + |
| 91 | + /* if no layout tag was found, this |
| 92 | + * function does nothing useful */ |
| 93 | + if (!$matches[1][0]) return array(); |
| 94 | + |
| 95 | + /* get the wiki markup (containing the |
| 96 | + * directives) from this page's layout */ |
| 97 | + $layout = array(); |
| 98 | + $layout_title = Title::newFromDBkey ("Layout:".$matches[1][0]); |
| 99 | + $layout_article = new Article ($layout_title); |
| 100 | + $layout_text = $layout_article->getContent(); |
| 101 | + |
| 102 | + // add the first element as page meta-data |
| 103 | + // and the second for the untitled first section |
| 104 | + $layout[] = array ("name" => $matches[1][0]); |
| 105 | + $layout[] = array(); |
| 106 | + |
| 107 | + // ignore (delete) the categories on the layout |
| 108 | + $layout_text = preg_replace ("/\[\[category:(.+?)\]\]/i", "", $layout_text); |
| 109 | + |
| 110 | + // break it up into sections (same regex as in displayEditPage) |
| 111 | + $nodes = preg_split ('/^(==?[^=].*)$/mi', $layout_text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 112 | + |
| 113 | + // build an array with the layout section attributes |
| 114 | + for ($i= 0; $i < count ($nodes); $i++) { |
| 115 | + $value = trim ($nodes[$i]); |
| 116 | + |
| 117 | + /* is this block of text a header? |
| 118 | + * update the 'current section' flag ($title), so |
| 119 | + * all following directives are dropped in to it */ |
| 120 | + if (preg_match ('/^(==?)\s*(.+?)\s*\\1$/i', $value, $matches)) { |
| 121 | + $layout[] = array( |
| 122 | + "title" => htmlspecialchars($matches[2]), |
| 123 | + "level" => strlen($matches[1]) |
| 124 | + ); |
| 125 | + |
| 126 | + // not header -> plain text |
| 127 | + } else { |
| 128 | + /* find and iterate all directives in this section, |
| 129 | + * and add them to the last-seen title array */ |
| 130 | + $re = "/^@(.+)$/m"; |
| 131 | + $section_num = count ($layout)-1; |
| 132 | + preg_match_all ($re, $value, $matches); |
| 133 | + foreach ($matches[1] as $attribute) |
| 134 | + $layout[$section_num][$attribute] = true; |
| 135 | + |
| 136 | + // add the remaining stuff as text |
| 137 | + $value = preg_replace ($re, "", $value); |
| 138 | + $layout[$section_num]['text'] = trim($value); |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + return $layout; |
| 143 | +} |
| 144 | + |
| 145 | +function UW_GenericEditPage_extractCategoriesIntoBox(&$text) { |
| 146 | + global $wgDBprefix, $wgAddCategory, $wgSuggestCategory, $wgRequest, |
| 147 | + $wgEmergencyContact, $wgUseCategoryPage, $wgCategoryPage; |
| 148 | + $out = ""; |
| 149 | + |
| 150 | + /* build an array of the categories, either from a page |
| 151 | + * or from all available categories in the wiki */ |
| 152 | + $categories = array(); |
| 153 | + if ($wgUseCategoryPage) { |
| 154 | + |
| 155 | + // from the specified page |
| 156 | + $revision = Revision::newFromTitle (Title::newFromDBKey ($wgCategoryPage)); |
| 157 | + $results = $revision ? split ("\n", $revision->getText()) : array(); |
| 158 | + foreach ($results as $result) { |
| 159 | + if (trim($result) != '') |
| 160 | + $categories[] = Title::newFromText (trim ($result))->getDBkey(); |
| 161 | + } |
| 162 | + } else { |
| 163 | + |
| 164 | + // all the categories |
| 165 | + $db = wfGetDB (DB_MASTER); |
| 166 | + $results = $db->resultObject ($db->query( |
| 167 | + "select distinct cl_to from {$wgDBprefix}categorylinks order by cl_to")); |
| 168 | + |
| 169 | + while ($result = $results->next()) |
| 170 | + $categories[] = $result->cl_to; |
| 171 | + } |
| 172 | + |
| 173 | + // extract the categories on this page |
| 174 | + $regex = "/\[\[category:(.+?)(?:\|.*)?\]\]/i"; |
| 175 | + preg_match_all ($regex, strtolower($text), $matches); |
| 176 | + $text = preg_replace ($regex, "", $text); |
| 177 | + |
| 178 | + // an array of the categories on the page (in db form) |
| 179 | + $on_page = array(); |
| 180 | + foreach ($matches[1] as $cat) |
| 181 | + $on_page[] = strtolower (Title::newFromText ($cat)->getDBkey()); |
| 182 | + |
| 183 | + /* add any categories that may have been passed with the |
| 184 | + * GET request as if they started out on the page */ |
| 185 | + $data = $wgRequest->data; |
| 186 | + foreach ($data as $key => $value) { |
| 187 | + if ($key == 'category') { |
| 188 | + $category = substr ($value, 9); // value = category-categoryname |
| 189 | + $on_page[] = strtolower ($category); |
| 190 | + if (!in_array ($category, $categories)) |
| 191 | + $categories[] = $category; |
| 192 | + } |
| 193 | + } |
| 194 | + |
| 195 | + /* add checkboxes for the categories, |
| 196 | + * with ones from the page already checked */ |
| 197 | + $out .= "<div id='category-box'><h3>".wfMsg ('gep_categories')."</h3>"; |
| 198 | + foreach ($categories as $category) { |
| 199 | + $fm_id = "category-$category"; |
| 200 | + $caption = Title::newFromDBkey ($category)->getText(); |
| 201 | + $checked = in_array (strtolower ($category), $on_page) |
| 202 | + ? "checked='checked'" : ''; |
| 203 | + |
| 204 | + $out .= " |
| 205 | + <div> |
| 206 | + <input type='checkbox' name='$fm_id' id='$fm_id' $checked/> |
| 207 | + <label for='$fm_id'>$caption</label> |
| 208 | + </div> |
| 209 | + "; |
| 210 | + } |
| 211 | + |
| 212 | + // add a text field to add new categories |
| 213 | + if ($wgAddCategory) { |
| 214 | + $out .= " |
| 215 | + <div class='add'> |
| 216 | + <label for='fm-add-cat'>".wfMsg ('gep_addcategory')."</label> |
| 217 | + <input type='text' id='fm-add-cat' autocomplete='off' /> |
| 218 | + <input type='button' value='".wfMsg ('gep_addcategorybutton')."' id='fm-add-cat-button' /> |
| 219 | + </div> |
| 220 | + <script type='text/javascript'> |
| 221 | + // hook up the 'add category' box events |
| 222 | + Uniwiki.GenericEditPage.Events.add_category(); |
| 223 | + </script> |
| 224 | + "; |
| 225 | + } |
| 226 | + |
| 227 | + /* add a text field to suggest a category |
| 228 | + * as email to $wgEmergencyContact */ |
| 229 | + if ($wgSuggestCategory) { |
| 230 | + $out .= " |
| 231 | + <div class='suggest'> |
| 232 | + <label for='fm-suggest-cat'>".wfMsg ('gep_suggestcategory')."</label> |
| 233 | + <input type='text' id='fm-suggest-cat' autocomplete='off' /> |
| 234 | + <input type='button' value='".wfMsg ('gep_suggestcategorybutton')."' id='fm-suggest-cat-button' /> |
| 235 | + </div> |
| 236 | + <script type='text/javascript'> |
| 237 | + $('fm-suggest-cat-button').addEvent ('click', function() { |
| 238 | + var field = this.getPrevious(); |
| 239 | + var that = this; |
| 240 | + |
| 241 | + // only if a category name was entered... |
| 242 | + var cat_name = field.value.trim(); |
| 243 | + if (cat_name != '') { |
| 244 | + sajax_do_call ('emailSuggestion', [cat_name], function (msg) { |
| 245 | + |
| 246 | + /* got response from the server, append it after the |
| 247 | + * suggest form (so subsequent suggestions are injected |
| 248 | + * ABOVE existing suggetions before they're removed) */ |
| 249 | + var n = new Element ('div') |
| 250 | + .injectAfter ('fm-suggest-cat-button', 'after') |
| 251 | + .appendText (msg.responseText) |
| 252 | + .highlight(); |
| 253 | + |
| 254 | + /* fade out and destroy the notification within |
| 255 | + * a timely manner, to keep the DOM tidy */ |
| 256 | + (function() { n.fade() }).delay(6000); |
| 257 | + (function() { n.destroy() }).delay(8000); |
| 258 | + }); |
| 259 | + |
| 260 | + // clear the suggestion |
| 261 | + field.value = ''; |
| 262 | + } |
| 263 | + }); |
| 264 | + |
| 265 | + // catch the ENTER key in the suggestion box, |
| 266 | + // to prevent the entire edit form from submitting |
| 267 | + $('fm-suggest-cat').addEvent ('keypress', function (e) { |
| 268 | + if (e.key == 'enter') { |
| 269 | + this.getNext().fireEvent ('click'); |
| 270 | + e.stop(); |
| 271 | + } |
| 272 | + }); |
| 273 | + </script> |
| 274 | + "; |
| 275 | + } |
| 276 | + |
| 277 | + // end of category box |
| 278 | + $out .= "</div>"; |
| 279 | + return $out; |
| 280 | +} |
| 281 | + |
| 282 | +function UW_GenericEditPage_renderSectionBox ($sections) { |
| 283 | + global $wgAddSection; |
| 284 | + $out = " |
| 285 | + <div id='section-box'> |
| 286 | + <h3>".wfMsg ('gep_sections')."</h3> |
| 287 | + <div class='sortables'> |
| 288 | + "; |
| 289 | + |
| 290 | + for ($i=1; $i<count ($sections); $i++) { |
| 291 | + if ($sections[$i]['required']) { |
| 292 | + |
| 293 | + /* required sections are checked and disabled, but... |
| 294 | + * this doesn't pass a value back to the server! so |
| 295 | + * we must include a hidden field to fill in */ |
| 296 | + $out .= " |
| 297 | + <div id='sect-$i' class='section-box disabled'> |
| 298 | + <input type='hidden' name='enable-$i' value='on' /> |
| 299 | + <input type='checkbox' checked='checked' disabled='disabled' /> |
| 300 | + <label title='".wfMsg ('gep_sectionnotdisabled')."'>{$sections[$i]['title']}</label> |
| 301 | + </div> |
| 302 | + "; |
| 303 | + } else { |
| 304 | + // sections that are currently in us are pre-checked |
| 305 | + $checked = $sections[$i]['in-use'] ? " checked='checked'" : ""; |
| 306 | + $out .= " |
| 307 | + <div id='sect-$i' class='section-box'> |
| 308 | + <input type='checkbox' name='enable-$i' $checked /> |
| 309 | + <label>{$sections[$i]['title']}</label> |
| 310 | + </div> |
| 311 | + "; |
| 312 | + } |
| 313 | + } |
| 314 | + |
| 315 | + $out .= " |
| 316 | + </div> |
| 317 | + "; |
| 318 | + |
| 319 | + if ($wgAddSection) { |
| 320 | + $out .= " |
| 321 | + <div class='add'> |
| 322 | + <label for='fm-add-sect'>".wfMsg ('gep_addsection')."</label> |
| 323 | + <input type='text' id='fm-add-sect' autocomplete='off' /> |
| 324 | + <input type='button' value='".wfMsg ('gep_addsectionbutton')."' id='fm-add-sect-button' /> |
| 325 | + </div> |
| 326 | + <script type='text/javascript'> |
| 327 | + // hook up the 'add section' box events |
| 328 | + Uniwiki.GenericEditPage.Events.add_section(); |
| 329 | + </script> |
| 330 | + "; |
| 331 | + } |
| 332 | + |
| 333 | + $out .= " |
| 334 | + </div> |
| 335 | + <script type='text/javascript'> |
| 336 | + Uniwiki.GenericEditPage.Events.toggle_sections(); |
| 337 | + Uniwiki.GenericEditPage.Events.reorder_sections(); |
| 338 | + </script> |
| 339 | + "; |
| 340 | + |
| 341 | + return $out; |
| 342 | +} |
| 343 | + |
| 344 | +$wgHooks['EditPage::showEditForm:fields'][] = 'UW_GenericEditPage_displayEditPage'; |
| 345 | +function UW_GenericEditPage_displayEditPage ($editor, $out) { |
| 346 | + global $wgHooks, $wgParser, $wgTitle, $wgRequest, $wgUser, $wgCategoryBox, $wgSectionBox, $wgRequireCategory; |
| 347 | + global $wgGenericEditPageClass, $wgSwitchMode, $wgGenericEditPageWhiteList; |
| 348 | + |
| 349 | + // disable this whole thing on conflict and comment pages |
| 350 | + if ($editor->section == "new" || $editor->isConflict) |
| 351 | + return true; |
| 352 | + |
| 353 | + // get the article text (as wiki markup) |
| 354 | + $text = trim ($editor->safeUnicodeOutput ($editor->textbox1)); |
| 355 | + |
| 356 | + // see if we have a link to a layout |
| 357 | + $layout = UW_GenericEditPage_extractLayout ($text); |
| 358 | + |
| 359 | + /* remove the categories, to be added as |
| 360 | + * checkboxes later (after the edit form) */ |
| 361 | + if ($wgCategoryBox) { |
| 362 | + $catbox = UW_GenericEditPage_extractCategoriesIntoBox ($text); |
| 363 | + $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'UW_GenericEditPage_addCssHookSidebar'; |
| 364 | + } |
| 365 | + |
| 366 | + /* break the page up into sections by splitting |
| 367 | + * at header level =one= or ==two== */ |
| 368 | + $nodes = preg_split('/^(==?[^=].*)$/mi', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 369 | + |
| 370 | + // add css hooks only to the edit page |
| 371 | + $wgHooks['SkinTemplateSetupPageCss'][] = 'UW_GenericEditPage_editPageCss'; |
| 372 | + $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'UW_GenericEditPage_addCssHookGenEd'; |
| 373 | + |
| 374 | + |
| 375 | + /* the current contents of the page we are |
| 376 | + * editing will be broken up into $page(and |
| 377 | + * combined with $layout, later on) */ |
| 378 | + $page = array(); |
| 379 | + $title = ""; |
| 380 | + |
| 381 | + /* always create a space for the first un-named |
| 382 | + * section, even if it is not used */ |
| 383 | + $page[] = array(); |
| 384 | + |
| 385 | + for ($i = 0; $i < count ($nodes); $i++) { |
| 386 | + $value = trim ($nodes[$i]); |
| 387 | + $this_section = count ($page) - 1; |
| 388 | + |
| 389 | + // is this block of text a header? |
| 390 | + $node_is_title = preg_match ('/^(==?)\s*(.+?)\s*\\1$/i', $value, $matches); |
| 391 | + |
| 392 | + /* for titles, create a new element in the |
| 393 | + * page array, to store the title and text */ |
| 394 | + if ($node_is_title) { |
| 395 | + |
| 396 | + // extract header level and title |
| 397 | + $level = strlen ($matches[1]); |
| 398 | + $title = htmlspecialchars ($matches[2]); |
| 399 | + |
| 400 | + // add this section and mark it as in use |
| 401 | + $page[] = array( |
| 402 | + 'title' => $title, |
| 403 | + 'level' => $level, |
| 404 | + 'in-use' => true |
| 405 | + ); |
| 406 | + |
| 407 | + /* not header -> plain text (store in |
| 408 | + / * the previous section, with title) */ |
| 409 | + } else { |
| 410 | + $page[$this_section]['text'] = $value; |
| 411 | + } |
| 412 | + |
| 413 | + /* fetch the meta-data for new sections, or |
| 414 | + * the un-named first section. this is done |
| 415 | + * here (not when merging) because meta-data |
| 416 | + * can ONLY come from the layout (not the page) */ |
| 417 | + if ($node_is_title or $i==0) { |
| 418 | + |
| 419 | + /* now check if any meta-data exists for this |
| 420 | + * section in the layout for this page |
| 421 | + * (ignore the first two sections) |
| 422 | + * j = 0: page meta-data |
| 423 | + * j = 1: special first section */ |
| 424 | + for ($j = 1; $j < count ($layout); $j++) { |
| 425 | + if ($layout[$j]['title'] == $title) { |
| 426 | + // we found a corresponding section in the layout |
| 427 | + // so we copy all the associated meta-data |
| 428 | + foreach ($layout[$j] as $k => $v) { |
| 429 | + |
| 430 | + // don't overwrite the page text! |
| 431 | + if ($k != "text") $page[count ($page)-1][$k] = $v; |
| 432 | + } |
| 433 | + } |
| 434 | + } |
| 435 | + } |
| 436 | + } |
| 437 | + |
| 438 | + /* the results of the |
| 439 | + * layout + page merge */ |
| 440 | + $result = array(); |
| 441 | + |
| 442 | + /* special case: if the first (un-named) section has text in the layout, |
| 443 | + * but not in the page, copy it. otherwise, use the page text (even if empty) */ |
| 444 | + $result[] = ($layout[0]['text'] && !$page[0]['text']) ? $layout[0] : $page[0]; |
| 445 | + |
| 446 | + /* only show the un-named section if it is being used. as |
| 447 | + * default, do not encourage people to use it by showing it */ |
| 448 | + $result[0]['in-use'] = ($result[0]['text'] != ""); |
| 449 | + |
| 450 | + // get sections that are in the layout |
| 451 | + for ($i = 2; $i < count ($layout); $i++) { |
| 452 | + $found_at = null; |
| 453 | + for ($j = 0; $j < count ($page); $j++) { |
| 454 | + if ($layout[$i]['title'] == $page[$j]['title']) { |
| 455 | + $found_at = $j; |
| 456 | + break; |
| 457 | + } |
| 458 | + } |
| 459 | + if (!$found_at) { // take the section from the layout |
| 460 | + $result[] = $layout[$i]; |
| 461 | + } else { |
| 462 | + $result[] = $page[$found_at]; |
| 463 | + } |
| 464 | + } |
| 465 | + |
| 466 | + // now put in the stuff that is not in the layout, but IS in the page |
| 467 | + for ($i = 1; $i < count ($page); $i++) { |
| 468 | + |
| 469 | + // if this section is already in the result, |
| 470 | + // then skip to the next page section |
| 471 | + for ($j=0; $j<count ($result); $j++) { |
| 472 | + if ($page[$i]['title'] == $result[$j]['title']) |
| 473 | + continue 2; |
| 474 | + } |
| 475 | + |
| 476 | + /* this page section has not been added yet! |
| 477 | + * re-iterate the results, to find the index |
| 478 | + * of the section BEFORE this section, which |
| 479 | + * we will insert after */ |
| 480 | + $insert_at = null; |
| 481 | + |
| 482 | + for ($j=0; $j<count ($result); $j++) { |
| 483 | + if ($result[$j]['title'] == $page[$i-1]['title']) { |
| 484 | + $insert_at = $j+1; |
| 485 | + break; |
| 486 | + } |
| 487 | + } |
| 488 | + |
| 489 | + if ($insert_at===null) $result[] = $page[$i]; |
| 490 | + else array_splice ($result, $insert_at, 0, array($page[$i])); |
| 491 | + } |
| 492 | + |
| 493 | + /* check to see if there were any sections in use |
| 494 | + * if there are not, we will display instructions */ |
| 495 | + $any_in_use = false; |
| 496 | + for ($i=0; $i<count( $result); $i++) { |
| 497 | + if ($result[$i]['in-use']) { |
| 498 | + $any_in_use = true; |
| 499 | + break; |
| 500 | + } |
| 501 | + } |
| 502 | + |
| 503 | + // use the default (untitled) section if there is nothing else |
| 504 | + if (!$any_in_use) { |
| 505 | + $result[0]['in-use'] = true; |
| 506 | + $any_in_use = true; |
| 507 | + } |
| 508 | + |
| 509 | + // this line is sort of outdated... may want to remove? |
| 510 | + $gen_editor_class = $any_in_use ? "" : " show-instructions"; |
| 511 | + |
| 512 | + /* add the buttons to switch between editing modes |
| 513 | + * (only one is visible at a time, via css/js) and |
| 514 | + * start the generic editor div */ |
| 515 | + $out->addHTML(" |
| 516 | + <script type='text/javascript' language='javascript'> |
| 517 | + $(window).addEvent ('domready', function() { |
| 518 | + /* add CLASSIC button |
| 519 | + * (visibility via css) */ |
| 520 | + new Element ('input', { |
| 521 | + type: 'button', |
| 522 | + 'class': 'switch sw-classic', |
| 523 | + events: { click: Uniwiki.GenericEditPage.toggle_mode }, |
| 524 | + value: '".wfMsg ('gep_classicmode')."' |
| 525 | + }).inject ($('content')); |
| 526 | + |
| 527 | + /* add GENERIC button |
| 528 | + * (visibility via css) */ |
| 529 | + new Element ('input', { |
| 530 | + type: 'button', |
| 531 | + 'class': 'switch sw-generic', |
| 532 | + events: { click: Uniwiki.GenericEditPage.toggle_mode }, |
| 533 | + value: '".wfMsg ('gep_genericmode')."' |
| 534 | + }).inject($('content')); |
| 535 | + "); |
| 536 | + |
| 537 | + /* only enforce the categorization of pages in the |
| 538 | + * main namespace, using the generic edit page */ |
| 539 | + if ($wgRequireCategory && ($wgTitle->getNamespace() == NS_MAIN)) { |
| 540 | + $out->addHTML(" |
| 541 | + /* when the form is submitted, check that one or |
| 542 | + * more categories were selected, or alert */ |
| 543 | + $('editform').addEvent ('submit', function (e) { |
| 544 | + |
| 545 | + // only enforce when in generic mode |
| 546 | + if (!document.body.hasClass ('edit-generic')) |
| 547 | + return true; |
| 548 | + |
| 549 | + /* iterate the category checkboxes, and count |
| 550 | + * how many of them are 'ticked' */ |
| 551 | + var checked = 0; |
| 552 | + $$('#category-box input[type=checkbox]').each (function (el) { |
| 553 | + if (el.checked) checked++; |
| 554 | + }); |
| 555 | + |
| 556 | + if (checked==0) { |
| 557 | + alert('".wfMsg ('gep_nocategories')."'); |
| 558 | + e.stop(); |
| 559 | + } |
| 560 | + }); |
| 561 | + "); |
| 562 | + } |
| 563 | + |
| 564 | + $out->addHTML(" |
| 565 | + /* if the sidebar is taller than the editor, |
| 566 | + * make the editor the same height */ |
| 567 | + var sbs = $('sidebar').getSize(); |
| 568 | + var eds = Uniwiki.GenericEditPage.editor().getSize(); |
| 569 | + if (sbs.y > eds.y) Uniwiki.GenericEditPage.editor().setStyle |
| 570 | + ((Browser.Engine.trident ? 'height' : 'min-height'), sbs.y+'px'); |
| 571 | + }); |
| 572 | + </script> |
| 573 | + <!-- will be assigned the name of 'wpPreview' when the |
| 574 | + switch-mode button is pressed, because mediawiki |
| 575 | + only checks for its presence, not value (?!) --> |
| 576 | + <input type='hidden' id='wpFakePreview' name='' value='' /> |
| 577 | + <input type='hidden' id='switch-mode' name='switch-mode' value='' /> |
| 578 | + <div class='generic-editor $gen_editor_class'> |
| 579 | + <div class='instructions'>".wfMsg ('gep_nosectioninstructions')."</div> |
| 580 | + "); |
| 581 | + |
| 582 | + // now build the results into a real HTML page |
| 583 | + for ($i=0; $i<count ($result); $i++) { |
| 584 | + $in_use = $result[$i]['in-use'] ? "in-use" : "not-in-use"; |
| 585 | + $out->addHTML("<div id='section-$i' class='section sect-".($i+1)." $in_use'>"); |
| 586 | + |
| 587 | + |
| 588 | + // if this section has a title, show it |
| 589 | + if ($result[$i]['title']) { |
| 590 | + $title = $result[$i]['title']; |
| 591 | + if ($result[$i]['lock-header']) { |
| 592 | + $out->addHTML ("<h2>$title</h2>"); |
| 593 | + $out->addHTML ("<input type='hidden' name='title-$i' value='$title' />"); |
| 594 | + } else { |
| 595 | + // wrap the editable section header in a div, for css hackery |
| 596 | + $out->addHTML ("<div class='sect-title'><input type='text' name='title-$i' class='section-title' value='$title' /></div>"); |
| 597 | + } |
| 598 | + |
| 599 | + // always include the level of titles |
| 600 | + $out->addHTML ("<input type='hidden' name='level-$i' value='{$result[$i]['level']}' />"); |
| 601 | + } |
| 602 | + |
| 603 | + /* always add a textarea, whether or |
| 604 | + * not it is currently in use. titles |
| 605 | + * without text are kind of useless */ |
| 606 | + if ($result[$i]['lock-text']) { |
| 607 | + |
| 608 | + /* render the wiki markup into HTML, the old-school |
| 609 | + * way which actually works, unlike recursiveTagParse() */ |
| 610 | + $text = $wgParser->parse ($result[$i]['text'], $wgTitle, new ParserOptions)->getText(); |
| 611 | + $out->addHTML ("<input type='hidden' name='section-$i' value='".htmlspecialchars ($result[$i]['text'], ENT_QUOTES)."' />"); |
| 612 | + $out->addHTML ("<div class='locked-text' id='locked-text-$i'>".$text."</div>"); |
| 613 | + } else { |
| 614 | + // add the editable text for this section |
| 615 | + $text = htmlspecialchars ($result[$i]['text'], ENT_QUOTES); |
| 616 | + $out->addHTML ("<textarea name='section-$i' class='editor'>$text</textarea>"); |
| 617 | + } |
| 618 | + |
| 619 | + $out->addHTML("</div>"); |
| 620 | + } |
| 621 | + |
| 622 | + |
| 623 | + /* end of .generic-editor |
| 624 | + * (and some javascript!) */ |
| 625 | + $out->addHTML(" |
| 626 | + </div> |
| 627 | + <script type='text/javascript'> |
| 628 | + /* when any section title is changed (in the generic |
| 629 | + * editor), update the sections on the right, too */ |
| 630 | + window.addEvent ('domready', function() { |
| 631 | + Uniwiki.GenericEditPage.Events.section_title_change() |
| 632 | + }); |
| 633 | + </script> |
| 634 | + "); |
| 635 | + |
| 636 | + |
| 637 | + /* if the article we're editing is in the whitelist, then |
| 638 | + * default to the generic editor; otherwise, default to |
| 639 | + * classic mode (but allow switching) */ |
| 640 | + $default = in_array ($wgTitle->getNamespace(), $wgGenericEditPageWhiteList) |
| 641 | + ? "generic" : "classic"; |
| 642 | + |
| 643 | + /* use the mode from the last request; default to generic (the first time) |
| 644 | + * if we are switching modes, then use the OPPOSITE mode */ |
| 645 | + $klass = $wgRequest->getVal ("edit-mode", $default); |
| 646 | + if ($wgSwitchMode) $klass = ($klass=="classic") ? "generic" : "classic"; |
| 647 | + $out->addHTML ("<input type='hidden' name='edit-mode' id='edit-mode' value='$klass' />"); |
| 648 | + $wgGenericEditPageClass = $klass; |
| 649 | + |
| 650 | + |
| 651 | + // pass the layout name back, to be re-appended |
| 652 | + $out->addHTML ("<input type='hidden' name='layout-name' value='{$layout[0]['name']}' />"); |
| 653 | + |
| 654 | + |
| 655 | + // build the sidebar (cats, sections) in its entirety |
| 656 | + if ($wgCategoryBox || $wgSectionBox) { |
| 657 | + $out->addHTML ("<div id='sidebar'>"); |
| 658 | + if ($wgSectionBox) $out->addHTML (UW_GenericEditPage_renderSectionBox($result)); |
| 659 | + if ($wgCategoryBox) $out->addHTML ($catbox); |
| 660 | + $out->addHTML ("</div>"); |
| 661 | + } |
| 662 | + |
| 663 | + return true; |
| 664 | +} |
| 665 | + |
| 666 | +/* OH, HOW I WISH FOR CLOSURES IN PHP, SO |
| 667 | + * THESE DIDN'T HAVE TO BE GLOBAL FUNCTIONS */ |
| 668 | + |
| 669 | + /* when this hook is called (only on the generic edit page), add a |
| 670 | + * special class to the <body> tag, to make targetting our css easier |
| 671 | + * (also add a hook if we just switched modes, to hide the preview) */ |
| 672 | + function UW_GenericEditPage_addCssHookGenEd (&$sktemplate, &$tpl) { |
| 673 | + global $wgGenericEditPageClass, $wgSwitchMode; |
| 674 | + $tpl->data['pageclass'] .= " edit-$wgGenericEditPageClass"; |
| 675 | + if ($wgSwitchMode) $tpl->data['pageclass'] .= " switching-mode"; |
| 676 | + return true; |
| 677 | + } |
| 678 | + function UW_GenericEditPage_addCssHookSidebar (&$sktemplate, &$tpl) { |
| 679 | + global $wgGenericEditPageClass; |
| 680 | + $tpl->data['pageclass'] .= " with-sidebar"; |
| 681 | + return true; |
| 682 | + } |
| 683 | + |
| 684 | + |
| 685 | + // also attach our generic editor stylesheet |
| 686 | + function UW_GenericEditPage_editPageCss (&$out) { |
| 687 | + global $wgScriptPath; |
| 688 | + $out .= "@import '$wgScriptPath/extensions/uniwiki/GenericEditPage/style.css';\n"; |
| 689 | + return true; |
| 690 | + } |
| 691 | + |
| 692 | + |
| 693 | +$wgHooks['EditPage::attemptSave'][] = 'UW_GenericEditPage_combineBeforeSave'; |
| 694 | +$wgHooks['EditPage::showEditForm:initial'][] = 'UW_GenericEditPage_combineBeforeSave'; |
| 695 | +function UW_GenericEditPage_combineBeforeSave (&$editpage_Obj) { |
| 696 | + global $wgRequest, $wgSwitchMode; |
| 697 | + $data = $wgRequest->data; |
| 698 | + |
| 699 | + /* if this request was triggered by the user |
| 700 | + * pressing the "switch mode" button, then |
| 701 | + * set a global to do some jiggery-pokery |
| 702 | + * in the displayEditPage function, later */ |
| 703 | + if ($data['switch-mode']) |
| 704 | + $wgSwitchMode = true; |
| 705 | + |
| 706 | + /* if we are editing in classic mode, |
| 707 | + * then this function does nothing! */ |
| 708 | + if ($data['edit-mode'] != "generic") |
| 709 | + return true; |
| 710 | + |
| 711 | + /* otherwise, clear the textbox and rebuild it |
| 712 | + * from the generic input POST data */ |
| 713 | + $editpage_Obj->textbox1 = ''; |
| 714 | + $nodes = array(); |
| 715 | + $categories = array(); |
| 716 | + $directives = array(); |
| 717 | + foreach ($data as $key => $value) { |
| 718 | + if (trim ($value) != '') { |
| 719 | + |
| 720 | + if (substr($key, 0, 6) == 'title-') { |
| 721 | + $index = intval (substr($key, 6)); |
| 722 | + |
| 723 | + /* only add this section if it is enabled, |
| 724 | + * by checking the associated checkbox */ |
| 725 | + if (isset ($data["enable-$index"])) { |
| 726 | + |
| 727 | + /* got a title -> add it back as a header, |
| 728 | + * by fetching the level from field "level-N" */ |
| 729 | + $level = isset ($data["level-$index"]) ? $data["level-$index"] : 2; |
| 730 | + $delim = str_repeat ( "=", $level ); |
| 731 | + $nodes[$index]['title'] = "$delim " . trim ($value) . " $delim\n"; |
| 732 | + } |
| 733 | + |
| 734 | + /* got a section -> check that associated checkbox is |
| 735 | + * ticked (or this is the first magic section, which |
| 736 | + * does not have a checkbox), and add it into the output */ |
| 737 | + } else if (substr ($key, 0, 8) == 'section-') { |
| 738 | + $index = intval (substr($key, 8)); |
| 739 | + if (isset ($data["enable-$index"]) || ($index==0)) { |
| 740 | + $nodes[$index]['text'] = trim($value) . "\n\n"; |
| 741 | + } |
| 742 | + |
| 743 | + /* got a category -> add it to the list of categories and put |
| 744 | + * it into the page as human-friendly text (i.e. not a DB key) */ |
| 745 | + } else if (substr ($key, 0, 9) == 'category-') { |
| 746 | + $categories[] = Title::newFromDBkey (substr ($key, 9))->getText(); |
| 747 | + } |
| 748 | + } |
| 749 | + } |
| 750 | + |
| 751 | + /* put the section titles and text |
| 752 | + * back into the default textbox */ |
| 753 | + foreach (array_keys ($nodes) as $k) { |
| 754 | + if ($nodes[$k]['title']) $editpage_Obj->textbox1 .= $nodes[$k]['title']; |
| 755 | + if ($nodes[$k]['text']) $editpage_Obj->textbox1 .= $nodes[$k]['text']; |
| 756 | + } |
| 757 | + |
| 758 | + // then add back the categories |
| 759 | + if (count ($categories) != 0) { |
| 760 | + sort ($categories); |
| 761 | + foreach ($categories as $category) { |
| 762 | + $editpage_Obj->textbox1 .= "[[Category:" . $category . "]]\n"; |
| 763 | + } |
| 764 | + } |
| 765 | + |
| 766 | + // finally, re-add the layout name |
| 767 | + if ($data['layout-name']) { |
| 768 | + $editpage_Obj->textbox1 .= "<layout name=\"{$data['layout-name']}\" />"; |
| 769 | + } |
| 770 | + |
| 771 | + return true; |
| 772 | +} |
| 773 | + |
Index: trunk/extensions/uniwiki/GenericEditPage/global.css |
— | — | @@ -0,0 +1,7 @@ |
| 2 | +/* vim: noet ts=4 sw=4 |
| 3 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 4 | + |
| 5 | +/* hide the [edit] section links */ |
| 6 | +.editsection { |
| 7 | + display: none; |
| 8 | +} |
Index: trunk/extensions/uniwiki/GenericEditPage/style.css |
— | — | @@ -0,0 +1,193 @@ |
| 2 | +/* vim: noet ts=4 sw=4 |
| 3 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Generic_Edit_Page |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | + |
| 7 | +#editform { |
| 8 | + position: relative; |
| 9 | + |
| 10 | + /* mootools sortables requires relative elements to |
| 11 | + * have "layout", to correctly calculate dimensions |
| 12 | + * see: http://dev.mootools.net/changeset/1499 */ |
| 13 | + zoom: 1; |
| 14 | +} |
| 15 | + |
| 16 | + .generic-editor .instructions { |
| 17 | + border: 1px solid #ccc; |
| 18 | + background: #eee; |
| 19 | + line-height: 6em; |
| 20 | + font-size: 200%; |
| 21 | + text-align: center; |
| 22 | + display: none; |
| 23 | + } |
| 24 | + |
| 25 | + .generic-editor.show-instructions .instructions { |
| 26 | + display: block; } |
| 27 | + |
| 28 | + .generic-editor input, |
| 29 | + .generic-editor h2 { |
| 30 | + font-size: 160%; |
| 31 | + width: 40%; |
| 32 | + } |
| 33 | + |
| 34 | + .generic-editor .in-use { |
| 35 | + padding-bottom: 2em; |
| 36 | + } |
| 37 | + |
| 38 | + #bodyContent .generic-editor h2 { |
| 39 | + margin-bottom: 3px; |
| 40 | + padding-top: 0; |
| 41 | + width: auto; |
| 42 | + } |
| 43 | + |
| 44 | + .generic-editor .not-in-use { |
| 45 | + display: none; |
| 46 | + } |
| 47 | + |
| 48 | + .generic-editor textarea { |
| 49 | + height: 12em; |
| 50 | + } |
| 51 | + |
| 52 | + .generic-editor .locked-text { |
| 53 | + } |
| 54 | + |
| 55 | +/* hide a lot of mediawiki junk at the |
| 56 | + * top of the edit form when it generic mode */ |
| 57 | +body.edit-generic #mw-anon-edit-warning, |
| 58 | +body.edit-generic .mw-newarticletext, |
| 59 | +body.edit-generic .mw-newarticletextanon, |
| 60 | +body.edit-generic #editpage-copywarn, |
| 61 | +body.edit-generic .templatesUsed, |
| 62 | + |
| 63 | +/* summary is really hard to hide, because the |
| 64 | + * mediawiki markup is a steaming heap of... */ |
| 65 | +body.edit-generic #wpSummary, |
| 66 | +body.edit-generic .editOptions br, |
| 67 | +body.edit-generic #wpSummaryLabel { |
| 68 | + display: none; |
| 69 | +} |
| 70 | + |
| 71 | +/* make the "you are recreating a deleted |
| 72 | + * page!" warning nicer in generic mode */ |
| 73 | +body.edit-generic div#mw-upload-deleted-warn, |
| 74 | +body.edit-generic div#mw-recreate-deleted-warn { |
| 75 | + margin: 1em; |
| 76 | + padding: 1em; |
| 77 | + background: #fee; |
| 78 | + border-color: #800; |
| 79 | + padding-top: 0.6em; |
| 80 | + margin-bottom: 2em; |
| 81 | +} |
| 82 | + |
| 83 | +/* to make space for the sidebar |
| 84 | + * when it's being used */ |
| 85 | +body.edit-generic.with-sidebar #editform { |
| 86 | + padding-right: 17em; } |
| 87 | + |
| 88 | + /* hide the sidebar as default */ |
| 89 | + #sidebar { |
| 90 | + position: absolute; |
| 91 | + display: none; |
| 92 | + right: 0; |
| 93 | + top: 0; |
| 94 | + width: 15em; |
| 95 | + background: #fff; |
| 96 | + } |
| 97 | + |
| 98 | + /* only make it visible in generic mode */ |
| 99 | + body.edit-generic #sidebar { |
| 100 | + display: block; } |
| 101 | + |
| 102 | + #section-box .sortables div, |
| 103 | + #category-box div { |
| 104 | + margin-bottom: 1px; |
| 105 | + padding: 1px; |
| 106 | + } |
| 107 | + |
| 108 | + /* hack to hide the crazy mootools temporary div (spawned |
| 109 | + * when dragging starts), to prevent the scrollbar jumping */ |
| 110 | + #section-box .sortables div { display: none; } |
| 111 | + #section-box .sortables div.section-box { display: block; } |
| 112 | + |
| 113 | + /* disabled/required sections */ |
| 114 | + #section-box .disabled { |
| 115 | + color: #888; |
| 116 | + } |
| 117 | + |
| 118 | + /* something is draggable, use the hand */ |
| 119 | + #section-box .sortables div, |
| 120 | + #section-box .sortables label { |
| 121 | + cursor: pointer; |
| 122 | + } |
| 123 | + |
| 124 | + /* something is currently being dragged, |
| 125 | + * so use the 'grabbing hand' cursor |
| 126 | + * (the whole box, to avoid flickering) */ |
| 127 | + #section-box .sortables.dragging, |
| 128 | + #section-box .sortables.dragging div, |
| 129 | + #section-box .sortables.dragging label { |
| 130 | + cursor: move !important; |
| 131 | + } |
| 132 | + |
| 133 | + /* sidebar contains both category-box |
| 134 | + * and section-box */ |
| 135 | + #section-box .add, |
| 136 | + #category-box, |
| 137 | + #category-box .add, |
| 138 | + #category-box .suggest { |
| 139 | + border-top: 1px dotted #ccc; |
| 140 | + margin: 1em 0 0 0; |
| 141 | + padding: 1em 0 0 0; |
| 142 | + } |
| 143 | + #category-box .add #fm-add-cat, |
| 144 | + #category-box .suggest #fm-suggest-cat { clear: both; } |
| 145 | + #fm-add-cat, #fm-add-sect { width: 10em; } |
| 146 | + #fm-suggest-cat { width: 8em; } |
| 147 | + |
| 148 | + #category-box .add #fm-add-cat-button, |
| 149 | + #category-box .suggest #fm-suggest-cat-button { |
| 150 | + margin-top: 0.5em; } |
| 151 | + |
| 152 | + /* the ajax response box */ |
| 153 | + #category-box .suggest div { |
| 154 | + margin-top: 1em; } |
| 155 | + |
| 156 | + #sidebar h3, |
| 157 | + #section-box .add label, |
| 158 | + #category-box .add label, |
| 159 | + #category-box .suggest label { |
| 160 | + padding: 0; |
| 161 | + margin: 0; |
| 162 | + font-size: 100%; |
| 163 | + font-weight: bold; |
| 164 | + padding-bottom: 0.5em; |
| 165 | + } |
| 166 | + |
| 167 | +.edit-classic .generic-editor, |
| 168 | +.edit-generic #toolbar, |
| 169 | +.edit-generic #wpTextbox1 { |
| 170 | + /* can't use display:none here, because wikibits.js (line 378) |
| 171 | + * relies on the textarea.selectionStart property, which doesn't |
| 172 | + * seem to work when the textarea is not displayed */ |
| 173 | + position: absolute; |
| 174 | + top: -9999px; |
| 175 | +} |
| 176 | + |
| 177 | +.edit-classic .sw-classic, |
| 178 | +.edit-generic .sw-generic { display: none; } |
| 179 | + |
| 180 | +/* move button to top-right (above |
| 181 | + * <h1>Editing Page Name</h1> underline) */ |
| 182 | +input.switch { |
| 183 | + position: absolute; |
| 184 | + right: 1em; |
| 185 | + top: 5px; |
| 186 | +} |
| 187 | + |
| 188 | +/* don't show the preview or categories list |
| 189 | + * (why is it even there?) when switching modes */ |
| 190 | +body.switching-mode #wikiPreview, |
| 191 | +body.switching-mode #catlinks { |
| 192 | + display: none; |
| 193 | +} |
| 194 | + |
Index: trunk/extensions/uniwiki/GenericEditPage/GenericEditPage.js |
— | — | @@ -0,0 +1,502 @@ |
| 2 | +/* vim: noet ts=4 sw=4 |
| 3 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Generic_Edit_Page |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | + |
| 7 | +Uniwiki.GenericEditPage = { |
| 8 | + |
| 9 | + /* store the instance of the Mootools sortable |
| 10 | + * class statically, so we can easily attach |
| 11 | + * and detach things to it */ |
| 12 | + sections_sortable: null, |
| 13 | + |
| 14 | + /* section sorting is enabled as default, but |
| 15 | + * can temporarily suspended while things are |
| 16 | + * sliding around */ |
| 17 | + sections_sorting: true, |
| 18 | + |
| 19 | + |
| 20 | + /* to switch between modes (generic and classic), |
| 21 | + * we must (effectively) click preview (to re- |
| 22 | + * combine the wiki markup server-side), and |
| 23 | + * reload the page in the opposite mode) */ |
| 24 | + toggle_mode: function() { |
| 25 | + /* picked up by the combineBeforeSave hook |
| 26 | + * in GenericEditor.php to set the new mode */ |
| 27 | + $("switch-mode").value = 1; |
| 28 | + |
| 29 | + /* simulate a click on "preview" by setting |
| 30 | + * a faux input field with the same name */ |
| 31 | + $("wpFakePreview").name = "wpPreview"; |
| 32 | + $("wpFakePreview").value = "Show preview"; |
| 33 | + $("editform").submit(); |
| 34 | + }, |
| 35 | + |
| 36 | + |
| 37 | + /* return the DOM node which contains |
| 38 | + * all of the generic editor stuff */ |
| 39 | + editor: function () { |
| 40 | + return $$(".generic-editor")[0]; |
| 41 | + }, |
| 42 | + |
| 43 | + /* util function to trigger a click event |
| 44 | + * upon receiving an [ENTER] key press (for |
| 45 | + * the add [cat | section] boxes, initially */ |
| 46 | + bind_enter_to_click: function(src,dest) { |
| 47 | + src.addEvent ("keypress", function(e) { |
| 48 | + if (e.key == "enter") { |
| 49 | + dest.fireEvent("click"); |
| 50 | + e.stop(); |
| 51 | + } |
| 52 | + }); |
| 53 | + }, |
| 54 | + |
| 55 | + /* update the visibility status of the instructions |
| 56 | + * box (says "there are no sections, add some, etc"); |
| 57 | + * show it only if there are no sections visible */ |
| 58 | + update_instructions_box: function() { |
| 59 | + |
| 60 | + /* count the number of sections which are now in |
| 61 | + * use. if it is NONE, show the instructions box */ |
| 62 | + var ed = Uniwiki.GenericEditPage.editor(); |
| 63 | + var in_use = ed.getElements(".in-use").length; |
| 64 | + if (in_use) { ed.removeClass("show-instructions"); } |
| 65 | + else { ed.addClass( "show-instructions"); } |
| 66 | + }, |
| 67 | + |
| 68 | + /* lock the height of the editor while sliding, |
| 69 | + * to prevent the window scrollbar from moving |
| 70 | + * around. it grabs the user's attention */ |
| 71 | + lock_editor_height: function() { |
| 72 | + var size = Uniwiki.GenericEditPage.editor().getSize(); |
| 73 | + Uniwiki.GenericEditPage.editor().setStyle('height', size.y + "px"); |
| 74 | + }, |
| 75 | + |
| 76 | + /* allow the editor to size naturally */ |
| 77 | + unlock_editor_height: function() { |
| 78 | + Uniwiki.GenericEditPage.editor().setStyle('height', ""); |
| 79 | + }, |
| 80 | + |
| 81 | + |
| 82 | + Events: { |
| 83 | + |
| 84 | + // == SYNCHRONISE SIDEBAR WITH EDITABLE TITLES == |
| 85 | + section_title_change: function() { |
| 86 | + $$(".generic-editor input.section-title"). |
| 87 | + addEvent ("keyup", function(e) { |
| 88 | + var title = e.target.value; |
| 89 | + var index = e.target.name.replace(/\D/g, ""); |
| 90 | + $$("#sect-" + index + " label").set("text", title); |
| 91 | + }); |
| 92 | + }, |
| 93 | + |
| 94 | + // == "ADD CATEGORY" BOX == |
| 95 | + add_category: function() { |
| 96 | + /* add category [field | button] */ |
| 97 | + var acat_fld = $("fm-add-cat"); |
| 98 | + var acat_btn = $("fm-add-cat-button"); |
| 99 | + |
| 100 | + /* when the add button is clicked, create a new category |
| 101 | + * checkbox + label, and insert it into the list. we don't |
| 102 | + * have to do insert any wiki markup, because the combine- |
| 103 | + * BeforeSave function in GenericEditPage.php will do it */ |
| 104 | + acat_btn.addEvent( "click", function(e) { |
| 105 | + |
| 106 | + // abort if no category name was entered |
| 107 | + var cat_name = acat_fld.value.trim(); |
| 108 | + if (cat_name == "") return true; |
| 109 | + |
| 110 | + /* iterate all category checkboxes, looking |
| 111 | + * for one by the name entered (to recycle) */ |
| 112 | + var already_exists = false; |
| 113 | + $$("#category-box input[type=checkbox]").each (function(obj) { |
| 114 | + if (obj.name == "category-" + cat_name) { |
| 115 | + |
| 116 | + /* ensure that the category is checked, |
| 117 | + * and highlight it to notify the user */ |
| 118 | + already_exists = true; |
| 119 | + acat_fld.value = ""; |
| 120 | + obj.checked = "checked"; |
| 121 | + obj.getParent().highlight(); |
| 122 | + } |
| 123 | + }); |
| 124 | + |
| 125 | + // abort if the new cat name already exists |
| 126 | + if (already_exists) return true; |
| 127 | + |
| 128 | + /* if no category by this name already exists, |
| 129 | + * then we will add a new checkbox (to be found |
| 130 | + * by the server-side combineBeforeSave function) */ |
| 131 | + var f_id = "category-" + cat_name; |
| 132 | + var div = new Element ("div").appendText(" "); |
| 133 | + |
| 134 | + // create the new checkbox |
| 135 | + var input = new Element ("input", { |
| 136 | + 'id': f_id, |
| 137 | + 'name': f_id, |
| 138 | + 'type': "checkbox", |
| 139 | + 'checked': "checked" |
| 140 | + }).inject(div); |
| 141 | + |
| 142 | + // create the label |
| 143 | + var label = new Element ("label", { 'for': f_id }) |
| 144 | + .appendText (cat_name).inject (div); |
| 145 | + |
| 146 | + /* insert the new category before the add |
| 147 | + * form and flash it, to notify the user */ |
| 148 | + div.inject (acat_btn.getParent(), "before"); |
| 149 | + div.highlight(); |
| 150 | + |
| 151 | + /* clear the new category name field */ |
| 152 | + acat_fld.value = ""; |
| 153 | + }); |
| 154 | + |
| 155 | + /* catch the ENTER key in the category name box, |
| 156 | + * to prevent the entire edit form from submitting |
| 157 | + * (redirect it to the click event, above) */ |
| 158 | + Uniwiki.GenericEditPage.bind_enter_to_click (acat_fld, acat_btn); |
| 159 | + }, |
| 160 | + |
| 161 | + // == "ADD SECTIONS" BOX == |
| 162 | + add_section: function() { |
| 163 | + /* add section [field | button] */ |
| 164 | + var asect_fld = $("fm-add-sect"); |
| 165 | + var asect_btn = $("fm-add-sect-button"); |
| 166 | + |
| 167 | + asect_btn.addEvent( "click", function(e) { |
| 168 | + var sect_name = asect_fld.value.trim(); |
| 169 | + if (sect_name == "") return true; |
| 170 | + |
| 171 | + /* find the next available section index |
| 172 | + * (will be incremented in iterator, below) */ |
| 173 | + var sect_index = 1; |
| 174 | + |
| 175 | + var already_exists = false; |
| 176 | + $$("#section-box input[type=checkbox]").each (function(obj) { |
| 177 | + |
| 178 | + /* fetch the NAME of this checkbox, via its label |
| 179 | + * (section checkboxes are only identified by index) */ |
| 180 | + var labels = obj.getParent().getElements('label'); |
| 181 | + if (labels) obj_name = labels[0].get('text'); |
| 182 | + |
| 183 | + if (obj.name == sect_name) { |
| 184 | + already_exists = true; |
| 185 | + asect_fld.value = ""; |
| 186 | + obj.checked = "checked"; |
| 187 | + obj.getParent().highlight(); |
| 188 | + } |
| 189 | + |
| 190 | + /* keep track of the highest section index, |
| 191 | + * in case we need to add a new section */ |
| 192 | + var obj_index = obj.name.replace (/\D/g, ''); |
| 193 | + if (obj_index > sect_index) sect_index = obj_index; |
| 194 | + }); |
| 195 | + |
| 196 | + // abort if the new section name already exists |
| 197 | + if (already_exists) return true; |
| 198 | + |
| 199 | + /* we're creating a new section; index |
| 200 | + * it one higher than the current maximum */ |
| 201 | + sect_index++; |
| 202 | + |
| 203 | + var div = new Element ("div", { |
| 204 | + 'id': "sect-" + sect_index, |
| 205 | + 'class': "section-box" |
| 206 | + }); |
| 207 | + |
| 208 | + // create the checkbox |
| 209 | + var f_name = "enable-" + sect_index; |
| 210 | + var f_id = "fm-" + f_name; |
| 211 | + var input = new Element ("input", { |
| 212 | + 'id': f_id, |
| 213 | + 'name': f_name, |
| 214 | + 'type': "checkbox", |
| 215 | + 'checked': "checked" |
| 216 | + }).inject(div); |
| 217 | + |
| 218 | + /* add a single space between the checkbox |
| 219 | + * and label, to match existing sections */ |
| 220 | + div.appendText(" "); |
| 221 | + |
| 222 | + // create the label |
| 223 | + var label = new Element ("label", { 'for': f_id }) |
| 224 | + .appendText (sect_name).inject (div); |
| 225 | + |
| 226 | + /* insert the new section div (in sidebar) into the |
| 227 | + * sortables container, and hook up the event handlers |
| 228 | + * to make it play nice with the other sections */ |
| 229 | + div.inject (asect_btn.getParent().getPrevious()); |
| 230 | + var sortables = Uniwiki.GenericEditPage.sections_sortables; |
| 231 | + if (sortables) sortables.addItems (div); |
| 232 | + div.highlight(); |
| 233 | + |
| 234 | + // create and inject the real section into the editor |
| 235 | + var klass = "section sect-" + (sect_index+1) + " in-use"; |
| 236 | + var div = new Element ("div", { 'id': "section-" + sect_index, 'class': klass }); |
| 237 | + var t_div = new Element ("div", { 'class': "sect-title" }).inject(div); |
| 238 | + new Element ("input", { 'type': "text", 'value': sect_name, 'class': "section-title", 'name': "title-" + sect_index }).inject(t_div); |
| 239 | + new Element ("input", { 'type': "hidden", 'value': 2, 'name': "level-" + sect_index }).inject(div); |
| 240 | + var txta = new Element ("textarea", { 'name': "section-" + sect_index, 'class': "editor" }).inject(div); |
| 241 | + div.inject (Uniwiki.GenericEditPage.editor()); |
| 242 | + |
| 243 | + /* if we are also running the custom toolbars |
| 244 | + * uniwiki extension, add a nice toolbar to |
| 245 | + * this section */ |
| 246 | + if (Uniwiki.CustomToolbar) |
| 247 | + Uniwiki.CustomToolbar.attach (txta); |
| 248 | + |
| 249 | + /* hide the instructions box, now that we |
| 250 | + * have at least one section in the editor */ |
| 251 | + Uniwiki.GenericEditPage.update_instructions_box(); |
| 252 | + |
| 253 | + // clear the "new section name" field |
| 254 | + asect_fld.value = ""; |
| 255 | + }); |
| 256 | + |
| 257 | + Uniwiki.GenericEditPage.bind_enter_to_click (asect_fld, asect_btn); |
| 258 | + }, |
| 259 | + |
| 260 | + toggle_sections: function() { |
| 261 | + // check that this document has a sortable sections box |
| 262 | + var sortables = $$("#section-box .sortables")[0]; |
| 263 | + if (!sortables) return true; |
| 264 | + |
| 265 | + // == HANDLE SECTION-IN-USE CHECKBOXES == |
| 266 | + var evt_type = Browser.Engine.trident ? 'click' : 'change'; |
| 267 | + sortables.addEvent(evt_type, function(e) { |
| 268 | + |
| 269 | + // don't mess with things that aren't checkboxes |
| 270 | + if ($(e.target).get('tag') != 'input') return true; |
| 271 | + |
| 272 | + // find the target section id and section |
| 273 | + var sect_index = parseInt(e.target.name.replace(/\D/g, '')); |
| 274 | + var target = $('section-' + sect_index); |
| 275 | + |
| 276 | + // show or hide the real section in the editor |
| 277 | + if (e.target.checked) { target.removeClass('not-in-use').addClass('in-use'); } |
| 278 | + else { target.addClass('not-in-use').removeClass('in-use'); } |
| 279 | + |
| 280 | + Uniwiki.GenericEditPage.update_instructions_box(); |
| 281 | + }); |
| 282 | + |
| 283 | + }, |
| 284 | + |
| 285 | + reorder_sections: function() { |
| 286 | + // TEMPORARILY DISABLED |
| 287 | + // HERE BE DRAGONS |
| 288 | + return false; |
| 289 | + |
| 290 | + // we will need this all over the place |
| 291 | + var editor = Uniwiki.GenericEditPage.editor(); |
| 292 | + |
| 293 | + // check that this document has a sortable sections box |
| 294 | + var sortables = $$("#section-box .sortables")[0]; |
| 295 | + if (!sortables) return true; |
| 296 | + |
| 297 | + // == HIGHLIGHT SORTABLES UPON MOUSEDOWN == |
| 298 | + /* watch for mouse-down events on draggable elements (which will trigger |
| 299 | + * the mootools sortables events (below)), to highlight a div which is |
| 300 | + * now draggable to sort. we must do this here (not in the onStart event), |
| 301 | + * because mootools waits for mousedown THEN mousemove to trigger; which |
| 302 | + * is quite confusing for end-users */ |
| 303 | + sortables.addEvent ("mousedown", function(e) { |
| 304 | + |
| 305 | + // don't highlight anything if sorting is suspended |
| 306 | + if (!Uniwiki.GenericEditPage.sections_sorting) |
| 307 | + return false; |
| 308 | + |
| 309 | + var t = $(e.target); |
| 310 | + var tag = t.get("tag"); |
| 311 | + |
| 312 | + /* do nothing for input (checkbox), as not to interfere |
| 313 | + * with their normal behaviour. otherwise, highlight |
| 314 | + * the section box (entire row) */ |
| 315 | + if (tag == "input") return true; |
| 316 | + else if (tag == "label") dragger = t.getParent(); |
| 317 | + else if (tag == "div" && t.hasClass ("section-box")) dragger = t; |
| 318 | + |
| 319 | + // we have no idea what's going on |
| 320 | + else return true; |
| 321 | + |
| 322 | + /* if this element is currently tweening, |
| 323 | + * then stop it, to re-highlight it */ |
| 324 | + if (dragger.retrieve ("tween")) { |
| 325 | + dragger.retrieve ("tween").cancel(); |
| 326 | + dragger.store ("tween", null); |
| 327 | + } |
| 328 | + |
| 329 | + // set css hooks to make dragging visible |
| 330 | + dragger.setStyle ("background-color", "#ff8"); |
| 331 | + dragger.getParent().addClass ("dragging"); |
| 332 | + dragger.addClass ("dragging"); |
| 333 | + |
| 334 | + /* watch the whole document for mouseup, because the |
| 335 | + * cursor may no longer be in the sortables box */ |
| 336 | + var evt = function() { |
| 337 | + |
| 338 | + // only fire this event once |
| 339 | + $(document).removeEvent ("mouseup", evt); |
| 340 | + |
| 341 | + /* fade from the highlight color, back |
| 342 | + * to white, then remove the background */ |
| 343 | + var tween = new Fx.Tween (dragger, { |
| 344 | + onComplete: function() { |
| 345 | + dragger.setStyle ("background-color", ""); |
| 346 | + dragger.store ("tween", null); |
| 347 | + } |
| 348 | + }).start ("background-color", "#fff"); |
| 349 | + |
| 350 | + /* keep note of the tween object in the element, |
| 351 | + * in case the mousedown event is re-fired before |
| 352 | + * it is completed - so we can cancel it */ |
| 353 | + dragger.store ("tween", tween); |
| 354 | + |
| 355 | + // also remove css hooks from DOM |
| 356 | + dragger.getParent().removeClass ("dragging"); |
| 357 | + dragger.removeClass ("dragging"); |
| 358 | + }; |
| 359 | + |
| 360 | + document.addEvent ("mouseup", evt); |
| 361 | + }); |
| 362 | + |
| 363 | + // == MAKE THEM SORTABLE! == |
| 364 | + Uniwiki.GenericEditPage.sections_sortables = |
| 365 | + new Sortables(sortables, { |
| 366 | + onComplete: function(obj) { |
| 367 | + |
| 368 | + // fetch the section we are moving |
| 369 | + var sect_id = obj.id.replace(/\D/g, ""); |
| 370 | + var section = $("section-" + sect_id); |
| 371 | + |
| 372 | + /* find the current (old) and target (new) indexes |
| 373 | + * (oldIndex - 2, to count around #instructions, and |
| 374 | + * the mostly-invisible first "introduction" section) */ |
| 375 | + var newIndex = obj.getParent().getChildren().indexOf(obj); |
| 376 | + var oldIndex = editor.getChildren().indexOf(section) - 2; |
| 377 | + |
| 378 | + // skip this whole thing is the position has not changed |
| 379 | + if (!section || (newIndex == oldIndex)) |
| 380 | + return true; |
| 381 | + |
| 382 | + /* disable sorting and sizing until all of the |
| 383 | + * re-ordering and sliding around is done */ |
| 384 | + Uniwiki.GenericEditPage.sections_sortables.detach(); |
| 385 | + Uniwiki.GenericEditPage.sections_sorting = false; |
| 386 | + Uniwiki.GenericEditPage.lock_editor_height(); |
| 387 | + |
| 388 | + var stage = 1; |
| 389 | + var slider = new Fx.Slide (section, { |
| 390 | + onComplete: function() { |
| 391 | + |
| 392 | + // 1 = SLIDE OUT EVENT |
| 393 | + if (stage==1) { |
| 394 | + stage = 2; |
| 395 | + var anchor = null; |
| 396 | + var rel = null; |
| 397 | + |
| 398 | + /* the div that is actually moving is |
| 399 | + * intermediate (inserted by MooTools) */ |
| 400 | + var moving = section.getParent(); |
| 401 | + |
| 402 | + /* newIndex offset is always +2, to skip the first (anonymous) |
| 403 | + * introduction section and the instruction box. both are inside |
| 404 | + * the generic editor (even if they shouldn't be) */ |
| 405 | + var target = $(editor.getChildren()[newIndex + 2]); |
| 406 | + |
| 407 | + if (newIndex < oldIndex) { |
| 408 | + /* we're moving UP - don't need to |
| 409 | + * check for failure, because there |
| 410 | + * will always be the first anonymous |
| 411 | + * section to anchor from */ |
| 412 | + anchor = target.getPrevious(); |
| 413 | + rel = "after"; |
| 414 | + |
| 415 | + } else { |
| 416 | + // moving DOWN |
| 417 | + anchor = target.getNext(); |
| 418 | + rel = "before"; |
| 419 | + |
| 420 | + /* if getNext failed, it's because there |
| 421 | + * are no more siblings - we're moving to |
| 422 | + * the bottom of the list! */ |
| 423 | + if (!anchor) { |
| 424 | + anchor = target.getParent(); |
| 425 | + rel = "bottom"; |
| 426 | + } |
| 427 | + } |
| 428 | + |
| 429 | + /* inject the intermediate slider at the right position in |
| 430 | + * the DOM, and slide back in. delay it to avoid weird race |
| 431 | + * condition in IE6, which i don't have time to debug */ |
| 432 | + moving.inject(anchor, rel); |
| 433 | + (function () { slider.slideIn(); }).delay(100); |
| 434 | + |
| 435 | + // 2 = SLIDE IN EVENT |
| 436 | + } else if (stage==2) { |
| 437 | + |
| 438 | + /* get rid of intermediate element, |
| 439 | + * and don't re-call this event. this |
| 440 | + * breaks encapsulation, and is a hack :( */ |
| 441 | + section.replaces (section.getParent()); |
| 442 | + section.store ("wrapper", null); |
| 443 | + slider.removeEvents ("onComplete"); |
| 444 | + |
| 445 | + /* remove all section and sect (checkbox) ids |
| 446 | + * (nodes can't share ids, even temporarily) */ |
| 447 | + var sections = $$(".generic-editor > div.section"); |
| 448 | + var sects = $$("#section-box .sortables > div"); |
| 449 | + var func_rem = function (el) { el.id = '' }; |
| 450 | + sections.each (func_rem); |
| 451 | + sects.each (func_rem); |
| 452 | + |
| 453 | + /* now re-name every field in each section, to |
| 454 | + * reflect their new position in the DOM */ |
| 455 | + sections.each (function (el,index) { |
| 456 | + el.id = "section-" + index; |
| 457 | + |
| 458 | + /* also update the indexes within each form field |
| 459 | + * of the section (so they're put back together |
| 460 | + * in the right order when we save changes */ |
| 461 | + el.getElements ("input,textarea").each (function (field) { |
| 462 | + field.name = field.name.replace (/\d+$/, index); |
| 463 | + }); |
| 464 | + }); |
| 465 | + |
| 466 | + /* as above, for sect /checkboxes, |
| 467 | + * which start at index 1 (no checkbox |
| 468 | + * for the anonymous first section */ |
| 469 | + sects.each(function(el,index) { |
| 470 | + el.id = "sect-" + (index+1); |
| 471 | + el.getElements ("input").each(function(field) { |
| 472 | + field.name = field.name.replace(/\d+$/, (index+1)); |
| 473 | + }); |
| 474 | + }); |
| 475 | + |
| 476 | + // turn back on reordering and natural sizing |
| 477 | + Uniwiki.GenericEditPage.sections_sortables.attach(); |
| 478 | + Uniwiki.GenericEditPage.sections_sorting = true; |
| 479 | + Uniwiki.GenericEditPage.unlock_editor_height(); |
| 480 | + |
| 481 | + /* in case i cocked-up this function, |
| 482 | + * and it ends up being called again */ |
| 483 | + stage = null; |
| 484 | + } |
| 485 | + } |
| 486 | + |
| 487 | + /* slide out first, then do some logic |
| 488 | + * (above, stage 1), then slide back in */ |
| 489 | + }).slideOut(); |
| 490 | + } |
| 491 | + }); |
| 492 | + |
| 493 | + // == PREVENT DRAGGING BY CHECKBOXES! == |
| 494 | + /* cancel mousedown events in checkboxes within the sections box, to |
| 495 | + * prevent the sortables behaviour from firing. this prevents people |
| 496 | + * dragging checkboxes around, and toggling them at the same time */ |
| 497 | + sortables.getElements("input[type=checkbox]").addEvent("mousedown", function(e) { |
| 498 | + e.stop(); |
| 499 | + }); |
| 500 | + } |
| 501 | + } // Events |
| 502 | +}; |
| 503 | + |
Index: trunk/extensions/uniwiki/CreatePage/CreatePage.i18n.php |
— | — | @@ -0,0 +1,50 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Generic_Edit_Page |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +$wgCreatePageMessages = array(); |
| 12 | +$wgCreatePageMessages['en'] = array( |
| 13 | + 'createpage' => "Create a page", |
| 14 | + 'createpage_submitbutton' => "Submit", |
| 15 | + 'createpage_instructions' => "Enter the title of the page you wish to create:", |
| 16 | + 'createpage_entertitle' => "Please enter a title for your page.", |
| 17 | + 'createpage_titleexists' => "A page with this title, [[$1]], already exists. Would you like to edit the existing page?", |
| 18 | + 'createpage_tryagain' => "No - I want to create a new page with a distinct title.", |
| 19 | + 'createpage_editexisting' => "Yes - I want to contribute to the existing page." |
| 20 | +); |
| 21 | + |
| 22 | +$wgCreatePageMessages['es'] = array( |
| 23 | + 'createpage' => "Crear una página", |
| 24 | + 'createpage_submitbutton' => "Enviar", |
| 25 | + 'createpage_instructions' => "Ingresa el título de la página que deseas crear:", |
| 26 | + 'createpage_entertitle' => "Ingresa un título para tu página.", |
| 27 | + 'createpage_titleexists' => "Ya existe una página con el título [[$1]]. ¿Quieres editar la página que ya existe?", |
| 28 | + 'createpage_tryagain' => "No – quiero crear una página nueva con un título diferente.", |
| 29 | + 'createpage_editexisting' => "Sí – quiero contribuir a la página que ya existe." |
| 30 | +); |
| 31 | + |
| 32 | +$wgCreatePageMessages['de'] = array( |
| 33 | + 'createpage' => "Neue Seite erstellen", |
| 34 | + 'createpage_submitbutton' => "Senden", |
| 35 | + 'createpage_instructions' => "Gib den Namen der neu zu erstellenden Seite ein:", |
| 36 | + 'createpage_entertitle' => "Titel für deine Seite.", |
| 37 | + 'createpage_titleexists' => "Eine Seite mit diesem Namen [[$1]] existiert bereits. Möchtest Du die existierende Seite bearbeiten?", |
| 38 | + 'createpage_tryagain' => "Nein - Ich möchte eine neue Seite mit einem anderen Titel anlegen.", |
| 39 | + 'createpage_editexisting' => "Ja - Ich möchte die existierende Seite bearbeiten." |
| 40 | +); |
| 41 | + |
| 42 | +$wgCreatePageMessages['pt-br'] = array( |
| 43 | + 'createpage' => "Criar uma página", |
| 44 | + 'createpage_submitbutton' => "Criar", |
| 45 | + 'createpage_instructions' => "Digite o título da página que você gostaria de criar:", |
| 46 | + 'createpage_entertitle' => "Digite um título para sua página.", |
| 47 | + 'createpage_titleexists' => "Uma página com o título, [[$1]], já existe. Você gostaria de editar a página existente?", |
| 48 | + 'createpage_tryagain' => "Não - Eu quero criar uma nova página com outro título.", |
| 49 | + 'createpage_editexisting' => "Sim - Eu quero editar a página existente." |
| 50 | +); |
| 51 | + |
Index: trunk/extensions/uniwiki/CreatePage/CreatePage.php |
— | — | @@ -0,0 +1,118 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Generic_Edit_Page |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined('MEDIAWIKI')) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +/* This code was adapted from CreatePage.php from: |
| 14 | + * Travis Derouin <travis@wikihow.com> |
| 15 | + * |
| 16 | + * originally licensed as: |
| 17 | + * GNU GPL v2.0 or later */ |
| 18 | + |
| 19 | +$wgExtensionCredits['other'][] = array( |
| 20 | + 'name' => "CreatePage", |
| 21 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 22 | + 'description' => "Adds a Special Page for creating new pages" |
| 23 | +); |
| 24 | + |
| 25 | +$wgHooks['BeforePageDisplay'][] = 'UW_CreatePage_CSS'; |
| 26 | +function UW_CreatePage_CSS($out) { |
| 27 | + global $wgScriptPath; |
| 28 | + $out->addScript ("<link rel='stylesheet' href='$wgScriptPath/extensions/uniwiki/CreatePage/style.css' />"); |
| 29 | + return true; |
| 30 | +} |
| 31 | + |
| 32 | + |
| 33 | +/* ---- INTERNATIONALIZATION ---- */ |
| 34 | + |
| 35 | +require_once( 'CreatePage.i18n.php' ); |
| 36 | +$wgExtensionFunctions[] = 'UW_CreatePage_i18n'; |
| 37 | + |
| 38 | +function UW_CreatePage_i18n() { |
| 39 | + // add this extension's messages to the message cache |
| 40 | + global $wgMessageCache, $wgCreatePageMessages; |
| 41 | + foreach ($wgCreatePageMessages as $lang => $messages) |
| 42 | + $wgMessageCache->addMessages ($messages, $lang); |
| 43 | +} |
| 44 | + |
| 45 | + |
| 46 | +/* ---- SPECIAL PAGE ---- */ |
| 47 | + |
| 48 | +require_once("SpecialPage.php"); |
| 49 | + |
| 50 | +$wgExtensionFunctions[] = "wfCreatePage"; |
| 51 | +function wfCreatePage() { |
| 52 | + SpecialPage::AddPage (new SpecialPage ("CreatePage")); } |
| 53 | + |
| 54 | + |
| 55 | +function wfSpecialCreatePage ($parser) { |
| 56 | + global $wgOut, $wgRequest, $wgUser; |
| 57 | + $skin = $wgUser->getSkin(); |
| 58 | + $thisPage = Title::newFromText ("CreatePage", NS_SPECIAL); |
| 59 | + $target = $wgRequest->getVal ("target", null); |
| 60 | + |
| 61 | + // check to see if we are trying to create a page |
| 62 | + if ($target != null) { |
| 63 | + $title = Title::newFromText ($target); |
| 64 | + |
| 65 | + if ($title->getArticleID() > 0) { |
| 66 | + |
| 67 | + // if the title exists then let the user know and give other options |
| 68 | + $wgOut->addWikiText (wfMsg ("createpage_titleexists", $title->getFullText())."<br/>"); |
| 69 | + $wgOut->addHTML ("<a href='".$title->getEditURL()."'>".wfMsg ("createpage_editexisting")."</a><br/>" |
| 70 | + .$skin->makeLinkObj ($thisPage, wfMsg ("createpage_tryagain")) |
| 71 | + ); |
| 72 | + } else { |
| 73 | + /* TODO - may want to search for closely named pages and give |
| 74 | + * other options here... */ |
| 75 | + |
| 76 | + // otherwise, redirect them to the edit page for their title |
| 77 | + $wgOut->redirect ($title->getEditURL()); |
| 78 | + } |
| 79 | + |
| 80 | + return; |
| 81 | + } |
| 82 | + |
| 83 | + // if this is just a normal GET, then output the form |
| 84 | + |
| 85 | + // prefill the input with the title, if it was passed along |
| 86 | + $newTitle = $wgRequest->getVal("newtitle", null); |
| 87 | + if ($newTitle != null) $newTitle = str_replace("_", " ", $newTitle); |
| 88 | + |
| 89 | + // add some instructions |
| 90 | + $wgOut->addHTML(wfMsg('createpage_instructions')); |
| 91 | + |
| 92 | + // js for checking the form |
| 93 | + $wgOut->addHTML(" |
| 94 | + <script type='text/javascript' > |
| 95 | + function checkForm(){ |
| 96 | + // check the title |
| 97 | + if (document.createpageform.target && document.createpageform.target.value == \"\") { |
| 98 | + alert('".wfMsg('createpage_entertitle')."'); |
| 99 | + document.createpageform.target.focus(); |
| 100 | + return false; |
| 101 | + } |
| 102 | + // everything is OK, return true |
| 103 | + return true; |
| 104 | + } |
| 105 | + </script> |
| 106 | + "); |
| 107 | + |
| 108 | + // output the form |
| 109 | + $wgOut->addHTML(" |
| 110 | + <form method=POST onsubmit='return checkForm()' name='createpageform'> |
| 111 | + <input type=text name=target size=50 value='$newTitle'><br/><br/> |
| 112 | + "); |
| 113 | + |
| 114 | + $wgOut->addHTML(" |
| 115 | + <input type=submit value='".wfMsg('createpage_submitbutton')."'> |
| 116 | + </form> |
| 117 | + "); |
| 118 | +} |
| 119 | + |
Index: trunk/extensions/uniwiki/CreatePage/style.css |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +/* create a page BUTTON */ |
| 3 | +#p-create h5 { display: none; } |
| 4 | + |
| 5 | +#p-create ul { |
| 6 | + margin: 0; |
| 7 | + border: 0; |
| 8 | + padding: 0; |
| 9 | +} |
| 10 | + |
| 11 | +#p-create li { |
| 12 | + list-style: none; |
| 13 | + margin-bottom: 1em; |
| 14 | + list-style-image: none; |
| 15 | +} |
| 16 | + |
| 17 | +#p-create .pBody { |
| 18 | + padding-bottom: 0; |
| 19 | + border: 0; |
| 20 | +} |
| 21 | + |
| 22 | + #p-create .pBody a { |
| 23 | + display: block; |
| 24 | + font-size: 18px; |
| 25 | + font-weight: bold; |
| 26 | + line-height: 1; |
| 27 | + text-align: center; |
| 28 | + border: 2px solid #c7c7c7; |
| 29 | + border-top-width: 4px; |
| 30 | + padding: 1em 0; |
| 31 | + color: #0099ff; |
| 32 | + } |
Index: trunk/extensions/uniwiki/Layouts/Layouts.i18n.php |
— | — | @@ -0,0 +1,50 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Layouts |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +$wgLayoutsMessages = array(); |
| 12 | +$wgLayoutsMessages['en'] = array( |
| 13 | + 'layouts_title' => "Create a page", |
| 14 | + 'layouts_chooselayout' => "Choose a Layout for $1:", |
| 15 | + 'layouts_nolayout' => "No layout", |
| 16 | + 'layouts_continue' => "Continue", |
| 17 | + 'layouts_choosecategory' => "Choose a Category for $1:", |
| 18 | + 'layouts_unknown' => "UNKNOWN", |
| 19 | + 'layouts_tagline' => "This page was generated by the <strong>$1</strong> layout." |
| 20 | +); |
| 21 | + |
| 22 | +$wgLayoutsMessages['es'] = array( |
| 23 | + 'layouts_title' => "Crear una página", |
| 24 | + 'layouts_chooselayout' => "Selecciona un Diseño para $1:", |
| 25 | + 'layouts_nolayout' => "Sin diseño", |
| 26 | + 'layouts_continue' => "Continuar", |
| 27 | + 'layouts_choosecategory' => "Elige una Categoría para $1:", |
| 28 | + 'layouts_unknown' => "DESCONOCIDO", |
| 29 | + 'layouts_tagline' => "Esta página se generó con el diseño <strong>$1</strong>." |
| 30 | +); |
| 31 | + |
| 32 | +$wgLayoutsMessages['de'] = array( |
| 33 | + 'layouts_title' => "Neue Seite erstellen", |
| 34 | + 'layouts_chooselayout' => "Suche ein Format aus für $1:", |
| 35 | + 'layouts_nolayout' => "Kein Format", |
| 36 | + 'layouts_continue' => "Weiter", |
| 37 | + 'layouts_choosecategory' => "Suche ein Club aus für $1:", |
| 38 | + 'layouts_unknown' => "UNBEKANNT", |
| 39 | + 'layouts_tagline' => "Diese Seite wurde mit dem <strong>$1</strong> Layout erstellt." |
| 40 | +); |
| 41 | + |
| 42 | +$wgLayoutsMessages['pt-br'] = array( |
| 43 | + 'layouts_title' => "Criar uma página", |
| 44 | + 'layouts_chooselayout' => "Escolher um Layout para o $1:", |
| 45 | + 'layouts_nolayout' => "Sem layout", |
| 46 | + 'layouts_continue' => "Continuar", |
| 47 | + 'layouts_choosecategory' => "Escolher uma Categoria para o $1:", |
| 48 | + 'layouts_unknown' => "DESCONHECIDO", |
| 49 | + 'layouts_tagline' => "Esta página foi gerada pelo layout <strong>$1</strong>." |
| 50 | +); |
| 51 | + |
Index: trunk/extensions/uniwiki/Layouts/Layouts.php |
— | — | @@ -0,0 +1,287 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Layouts |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined('MEDIAWIKI')) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +$wgExtensionCredits['other'][] = array( |
| 14 | + 'name' => "Layouts", |
| 15 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 16 | + 'description' => "Populate newly-created pages with editable \"layouts\", to encourage a common structure to articles" |
| 17 | +); |
| 18 | + |
| 19 | + |
| 20 | +/* ---- CONFIGURABLE OPTIONS ---- */ |
| 21 | + |
| 22 | +$wgAddLayoutLink = true; |
| 23 | +$wgLayoutWhiteList = array(NS_MAIN); |
| 24 | +$wgLayoutCategories = false; |
| 25 | +$wgLayoutUseCategoryPage = true; |
| 26 | +$wgLayoutCategoryPage = "MediaWiki:Editpagetags"; |
| 27 | +$wgLayoutCategoryNSWhiteList = array(NS_MAIN); |
| 28 | +$wgNoLayoutOption = true; |
| 29 | + |
| 30 | + |
| 31 | +/* ---- INTERNATIONALIZATION ---- */ |
| 32 | + |
| 33 | +require_once ("Layouts.i18n.php"); |
| 34 | +$wgExtensionFunctions[] = "UW_Layouts_i18n"; |
| 35 | + |
| 36 | +function UW_Layouts_i18n() { |
| 37 | + // add this extension's messages to the message cache |
| 38 | + global $wgMessageCache, $wgLayoutsMessages; |
| 39 | + foreach ($wgLayoutsMessages as $lang => $messages) |
| 40 | + $wgMessageCache->addMessages ($messages, $lang); |
| 41 | +} |
| 42 | + |
| 43 | + |
| 44 | +/* ---- NAMESPACES ---- */ |
| 45 | + |
| 46 | +/* assign constants to number our namespaces if they |
| 47 | + * haven't already been defined (in localsettings) */ |
| 48 | +if (!defined ("NS_LAYOUT")) define ("NS_LAYOUT", 100); # even = content |
| 49 | +if (!defined ("NS_LAYOUT_TALK")) define ("NS_LAYOUT_TALK", 101); # odd = discussion |
| 50 | + |
| 51 | +// create the namespaces |
| 52 | +$wgExtraNamespaces[NS_LAYOUT] = "Layout"; |
| 53 | +$wgExtraNamespaces[NS_LAYOUT_TALK] = "Layout_talk"; |
| 54 | + |
| 55 | +# only sysops can edit the layouts |
| 56 | +$wgNamespaceProtection[NS_LAYOUT] = array ("editlayouts"); |
| 57 | +$wgGroupPermissions['sysop']['editlayouts'] = true; |
| 58 | + |
| 59 | + |
| 60 | +/* ---- TAGS ---- */ |
| 61 | + |
| 62 | +$wgExtensionFunctions[] = "UW_Layouts_EF"; |
| 63 | +function UW_Layouts_EF() { |
| 64 | + global $wgParser; |
| 65 | + $wgParser->setHook ("layout", "UW_Layouts_EF_Render"); |
| 66 | +} |
| 67 | + |
| 68 | +/* render a note to display the name of the |
| 69 | + * layout that this page was created from */ |
| 70 | +function UW_Layouts_EF_Render ($input, $args, $parser) { |
| 71 | + //$name = isset($args['name']) ? Title::newFromURL("Layout:".$args['name'])->getText() : wfMsg('layouts_unknown'); |
| 72 | + //return "<div class='layout-name'><p>".wfMsg('layouts_tagline', $name)."</p></div>"; |
| 73 | + return ""; |
| 74 | +} |
| 75 | + |
| 76 | + |
| 77 | +/* ---- HOOKS ---- */ |
| 78 | + |
| 79 | +$wgHooks['CustomEditor'][] = "UW_Layouts_maybeRedirectToLayout"; |
| 80 | +function UW_Layouts_maybeRedirectToLayout($article, $user) { |
| 81 | + global $wgOut, $wgRequest, $wgLayoutWhiteList; |
| 82 | + |
| 83 | + /* don't hijack the request if we are |
| 84 | + * in the middle of switching modes */ |
| 85 | + if ($wgRequest->data['switch-mode']) |
| 86 | + return true; |
| 87 | + |
| 88 | + /* if this page is new, |
| 89 | + * no layout variable is in the query string, |
| 90 | + * and the page is in a namespace that is using the extension |
| 91 | + * and we are not submitting the form (either saving OR preview) */ |
| 92 | + if ($article->fetchContent()===false |
| 93 | + && ($wgRequest->getVal ("layout")===NULL) |
| 94 | + && in_array ($article->mTitle->getNamespace(), $wgLayoutWhiteList) |
| 95 | + && ($wgRequest->getVal("action") != "submit")) |
| 96 | + |
| 97 | + // redirect to the "pick a layout" page! |
| 98 | + $wgOut->redirect($article->mTitle->getInternalUrl ("action=layout")); |
| 99 | + |
| 100 | + return true; |
| 101 | +} |
| 102 | + |
| 103 | +$wgHooks['UnknownAction'][] = "UW_Layouts_checkActionIsLayout"; |
| 104 | +function UW_Layouts_checkActionIsLayout($action, $article) { |
| 105 | + global $wgOut, $wgDBprefix, $wgLayoutCategories, $wgLayoutUseCategoryPage, |
| 106 | + $wgNoLayoutOption, $wgLayoutCategoryPage, $wgContLang, |
| 107 | + $wgLayoutCategoryNSWhiteList; |
| 108 | + |
| 109 | + // not layout = do nothing |
| 110 | + if ($action!="layout") |
| 111 | + return true; |
| 112 | + |
| 113 | + /* if this page already exists, or |
| 114 | + * is a discussion page, redirect |
| 115 | + * to the regular edit page */ |
| 116 | + if ($article->fetchContent()!==false |
| 117 | + || ($article->mTitle->getNamespace() % 2)) { |
| 118 | + $wgOut->redirect($article->mTitle->getInternalUrl ("action=edit")); |
| 119 | + return false; |
| 120 | + } |
| 121 | + |
| 122 | + // pluck out the bits that we need from mTitle |
| 123 | + $title = $article->mTitle->getPrefixedText(); |
| 124 | + $url = $article->mTitle->getInternalUrl(); |
| 125 | + $name = $article->mTitle->getPrefixedURL(); |
| 126 | + $namespace = $article->mTitle->getNamespace(); |
| 127 | + |
| 128 | + $wgOut->setPageTitle (wfMsg ("layouts_title")); |
| 129 | + |
| 130 | + /* fetch all articles/pages in the NS_LAYOUT namespace |
| 131 | + * by directly querying the database. mediawiki doesn't |
| 132 | + * provide any OO way of doing this :( */ |
| 133 | + $db = wfGetDB(DB_MASTER); |
| 134 | + $layouts = $db->resultObject ($db->query ("select * from {$wgDBprefix}page where page_namespace=".NS_LAYOUT." order by page_title")); |
| 135 | + |
| 136 | + $wgOut->addHTML (wfMsg ("layouts_chooselayout", $title)." |
| 137 | + <form action='$url' method='get'> |
| 138 | + <input type='hidden' name='title' value='$name' /> |
| 139 | + <input type='hidden' name='action' value='edit' /> |
| 140 | + "); |
| 141 | + |
| 142 | + /* iterate the pages we found in the Layouts |
| 143 | + * namespace, and list each one as an option |
| 144 | + * as long as it is not restricted to specific |
| 145 | + * namespaces */ |
| 146 | + $default = true; |
| 147 | + while ($result=$layouts->next()) { |
| 148 | + // page info |
| 149 | + $title = Title::newFromURL ($result->page_title)->getText(); |
| 150 | + $revision = Revision::loadFromPageId ($db, $result->page_id); |
| 151 | + $text = $revision->getText(); |
| 152 | + $lines = explode ("\n", $text); |
| 153 | + $namespaces = array(); |
| 154 | + |
| 155 | + // add this layout to the choices by default |
| 156 | + $add = true; |
| 157 | + |
| 158 | + /* go through the layout text and see if it has an @namespace |
| 159 | + * restriction, if so only add the layout as a choice if we find |
| 160 | + * the namespace of this page in the layout text */ |
| 161 | + foreach ($lines as $line) { |
| 162 | + if (preg_match ("/^@namespace(.+?)$/m", $line, $matches)) { |
| 163 | + $namespaces = explode (" ", trim($matches[1])); |
| 164 | + $add = in_array ($wgContLang->getNsText ($namespace), $namespaces) || |
| 165 | + $namespace == NS_MAIN && in_array ("Main", $namespaces); |
| 166 | + } |
| 167 | + } |
| 168 | + if ($add) { |
| 169 | + $checked = $default ? "checked='checked'" : ""; |
| 170 | + $default = false; |
| 171 | + $fm_id = "layout-".$result->page_id; |
| 172 | + $wgOut->addHTML(" |
| 173 | + <div> |
| 174 | + <input type='radio' name='layout' id='$fm_id' value='$title' $checked/> |
| 175 | + <label for='$fm_id'>$title</label> |
| 176 | + </div> |
| 177 | + "); |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + /* include an option to create a page |
| 182 | + * without any layout (before any are created, |
| 183 | + * this will be the only option available) */ |
| 184 | + if ($wgNoLayoutOption) { |
| 185 | + $wgOut->addHTML(" |
| 186 | + <div> |
| 187 | + <input type='radio' name='layout' id='layout-0' value='none' /> |
| 188 | + <label for='layout-0'>".wfMsg('layouts_nolayout')."</label> |
| 189 | + </div> |
| 190 | + "); |
| 191 | + } |
| 192 | + $wgOut->addHTML("<br/>"); |
| 193 | + |
| 194 | + /* check to see if we are allowing categories on the layout page |
| 195 | + * and if so then, either grab all the categories, or get them from |
| 196 | + * the designated page (do this for pages in the whitelisted namespaces) */ |
| 197 | + if ($wgLayoutCategories && in_array($namespace, $wgLayoutCategoryNSWhiteList)) { |
| 198 | + $categories = array(); |
| 199 | + |
| 200 | + /* get the categories from the page if desired, |
| 201 | + * otherwise grab them from the db */ |
| 202 | + if ($wgLayoutUseCategoryPage) { |
| 203 | + $revision = Revision::newFromTitle(Title::newFromDBKey($wgLayoutCategoryPage)); |
| 204 | + $results = $revision ? split("\n", $revision->getText()) : array(); |
| 205 | + foreach ($results as $result) { |
| 206 | + if (trim ($result) != '') |
| 207 | + $categories[] = Title::newFromText(trim($result))->getDBkey(); |
| 208 | + } |
| 209 | + } else { |
| 210 | + // todo: implement this later... |
| 211 | + } |
| 212 | + |
| 213 | + // add radio buttons for the categories |
| 214 | + $default = true; |
| 215 | + $title = $article->mTitle->getPrefixedText(); |
| 216 | + $wgOut->addHTML("<div id='category-box'>".wfMsg ("layouts_choosecategory", $title)); |
| 217 | + foreach ($categories as $category) { |
| 218 | + $checked = $default ? "checked='checked'" : ""; |
| 219 | + $default = false; |
| 220 | + $fm_id = "category-$category"; |
| 221 | + $caption = Title::newFromDBkey ($category)->getText(); |
| 222 | + $wgOut->addHTML(" |
| 223 | + <div> |
| 224 | + <input type='radio' name='category' id='$fm_id' value='$fm_id' $checked/> |
| 225 | + <label for='$fm_id'>$caption</label> |
| 226 | + </div> |
| 227 | + "); |
| 228 | + } |
| 229 | + $wgOut->addHTML ("</div><br/>"); |
| 230 | + } |
| 231 | + |
| 232 | + $wgOut->addHTML ("<input type='submit' value='".wfMsg('layouts_continue')."' />"); |
| 233 | + $wgOut->addHTML ("</form>"); |
| 234 | + |
| 235 | + return false; |
| 236 | +} |
| 237 | + |
| 238 | +$wgHooks['SkinTemplateSetupPageCss'][] = "UW_Layouts_Css"; |
| 239 | +function UW_Layouts_Css (&$out) { |
| 240 | + global $wgScriptPath; |
| 241 | + $out .= "@import '$wgScriptPath/extensions/uniwiki/Layouts/style.css';\n"; |
| 242 | + return true; |
| 243 | +} |
| 244 | + |
| 245 | +$wgHooks['EditFormPreloadText'][] = "UW_Layouts_preFillTextBox"; |
| 246 | +function UW_Layouts_preFillTextBox (&$text, $title) { |
| 247 | + global $wgRequest, $wgAddLayoutLink; |
| 248 | + |
| 249 | + /* fetch the layout from the query string, |
| 250 | + * or abort this hook if it is missing */ |
| 251 | + $layout_slug = $wgRequest->getVal ("layout"); |
| 252 | + if ($layout_slug === NULL) |
| 253 | + return true; |
| 254 | + |
| 255 | + // fetch the layout object |
| 256 | + $layout_title = Title::newFromURL ("Layout:".$layout_slug); |
| 257 | + $layout_article = new Article ($layout_title); |
| 258 | + |
| 259 | + /* if the layout article exists, pre-fill the textarea with its |
| 260 | + * wiki text. if it doesn't exist, do nothing (no error) */ |
| 261 | + if (($layout_text = $layout_article->fetchContent()) !== false) { |
| 262 | + |
| 263 | + /* break the layout text into sections by splitting |
| 264 | + * at header level =one= or ==two==, and iterate */ |
| 265 | + $nodes = preg_split ("/^(==?[^=].*)$/mi", $layout_text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 266 | + for ($i=0; $i<count($nodes); $i++) { |
| 267 | + |
| 268 | + /* if the next node is OPTIONAL, then skip over it |
| 269 | + * (it will be included if using GenericEditor) */ |
| 270 | + if (preg_match ("/^@optional$/m", $nodes[$i+1])) { |
| 271 | + $i++; |
| 272 | + |
| 273 | + /* not an optional section, or |
| 274 | + * text that hasn't been skipped */ |
| 275 | + } else { |
| 276 | + |
| 277 | + // DO NOT copy over directives. remove them all! |
| 278 | + $text .= preg_replace ("/^@.*/m", "", $nodes[$i]); |
| 279 | + } |
| 280 | + } |
| 281 | + } |
| 282 | + |
| 283 | + if ($wgAddLayoutLink && $layout_slug != 'none') |
| 284 | + $text .= "\n\n<layout name=\"$layout_slug\" />"; |
| 285 | + |
| 286 | + return true; |
| 287 | +} |
| 288 | + |
Index: trunk/extensions/uniwiki/Layouts/style.css |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +div.layout-name { |
| 3 | + position: absolute; |
| 4 | + border: 1px solid #aaa; |
| 5 | + background: #f0f0f0; |
| 6 | + right: 1em; |
| 7 | + padding: 5px 10px; |
| 8 | + margin-top: 1em; |
| 9 | + color: #888; |
| 10 | +} |
| 11 | + |
| 12 | +div.layout-name strong { |
| 13 | + color: #444; |
| 14 | +} |
| 15 | + |
| 16 | +/* sidebar search form */ |
| 17 | +#p-search .pBody { |
| 18 | + padding: 0pt 0.8em 0.3em 0.5em; |
| 19 | +} |
| 20 | + |
| 21 | + #p-search form { |
| 22 | + padding: 5px; |
| 23 | + } |
| 24 | + |
| 25 | + #searchInput { |
| 26 | + width: 10em; |
| 27 | + margin-bottom: 4px; |
| 28 | + } |
| 29 | + |
| 30 | + /* hide the "GO" button, but leave |
| 31 | + * it accessible by hitting ENTER */ |
| 32 | + #searchGoButton { display: none; } |
| 33 | + |
Index: trunk/extensions/uniwiki/FormatChanges/FormatChanges.i18n.php |
— | — | @@ -0,0 +1,14 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | +if (!defined("MEDIAWIKI")) |
| 7 | + die(); |
| 8 | + |
| 9 | +$wgFormatChangesMessages = array(); |
| 10 | + |
| 11 | +$wgFormatChangesMessages['en'] = array( |
| 12 | + 'fc_anonymous' => "Anonymous", |
| 13 | + 'fc_createdby' => "created by", |
| 14 | + 'fc_editedby' => "edited by" |
| 15 | +); |
Index: trunk/extensions/uniwiki/FormatChanges/FormatChanges.php |
— | — | @@ -0,0 +1,88 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | +if (!defined("MEDIAWIKI")) |
| 7 | + die(); |
| 8 | + |
| 9 | + |
| 10 | +/* ---- CREDITS ---- */ |
| 11 | + |
| 12 | +$wgExtensionCredits['other'][] = array( |
| 13 | + 'name' => "Authors", |
| 14 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 15 | + 'description' => "Reformats the recent changes in a human-readable fashion." |
| 16 | +); |
| 17 | + |
| 18 | +/* ---- INTERNATIONALIZATION ---- */ |
| 19 | + |
| 20 | +require_once ("FormatChanges.i18n.php"); |
| 21 | +$wgExtensionFunctions[] = "UW_FormatChanges_i18n"; |
| 22 | + |
| 23 | +function UW_FormatChanges_i18n() { |
| 24 | + // add this extension's messages to the message cache |
| 25 | + global $wgMessageCache, $wgFormatChangesMessages; |
| 26 | + foreach ($wgFormatChangesMessages as $lang => $messages) |
| 27 | + $wgMessageCache->addMessages ($messages, $lang); |
| 28 | +} |
| 29 | + |
| 30 | +/* ---- HOOKS ---- */ |
| 31 | + |
| 32 | +$wgHooks['FetchChangesList'][] = "UW_FormatChanges"; |
| 33 | +function UW_FormatChanges($user, $skin, $list) { |
| 34 | + $list = new UniwikiChangesList($skin); |
| 35 | + return false; |
| 36 | +} |
| 37 | + |
| 38 | +class UniwikiChangesList extends ChangesList { |
| 39 | + |
| 40 | + public function recentChangesLine(&$rc, $watched=false) { |
| 41 | + global $wgLang; |
| 42 | + |
| 43 | + // set local vars (this apparently does that) |
| 44 | + extract($rc->mAttribs); |
| 45 | + |
| 46 | + $this->insertDateHeader($line, $rc_timestamp); |
| 47 | + |
| 48 | + /* NOTE: the following logic is reproduced from |
| 49 | + * the old version of the recent changes |
| 50 | + * page in case we want to produce a |
| 51 | + * similar result (though much is not |
| 52 | + * implemented yet)... |
| 53 | + */ |
| 54 | + |
| 55 | + // moved pages |
| 56 | + if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { |
| 57 | + // handle these? |
| 58 | + } |
| 59 | + // log entries(old) and special pages |
| 60 | + else if ($rc_namespace == NS_SPECIAL) { |
| 61 | + // handle these? |
| 62 | + } |
| 63 | + // new unpatrolled pages |
| 64 | + else if ($rc->unpatrolled && $rc_type == RC_NEW) { |
| 65 | + // handle these? |
| 66 | + } |
| 67 | + // log entries |
| 68 | + else if ($rc_type == RC_LOG) { |
| 69 | + // handle these? |
| 70 | + } |
| 71 | + // edits and new pages |
| 72 | + else { |
| 73 | + $line .= "<li>"; |
| 74 | + $page_link = $this->skin->makeKnownLinkObj($rc->getTitle(), ''); |
| 75 | + if ($this->isDeleted($rc, Revision::DELETED_USER)) { |
| 76 | + $user_link = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>'; |
| 77 | + } else { |
| 78 | + $user_link = ($rc_user > 0) ? $this->skin->userLink($rc_user, $rc_user_text) : wfMsg('fc_anonymous'); |
| 79 | + } |
| 80 | + $timestamp = $wgLang->time($rc->mAttribs['rc_timestamp'], true, true); |
| 81 | + $action = ($rc_type == RC_NEW) ? wfMsg('fc_createdby') : wfMsg('fc_editedby'); |
| 82 | + $line .= $page_link . " - " . $action . " " . $user_link . " (" . $timestamp . ")"; |
| 83 | + $line .= "</li>"; |
| 84 | + } |
| 85 | + |
| 86 | + return $line; |
| 87 | + } |
| 88 | + |
| 89 | +} |
Index: trunk/extensions/uniwiki/uniwiki.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/uniwiki/uniwiki.png |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 90 | + application/octet-stream |
Index: trunk/extensions/uniwiki/Authors/Authors.i18n.php |
— | — | @@ -0,0 +1,13 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | +if (!defined("MEDIAWIKI")) |
| 7 | + die(); |
| 8 | + |
| 9 | +$wgAuthorsMessages = array(); |
| 10 | + |
| 11 | +$wgAuthorsMessages['en'] = array( |
| 12 | + 'authors_authors' => "Authors", |
| 13 | + 'authors_anonymous' => "Anonymous" |
| 14 | +); |
Index: trunk/extensions/uniwiki/Authors/Authors.php |
— | — | @@ -0,0 +1,109 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Authors |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined("MEDIAWIKI")) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +/* ---- CREDITS ---- */ |
| 12 | + |
| 13 | +$wgExtensionCredits['other'][] = array( |
| 14 | + 'name' => "Authors", |
| 15 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 16 | + 'description' => "Appends a list of contributors to articles" |
| 17 | +); |
| 18 | + |
| 19 | +/* ---- INTERNATIONALIZATION ---- */ |
| 20 | + |
| 21 | +require_once ("Authors.i18n.php"); |
| 22 | +$wgExtensionFunctions[] = "UW_Authors_i18n"; |
| 23 | + |
| 24 | +function UW_Authors_i18n() { |
| 25 | + // add this extension's messages to the message cache |
| 26 | + global $wgMessageCache, $wgAuthorsMessages; |
| 27 | + foreach ($wgAuthorsMessages as $lang => $messages) |
| 28 | + $wgMessageCache->addMessages ($messages, $lang); |
| 29 | +} |
| 30 | + |
| 31 | +/* ---- CONFIGURABLE OPTIONS ---- */ |
| 32 | + |
| 33 | +$wgShowAuthorsNamespaces = array (NS_MAIN); |
| 34 | +$wgShowAuthors = true; |
| 35 | + |
| 36 | + |
| 37 | +/* ---- HOOKS ---- */ |
| 38 | + |
| 39 | +$wgHooks['OutputPageBeforeHTML'][] = "UW_Authors_List"; |
| 40 | +function UW_Authors_List (&$out, &$text) { |
| 41 | + global $wgTitle, $wgRequest, $wgShowAuthorsNamespaces, $wgShowAuthors; |
| 42 | + |
| 43 | + /* do nothing if the option is disabled |
| 44 | + * (but why would the extension be enabled?) */ |
| 45 | + if (!wgShowAuthors) |
| 46 | + return true; |
| 47 | + |
| 48 | + // only build authors on namespaces in $wgShowAuthorsNamespaces |
| 49 | + if (!in_array ($wgTitle->getNamespace(), $wgShowAuthorsNamespaces)) |
| 50 | + return true; |
| 51 | + |
| 52 | + /* get the contribs from the database (don't use the default |
| 53 | + * MediaWiki one since it ignores the current user) */ |
| 54 | + $article = new Article ($wgTitle); |
| 55 | + $contribs = array(); |
| 56 | + $db = wfGetDB (DB_MASTER); |
| 57 | + $rev_table = $db->tableName ("revision"); |
| 58 | + $user_table = $db->tableName ("user"); |
| 59 | + |
| 60 | + $sql = "SELECT rev_user, rev_user_text, user_real_name, MAX(rev_timestamp) as timestamp |
| 61 | + FROM $rev_table LEFT JOIN $user_table ON rev_user = user_id |
| 62 | + WHERE rev_page = {$article->getID()} |
| 63 | + GROUP BY rev_user, rev_user_text, user_real_name |
| 64 | + ORDER BY timestamp DESC"; |
| 65 | + |
| 66 | + $results = $db->query ($sql, __METHOD__); |
| 67 | + while ($line = $db->fetchObject ($results)) { |
| 68 | + $contribs[] = array( |
| 69 | + $line->rev_user, |
| 70 | + $line->rev_user_text, |
| 71 | + $line->user_real_name |
| 72 | + ); |
| 73 | + } |
| 74 | + |
| 75 | + $db->freeResult ($results); |
| 76 | + |
| 77 | + |
| 78 | + // return if there are no authors |
| 79 | + if (sizeof ($results) <= 0) |
| 80 | + return true; |
| 81 | + |
| 82 | + // now build a sensible authors display in HTML |
| 83 | + require_once ("includes/Credits.php"); |
| 84 | + $authors = "\n<div class='authors'>". |
| 85 | + "<h4>" . wfMsg('authors_authors') . "</h4>". |
| 86 | + "<ul>"; |
| 87 | + $anons = 0; |
| 88 | + foreach ($contribs as $author) { |
| 89 | + $id = $author[0]; |
| 90 | + $username = $author[1]; |
| 91 | + $realname = $author[2]; |
| 92 | + |
| 93 | + if ($id != "0") { // user with an id |
| 94 | + $author_link = $realname |
| 95 | + ? creditLink($username, $realname) |
| 96 | + : creditLink($username); |
| 97 | + $authors .= "<li>$author_link</li>"; |
| 98 | + } else { // anonymous |
| 99 | + $anons++; |
| 100 | + } |
| 101 | + } |
| 102 | + // add the anonymous entries |
| 103 | + if ($anons > 0) |
| 104 | + $authors .= "<li>" . wfMsg('authors_anonymous') . "</li>"; |
| 105 | + $authors .= "</ul></div>"; |
| 106 | + |
| 107 | + $text .= $authors; |
| 108 | + return true; |
| 109 | +} |
| 110 | + |
Index: trunk/extensions/uniwiki/Javascript/uniwiki.js |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +/* vim: noet ts=4 sw=4 |
| 3 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Javascript |
| 4 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 5 | + |
| 6 | + |
| 7 | +// global uniwiki stuff |
| 8 | +var Uniwiki = { |
| 9 | + i18n: { |
| 10 | + |
| 11 | + /* other extensions should use this function |
| 12 | + * to make their i18n strings accessible to JS */ |
| 13 | + add: function(obj) { |
| 14 | + for (i in obj) { |
| 15 | + Uniwiki.i18n[i] = obj[i]; |
| 16 | + } |
| 17 | + } |
| 18 | + } |
| 19 | +}; |
| 20 | + |
| 21 | +/* global function to make internationalization rather |
| 22 | + * easier, by looking up strings in the i18n hash */ |
| 23 | +function wfMsg (key) { |
| 24 | + return Uniwiki.i18n[key]; |
| 25 | +} |
| 26 | + |
Index: trunk/extensions/uniwiki/Javascript/Javascript.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | +/* vim: noet ts=4 sw=4 |
| 4 | + * http://www.mediawiki.org/wiki/Extension:Uniwiki_Javascript |
| 5 | + * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 6 | + |
| 7 | +if (!defined('MEDIAWIKI')) |
| 8 | + die(); |
| 9 | + |
| 10 | + |
| 11 | +$wgExtensionCredits['other'][] = array( |
| 12 | + 'name' => "Uniwiki Javascript", |
| 13 | + 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
| 14 | + 'description' => "Adds uniwiki.js to each page (which currently just provides lightweight i18n support in Javascript), and serves as a placeholder for future Javascript code shared between Uniwiki extensions" |
| 15 | +); |
| 16 | + |
| 17 | + |
| 18 | +$wgHooks['BeforePageDisplay'][] = "UW_Javascript_addJS"; |
| 19 | +function UW_Javascript_addJS($out) { |
| 20 | + global $wgScriptPath; |
| 21 | + $src = "$wgScriptPath/extensions/uniwiki/Javascript/uniwiki.js"; |
| 22 | + $out->addScript ("<script type='text/javascript' src='$src'></script>"); |
| 23 | + return true; |
| 24 | +} |
| 25 | + |