<?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>GoodLux Media &#187; qcodo</title>
	<atom:link href="http://goodluxmedia.com/category/qcodo/feed/" rel="self" type="application/rss+xml" />
	<link>http://goodluxmedia.com</link>
	<description>systems integration ~ programming ~ consultation</description>
	<lastBuildDate>Mon, 24 Aug 2009 21:50:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>creating control arrays with qcodo</title>
		<link>http://goodluxmedia.com/2008/03/11/creating-control-arrays-with-qcodo/</link>
		<comments>http://goodluxmedia.com/2008/03/11/creating-control-arrays-with-qcodo/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 05:12:14 +0000</pubDate>
		<dc:creator>rob kunkle</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[qcodo]]></category>

		<guid isPermaLink="false">http://blog.massivemissive.com/?p=4</guid>
		<description><![CDATA[Lately I&#8217;ve been playing around with the qcodo framework. There&#8217;s a lot of things to love about qcodo, but the 4 or 5 lines of code required to put together a single control is not one of them.
For instance, if I wanted to create a text box on a page. I could something like this.
class [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been playing around with the <a href="http://qcodo.com">qcodo</a> framework. There&#8217;s a lot of things to love about qcodo, but the 4 or 5 lines of code required to put together a single control is not one of them.</p>
<p>For instance, if I wanted to create a text box on a page. I could something like this.</p>
<div class="codesnip-container" >class MyCoolPage extends QForm {</div>
<blockquote><div class="codesnip-container" >protected $txtYourNameGoesHere;</div>
<div class="codesnip-container" >function Form_Create{</div>
<blockquote><div class="codesnip-container" >$txtYourNameGoesHere = new QLabel($this);</div>
<div class="codesnip-container" >$txtYourNameGoesHere-&gt;Name = &#8220;NameBox&#8221;;</div>
<div class="codesnip-container" >$txtYourNameGoesHere-&gt;Text = &#8220;Write your name here&#8221;;</div>
<div class="codesnip-container" >$txtYourNameGoesHere-&gt;Width = 100;</div>
<div class="codesnip-container" >$txtYourNameGoesHere-&gt;CssClass = &#8220;name-box&#8221;;</div>
<div class="codesnip-container" >$txtYourNameGoesHere-&gt;Required = TRUE;</div>
</blockquote>
<div class="codesnip-container" >}</div>
<div class="codesnip-container" ></div>
</blockquote>
<div class="codesnip-container" >}</div>
<p>If you just have one or two controls on a page, this is not big deal, but if you have a full page of text boxes and labels this gets unwieldy quickly. One solution for this is to first create an array with details about all the controls you&#8217;d like to have on your pages, then create a second control array that contains all of your controls. For instance, you can do something like this:</p>
<div class="codesnip-container" >protected $arrListOfControls = Array();<br />
protected $arrControls = Array();<br />
function Form_Create() {</div>
<blockquote><div class="codesnip-container" >$arrListOfControls = Array(</div>
<div class="codesnip-container" ></div>
<blockquote><div class="codesnip-container" >&#8216;BillName&#8217; 		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillName&#8217;,		&#8216;Text&#8217;=&gt;&#8217;Default Name&#8217;, 			&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;addressee&#8217;),</div>
<div class="codesnip-container" >&#8216;BillAddress1&#8242; 	=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillAddress1&#8242;,	&#8216;Text&#8217;=&gt;&#8217;default Address1&#8242;, 		&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;street-address&#8217;),</div>
<div class="codesnip-container" >&#8216;BillAddress2&#8242; 	=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillAddress2&#8242;,	&#8216;Text&#8217;=&gt;&#8217;default Address2&#8242;, 		&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;street-address&#8217;),</div>
<div class="codesnip-container" >&#8216;BillCity&#8217; 		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillCity&#8217;,		&#8216;Text&#8217;=&gt;&#8217;default City&#8217;, 			&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;locality&#8217;),</div>
<div class="codesnip-container" >&#8216;BillZip&#8217; 		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillZip&#8217;,		&#8216;Text&#8217;=&gt;&#8217;99999&#8242;, 					&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;postal-code&#8217;),</div>
<div class="codesnip-container" >&#8216;BillState&#8217;		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillState&#8217;,		&#8216;Text&#8217;=&gt;&#8217;ST&#8217;, 						&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;region&#8217;),</div>
<div class="codesnip-container" >&#8216;BillPhone&#8217; 	=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;BillPhone&#8217;,		&#8216;Text&#8217;=&gt;&#8217;123-452-4444&#8242;, 			&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;country-name&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipName&#8217;		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipName&#8217;,		&#8216;Text&#8217;=&gt;&#8217;Default Name&#8217;,			 	&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;addressee&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipAddress1&#8242; 	=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipAddress1&#8242;,	&#8216;Text&#8217;=&gt;&#8217;default Address1&#8242;, 		&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;street-address&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipAddress2&#8242; 	=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipAddress2&#8242;,	&#8216;Text&#8217;=&gt;&#8217;default Address2&#8242;, 		&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;street-address&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipCity&#8217; 		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipCity&#8217;,		&#8216;Text&#8217;=&gt;&#8217;default City&#8217;,			 	&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;locality&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipZip&#8217; 		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipZip&#8217;,		&#8216;Text&#8217;=&gt;&#8217;99998&#8242;, 					&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;postal-code&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipState&#8217;		=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipState&#8217;,		&#8216;Text&#8217;=&gt;&#8217;TS&#8217;, 						&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;region&#8217;),</div>
<div class="codesnip-container" >&#8216;ShipPhone&#8217; 	=&gt; Array(&#8217;Name&#8217; =&gt; &#8216;ShipPhone&#8217;,		&#8216;Text&#8217;=&gt;&#8217;777-777-7777&#8242;, 			&#8216;Width&#8217; 	=&gt; 100,	&#8216;Required&#8217; =&gt; false,	&#8216;Type&#8217; =&gt; &#8216;Label&#8217;, 	&#8216;CssClass&#8217;=&gt;&#8217;country-name&#8217;)</div>
</blockquote>
<div class="codesnip-container" >foreach ($arrListOfControls as $ctlname =&gt; $properties) {</div>
<blockquote><div class="codesnip-container" >buildTextBoxes ( $arrControls[$ctlname] );</div>
<div class="codesnip-container" ></div>
</blockquote>
<div class="codesnip-container" >}</div>
<div class="codesnip-container" ></div>
</blockquote>
<div class="codesnip-container" >}<br />
function buildTextBoxes(&amp;$ctl , array $properties) {</div>
<blockquote><div class="codesnip-container" >$ctl = new QTextBox($this, $properties['Name']);</div>
<div class="codesnip-container" >$ctl-&gt;CssClass = $properties['CssClass'];</div>
<div class="codesnip-container" >$ctl-&gt;Width = $properties['Width'];</div>
<div class="codesnip-container" >$ctl-&gt;Text = $properties['Text'];</div>
<div class="codesnip-container" >$ctl-&gt;BlahBlahBlah = $properties['BlahBlahBlah'];</div>
<div class="codesnip-container" ></div>
</blockquote>
<div class="codesnip-container" >}</div>
<p>Notice two things of importance here&#8230;in the buildTextBoxes function, there is an ampersand&#8230;this informs php to pass the whole variable, instead of just the value of the variable. When the function is complete, the new control object dressed up in the properties you provided. Another thing to note is when we create the QTextBox, we specifiy a name for the control. This is important to distinguish the contols in your html source when you view them page&#8230;it makes formatting your template easier!</p>
]]></content:encoded>
			<wfw:commentRss>http://goodluxmedia.com/2008/03/11/creating-control-arrays-with-qcodo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

