<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flexmaniak.pl &#187; PHP</title>
	<atom:link href="http://blog.flexmaniak.pl/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.flexmaniak.pl</link>
	<description>Flex, Papervision3D, PHP, Symfony</description>
	<lastBuildDate>Sat, 07 Aug 2010 11:49:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Pagination + DataGrid + Service = PaginatedDataGrid v0.1 [english]</title>
		<link>http://blog.flexmaniak.pl/flex_i_php/pagination-datagrid-service-paginateddatagrid-v0-1-english</link>
		<comments>http://blog.flexmaniak.pl/flex_i_php/pagination-datagrid-service-paginateddatagrid-v0-1-english#comments</comments>
		<pubDate>Fri, 19 Feb 2010 17:57:30 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[Flex i PHP]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://blog.flexmaniak.pl/?p=357</guid>
		<description><![CDATA[Lately I was building an backend (admin-side) application in Flex. Most of the data was presented in data grids. However, when working with services (PHP in my case) it is risky to load all data  to the DataGrid. It may lead to an application crash, ie. when we work on 1000&#8242;s of items. Therefore I [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I was building an backend (admin-side) application in Flex. Most of the data was presented in data grids.</p>
<p>However, when working with services (PHP in my case) it is risky to load all data  to the DataGrid. It may lead to an application crash, ie. when we work on 1000&#8242;s of items.</p>
<p>Therefore I decided to create the component that handles pagination itself &#8211; it is similar to ExtJS&#8217; data grid (however much simpler :) ).</p>
<p><span id="more-357"></span></p>
<p>The example is below&#8230; (You can view source by right-clicking on application)</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="200" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blog.flexmaniak.pl/examples/paginatedDataGrid/paginatedDatagrid.swf" /><embed type="application/x-shockwave-flash" width="100%" height="200" src="http://blog.flexmaniak.pl/examples/paginatedDataGrid/paginatedDatagrid.swf"></embed></object></p>
<p>This components dispatches 2 events (for now):</p>
<ul>
<li>when page is changes</li>
<li>when data is sorted</li>
</ul>
<p>I also added DATA_FILTER event, but I do not have idea how to include the filtration form in the component GUI.</p>
<p>To download source click <a href="http://blog.flexmaniak.pl/examples/paginatedDataGrid/srcview/paginatedDatagrid.zip">here</a>.</p>
<p>Any comments would be welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flexmaniak.pl/flex_i_php/pagination-datagrid-service-paginateddatagrid-v0-1-english/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Przesyłanie danych z Flexa do PHP za pomocą XMLa</title>
		<link>http://blog.flexmaniak.pl/flex_i_php/przesylanie-danych-z-flexa-do-php-za-pomoca-xmla</link>
		<comments>http://blog.flexmaniak.pl/flex_i_php/przesylanie-danych-z-flexa-do-php-za-pomoca-xmla#comments</comments>
		<pubDate>Sun, 25 Oct 2009 14:31:02 +0000</pubDate>
		<dc:creator>Piotr Wierzgała</dc:creator>
				<category><![CDATA[Flex i PHP]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.na14.pl/wordpress/?p=20</guid>
		<description><![CDATA[Nie samym Flexem i ActionScriptem programista żyje dlatego czasem musi zwrócić się do innych technologii. W komunikacji na linii Flex &#8211; PHP z pomocą przychodzą nam XML, JSON i AMFPHP. W tym wpisie zajmiemy się pierwszym z trójcy czyli XMLem. FLEX 3.0, PHP 5.3.0 W celu zaprezentowania mechanizmu komunikacji na linii Flex – PHP za [...]]]></description>
			<content:encoded><![CDATA[<p>Nie samym Flexem i ActionScriptem programista żyje dlatego czasem musi zwrócić się do innych technologii. W komunikacji na linii Flex &#8211; PHP z pomocą przychodzą nam XML, JSON i AMFPHP. W tym wpisie zajmiemy się pierwszym z trójcy czyli XMLem.<br />
<span id="more-20"></span><br />
FLEX 3.0, PHP 5.3.0<br />
<embed src="http://blog.na14.pl/examples/flex_xml_php/FLEX_XML_PHP.swf" width="100%" height="270"></embed></p>
<p>W celu zaprezentowania mechanizmu komunikacji na linii Flex – PHP za pomocą XMLa posłużymy się prostą aplikacją, która będzie posiadała dwa pola tekstowe i jedną listę oraz przycisk wysyłający dane z tych komponentów do skryptu PHP.</p>
<p>Na początek stworzymy graficzny interfejs naszej apliakcji.</p>
<p>Będziemy potrzebować usługi HTTP przesyłającej dane do skryptu PHP. Usługa HTTP będzie mieć dwa zdarzenia “result” i “fault”, z których każde będzie wyświetlać alert boxa odpowiednio z rezultatem działania skryptu i informacją o niepowodzeniu w wykonaniu usługi.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;httpService&quot;</span> resultFormat=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;http://localhost/phpScript.php&quot;</span> result=<span style="color: #ff0000;">&quot;httpServiceResult(event)&quot;</span> fault=<span style="color: #ff0000;">&quot;httpServiceFault(event)&quot;</span><span style="color: #66cc66;">/&gt;</span></div></div>
<p>Dalej zgodnie z założeniami dodamy dwa pola tekstowe.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;TextInput 1:&quot;</span><br />
&nbsp;x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;12&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;textInput1&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;textInput1&quot;</span><br />
&nbsp;x=<span style="color: #ff0000;">&quot;134&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;98&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;TextInput 2:&quot;</span><br />
&nbsp;x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;42&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;textInput2&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;textInput2&quot;</span><br />
&nbsp;x=<span style="color: #ff0000;">&quot;134&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;98&quot;</span><span style="color: #66cc66;">/&gt;</span></div></div>
<p>Edytowalna listę wypełnioną przykładowymi danymi. DataProvider będzie znajdował się w zewnętrznym pliku ActionScript.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{listDataProvider}&quot;</span> editable=<span style="color: #ff0000;">&quot;true&quot;</span><br />
x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;70&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;183&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;156&quot;</span><span style="color: #66cc66;">/&gt;</span></div></div>
<p>Oraz przycisk wysyłający dane do pliku PHP.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Wyslij&quot;</span> click=<span style="color: #ff0000;">&quot;send()&quot;</span><br />
x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;234&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;183&quot;</span><span style="color: #66cc66;">/&gt;</span></div></div>
<p>Na koniec jeszcze musimy dodać referencję do pliku z kodem ActionScript i pierwszą część pracy mamy za sobą.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:Script source=<span style="color: #ff0000;">&quot;FLEX_XML_PHP_Script.as&quot;</span> <span style="color: #66cc66;">/&gt;</span></div></div>
<p>A tak wygląda to w całości.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span><span style="color: #66cc66;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Script source=<span style="color: #ff0000;">&quot;FLEX_XML_PHP_Script.as&quot;</span> <span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;httpService&quot;</span> resultFormat=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;http://localhost/phpScript.php&quot;</span> result=<span style="color: #ff0000;">&quot;httpServiceResult(event)&quot;</span> fault=<span style="color: #ff0000;">&quot;httpServiceFault(event)&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> dataProvider=<span style="color: #ff0000;">&quot;{listDataProvider}&quot;</span> editable=<span style="color: #ff0000;">&quot;true&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;70&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;183&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;156&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Wyslij&quot;</span> click=<span style="color: #ff0000;">&quot;send()&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;234&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;183&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;textInput1&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;textInput1&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; x=<span style="color: #ff0000;">&quot;134&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;98&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;textInput2&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;textInput2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x=<span style="color: #ff0000;">&quot;134&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;98&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;TextInput 1:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;12&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;TextInput 2:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x=<span style="color: #ff0000;">&quot;50&quot;</span> y=<span style="color: #ff0000;">&quot;42&quot;</span><span style="color: #66cc66;">/&gt;</span><br />
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></div></td></tr></tbody></table></div>
<p>Drugi etap na naszej drodze to zbudowanie kodu ActionScript, który to wszystko obsłuży.</p>
<p>Tworzymy DataProvider z przykładowymi danymi dla naszej listy.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> listDataProvider:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;A&quot;</span>,<span style="color: #ff0000;">&quot;B&quot;</span>,<span style="color: #ff0000;">&quot;C&quot;</span>,<span style="color: #ff0000;">&quot;D&quot;</span>,<span style="color: #ff0000;">&quot;E&quot;</span>,<span style="color: #ff0000;">&quot;F&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Definiujemy funkcję wysyłającą dane do skryptu PHP. Na początku deklarujemy zmienną, która będzie przechowywać nasz kod XML i ustawiamy jej węzeł główny na .</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Wartość pierwszego pola tekstowego posłuży nam do ustawienia atrybutu o nazwie textInput1 dla węzła</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">xml</span>.<span style="color: #66cc66;">@</span>textInput1 = textInput1.<span style="color: #0066CC;">text</span>;</div></div>
<p>Wartość drugiego pola tekstowego użyjemy do nadania wartości nowemu węzłowi dodanemu do naszej struktury XML za pomocą operatora kropki.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">xml</span>.<span style="color: #006600;">textInput2</span> = textInput2.<span style="color: #0066CC;">text</span>;</div></div>
<p>W celu połączenia danych z listy w ciąg XML użyjemy metody encodeValue klasy SimpleXMLEncoder. Metoda encodeValue przyjmuje trzy parametry: obiekt do serializacji, nazwę węzła w którym umieści zserializowany obiekt oraz zmienną typu XMLDocument, w której zostanie zapisany wynikowy kod XML. Nowy węzeł do naszej struktury XML dodamy za pomocą metody appendChild.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> qName:QName = <span style="color: #000000; font-weight: bold;">new</span> QName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;list&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> xmlDocument:XMLDocument = <span style="color: #000000; font-weight: bold;">new</span> XMLDocument<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> simpleXMLEncoder:SimpleXMLEncoder = <span style="color: #000000; font-weight: bold;">new</span> SimpleXMLEncoder<span style="color: #66cc66;">&#40;</span>xmlDocument<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">xmlNode</span>:<span style="color: #0066CC;">XMLNode</span> = simpleXMLEncoder.<span style="color: #006600;">encodeValue</span><span style="color: #66cc66;">&#40;</span>listDataProvider.<span style="color: #006600;">source</span>, qName, xmlDocument<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">list</span>:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>xmlDocument.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">xml</span>.<span style="color: #0066CC;">appendChild</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">list</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Na koniec dodajemy nasz kod XML do zmiennej typu Object, która zostanie przekazana do skryptu PHP.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">object</span>.<span style="color: #0066CC;">xml</span> = <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
httpService.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">object</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Całość prezentuje się następująco:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;<br />
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">XMLListCollection</span>;<br />
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;<br />
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">FaultEvent</span>;<br />
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;<br />
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">SimpleXMLEncoder</span>;<br />
<br />
<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> listDataProvider:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;A&quot;</span>,<span style="color: #ff0000;">&quot;B&quot;</span>,<span style="color: #ff0000;">&quot;C&quot;</span>,<span style="color: #ff0000;">&quot;D&quot;</span>,<span style="color: #ff0000;">&quot;E&quot;</span>,<span style="color: #ff0000;">&quot;F&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">xml</span>:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">//Dodanie atrybutu za pomocą .@</span><br />
<span style="color: #0066CC;">xml</span>.<span style="color: #66cc66;">@</span>textInput1 = textInput1.<span style="color: #0066CC;">text</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">//Dodanie węzła za pomocą .</span><br />
<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">textInput2</span> = textInput2.<span style="color: #0066CC;">text</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">//Dodanie węzła za pomocą .appendChild</span><br />
<span style="color: #000000; font-weight: bold;">var</span> qName:QName = <span style="color: #000000; font-weight: bold;">new</span> QName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;list&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> xmlDocument:XMLDocument = <span style="color: #000000; font-weight: bold;">new</span> XMLDocument<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> simpleXMLEncoder:SimpleXMLEncoder = <span style="color: #000000; font-weight: bold;">new</span> SimpleXMLEncoder<span style="color: #66cc66;">&#40;</span>xmlDocument<span style="color: #66cc66;">&#41;</span>;<br />
simpleXMLEncoder.<span style="color: #006600;">encodeValue</span><span style="color: #66cc66;">&#40;</span>listDataProvider.<span style="color: #006600;">source</span>, qName, xmlDocument<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">list</span>:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>xmlDocument.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">xml</span>.<span style="color: #0066CC;">appendChild</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">list</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">//Wyslanie XML'a do skryptu PHP</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">object</span>:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">object</span>.<span style="color: #0066CC;">xml</span> = <span style="color: #0066CC;">xml</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
httpService.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">object</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">//send</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> httpServiceResult<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">result</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">&quot;HTTP Service Result&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">//httpServiceResult</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> httpServiceFault<span style="color: #66cc66;">&#40;</span>event:FaultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">fault</span>.<span style="color: #006600;">faultString</span>,<span style="color: #ff0000;">&quot;HTTP Service Fault&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">//httpServiceFault</span></div></td></tr></tbody></table></div>
<p>Pozostaje nam jeszcze tylko napisać prosty skrypt PHP, który przetworzy i wyświetli otrzymany kod XML. Ponieważ klasa XMLReader jest opisana w manualu PHP dlatego daruję sobie rozkład poniżeszego skryptu na czynniki pierwsze i zamiast tego odeślę do wspomnianego źródła: <a href="http://php.net/manual/en/book.xmlreader.php">XMLReader PHP Manual</a></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XMLReader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">XML</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;xml&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeType</span> <span style="color: #339933;">==</span> XMLReader<span style="color: #339933;">::</span><span style="color: #004000;">ELEMENT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;TextInput 1: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;textInput1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;item: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">value</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;textInput2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;TextInput 2: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">value</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.flexmaniak.pl/flex_i_php/przesylanie-danych-z-flexa-do-php-za-pomoca-xmla/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
