Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: XUL I php + ZDARZENIA
Forum PHP.pl > Forum > XML, AJAX > XML
dado
O xul- u niedawno sie dowiedziałem i nie jestem w tym wymiataczem, przegyzam własnie dokumentację. Oczywiście sam xul moze ni był by taki interesujac gdyby nie jego interakcja z php która podbno jest możliwa.

Otóż odpaliłem w koncu przykładowy pliczek php z xul-em nie bez trudu przynam
gdyz wpisaie np tych lini
Kod
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

spowoduje w php wyswietlenie błedu z powodu znaczników <?.


  1. <?php header( "Content-type: application/vnd.mozilla.xul+xml" ); 
  2.  
  3. echo"<!DOCTYPE window>
  4. <window 
  5. id  = \"remote\"
  6. xmlns = \"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\"
  7. title = \"moje testy\"
  8. orient = \"vertical\">
  9.  
  10. <toolbox flex=\"1\">
  11. <menubar id=\"sample-menubar\">
  12. <menu id=\"file-menu\" label=\"Akcje podstawowe\">
  13. <menupopup id=\"file-popup\">
  14. <menuitem label=\"Dodaj użytkownika\"/>
  15. <menuitem label=\"Połącz z MySql\"/>
  16. <menuitem oncommand=\"alert('tylko javascript questionmark.gifquestionmark.gif?');\" label=\"Zamknij Onko\"/>
  17. <menuseparator/>
  18. <menuitem label=\"Exit\"/>
  19. </menupopup>
  20. </menu>
  21. <menu id=\"edit-menu\" label=\"Edycja\">
  22. <menupopup id=\"edit-popup\">
  23. <menuitem label=\"edycja usera w bazie\"/>
  24. <menuitem label=\"jak go wczytać z bazy?\"/>
  25. </menupopup>
  26. </menu>
  27. </menubar>
  28. </toolbox>";
  29. ?>


i teraz najbardziej abstrakcyjne pytanie:
jak to wykombinować zeby po wybraniu z menu opcjiedycja usera w bazie pokazywało sie okno edycji, czyli jakas akcja zdarzenie które php mogło by przejec i na nie zareagować .

znajduje sie tu linia
Kod
<menuitem oncommand=\"alert('tylko javascript questionmark.gifquestionmark.gif?');\" label=\"Zamknij Onko\"/>
są xulu zdarzenia ale dotyczą tylko javascriptu, nie ma takioego czegoś jak get czy post wiec jak to ugryźć drodzy panowie.

Nie smiejcie sie tylko ze mnie jestm nowy w tych kklimatach smile.gif

będe bardzo wdzieczny za kazdą wskazówke .
splatch
Pierwszy błąd w php.ini - short_open_tag ustaw na off
Zdarzenia możesz obsłużyć przy pomocy ajaxa.
Sh4dow
W jednym z php Solution czytalem obsluge XUL'a z SOAP'em.
Mozilla posiada w swojej bibliotece JS obsluge soap'a. Jesli uda mi sie znalesc to poszukam w domu plyty z przykladami to przesle tutaj. Ale mozesz poszukac na necie moze jest artykul o tym.
splatch
Dawno, dawno temu wyprodukowałem taki kod:
  1. var zupa = new Array();
  2.  
  3. function SOAPParameter(name,value) {
  4. this.name = name;
  5. this.value = value;
  6. return this;
  7. }
  8.  
  9. function getIds(id) {
  10. if( id == undefined ) {
  11. id = 0;
  12. }
  13. mySOAPCall = new SOAPCall();
  14. mySOAParametr = new SOAPParameter('id',id);
  15. arr = new Array(mySOAParametr);
  16. object = new Array();
  17. mySOAPCall.transportURI = "http://splatch.hopto.org/xul-builder/www/soap/server3.php"
  18. mySOAPCall.encode(0, "getList", object, 0, null, arr.length, arr);
  19. response = mySOAPCall.invoke();
  20. r = response.getParameters(false, {});
  21. result = new Array();
  22. for( i in r ) {
  23. result[ r[i].name ] = r[i].value;
  24. }
  25. appendChildsFromResult(result);
  26. }
  27.  
  28. function appendChildsFromResult(result) {
  29. chi = new Array();
  30. li1 = document.createElement('listitem');
  31. for( i in result ) {
  32. chi[chi.length] = create_child(result[i]);
  33. }
  34. for( i in chi ) {
  35. li1.appendChild(chi[i]);
  36. }
  37.  
  38. listbox = window.document.getElementById('listMethodsListBox');
  39. listbox.appendChild(li1);
  40. }
  41.  
  42. function getAll() {
  43. mySOAPCall = new SOAPCall();
  44. object = new Array();
  45. mySOAPCall.transportURI = "http://splatch.hopto.org/xul-builder/www/soap/server4.php"
  46. mySOAPCall.encode(0, "getAll", object, 0, null, 0, null);
  47. response = mySOAPCall.invoke();
  48. z = soap_response_to_array(response);
  49. for( i in z ) {
  50. appendChildsFromResult(z[i]);
  51. }
  52. }
  53.  
  54. function soap_response_to_array(r) {
  55. data = new Array();
  56. r = r.getParameters(false,{});
  57. r = r[0].element.childNodes;
  58. for( i = 0; i < r.length; i++ ) {
  59. o = r[i].childNodes;
  60. data[i] = new Array();
  61. for( j = 0; j < o.length; j++ ) {
  62. data[i][ o[j].childNodes[0].childNodes[0].data ] = o[j].childNodes[1].childNodes[0].data;
  63. }
  64. }
  65. return data;
  66. }
  67.  
  68. function create_child(label) {
  69. child = document.createElement('listcell');
  70. child.setAttribute('label',label);
  71. return child;
  72. }
  73.  
  74. function var_dump(obj) {
  75. str = '';
  76. for( i in obj ) {
  77. str = str + i +"=>"+ obj[i] +"\n";
  78. }
  79. return str;
  80. }


