Changeset 150

Show
Ignore:
Timestamp:
04/29/06 01:14:42 (3 years ago)
Author:
laurentj
Message:

ajout binding jxulform pour jsonrpc, fix sur le chargement des plugins, fix sur le plugin auth

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jelix-dev.mn

    r145 r150  
    139139cd lib/jelix-www/xul/test/ 
    140140  testxulform.php 
     141  testxulform_jsonrpc.php 
    141142  testxulform.xul 
  • trunk/build/manifests/jelix-lib.mn

    r146 r150  
    210210cd lib/jelix-modules/auth/controllers 
    211211  login.classic.php 
     212  loginsw.classic.php 
     213  login.jsonrpc.php 
    212214cd lib/jelix-modules/auth/zones 
    213215  loginform.zone.php 
     
    250252  jxulform.xml 
    251253  throbber.gif 
     254  jsonrpc.js 
     255 
    252256 
    253257cd temp 
  • trunk/lib/jelix-modules/auth/plugins/auth/auth.plugin.php

    r98 r150  
    1717*/ 
    1818 
    19 class AuthPlugin implements jPlugin { 
     19class AuthPlugin implements jIPlugin { 
    2020    public $config; 
    2121 
     
    2828     * @return null or jSelectorAct  if action should change 
    2929     */ 
    30     public function beforeProcess ($params){ 
     30    public function beforeAction ($params){ 
    3131        $notLogged = false; 
    3232        $badip = false; 
     
    5050        if (! isset ($_SESSION['JELIX_USER'])){ 
    5151            $notLogged = true; 
    52             $_SESSION['JELIX_USER'] = new jUser(); 
     52            $_SESSION['JELIX_USER'] = new jAuthUser(); 
    5353        }else{ 
    5454            $notLogged = ! jAuth::isConnected(); 
     
    6363            } 
    6464        } 
    65  
    66         $needAuth = isset($action->pluginParams['auth.required']) ? ($action->pluginParams['auth.required']==true):$this->config['auth_required']; 
     65        $needAuth = isset($params['auth.required']) ? ($params['auth.required']==true):$this->config['auth_required']; 
    6766        $authok = false; 
    6867 
  • trunk/lib/jelix-plugins/magicquotes/magicquotes.plugin.php

    r98 r150  
    1616*/ 
    1717 
    18 class MagicQuotesPlugin implements jPlugin { 
     18class MagicQuotesPlugin implements jIPlugin { 
    1919 
    2020   /** 
  • trunk/lib/jelix-www/xul/jxulform.css

    r144 r150  
    11 
    2 @namespace jfx url("http://jelix.org/ns/jformxul/1.0"); 
     2@namespace jxf url("http://jelix.org/ns/jxulform/1.0"); 
    33@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); 
    44@namespace html url("http://www.w3.org/1999/xhtml"); 
    55 
    6 jfx|submission { 
     6jxf|submission { 
    77  display: -moz-box; 
    88  visibility:collapse; 
    9   -moz-binding: url("jformxul.xml#submission"); 
     9  -moz-binding: url("jxulform.xml#submission"); 
    1010} 
    11  
    12 /*jfx|submission[format="urlencoded-post-php"] { 
     11jxf|submission[format="json-rpc"] { 
    1312  display: -moz-box; 
    14   -moz-binding: url("jformxul.xml#submission-post-php"); 
     13  -moz-binding: url("jxulform.xml#submission-json-rpc"); 
     14
     15/*jxf|submission[format="urlencoded-post-php"] { 
     16  display: -moz-box; 
     17  -moz-binding: url("jxulform.xml#submission-post-php"); 
    1518}*/ 
    1619 
    17 jfx|submit { 
     20jxf|submit { 
    1821  display: -moz-box; 
    19   -moz-binding: url("jformxul.xml#submit"); 
     22  -moz-binding: url("jxulform.xml#submit"); 
    2023 
    2124} 
    2225 
    23 jfx|submit[loading=true]:not([nothrobber]) { 
     26jxf|submit[loading=true]:not([nothrobber]) { 
    2427  list-style-image:url(throbber.gif); 
    2528} 
  • trunk/lib/jelix-www/xul/jxulform.xml

    r147 r150  
    106106        </method> 
    107107 
     108        <method name="_onload"> 
     109            <body><![CDATA[ 
     110            var evt = document.createEvent("HTMLEvents"); 
     111            evt.initEvent("result", true, false); 
     112            this.dispatchEvent(evt); 
     113            ]]> 
     114            </body> 
     115        </method> 
    108116        <method name="_UIendofload"> 
    109117            <body><![CDATA[ 
     
    119127            </body> 
    120128        </method> 
     129 
    121130 
    122131        <method name="_submit"> 
     
    130139            this.httpreq.onload = function() { 
    131140                this.submission._UIendofload(); 
    132                 var evt = document.createEvent("HTMLEvents"); 
    133141                if(this.status >=200 && this.status < 300) 
    134                     evt.initEvent("result", true, false); 
     142                    this.submission._onload(); 
    135143                else{ 
     144                    var evt = document.createEvent("HTMLEvents"); 
    136145                    evt.errorCode = this.status ; 
    137146                    evt.initEvent("httperror", true, false); 
    138                 } 
    139                 this.submission.dispatchEvent(evt); 
     147                    this.submission.dispatchEvent(evt); 
     148                } 
     149 
    140150            } 
    141151            this.httpreq.onerror = function() { 
     
    429439</binding> 
    430440 
     441<binding id="submission-json-rpc" extends="#submission"> 
     442    <implementation> 
     443        <field name="contentType">"text/plain"</field> 
     444        <field name="jsonResponse" /> 
     445        <property name="rpcmethod" 
     446                  onget="return this.getAttribute('rpcmethod');" 
     447                  onset="this.setAttribute('rpcmethod', val); return val;"/> 
     448        <method name="_prepareContent"> 
     449            <body><![CDATA[ 
     450                this.jsonReponse = null; 
     451                this.method="POST"; 
     452                var datas = { method: this.rpcmethod, params:this.formDatas, id:1 }; 
     453                var content= datas.toSource(); 
     454                return content.substring(1, content.length -1); // on enleve les () qui entourent; 
     455            ]]></body> 
     456        </method> 
     457        <method name="_onload"> 
     458            <body><![CDATA[ 
     459                var evt = document.createEvent("HTMLEvents"); 
     460                eval("this.jsonResponse="+this.httpreq.responseText); 
     461                var evtname; 
     462                if(this.jsonResponse.error ==null){ 
     463                   evtname="result"; 
     464                }else{ 
     465                   evtname="rpcerror"; 
     466                } 
     467                evt.initEvent(evtname, true, false); 
     468                this.dispatchEvent(evt); 
     469                ]]> 
     470            </body> 
     471        </method> 
     472 
     473    </implementation> 
     474    <handlers> 
     475        <handler event="rpcerror" phase="at-target"> 
     476            var onrpcerror = this.getAttribute("onrpcerror"); 
     477            if( onrpcerror){ 
     478                var func = new Function("event", onrpcerror+"\n return true;"); 
     479                var retval = func.call(this, event); 
     480                this.httpreq = null; 
     481                return retval; 
     482            }else{ 
     483                return true; 
     484            } 
     485        </handler> 
     486    </handlers> 
     487 
     488</binding> 
    431489 
    432490 
  • trunk/lib/jelix-www/xul/test/testxulform.xul

    r144 r150  
    1818             oninvalidate="alert('erreur dans les valeurs')" 
    1919             /> 
    20   <groupbox> 
    21     <textbox label="toto" name="text" form="test" value="" required="true"/> 
    22     <textbox name="entier" form="test" value="" required="true" datatype="integer"/> 
    23     <textbox name="decimal" form="test" value="" required="true" datatype="float"/> 
    24     <textbox name="entier" form="test" value="" required="true" datatype="integer" constraint="return val&gt;50 &amp;&amp;val&lt;100;"/> 
    25     <checkbox name="checkbox" form="test" label="checkbox" checked="true"/> 
    26     <radiogroup id="radioGroup" name="radio" value="" form="test bar"> 
     20 
     21    <jxf:submission id="test2" action="testxulform_jsonrpc.php" format="json-rpc" rpcmethod="module.action" 
     22                    onsubmit="document.getElementById('sendBox').value=this.formDatas.toSource()+'\n\net donc:\n'+this._prepareContent(); document.getElementById('receiveBox').value=''" 
     23                    onresult="document.getElementById('receiveBox').value=this.jsonResponse.toSource()" 
     24                    onrpcerror="alert('erreur rpc :' + this.jsonResponse.error)" 
     25                    onhttperror="alert('erreur http :' + event.errorCode)" 
     26                    progressmeter="progression" 
     27                    oninvalidate="alert('erreur dans les valeurs')" 
     28                    /> 
     29 
     30 
     31 
     32 <groupbox> 
     33     <hbox><label value="chaine"/><textbox label="toto" name="text" form="test test2" value="aaa" required="true"/></hbox> 
     34    <hbox><label value="un entier"/><textbox name="entier" form="test test2" value="123" required="true" datatype="integer"/></hbox> 
     35    <hbox><label value="un decimal"/><textbox name="decimal" form="test test2" value="45.65" required="true" datatype="float"/></hbox> 
     36    <hbox><label value="un entier entre 50 et 100"/><textbox name="entier" form="test test2" value="68" required="true" datatype="integer" constraint="return val&gt;50 &amp;&amp;val&lt;100;"/></hbox> 
     37    <checkbox name="checkbox" form="test test2" label="checkbox" checked="true"/> 
     38    <radiogroup id="radioGroup" name="radio" value="" form="test bar test2"> 
    2739      <radio value="one" label="one" selected="true"/> 
    2840      <radio value="two" label="two"/> 
     
    3244 <hbox> 
    3345     <jxf:submit form="test" label="Envoyer"/> 
     46     <jxf:submit form="test2" label="Envoyer en jsonrpc"/> 
    3447     <progressmeter   id="progression"/> 
    3548 </hbox> 
  • trunk/lib/jelix/core/jCoordinator.class.php

    r145 r150  
    9797                    $conf = array(); 
    9898                } 
    99                 include( $GLOBALS['gJConfig']->pluginsPathList[$name]); 
     99                include( $GLOBALS['gJConfig']->pluginsPathList[$name].$name.".plugin.php"); 
    100100                $class= $name.'Plugin'; 
    101101                $this->plugins[strtolower($name)] = new $class($conf); 
     
    169169 
    170170        foreach ($this->plugins as $name => $obj){ 
    171             $result = $this->plugins[$name]->beforeProcess ($pluginparams); 
     171            $result = $this->plugins[$name]->beforeAction ($pluginparams); 
    172172            if($result){ 
    173173               $this->action = $result; 
  • trunk/lib/jelix/init.php

    r136 r150  
    4747require_once (JELIX_LIB_CORE_PATH . 'jLocale.class.php'); 
    4848require_once (JELIX_LIB_CORE_PATH . 'jIncluder.class.php'); 
     49require_once (JELIX_LIB_CORE_PATH . 'jIPlugin.iface.php'); 
    4950 
    5051// global variables 
Download in other formats: Unified Diff Zip Archive