<?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>Tara Andrei</title>
	<atom:link href="http://andreitara.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://andreitara.com</link>
	<description>I could change the world if they would let my allocate more instances of myself.</description>
	<lastBuildDate>Wed, 07 Mar 2012 21:30:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Iframe preloader animation</title>
		<link>http://andreitara.com/2012/03/iframe-preloader-animation/</link>
		<comments>http://andreitara.com/2012/03/iframe-preloader-animation/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 21:29:55 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation on loading iframe]]></category>
		<category><![CDATA[iframe loading]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=512</guid>
		<description><![CDATA[I love working with iframe content loading&#8230; noo no way, I actually hate it, but there are situations when loading the content inside the iframe is the only viable technical solution. I am sure you have use it before and maybe you have asked yourself how to add something like a loding animation while the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/03/images.jpg"><img src="http://andreitara.com/wp-content/uploads/2012/03/images-150x150.jpg" alt="" title="images" width="150" height="150" class="alignleft size-thumbnail wp-image-517" /></a>I love working with iframe content loading&#8230; noo no way, I actually hate it, but there are situations when loading the content inside the iframe is the only viable technical solution. I am sure you have use it before and maybe you have asked yourself how to add something like a loding animation while the frame is loading. I will provide a example but today I am fling lazy so I will use jQuery, the code should be something like:<br />
<span id="more-512"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> ContentLoader <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">function</span> load<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> onContentLoaded<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#content'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;iframe id=&quot;myBelovedIframe&quot; frameborder=&quot;0&quot; width=&quot;500&quot; height=&quot;50&quot;&gt;&lt;/iframe&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'iframe#myBelovedIframe'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// On iframe content load</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'iframe#myBelovedIframe'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			onContentLoaded<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
c <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ContentLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
c.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://andreitara.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#content'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'loading'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// TODO Add any code that has to be executed after the frame is loaded</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is how the script should look like, and the HTML could be something like:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&nbsp;
....
&lt;div id=&quot;content&quot; class='loading'&gt;&lt;/div&gt;
...</pre></div></div>

<p>of course you will need also some CSS for the loading animation like:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&nbsp;
.loading<span style="color: #00AA00;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'loading.gif'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Your parents should be so proud of you, you first iframe with loading animation <img src='http://andreitara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , now you can celebrate.</p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/03/iframe-preloader-animation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with models data.store and list in Sencha</title>
		<link>http://andreitara.com/2012/03/working-with-models-data-store-and-list-in-sencha/</link>
		<comments>http://andreitara.com/2012/03/working-with-models-data-store-and-list-in-sencha/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 22:06:07 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sencha]]></category>
		<category><![CDATA[sencha list]]></category>
		<category><![CDATA[sencha model]]></category>
		<category><![CDATA[sencha store]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=502</guid>
		<description><![CDATA[There is no point in explaining what is MVC, if you don&#8217;t already know what is MVC well dear, then you got an issue &#8230; trust me I am an engineer . OK, now lets see how do we create our models in Sencha and fill the with information form back-end. I will create a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/apple-touch-icon.png"><img src="http://andreitara.com/wp-content/uploads/2012/02/apple-touch-icon-150x150.png" alt="" title="apple-touch-icon" width="150" height="150" class="alignleft size-thumbnail wp-image-413" /></a>There is no point in explaining what is MVC, if you don&#8217;t already know what is MVC well dear, then you got an issue &#8230; trust me I am an engineer <img src='http://andreitara.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . OK, now lets see how do we create our models in Sencha  and fill the with information form back-end. I will create a models that holds the information related to user contact information. To keep this minimal the model could be something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #339933;">**</span>
 <span style="color: #339933;">*</span> Model mapping the contact details
 <span style="color: #339933;">*/</span>
Ext.<span style="color: #660066;">regModel</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ContactDetails'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>        
	<span style="color: #006600; font-style: italic;">//Contact website</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'website'</span><span style="color: #339933;">,</span>
		type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'string'</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #006600; font-style: italic;">//Twitter account</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'twitter'</span><span style="color: #339933;">,</span>
		type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'string'</span>
	<span style="color: #009900;">&#125;</span>
        <span style="color: #006600; font-style: italic;">//TODO Add more  details :), I am lazy  </span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">**</span>
 <span style="color: #339933;">*</span> Model mapping the contact structure
 <span style="color: #339933;">*/</span>
Ext.<span style="color: #660066;">regModel</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Contact'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//Contact name</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span>
		type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'string'</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #006600; font-style: italic;">//Contact email</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'email'</span><span style="color: #339933;">,</span>
		type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'string'</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">//Contact details</span>
        <span style="color: #006600; font-style: italic;">// Mapping Contact details model</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">name</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'detail'</span><span style="color: #339933;">,</span>
		type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'ContactDetails'</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-502"></span><br />
OK now that we have created our model lets create our store that use the Contact model</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> ContactStore <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// mapping model</span>
	model <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Contact'</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// auto load with data from back-end</span>
	autoLoad <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// sort our contacts</span>
	sortOnLoad <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	proxy <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>		
		type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'ajax'</span><span style="color: #339933;">,</span>
		url <span style="color: #339933;">:</span> <span style="color: #3366CC;">'example.com/contacts.json/'</span><span style="color: #339933;">,</span>		
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">//Add a custom sorting function by name</span>
	sorters <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #006600; font-style: italic;">//Set field used to sort the </span>
		property <span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span>		
		sorterFn <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>o1<span style="color: #339933;">,</span> o2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> v1 <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getRoot</span><span style="color: #009900;">&#40;</span>o1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">property</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			 v2 <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getRoot</span><span style="color: #009900;">&#40;</span>o2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">property</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">return</span> v1 <span style="color: #339933;">&gt;</span> v2 <span style="color: #339933;">?</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>v1 <span style="color: #339933;">&lt;</span> v2 <span style="color: #339933;">?</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We did successfully created our store now lets put out data inside a list, this can be easily done by the following voodoo :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">//Create the list of contacts</span>
ContactsList <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">List</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	id <span style="color: #339933;">:</span> <span style="color: #3366CC;">'contactslist'</span><span style="color: #339933;">,</span>
	<span style="color: #006600; font-style: italic;">//Set data source</span>
	store <span style="color: #339933;">:</span> ContactStore
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is it, now the model strong in you is Luke <img src='http://andreitara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/03/working-with-models-data-store-and-list-in-sencha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Doctrine CLI</title>
		<link>http://andreitara.com/2012/02/setup-doctrine-cli/</link>
		<comments>http://andreitara.com/2012/02/setup-doctrine-cli/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 18:39:22 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[doctrine cli]]></category>
		<category><![CDATA[doctrine orm]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=494</guid>
		<description><![CDATA[In the previous article have showed you how to integrate the almighty Doctrine ORM in Zend. But I haven&#8217;t mentioned nothing about the magic of this wonderful framework CLI. I suppose that you have already done all the required magic incantations to integrate Doctrine in Zend, now what you are supposed to do next is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/doctrine.jpg"><img src="http://andreitara.com/wp-content/uploads/2012/02/doctrine.jpg" alt="" title="doctrine" width="160" height="160" class="alignleft size-full wp-image-498" /></a>In the previous article have showed you how to integrate the almighty Doctrine ORM in Zend. But I haven&#8217;t mentioned nothing about the magic of this wonderful framework CLI.</p>
<p>I suppose that you have already done all the required magic incantations to integrate Doctrine in Zend, now what you are supposed to do next is to create in your Zend project a folder called bin and add doctrine.php file with the following content :<br />
<span id="more-494"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'development'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../application'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span>PATH_SEPARATOR<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Doctrine and Symfony Classes</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Doctrine/Common/ClassLoader.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Doctrine'</span><span style="color: #339933;">,</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Symfony'</span><span style="color: #339933;">,</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library/Doctrine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Entities'</span><span style="color: #339933;">,</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/models'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setNamespaceSeparator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Zend Components</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Application.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create application</span>
<span style="color: #000088;">$application</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application<span style="color: #009900;">&#40;</span>
APPLICATION_ENV<span style="color: #339933;">,</span>
APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/configs/application.ini'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// bootstrap doctrine</span>
<span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'doctrine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$em</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'doctrine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// generate the Doctrine HelperSet</span>
<span style="color: #000088;">$helperSet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Symfony\Component\Console\Helper\HelperSet<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'db'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper<span style="color: #009900;">&#40;</span><span style="color: #000088;">$em</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'em'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper<span style="color: #009900;">&#40;</span><span style="color: #000088;">$em</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
\Doctrine\ORM\Tools\Console\ConsoleRunner<span style="color: #339933;">::</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$helperSet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now you have the php file that will provide you basic functionalities for Doctrine CLI, next add a file called doctrine (wihtout extension) containing</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env php
</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'doctrine.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>open the almighty console and mark this as executable (using chmod 777) and now you are done open the console and type ./doctrine, if everything is OK you should get something like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Doctrine Command Line Interface version 2.1.0
&nbsp;
Usage:
<span style="color: #7a0874; font-weight: bold;">&#91;</span>options<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>arguments<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Options:
--help           <span style="color: #660033;">-h</span> Display this <span style="color: #7a0874; font-weight: bold;">help</span> message.
--quiet          <span style="color: #660033;">-q</span> Do not output any message.
--verbose        <span style="color: #660033;">-v</span> Increase verbosity of messages.
--version        <span style="color: #660033;">-V</span> Display this program version.
--ansi              Force ANSI output.
--no-ansi           Disable ANSI output.
<span style="color: #660033;">--no-interaction</span> <span style="color: #660033;">-n</span> Do not ask any interactive question.
&nbsp;
Available commands:
<span style="color: #7a0874; font-weight: bold;">help</span>                             Displays <span style="color: #7a0874; font-weight: bold;">help</span> <span style="color: #000000; font-weight: bold;">for</span> a <span style="color: #7a0874; font-weight: bold;">command</span>
list                             Lists commands
dbal
dbal:import                      Import SQL <span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> directly to Database.
dbal:run-sql                     Executes arbitrary SQL directly from the <span style="color: #7a0874; font-weight: bold;">command</span> line.
orm
orm:clear-cache:metadata         Clear all metadata cache of the various cache drivers.
orm:clear-cache:query            Clear all query cache of the various cache drivers.
orm:clear-cache:result           Clear result cache of the various cache drivers.
orm:convert-d1-schema            Converts Doctrine <span style="color: #000000;">1</span>.X schema into a Doctrine <span style="color: #000000;">2</span>.X schema.
orm:convert-mapping              Convert mapping information between supported formats.
orm:ensure-production-settings   Verify that Doctrine is properly configured <span style="color: #000000; font-weight: bold;">for</span> a production environment.
orm:generate-entities            Generate entity classes and method stubs from your mapping information.
orm:generate-proxies             Generates proxy classes <span style="color: #000000; font-weight: bold;">for</span> entity classes.
orm:generate-repositories        Generate repository classes from your mapping information.
orm:info                         Show basic information about all mapped entities
orm:run-dql                      Executes arbitrary DQL directly from the <span style="color: #7a0874; font-weight: bold;">command</span> line.
orm:schema-tool:create           Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.
orm:schema-tool:drop             Drop the <span style="color: #7a0874; font-weight: bold;">complete</span> database schema of EntityManager Storage Connection or generate the corresponding SQL output.
orm:schema-tool:update           Executes <span style="color: #7a0874; font-weight: bold;">&#40;</span>or dumps<span style="color: #7a0874; font-weight: bold;">&#41;</span> the SQL needed to update the database schema to match the current mapping metadata.
orm:validate-schema              Validate that the mapping files.</pre></div></div>

<p>So this is it, </p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/setup-doctrine-cli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating Doctrine in Zend framework</title>
		<link>http://andreitara.com/2012/02/integrating-doctrine-in-zend-framework/</link>
		<comments>http://andreitara.com/2012/02/integrating-doctrine-in-zend-framework/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 20:55:37 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[doctrine orm]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[zend doctrine integration]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=478</guid>
		<description><![CDATA[Zend is, in my opinion, the best PHP framework ever it has a lot of really nice useful stuff, but it doesn&#8217;t have a build in ORM. I have recently worked with Doctrine ORM 2.0 that is a superb ORM framework, wrote on PHP 5.3 can be easily integrated in Zend. So, lets keep it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/zend-icon.jpg"><img src="http://andreitara.com/wp-content/uploads/2012/02/zend-icon.jpg" alt="" title="zend-icon" width="170" height="190" class="alignleft size-full wp-image-397" /></a>Zend is, in my opinion, the best PHP framework ever it has a lot of really nice useful stuff, but it doesn&#8217;t have a build in ORM. I have recently worked with Doctrine ORM 2.0 that is a superb ORM framework, wrote on PHP 5.3 can be easily integrated in Zend.<br />
So, lets keep it short,<br />
1. download and copy the doctrine framework to the library folder<br />
2. add the following lines to the applicaion.ini:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">doctrine.connection.host <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 'mysql db host'</span>
doctrine.connection.user <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 'mysql user'</span>
doctrine.connection.pass <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 'mysql pass'</span>
doctrine.connection.driv <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 'pdo_mysql'</span>
doctrine.connection.dbname <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 'mysql databse'</span>
doctrine.path.models <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/models/&quot;</span>
doctrine.proxyNamespace<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">'\Proxies'</span>
doctrine.proxyPath<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">APPLICATION_PATH . '/models/Proxies'</span>
doctrine.modelsPath<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH . '/models'</span></pre></div></div>

<p><span id="more-478"></span><br />
2. add some glue code in Bootstrap.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
* Initialize Doctrine
* @return Doctrine_Manager
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> _initDoctrine<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// include and register Doctrine's class loader</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Doctrine/Common/ClassLoader.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'Doctrine'</span><span style="color: #339933;">,</span>
APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library/'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// now create the entity manager and use the connection</span>
<span style="color: #666666; font-style: italic;">// settings we defined in our application.ini</span>
<span style="color: #000088;">$doctrineSettings</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'doctrine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// create the Doctrine configuration</span>
<span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\ORM\Configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// setting the cache ( to ArrayCache. Take a look at</span>
<span style="color: #666666; font-style: italic;">// the Doctrine manual for different options ! )</span>
<span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\Cache\ArrayCache<span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMetadataCacheImpl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setQueryCacheImpl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// choosing the driver for our database schema</span>
<span style="color: #666666; font-style: italic;">// we'll use annotations</span>
<span style="color: #000088;">$driver</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">newDefaultAnnotationDriver</span><span style="color: #009900;">&#40;</span>
<span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'modelsPath'</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMetadataDriverImpl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$driver</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// set the proxy dir and set some options</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setProxyDir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'proxyPath'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAutoGenerateProxyClasses</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setProxyNamespace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'proxyNamespace'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'driver'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'driv'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'dbname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dbname'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'host'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$doctrineSettings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$entityManager</span> <span style="color: #339933;">=</span> \Doctrine\ORM\EntityManager<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// push the entity manager into our registry for later use</span>
<span style="color: #000088;">$registry</span> <span style="color: #339933;">=</span> Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$registry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entitymanager</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entityManager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$entityManager</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So this is it, you have successfully added doctrine to your Zend project.</p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/integrating-doctrine-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty plugin for Kohana</title>
		<link>http://andreitara.com/2012/02/smarty-plugin-for-kohana/</link>
		<comments>http://andreitara.com/2012/02/smarty-plugin-for-kohana/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 07:01:46 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[kohana]]></category>
		<category><![CDATA[smary]]></category>
		<category><![CDATA[template engine]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=455</guid>
		<description><![CDATA[I&#8217;ve been working for a while with Kohana 3 and really enjoin the features provided by it such as HMVC, ORM and caching, features that makes our live as developers really easy allowing us to create really nice pink application. But, yeah &#8230; there are no pink ponies jumping on rainbows, or are  there any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/kohana-lg1.jpg"><img src="http://andreitara.com/wp-content/uploads/2012/02/kohana-lg1.jpg" alt="" title="kohana-lg" width="251" height="95" class="alignleft size-full wp-image-460" /></a>I&#8217;ve been working for a while with Kohana 3 and really enjoin the features provided by it such as HMVC, ORM and caching, features that makes our live as developers really easy allowing us to create really nice pink application. But, yeah &#8230; there are no pink ponies jumping on rainbows, or are  there any ?? I am talking about views from Kohana,  I really don&#8217;t like the way they mix HTML markup and PHP code it is really annoying when you see a foreach loop and inside it some echo, I am sure that you really understand what I mean. But tanks God there are some really smart people that were thinking about this long time before, so this people have invented something that we are calling Smarty. <strong>Smarty</strong> is a <strong>template engine</strong>, a template engine&#8217;s life purpose is to provide a <strong>clear</strong> <strong>separation</strong>  between the <strong>application</strong> business <strong>logic</strong> and the way the data presentation, or you know&#8230;in ancestor time this was called <strong>design </strong>right ?. Well that is necessary because there are two main categories of players: developers and designers and each loves only their own toys. This article is not aiming to learn you advanced topics about Smarty, I suppose that if you are instead of it you can ask the almighty Google about that.</p>
<p>I have wrote some glue code that make possible the utilization of the Smarty template engine in Kohana very simple and transparent, so you don&#8217;t have to change nothing in your existing application. All you have to do is to download the module form <strong><a href="https://github.com/andrei-tara/Smarty-views-for-Kohana" target="_blank">Smarty-views-for-Kohana</a></strong>  repository, extract it in your modules folder and add the following line in your bootstrap.php on module loading section and you are ready to go.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'smarty'</span>  <span style="color: #339933;">=&gt;</span> MODPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'smarty'</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// Smarty views</span></pre></div></div>

<p>So basically now you have finished, have fun with Kohana and Smarty. <img src='http://andreitara.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/smarty-plugin-for-kohana/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Magento product chooser widget in you&#8217;re own module.</title>
		<link>http://andreitara.com/2012/02/using-magento-product-chooser-widget-in-youre-own-module/</link>
		<comments>http://andreitara.com/2012/02/using-magento-product-chooser-widget-in-youre-own-module/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 09:39:10 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[magento custom module]]></category>
		<category><![CDATA[magento product selector]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=442</guid>
		<description><![CDATA[From my personal experience Magento is in the greatest e-commerce platform when it comes to architecture and the way this is built but in the same time the it really piss me off when it comes to documentation. Well the documentation is so fuzzy and the samples are so minimal or outdated, I mean really [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/magento-product-selector.png"><img src="http://andreitara.com/wp-content/uploads/2012/02/magento-product-selector-300x112.png" alt="" title="magento-product-selector" width="300" height="112" class="alignleft size-medium wp-image-447" /></a>From my personal experience Magento is in the greatest e-commerce platform when it comes to architecture and the way this is built but in the same time the it really piss me off when it comes to documentation. Well the documentation is so fuzzy and the samples are so minimal or outdated, I mean really useless. Even when you have to do a really simple task you have to do some reverse engineering and try to understand how to solve your problem (although in the old good days I love playing with decompilers and ASM to try to find out more about how the stuff are done under the hood). But when it comes to have a result in a specified amount of time this is not funny at all.<span id="more-442"></span><br />
OK so one of the task that I had to figure out, was to add a product chooser widget in a custom made component. Sound easy but in reality this was frustrating because I couldn&#8217;t find anything useful and thous guys form Magento community don&#8217;t want to share anything with other (damn bastards), that is the main reason that I am sharing this with you.<br />
Supposing that you already know how to create a module.<br />
The product selector will be triggered by a button and will put all the product SKU in a textbox or something like.<br />
1. create an new JS add it to js folder, this will contain something like :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">getProductChooser <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Request</span><span style="color: #009900;">&#40;</span>
    url<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        method<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;post&quot;</span><span style="color: #339933;">,</span>
        onSuccess<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;chosser-container&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            a.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span>b.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            a.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> VarienRulesForm <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
VarienRulesForm.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    initialize<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">newChildUrl</span> <span style="color: #339933;">=</span> a<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">shownElement</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">updateElement</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;skus&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span> <span style="color: #339933;">=</span> $H<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    initParam<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        b.<span style="color: #660066;">rulesObject</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.label&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showParamInputField</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.element&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> f.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.rule-chooser-trigger&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>e<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">toggleChooser</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> f.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.rule-param-apply&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hideParamInputField</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                f <span style="color: #339933;">=</span> f.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>f.<span style="color: #660066;">multiple</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>f<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hideParamInputField</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#125;</span>
                Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>f<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;blur&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hideParamInputField</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.rule-param-remove&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">removeRuleEntry</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    showChooserElement<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span> <span style="color: #339933;">=</span> $H<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">updateElement</span>.<span style="color: #660066;">value</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            b <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> a.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            b <span style="color: #339933;">=</span> a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">strip</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Updater</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">,</span> c.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
            evalScripts<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            parameters<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
                form_key<span style="color: #339933;">:</span> FORM_KEY<span style="color: #339933;">,</span>
                <span style="color: #3366CC;">&quot;selected[]&quot;</span><span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">keys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            onSuccess<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>._processSuccess.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showChooserLoaded</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            onFailure<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>._processFailure.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    showChooserLoaded<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        a.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;block&quot;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    showChooser<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> a.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span>
        <span style="color: #009900;">&#125;</span>
        b <span style="color: #339933;">=</span> b.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.rule-chooser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showChooserElement</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    hideChooser<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> a.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span>
        <span style="color: #009900;">&#125;</span>
        b <span style="color: #339933;">=</span> b.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.rule-chooser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span>
        <span style="color: #009900;">&#125;</span>
        b.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;none&quot;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    toggleChooser<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> a.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.rule-chooser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            b.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">cleanChooser</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showChooserElement</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    cleanChooser<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> a.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.rule-chooser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span>
        <span style="color: #009900;">&#125;</span>
        b.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    showParamInputField<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">shownElement</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hideParamInputField</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">shownElement</span><span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
        Element.<span style="color: #660066;">addClassName</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;rule-param-edit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.element&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;input.input-text&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            b.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b <span style="color: #339933;">&amp;&amp;</span> b.<span style="color: #660066;">id</span> <span style="color: #339933;">&amp;&amp;</span> b.<span style="color: #660066;">id</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/__value$/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">updateElement</span> <span style="color: #339933;">=</span> b
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            b.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">shownElement</span> <span style="color: #339933;">=</span> a
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    hideParamInputField<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Element.<span style="color: #660066;">removeClassName</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;rule-param-edit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.label&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            c<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>a.<span style="color: #660066;">hasClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rule-param-new-child&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            c <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">&amp;&amp;</span> c.<span style="color: #660066;">options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> c.<span style="color: #660066;">options</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">selected</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        f.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> f.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                b.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> e <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">?</span> e <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span>
            <span style="color: #009900;">&#125;</span>
            c <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;input.input-text&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> c.<span style="color: #660066;">value</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(^\s+|\s+$)/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                c.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> e<span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    e <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;...&quot;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        e <span style="color: #339933;">=</span> e.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;...&quot;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
                b.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> e
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            c <span style="color: #339933;">=</span> Element.<span style="color: #660066;">down</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">addRuleNewChild</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
            c.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">&amp;&amp;</span> c.<span style="color: #660066;">id</span> <span style="color: #339933;">&amp;&amp;</span> c.<span style="color: #660066;">id</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/__value$/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hideChooser</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">updateElement</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">shownElement</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    addRuleNewChild<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> b.<span style="color: #660066;">id</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^.*__(.*)__.*$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;$1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> h <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>b.<span style="color: #660066;">id</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/__/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[^:]*$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;children&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/:/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;__&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
            c<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> Selector.<span style="color: #660066;">findChildElements</span><span style="color: #009900;">&#40;</span>h<span style="color: #339933;">,</span> $A<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;input.hidden&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>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            a.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>k<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>k.<span style="color: #660066;">id</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/__type$/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    c <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">*</span> k.<span style="color: #660066;">id</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^.*__.*?([0-9]+)__.*$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;$1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    d <span style="color: #339933;">=</span> c <span style="color: #339933;">&gt;</span> d <span style="color: #339933;">?</span> c <span style="color: #339933;">:</span> d
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> g <span style="color: #339933;">=</span> f <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;--&quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>d <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> j <span style="color: #339933;">=</span> b.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;LI&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        e.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;rule-param-wait&quot;</span><span style="color: #339933;">;</span>
        e.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> Translator.<span style="color: #660066;">translate</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please wait, loading...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        h.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span>e<span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Updater</span><span style="color: #009900;">&#40;</span>e<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">newChildUrl</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
            evalScripts<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            parameters<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
                form_key<span style="color: #339933;">:</span> FORM_KEY<span style="color: #339933;">,</span>
                type<span style="color: #339933;">:</span> j.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;-&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                id<span style="color: #339933;">:</span> g
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            onComplete<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onAddNewChildComplete</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> e<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            onSuccess<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>._processSuccess.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            onFailure<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>._processFailure.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    _processSuccess<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> b.<span style="color: #660066;">responseText</span>.<span style="color: #660066;">evalJSON</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">ajaxExpired</span> <span style="color: #339933;">&amp;&amp;</span> a.<span style="color: #660066;">ajaxRedirect</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>Translator.<span style="color: #660066;">translate</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Your session has been expired, you will be relogged in now.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            location.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> a.<span style="color: #660066;">ajaxRedirect</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    _processFailure<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        location.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> BASE_URL
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    onAddNewChildComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rule-param-wait&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> c.<span style="color: #660066;">getElementsByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rule-param&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> b <span style="color: #339933;">&lt;</span> a.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> b<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">initParam</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#91;</span>b<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    removeRuleEntry<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> Element.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        a.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    chooserGridInit<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    chooserGridRowInit<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>a.<span style="color: #660066;">reloadParams</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            a.<span style="color: #660066;">reloadParams</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #3366CC;">&quot;selected[]&quot;</span><span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">keys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    chooserGridRowClick<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> Event.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;tr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> Event.<span style="color: #660066;">element</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tagName</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;INPUT&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> Element.<span style="color: #660066;">select</span><span style="color: #009900;">&#40;</span>f<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> a <span style="color: #339933;">?</span> e<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">checked</span> <span style="color: #339933;">:</span> <span style="color: #339933;">!</span>e<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">checked</span><span style="color: #339933;">;</span>
                b.<span style="color: #660066;">setCheckboxChecked</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    chooserGridCheckboxCheck<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> a<span style="color: #339933;">,</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>a.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;th&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">value</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>
        b.<span style="color: #660066;">reloadParams</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #3366CC;">&quot;selected[]&quot;</span><span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">keys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">updateElement</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">chooserSelectedItems</span>.<span style="color: #660066;">keys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>2. be sure that the js file will be hooked in the header, for that add the following line to the adminhtlm layout XML (note that my module is called znuv so you would replace wit the popper name):</p>
<p>3. now you have a code that it will add the widget to the interface so let&#8217;s add a backend form with a button that will show the chooser, so for that add the following lines:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$action</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'getProductChooser(\''</span> <span style="color: #339933;">.</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'adminhtml/promo_widget/chooser/attribute/sku/form/rule_conditions_fieldset'</span><span style="color: #339933;">,</span>
<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_secure'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isAdminUrlSecure</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'?isAjax=true\'); return false;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$productFieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'trigger'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'button'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'trigger'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'whooparoo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Choose Products'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'whooparoo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Choose Products'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'rule-chooser-trigger'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'onclick'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$action</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So that&#8217;s all, happy coding <img src='http://andreitara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/using-magento-product-chooser-widget-in-youre-own-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overwrite Magento checkout controller route</title>
		<link>http://andreitara.com/2012/02/overwrite-magento-checkout-controller-route/</link>
		<comments>http://andreitara.com/2012/02/overwrite-magento-checkout-controller-route/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 20:12:53 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[magento custom module]]></category>
		<category><![CDATA[onepage checkout]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=431</guid>
		<description><![CDATA[I&#8217;v been playing with Magento for a while and yes! there are times when I love it and there times when I wish that it hadn&#8217;t be borned. I remember first time when I had to inject some new functionality over the onepage checkout controller. Doing it for the fist time is really painful but [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/magento1-6.png"><img src="http://andreitara.com/wp-content/uploads/2012/02/magento1-6.png" alt="" title="magento1-6" width="128" height="128" class="alignleft size-full wp-image-435" /></a>I&#8217;v been playing with Magento for a while and yes! there are times when I love it and there times when I wish that it hadn&#8217;t be borned. I remember first time when I had to inject some new functionality over the onepage checkout controller. Doing it for the fist time is really painful but after you get the trick it&#8217;s really simple.</p>
<p>So first step you have to do is to touch the etc/config.xml local module configuration file (I suppose that you already have set a module in the app/code/local/Namespace/Module) on the routes section and add the following lines of code:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;routers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;checkout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;args<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- Overwrite onepage checkout controller --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Namespace_Module</span> <span style="color: #000066;">before</span>=<span style="color: #ff0000;">&quot;Mage_Checkout&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Namespace_Module <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Namespace_Module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/args<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/checkout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/routers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><span id="more-431"></span><br />
In the XML configuration you have informed Magento that the Mage_Checkout module route is overwritten by our Namespace_Module module. Now we only have to extend the Checkout controller and add our functionality, so create the app/code/local/Namespace/Module/controllers/OnepageController.php with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//You need to include the extended controller by hand, the auto-load will not get it for you this time </span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Mage/Checkout/controllers/OnepageController.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Namespace_Module_OnepageController <span style="color: #000000; font-weight: bold;">extends</span> Mage_Checkout_OnepageController <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Index action 
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #666666; font-style: italic;">//TODO add functionality </span>
       parent<span style="color: #339933;">::</span><span style="color: #004000;">indexAction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now you&#8217;we got the trick, go ahead and be wild !! <img src='http://andreitara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/overwrite-magento-checkout-controller-route/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sencha touch list and taphold event</title>
		<link>http://andreitara.com/2012/02/sencha-touch-list-and-taphold-event/</link>
		<comments>http://andreitara.com/2012/02/sencha-touch-list-and-taphold-event/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 23:44:22 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sencha]]></category>
		<category><![CDATA[sencha touch]]></category>
		<category><![CDATA[taphold]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=407</guid>
		<description><![CDATA[Sencha touch allows you to create in no time applications for mobile device and all you need  is love  and&#8230; JavaScript. My latest challenge was to show a menu when user was holding the finger ( not necessary the middle  one  ) on any list element. It tokes me a while but in the end I have  found the magic spell that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/apple-touch-icon.png"><img class="alignleft  wp-image-413" title="apple-touch-icon" src="http://andreitara.com/wp-content/uploads/2012/02/apple-touch-icon.png" alt="" width="111" height="111" /></a>Sencha touch allows you to create in no time applications for mobile device and all you need  is love <img src='http://andreitara.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />   and&#8230; JavaScript. My latest challenge was to show a menu when user was holding the finger ( not necessary the middle  one <img src='http://andreitara.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />   ) on any list element. It tokes me a while but in the end I have  found the magic spell that solved the problem. So to keep it short the code should look something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Create the list</span>
FileList <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">List</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// list setting</span>
<span style="color: #006600; font-style: italic;">// another list setting</span>
<span style="color: #006600; font-style: italic;">// ...</span>
<span style="color: #006600; font-style: italic;">/**
* Listeners binding
*/</span>
listeners <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
el <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">/**
  * Binding tap hold event on list element 
  */</span>
  taphold <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>record<span style="color: #339933;">,</span> btn<span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">//Here you can add the required logic </span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/sencha-touch-list-and-taphold-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multilanguage in Zend</title>
		<link>http://andreitara.com/2012/02/multilanguage-in-zend/</link>
		<comments>http://andreitara.com/2012/02/multilanguage-in-zend/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 22:30:54 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[i18N]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://andreitara.com/?p=390</guid>
		<description><![CDATA[Unfortunately not all of us are spoking the same language, hmm..  weird isn&#8217;t it  ? So is this affecting me as a developer ? would you ask ? actually yes my fellow, it does. If is the first tine when you are developing a multi-language web application you will have to solve a lot of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreitara.com/wp-content/uploads/2012/02/zend-icon.jpg"><img class="alignleft  wp-image-397" title="zend-icon" src="http://andreitara.com/wp-content/uploads/2012/02/zend-icon.jpg" alt="" width="122" height="131" /></a>Unfortunately not all of us are spoking the same language, hmm..  weird isn&#8217;t it  ? So is this affecting me as a developer ? would you ask ? actually yes my fellow, it does. If is the first tine when you are developing a multi-language web application you will have to solve a lot of problems that normally you wouldn&#8217;t have, yes.. you will ! OK so I am not going to explain the paint you will have to endure, but I will show you how to do that in Zend, just follow the steps:</p>
<ul>
<li>Step 1: add a method in the almighty Bootsrap.php something like this:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initLanguage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
 <span style="color: #000088;">$zl</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Locale<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$zl</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setLocale<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ro_RO'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Zend_Locale'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$zl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$lang</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ro'</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000088;">$translate</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Translate<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'csv'</span><span style="color: #339933;">,</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/configs/lang/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$lang</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.csv'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lang</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Zend_Translate'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$translate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$translate</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<ul>
<li>Step 2: add the language files in the APPLICATION_PATH /configs/lang/ this are some  strange csv files <img src='http://andreitara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</li>
<li>Step 3: hmm &#8230; there is no step 3</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2012/02/multilanguage-in-zend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perform face detection in PHP</title>
		<link>http://andreitara.com/2011/06/perform-face-detection-in-php/</link>
		<comments>http://andreitara.com/2011/06/perform-face-detection-in-php/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 21:31:41 +0000</pubDate>
		<dc:creator>andreiT</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[face detection php]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[php module]]></category>

		<guid isPermaLink="false">http://www.andreitara.com/?p=364</guid>
		<description><![CDATA[This short article will learn you how to perform face detection in PHP. So basically we are going to make use of OpenCV ( you know it you are using it everyday &#8230;aren&#8217;t you ?? ) we actually will abuse only on face detection algorithm that comes with it. We are going to compile the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.andreitara.com/wp-content/uploads/2011/06/clip_php_cms.png"><img class="alignleft size-full wp-image-374" style="margin: 10px;" title="clip_php_cms" src="http://www.andreitara.com/wp-content/uploads/2011/06/clip_php_cms.png" alt="" width="342" height="198" /></a>This short article will learn you how to perform <strong>face detection</strong> in <strong>PHP</strong>. So basically we are going to make use of OpenCV ( you know it you are using it everyday &#8230;aren&#8217;t you ?? <img src='http://andreitara.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ) we actually will abuse only on face detection algorithm that comes with it. We are going to compile the face detection as an .so module for php and hook this module in PHP.</p>
<p>&nbsp;</p>
<p>Requirements:</p>
<ul>
<li>LAMP stack installed, you know&#8230; Apache 2, PHP</li>
<li>Build essentials (gcc compilers and all the hoard )</li>
<li>A Linux distribution (mine is Ubuntu  11.something)</li>
<li>1 beer &amp; nothing beater to do  <img src='http://andreitara.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> <span id="more-364"></span></li>
</ul>
<p>OK so the fist thing that you have to do is to install the build essentials by running the command :</p>
<blockquote>
<pre>sudo apt-get install build-essential</pre>
</blockquote>
<p>Be proud ! and tell to all you&#8217;re friends ! you are a linux developer &#8217;cause you have a compiler running on you PC. Now that you can compile c/c++ files you will need the OpenCV library. There are two ways to install it: that first is to download the latest version from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.2/ and run make and make-install commands (not recommended, there is always a missing library or a stupid error ) or you just can open System-&gt;Administration-&gt;Synaptic package manager search <strong>opencv</strong> and check all the libraries as in the following image:</p>
<p><a href="http://www.andreitara.com/wp-content/uploads/2011/06/Screenshot-3.png"><img class="size-full wp-image-365 alignnone" title="Screenshot-3" src="http://www.andreitara.com/wp-content/uploads/2011/06/Screenshot-3.png" alt="" width="545" height="396" /></a></p>
<p>OpenCv library is installed but&#8230; hold on, do not touch you&#8217;re beer yet ! you still have to download and compile facedetection library, do that by using the following magic incantation :</p>
<blockquote>
<pre>wget http://www.xarg.org/download/facedetect-1.0.1.tar.gz
tar -xvf facedetect-1.0.1.tar.gz
cd facedetect
phpize
configure
make
make-install</pre>
</blockquote>
<p>Congratulation !! you parents should be so proud of  you, now is the first time when you have compiled a module for PHP. The facedetect.so was created and copied to the corresponding PHP lib directory (/usr/lib/PPH5), add <strong>extension=facedetect.so</strong> to the php.ini file ( in  /etc/php5/apache2/php.ini or a similar location) restart the apache, now if you run phpinfo you should see the facedetect module up and running:</p>
<p><a href="http://www.andreitara.com/wp-content/uploads/2011/06/Screenshot-4.png"><img class="alignnone size-full wp-image-366" title="Screenshot-4" src="http://www.andreitara.com/wp-content/uploads/2011/06/Screenshot-4.png" alt="" width="541" height="202" /></a></p>
<p>Now let&#8217;s create a PHP file ( for e.g. face.php)  with the following content:</p>
<blockquote><p>&lt;?php</p>
<p>function LoadJpeg($img) {<br />
$im = @imagecreatefromjpeg($img);<br />
if (!$im) {</p>
<p>echo &#8216;Bad image&#8217;;<br />
}</p>
<p>$total = face_count($_GET['file'], &#8216;haarcascade_frontalface_alt.xml&#8217;);<br />
$rectangles = face_detect($_GET['file'], &#8216;haarcascade_frontalface_alt.xml&#8217;);</p>
<p>$im = LoadJpeg($_GET['file']);<br />
$pink = imagecolorallocate($im, 255, 105, 180);</p>
<p>if (count($rectangles) &gt; 0) {</p>
<p>foreach ($rectangles as $arr) {<br />
imagerectangle($im, $arr['x'], $arr['y'], $arr['x'] + $arr['w'],<br />
$arr['y'] + $arr['h'], $pink);<br />
}<br />
}<br />
header(&#8216;Content-Type: image/jpeg&#8217;);<br />
imagejpeg($im);<br />
imagedestroy($im);</p></blockquote>
<p>now run it in the browser http://localhost/face.php?file=lena.jpg and voala !!! you have detected the face of Lenna (still have to test it on fill version of Lenna <img src='http://andreitara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) .</p>
<p><a href="http://www.andreitara.com/wp-content/uploads/2011/06/Screenshot-5.png"><img class="alignnone size-full wp-image-367" title="Screenshot-5" src="http://www.andreitara.com/wp-content/uploads/2011/06/Screenshot-5.png" alt="" width="406" height="395" /></a></p>
<p>While you are enjoying you&#8217;re beer just add few words as feed back in section belowww.</p>
]]></content:encoded>
			<wfw:commentRss>http://andreitara.com/2011/06/perform-face-detection-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