Wygląd wiersza:
  1. <?php
  2. 'imie' => 'Lukasz',
  3.  'nazwisko' => 'Pak',
  4. 'kod_kreskowy' =>'82-213',
  5.  'miasto' =>'Wąbrzeźno');
  6. ?>


WSDL:
  1. <?xml version='1.0' encoding='UTF-8' ?>
  2. <definitions name='Get'
  3. targetNamespace='http://download/xul-builder/www/soap/stocquote.wsdl'
  4. xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
  5. xmlns:xsd='http://www.w3.org/2001/XMLSchema'
  6. xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
  7. xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
  8. xmlns='http://schemas.xmlsoap.org/wsdl/'>
  9.  
  10. <types>
  11. <xsd:schema targetNamespace="http://www.xmethods.net/interfaces/query.xsd">
  12. <xsd:complexType name="UserData">
  13. <xsd:all>
  14. <xsd:element name="imie" nillable="true" type="xsd:string"/>
  15. <xsd:element name="nazwisko" nillable="true" type="xsd:string"/>
  16. <xsd:element name="kod_kreskowy" nillable="true" type="xsd:string"/>
  17. <xsd:element name="miasto" nillable="true" type="xsd:string"/>
  18. </xsd:all>
  19. </xsd:complexType>
  20. <xsd:complexType name="ArrayOfUserData">
  21. <xsd:complexContent>
  22. <xsd:restriction base="soapenc:Array">
  23. <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:UserData[]"/>
  24. </xsd:restriction>
  25. </xsd:complexContent>
  26. </xsd:complexType>
  27. </xsd:schema>
  28. </types>
  29.  
  30.  
  31. <message name='getListRequest'>
  32. <part name='id' type='xsd:int'/>
  33. </message>
  34. <message name='getListResponse'>
  35. <part name="data" type="xsd:UserData"/>
  36. </message>
  37.  
  38. <message name='GetAllRequest'/>
  39. <message name='GetAllResponse'>
  40. <part name="Result" type="xsd:ArrayOfUserData"/>
  41. </message>
  42.  
  43. <portType name='GetPortType'>
  44. <operation name='getList'>
  45. <input message='tns:getListRequest'/>
  46. <output message='tns:getListResponse'/>
  47. </operation>
  48. <operation name='GetAll'>
  49. <input message='tns:GetAllRequest'/>
  50. <output message='tns:GetAllResponse'/>
  51. </operation>
  52. </portType>
  53.  
  54. <binding name='GetBinding' type='tns:GetPortType'>
  55. <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
  56.  
  57. <operation name='getList'>
  58. <soap:operation soapAction='urn:xmethods-delayed-quotes#getList'/>
  59. <input>
  60. <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
  61. encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  62. </input>
  63. <output>
  64. <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
  65. encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  66. </output>
  67. </operation>
  68.  
  69. <operation name='GetAll'>
  70. <soap:operation soapAction='urn:xmethods-delayed-quotes#GetAll'/>
  71. <input>
  72. <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
  73. encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  74. </input>
  75. <output>
  76. <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
  77. encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  78. </output>
  79. </operation>
  80. </binding>
  81.  
  82. <service name='GetService'>
  83. <port name='GetPort' binding='GetBinding'>
  84. <soap:address location='http://download/xul-builder/www/soap/server4.php'/>
  85. </port>
  86. </service>
  87.  
  88. </definitions>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.