<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Zendstyle&#039;s Blog</title>
	<atom:link href="http://zendstyle.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://zendstyle.wordpress.com</link>
	<description>A ZF Engineer&#039;s Blog</description>
	<lastBuildDate>Wed, 17 Jun 2009 05:59:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='zendstyle.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Zendstyle&#039;s Blog</title>
		<link>http://zendstyle.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://zendstyle.wordpress.com/osd.xml" title="Zendstyle&#039;s Blog" />
	<atom:link rel='hub' href='http://zendstyle.wordpress.com/?pushpress=hub'/>
		<item>
		<title>out</title>
		<link>http://zendstyle.wordpress.com/2009/06/17/out/</link>
		<comments>http://zendstyle.wordpress.com/2009/06/17/out/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 05:59:48 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[out]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/2009/06/17/out/</guid>
		<description><![CDATA[out for 2 weeks&#8230;..I have some tough exams&#8230;&#8230;don&#8217;t know if i&#8217;ll have the time or mood to blog&#8230;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=66&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>out for 2 weeks&#8230;..I have some tough exams&#8230;&#8230;don&#8217;t know if i&#8217;ll have the time or mood to blog&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=66&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/06/17/out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Separating the views from the js code(III)</title>
		<link>http://zendstyle.wordpress.com/2009/06/13/separating-the-views-from-the-js-codeiii/</link>
		<comments>http://zendstyle.wordpress.com/2009/06/13/separating-the-views-from-the-js-codeiii/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 13:33:08 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[js aggregator]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=61</guid>
		<description><![CDATA[Ok, in my last post I have presented you the the code for One_Asset class which basically combines some js files into one larger js files, today I will show you it&#8217;s members, methods and how to instantiate it. Basically you use it like this: $inflector = new ZendAssetInflector(); $options = array( 'cfg_array' =&#62; $this-&#62;cfg_array, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=61&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok, in my last post I have presented you the the code for One_Asset class which basically combines some js files into one larger js files, today I will show you it&#8217;s members, methods and how to instantiate it.</p>
<p>Basically you use it like this: </p>
<p><code><br />
$inflector 		= new ZendAssetInflector();</p>
<p>$options = array(<br />
 'cfg_array'         =&gt; $this-&gt;cfg_array,<br />
 'under_development' =&gt; $this-&gt;cfg_array["under_development"],<br />
 'js_file'   =&gt; $inflector-&gt;get_final_js_filename(),// The resulted js file<br />
 'inflector'		 =&gt; $inflector,<br />
 'js_config_dir'	 =&gt; $this-&gt;cfg_array['site_phisic_path'].<br />
'application/config/js_config/'   // the dir where we have the js config files	 );</p>
<p>$asset = new OneAsset($options);<br />
$asset-&gt;create(); </code></p>
<p>As you can see the constructor takes as a paramter one array with options(I have multiple apaches, mysqls at work so you will probably have to change some things, to adapt it to your personal setup). The keys of this array are:</p>
<p>inflector: a ZendAssetInflector object, an auxiliary class which I will present a little later.</p>
<p>cfg_Array: is a website config array which resulted from a ini config file with general options for the website:</p>
<p>under_development: true/false , whether in produciton or not(I know, it&#8217;s kinda superfluous, because I already have $cfg_Array above), it&#8217;s role is to echo or not error messages inside the class.</p>
<p>js_file: The name of the big js file that will result for this page:</p>
<p>js_config_dir: The absolute dir path where we have all the js config files. Below these dir there a directory for each module, under each module, there is a directory for each controller and bellw each controller directory there is a config file for every action like this:<br />
For example for the index action in the index controller(let&#8217;s say that<br />
js_config dir  is /var/www/html/mywebsite/config/js_config/ and<br />
we are in the default module<br />
)</p>
<p>/var/www/html/mywebsite/config/js_config/default/index/config.index.php</p>
<p><code>[remote]<br />
yui_url[]="yahoo/yahoo-min.js";<br />
yui_url[]="event/event-min.js";<br />
yui_url[]="connection/connection-min.js";<br />
yui_url[]="yahoo-dom-event/yahoo-dom-event.js";<br />
yui_url[]="dragdrop/dragdrop-min.js";<br />
yui_url[]="container/container-min.js";<br />
yui_url[]="utilities/utilities.js";<br />
yui_url[]="element/element-min.js";<br />
yui_url[]="animation/animation-min.js";<br />
yui_url[]="carousel/carousel.js";</p>
<p>[local]<br />
files[]= "swfobject.js";<br />
files[]= "poll_functions.js";<br />
files[]= "index_cover.js";<br />
files[]= "homepage.js";<br />
files[]= "home_carusel.js";<br />
files[]= "validatePublishDate.js";</code></p>
<p>Ok, now the class methods:</p>
<p>__construct : the constructor, initializes the class variables, and calls init_files method </p>
<p>init_files: parses the js config file for every action, creates the local or remote paths of every js file, and then calls the methods<br />
add_files, to add all the files to the $_files class variable:<br />
$this-&gt;_files is an array with 2 keys, &#8220;local&#8221; and &#8220;remote&#8221; which contains arrays with the local and remote paths of the js files that will be aggregated.</p>
<p>needs_rebuilding: A method that will check if a local js file, or the config of this action has been modified in which case it will rebuild the js file of this action automatically.</p>
<p>create: This method will check if the &#8220;big js file&#8221; of a specific actions does not exist, or it needs rebuilding in which case it will create it/recreate it.</p>
<p>Ok, In the next post and the last one of these series, I will show you the auxiliary class ZendAssetInflector, and how you can use One_Asset together with Zend Framework!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=61&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/06/13/separating-the-views-from-the-js-codeiii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Separating the views from the js code(II)</title>
		<link>http://zendstyle.wordpress.com/2009/06/10/separating-the-views-from-the-js-codeii/</link>
		<comments>http://zendstyle.wordpress.com/2009/06/10/separating-the-views-from-the-js-codeii/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 17:30:11 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[js aggregator]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[views]]></category>
		<category><![CDATA[Zend_View]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=51</guid>
		<description><![CDATA[Today I will show you my JS aggregator class. What this class does is, it reads from a ini file all the js files a page uses it takes them, combines them in one big file, and then the page will contain something like &#60;script src=&#8221;my_big_js_file.js&#8221;&#62; This is a great optimization for your webserver, because [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=51&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I will show you my JS aggregator class. What this class does is, it reads from a ini file all the js files a page uses it takes them, combines them in one big file, and then the page will contain something like</p>
<p>&lt;script src=&#8221;my_big_js_file.js&#8221;&gt;<br />
This is a great optimization for your webserver, because instead of having a dozen of requests to external js files, you will have only one request to a bigger file.This is also a good optimization for your visitor, because the page will load faster, and you can also cache the big js file on the client side. GREAT ADVANTAGE,I&#8217;d say!!!!<br />
More exactly my application setup for ZF contains more modules, every module contains some controllers and every controller some actions of course. I think of every action as a &#8220;page&#8221;, and every &#8220;page&#8221; can be configured to use whichever js files I want. So i have in my application the following dir structure:<br />
(Abbreviations used m =  module,c= controller, a =action)</p>
<p>/config/js_config/m1/m1c1/config.m1c1a1.php<br />
/config.m1c1a2.php<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<br />
/m1c2/config.m1c2a1.php</p>
<p>/config.m1c2a2.php</p>
<p>/m2/m2c1/config.m2c1a1.php<br />
/config.m2c1a2.php<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<br />
/m2c2/config.m1c2a1.php<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<br />
So the modular structure from ZF in reflected on the modular structure of js config file.<br />
A js config file looks like this:<br />
ex: config.m<em>i</em>c<em>j</em>a<em>k</em>.php</p>
<p>[remote]<br />
yui_url[]=&#8221;yahoo/yahoo-min.js&#8221;;<br />
yui_url[]=&#8221;event/event-min.js&#8221;;<br />
yui_url[]=&#8221;connection/connection-min.js&#8221;;<br />
yui_url[]=&#8221;yahoo-dom-event/yahoo-dom-event.js&#8221;;<br />
yui_url[]=&#8221;dragdrop/dragdrop-min.js&#8221;;<br />
yui_url[]=&#8221;container/container-min.js&#8221;;<br />
yui_url[]=&#8221;utilities/utilities.js&#8221;;<br />
yui_url[]=&#8221;element/element-min.js&#8221;;<br />
yui_url[]=&#8221;animation/animation-min.js&#8221;;<br />
yui_url[]=&#8221;carousel/carousel.js&#8221;;</p>
<p>[local]<br />
files[]= &#8220;swfobject.js&#8221;;<br />
files[]= &#8220;poll_functions.js&#8221;;<br />
files[]= &#8220;index_cover.js&#8221;;<br />
files[]= &#8220;homepage.js&#8221;;<br />
files[]= &#8220;home_carusel.js&#8221;;<br />
files[]= &#8220;validatePublishDate.js&#8221;;<br />
files[]= &#8220;functions.js&#8221;;<br />
files[]= &#8220;right_column.js&#8221;;</p>
<p>As you can see there are 2 sections in my ini files: remote and local. That&#8217;s because, you&#8217;ve guessed some js files are remote on other servers, and are fetched via curl, and other are local to the apache server. <strong>All these files are read and combined together resulting one big js file!</strong></p>
<p>Enough words here is the class, One_Asset:</p>
<p><code>/************<br />
  7 ian 2009 	/changes for the Zend Framework, (it should work independently of any Framework now)<br />
 27 feb 2009	/small changes for debugging non-existentent js configs </p>
<p>***********/<br />
class OneAsset{</p>
<p>	private $_files;<br />
	//no. of seconds to cache, or false if cache is disabled</p>
<p>	private $_under_development;</p>
<p>	private $_js_file;</p>
<p>	private $_inflector;</p>
<p>	private $_cfg_js_array;</p>
<p>	public function __construct($options){</p>
<p>		$this-&gt;_cfg_array 	  		  = $options['cfg_array'];<br />
		$this-&gt;_under_development 	  = $options['under_development'];<br />
		$this-&gt;_js_file			 	  = $options['js_file'];<br />
		$this-&gt;_inflector		 	  = $options['inflector'];<br />
		$this-&gt;_js_config_dir         = $options['js_config_dir'];</p>
<p>		if(!is_array($options['cfg_array']) &amp;&amp; $this-&gt;_under_development)<br />
			die('cfg_Array nu e array in constructorul clasei ' . get_class($this));</p>
<p>		$this-&gt;_files 	  = array( "remote"=&gt;array(),<br />
								   "local"=&gt;array()<br />
								   );<br />
		$this-&gt;init_files();<br />
	}</p>
<p>	//adds the js files from the config<br />
	public function init_files(){</p>
<p>		$remote = array();<br />
		$local = array();</p>
<p>		$base_config 	  = $this-&gt;_inflector-&gt;get_js_config_name();<br />
		$this-&gt;_js_config = $this-&gt;_js_config_dir . $base_config;</p>
<p>		//echo 'js config e ' . $this-&gt;_js_config ;</p>
<p>		 //if($this-&gt;_under_development)<br />
		 	//echo 'devel';</p>
<p>		if(file_exists($this-&gt;_js_config))<br />
			$this-&gt;_cfg_js_array =  parse_ini_file($this-&gt;_js_config , true);<br />
		elseif(!file_exists($this-&gt;_js_config) &amp;&amp;  $this-&gt;_under_development)<br />
			die($this-&gt;_js_config . 'js config does not exist ');</p>
<p>		//print_r($this-&gt;_cfg_js_array);<br />
		//die();</p>
<p>	    if(is_array($this-&gt;_cfg_array['js_libraries'])){<br />
			foreach($this-&gt;_cfg_array['js_libraries'] as $library){//for every library in the config</p>
<p>				$url = $this-&gt;_cfg_array[$library];	</p>
<p>				if(is_array($this-&gt;_cfg_js_array['remote'][$library])){//if we use files from this library<br />
						foreach($this-&gt;_cfg_js_array['remote'][$library] as $file){ //create the url of every file in the library<br />
							$remote[] = $url . $file;<br />
						}<br />
				}//if</p>
<p>			}//foreach<br />
	   }		</p>
<p>	  if(is_array($this-&gt;_cfg_js_array['local']['files'])){<br />
		   foreach($this-&gt;_cfg_js_array['local']['files'] as $file)<br />
		   		$local[]= $this-&gt;_cfg_array['site_phisic_path'] . $this-&gt;_cfg_array['local_js_dir']  . $file;<br />
	  }			</p>
<p>	   //print_r($local);<br />
	   //print_r($remote);<br />
	   //die();</p>
<p>	   $this-&gt;add_files(array('local'=&gt;$local,<br />
							  'remote'=&gt;$remote)<br />
							);</p>
<p>	}</p>
<p>	public function add_files($files){</p>
<p>		if(is_array($files)){<br />
			if(is_array($files["local"]))<br />
			foreach($files["local"] as $file){<br />
				if(!in_array($file, $this-&gt;_files['local'])){<br />
					if(!is_file($file)){<br />
							if($this-&gt;_under_development){<br />
								die('Nu exista fisierul ' . $file . "<br />\n");<br />
							}<br />
						continue;<br />
					}<br />
					$this-&gt;_files["local"][] = $file; </p>
<p>					//echo "local e " . $file  . "\n";<br />
				}//If</p>
<p>			}//foreach</p>
<p>			if(is_array($files["remote"]))<br />
			foreach($files["remote"] as $file){<br />
				if(!in_array($file, $this-&gt;_files['remote'])){<br />
					$this-&gt;_files["remote"][] = $file;<br />
					//echo "remote e " . $file  . "\n";<br />
				}//If</p>
<p>			}//foreach<br />
		}		</p>
<p>	}</p>
<p>	public function needs_rebuilding($file){</p>
<p>		//echo $file ." "  . date("F d Y H:i:s",filemtime($file)) . "<br />";</p>
<p>		if(filemtime($this-&gt;_js_config) &gt; filemtime($file)){<br />
				if($this-&gt;_under_development){<br />
					//echo $file ." "  . date("F d Y H:i:s",filemtime($file)) . "<br />\n";<br />
					//echo $this-&gt;_js_config ." "  . date("F d Y H:i:s",filemtime($this-&gt;_js_config)) . "<br />";<br />
			    	//die('sa modificat configul sau aia de la IT n-au serverele sincronizate:)) ');<br />
				}<br />
				return true;<br />
		}</p>
<p>		foreach($this-&gt;_files['local'] as $file_js){<br />
			clearstatcache();</p>
<p>			//echo '<br /> ' . $file_js. " ". date("F d Y H:i:s",filemtime($file_js)) ."<br />";<br />
			if(filemtime($file_js) &gt; filemtime($file)){<br />
				//die('needs rebuilding because of local');</p>
<p>				return true;<br />
			}</p>
<p>			//echo $file ." "  . date("F d Y H:i:s",filemtime($file)) . "<br />\n";<br />
			//echo $file_js ." "  . date("F d Y H:i:s",filemtime($file_js)) . "<br />";<br />
		   	//die('sa modificat configul sau aia de la IT n-au serverele sincronizate:)) ');</p>
<p>			//clearstatcache();<br />
		}</p>
<p>		return false;</p>
<p>	}</p>
<p>	public function create(){</p>
<p>		//print_r($this-&gt;_files);<br />
		//die('creez');</p>
<p>		if(!( count($this-&gt;_files['remote']) || count($this-&gt;_files['local'])))//if we have nothing to create we return<br />
			return 1;</p>
<p>		foreach($this-&gt;_cfg_array['assets_dirs'] as $dir){<br />
			$file = $dir. $this-&gt;_cfg_array['js_save_path'] . $this-&gt;_js_file;</p>
<p>			//echo $file  . "<br />\n";<br />
			if( !file_exists($file) ||<br />
				(file_exists($file) &amp;&amp; $this-&gt;needs_rebuilding($file) ) ){</p>
<p>					if( (file_exists($file)) &amp;&amp; (!is_writable($file)) &amp;&amp; ($this-&gt;_under_development == true)){<br />
						die('nu exista permisiuni ptr scrierea fisierului '. $file. '<br /> Ask IT');<br />
					}</p>
<p>				$fp = fopen($file,"w");<br />
				if(!$fp &amp;&amp; $this-&gt;_under_development){<br />
					echo "eroare la deschiderea fisierului " . $file;<br />
					die();<br />
				}else{</p>
<p>					  fputs($fp,'// Generated by '.$_SERVER['SERVER_ADDR'].' at : ' .<br />
					  date("Y-m-d G:i:s") . " " . filemtime($file) . "  by class " . get_class($this)  ."  \n\n\n");</p>
<p>					  foreach($this-&gt;_files["remote"] as $file){<br />
							fputs($fp, "//   From file  " . $file . "\r\n\r\n");<br />
							$ret = fputs($fp, $this-&gt;fetch_asset($file));</p>
<p>							if(!$ret &amp;&amp; $this-&gt;_under_development)<br />
								die('nu am putut scrie in fisier');</p>
<p>							fputs($fp, "\r\n\r\n\r\n");<br />
					  }	</p>
<p>					  foreach($this-&gt;_files["local"] as $file){<br />
							fputs($fp, "//   From file  " . $file . "\r\n\r\n");</p>
<p>							$ret = fputs($fp,file_get_contents($file));</p>
<p>							if(!$ret &amp;&amp; $this-&gt;_under_development)<br />
								die('nu am putut scrie in fisier');</p>
<p>							fputs($fp, "\r\n\r\n\r\n");<br />
					  }</p>
<p>				}<br />
				fclose($fp);	</p>
<p>			}//if !file_exists<br />
		}//foreach</p>
<p>	}</p>
<p>	function fetch_asset($asset_url){</p>
<p>	   $curl = curl_init();<br />
       curl_setopt($curl,CURLOPT_URL,$asset_url);<br />
       curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);<br />
       curl_setopt($curl,CURLOPT_HEADER, 0 );<br />
       curl_setopt($curl,CURLOPT_COOKIESESSION, 1);<br />
       curl_setopt($curl,CURLOPT_USERAGENT," Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12");<br />
       $result = curl_exec ($curl);  // culegem codul html al paginii cu tabel &amp;cauta=Selectie<br />
       //echo  "<b>".curl_error($curl). "</b>";</p>
<p>	   if(strpos($result,'404 - Not Found') &amp;&amp; $this-&gt;_under_development){<br />
	   		die('eroare la fetchuirea ' . $asset_url . "\n\n\n"  . $result );<br />
	   }		</p>
<p>       curl_close ($curl);</p>
<p>	   return $result;</p>
<p>	}</p>
<p>}<br />
</code></p>
<p>As this has already been a big post, I&#8217;ll stop here for the moment and continue in the next post. <strong>Don&#8217;t worry if this may seem complicated it&#8217;s actually very simple to use!</strong>. I&#8217;ll show you in the next post how to instantiate this class, it&#8217;s methods and variables. Now take a break!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=51&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/06/10/separating-the-views-from-the-js-codeii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>short holiday:)</title>
		<link>http://zendstyle.wordpress.com/2009/06/05/short-holiday/</link>
		<comments>http://zendstyle.wordpress.com/2009/06/05/short-holiday/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 19:50:46 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[holiday]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=49</guid>
		<description><![CDATA[Be back in 4 days. I will show you how I aggregate all my js files in one single js file, part of my &#8220;Separating the views from the js code&#8221;, part 2&#8230;.It includes caching,regeneration on the fly, breaking the cache on the client side and other juicy stuff on the Apache server&#8230;.OOP style of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=49&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Be back in 4 days. I will show you how I aggregate all my js files in one single js file, part of my &#8220;Separating the views from the js code&#8221;, part 2&#8230;.It includes caching,regeneration on the fly, breaking the cache on the client side and other juicy stuff on the Apache server&#8230;.OOP style of course&#8230;..hope I made you curious;)&#8230;&#8230;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=49&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/06/05/short-holiday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Advices for the ZF exam</title>
		<link>http://zendstyle.wordpress.com/2009/06/03/advices-for-the-zf-exam/</link>
		<comments>http://zendstyle.wordpress.com/2009/06/03/advices-for-the-zf-exam/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 16:54:18 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[zf]]></category>
		<category><![CDATA[ZF exam]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=42</guid>
		<description><![CDATA[A few advices and conclusions from the ZF exam : 1)Download the PDF named Study Guide available for free from zend.com and read it(very carefully) 2 or 3 times. Take a good look at the questions. Once you will understand those questions, you will have a very good idea about what kind of questions you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=42&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few advices and conclusions from the ZF exam :</p>
<p>1)Download the PDF named Study Guide available for free from zend.com and read it(very carefully) 2 or 3 times. Take a good look at the questions. Once you will understand those questions, you will have a very good idea about what kind of questions you will be asked at the exam.</p>
<p>2)You will have something like 12 big chapters to learn from the study guide, each of them containing one big class or 2,3,4 perhaps even five smaller classes. Study <strong><a href="http://framework.zend.com/manual/en/">the API</a> </strong>of those classes very good and try to memorize most of their methods. The more you memorize the better! I did not joke in <a href="http://zendstyle.wordpress.com/2009/05/28/zend-framework-exam/">the first post</a> when I said they will ask you from all of their API!!!</p>
<p>3)Try to answer at the questions from the Study Guide (after you think you are prepared and learned <strong><a href="http://framework.zend.com/manual/en/">the API</a></strong>) and if you can answer at those you will probably do just fine at the exam. Attention! Do not look at those questions daily, because you will learn them by heart and it&#8217;s 100% that you will not be asked those questions at the exam!!!</p>
<p>4)I did not pay 1000$ for the training they offer because that would be an important financial effort for me and I passed the exam from the first time and so can you!!!</p>
<p>5)Basically all you have to have to pass the exam is<br />
  A)Good Memory, to memorize all those classes methods<br />
  B)a bit of logical thinking in your head and if you&#8217;re interested in ZF, you probably have it;)<br />
  C)190$, the price I have paid for the exam + VAT</p>
<p>I think that would be about all for the moment&#8230;. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=42&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/06/03/advices-for-the-zf-exam/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Request class with auto-sanitization</title>
		<link>http://zendstyle.wordpress.com/2009/06/02/request-class-with-auto-sanitization/</link>
		<comments>http://zendstyle.wordpress.com/2009/06/02/request-class-with-auto-sanitization/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 19:39:26 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[auto-sanitization]]></category>
		<category><![CDATA[Zend_Controller_Request]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=34</guid>
		<description><![CDATA[I will show you here a Request class, which extends the Zend_Controller_Request_Http and also does a basic xss sanitization(automatically, so you will never miss anything)! I know, it&#8217;s a poor example, I have a lot of ideas of writing a better one, using Zend_Filter_Input and the Zend_View object. This is an example ONLY to show [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=34&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I will show you here a Request class, which extends the  Zend_Controller_Request_Http and also does a basic xss sanitization(automatically, so you will never miss anything)! I know, it&#8217;s a poor example, I have a lot of ideas of writing a better one, using Zend_Filter_Input and the Zend_View object. <strong>This is an example ONLY to show you, that I like to do sanitizations AUTOMATICALLY so I never miss any input variables.</strong></p>
<p><code>class ZendExt_Request extends Zend_Controller_Request_Http{</p>
<p>    /**<br />
    * Retrieve an ESCAPED parameter<br />
    *<br />
    * Retrieves an ESCAPED parameter from the instance. Priority is in the order of<br />
    * userland parameters (see {@link setParam()}), $_GET, $_POST. If a<br />
    * parameter matching the $key is not found, null is returned.<br />
    *<br />
    * If the $key is an alias, the actual key aliased will be used.<br />
    *<br />
    * @param mixed $key<br />
    * @param mixed $default Default value to use if key not found<br />
    * @return mixed<br />
    */<br />
    public function getParam($key, $default = null){</p>
<p>        $value = parent::getParam($key,$default);   </p>
<p>        if(is_string($value))<br />
            return htmlentities($value,ENT_QUOTES,'UTF-8');<br />
        else<br />
            return $value;   </p>
<p>    }</p>
<p>    /**<br />
    * Retrieve an array of ESCAPED parameters<br />
    *<br />
    * Retrieves a merged array of parameters, with precedence of userland<br />
    * params (see {@link setParam()}), $_GET, $POST (i.e., values in the<br />
    * userland params will take precedence over all others).<br />
    *<br />
    * @return array<br />
    */<br />
    public function getParams(){<br />
        $values = parent::getParams();</p>
<p>        foreach($values as $k=&gt;$v){<br />
            if(is_string($v))<br />
                $values[$k] = htmlentities($v,ENT_QUOTES,'UTF-8');<br />
        }   </p>
<p>          return $values;   </p>
<p>    }</p>
<p>}</p>
<p></code></p>
<p>You set this this class in your front controller like this:<br />
$front-&gt;setRequest(&#8216;Zend_Controller_Request_Http&#8217;);<br />
Next everytime in your controllers you will use<br />
$this-&gt;_getParam(&#8216;some_variable&#8217;), and then assign the variable to the $this-&gt;view object, you can echo it in the view script, without using $this-&gt;escape(&#8230;.).  Code example:<br />
Before:</p>
<p>   In controller:<br />
  <code>$variable = $this-&gt;_getParam('variable');<br />
  $this-&gt;view-&gt;variable = $variable;</code></p>
<p>   In the view script<br />
   <code>&lt;?=$this-&gt;escape($this-&gt;variable)?&gt;</code></p>
<p>After:<br />
  In controller:<br />
  <code>$variable = $this-&gt;_getParam('variable');<br />
  $this-&gt;view-&gt;variable = $variable;</code></p>
<p>  In the view script<br />
  <code>&lt;?=$this-&gt;variable?&gt;</code></p>
<p>AUTOMATICALLY is the keyword here!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=34&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/06/02/request-class-with-auto-sanitization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Separating the views from the js code(I)</title>
		<link>http://zendstyle.wordpress.com/2009/05/30/separating-the-views-from-the-js-codei/</link>
		<comments>http://zendstyle.wordpress.com/2009/05/30/separating-the-views-from-the-js-codei/#comments</comments>
		<pubDate>Sat, 30 May 2009 13:44:47 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[views]]></category>
		<category><![CDATA[Zend_View]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=27</guid>
		<description><![CDATA[I try to keep the js and html code mixing at the minimun. The only Js code you will see in my views scripts is only some variable assignments.For example in a view script,lets&#8217; say views/scripts/index/index.php: ......... ......HTML code.. &#60;script&#62; a = '....'; b='......'; &#60;/script&#62; ......more HTML code.... ........ All the js functions and classes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=27&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I try to keep the js and html code mixing at the minimun. The only Js code you will see in my views scripts is only some variable assignments.For example in a view script,lets&#8217; say views/scripts/index/index.php:<br />
<code><br />
.........<br />
......HTML code..</p>
<p>&lt;script&gt;<br />
a = '....';<br />
b='......';<br />
&lt;/script&gt;<br />
......more HTML code....<br />
........<br />
</code><br />
All the js functions and classes are in separate .js files.If i need a function to run when a page loads, i register it as an onload event with YUI. For example, let&#8217;s say I want a videoplayer to run when the page loads.<br />
I include the following js file in my page:</p>
<p style="text-align:left;">video_player.js<br />
<code><br />
function play_video(){<br />
try {<br />
if(video_file != undefined &amp;&amp; image_file != undefined ) {<br />
var player = new SWFObject( site_url + "design/flash/player.swf", "player-box", "400", "300", "8", "transparent");<br />
player.addParam('wmode','transparent');<br />
player.addParam('quality','best');<br />
player.addParam('allowFullScreen','true');<br />
player.addParam("allowScriptAccess", "always");<br />
player.addParam("allowNetworking","all");<br />
player.addParam("scale","exactfit");<br />
player.addVariable("file",  video_file);<br />
player.addVariable("image", image_file);</code></p>
<p>player.addVariable(&#8220;controlbar&#8221;,&#8221;over&#8221; );<br />
player.addVariable(&#8220;autostart&#8221;, autoplay);<br />
player.addVariable(&#8220;channelIdentifier&#8221;, &#8220;X57wx%2BoGo%2Bfwl%2FmoJl5YMQ%3D%3D&#8221;);//CHANNEL IDENTIFIER &#8211; from NoPrimeTime system<br />
player.write(&#8220;videoPlayer&#8221;);<br />
}<br />
}</p>
<p>}<br />
catch(e) {<br />
         }<br />
}<br />
YAHOO.util.Event.addListener(window, &#8220;load&#8221;, play_video);</p>
<p>Now as you may be asking how does this function knows what video to play?It doesn&#8217;t take any parameters right? Wrong!!! If you will look closely it uses 3 GLOBAL VARIABLES, video_file,image_file, and site_url? Where do they come from?<br />
Very simple actually! I set them in the view script, as I told you at the beggining. In my view script I will have:<br />
<code><br />
........html code.......<br />
..............<br />
&lt;script&gt;<br />
video_file='&lt;?=$this-&gt;video_file?&gt;';<br />
image_file='&lt;?=$this-&gt;image_file?&gt;';<br />
site_url='&lt;?=$this-&gt;site_url?&gt;';<br />
&lt;/script&gt;<br />
........html code.......<br />
..............</p>
<p></code><br />
As you can see the js variables are set from the $this, view variable, which you guessed it it&#8217;s set in a controller&#8230;..<br />
How does this function? When the page loads, the js parser will first discover the 3 variables, which will act as parameters to the play_video function, which will run on the window.onload event.  What is the advantage of this technique? Well your views scripts are much easier to read and mantain and of course to reuse them. The same is true for your js code too.<br />
In a future post, I will tell you how I aggregate all the js files, in one single file to reduce the no. of requests to your server.<span id="more-27"></span><!--more--></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=27&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/05/30/separating-the-views-from-the-js-codei/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend Framework with replication</title>
		<link>http://zendstyle.wordpress.com/2009/05/29/zend-framework-with-replication/</link>
		<comments>http://zendstyle.wordpress.com/2009/05/29/zend-framework-with-replication/#comments</comments>
		<pubDate>Fri, 29 May 2009 19:03:54 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[Zend_Db_Table]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/?p=13</guid>
		<description><![CDATA[We have at work a database setup which uses replication. So we have one mysql master, and a few slaves. We have 2 connections, $write(the master) and $read(slaves). All the inserts, updates ,deletes go to the master ($write) and the selects to the slaves($read). More precisely: $read = Zend_Db :: factory(...); $write = Zend_Db :: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=13&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We have at work a database setup which uses replication. So we have one mysql master, and a few slaves.<br />
We have  2 connections, $write(the master) and $read(slaves). All the inserts, updates ,deletes go to the master ($write) and the selects to the slaves($read).</p>
<p>More precisely:<br />
<code>$read = Zend_Db :: factory(...);<br />
$write = Zend_Db :: factory(...);</p>
<p>Zend_Registry::set('write',$write);<br />
Zend_Registry::set('read',$read);<br />
Zend_Db_Table_Abstract::setDefaultAdapter($read);</code></p>
<p>So one solution would be for example to do like this<br />
<code>$write-&gt;insert(....),<br />
$write-&gt;delete(....),<br />
$read-&gt;fetchAll(....),<br />
</code><br />
But if i do it like above I have to always be extra careful not to mix $write with $read. This is a very error proned solution.I&#8217;m lazy and I want this job to be done automatically so I don&#8217;t have to be extra careful everytime I write a query. So this is my solution:</p>
<p>I have extended Zend_Db_Table:<br />
<code><br />
class ZendExt_Table extends Zend_Db_Table {</p>
<p>        public function insert(array $data){</p>
<p>            $this-&gt;_setAdapter('db_write');<br />
            $return = parent::insert($data);<br />
            $this-&gt;_setAdapter('db_read');</p>
<p>            return $return;<br />
          }</p>
<p>        public function update(array $data, $where){</p>
<p>            $this-&gt;_setAdapter('db_write');<br />
            $return = parent::update($data, $where);<br />
            $this-&gt;_setAdapter('db_read');</p>
<p>            return $return;</p>
<p>            }</p>
<p>        public function delete($where){</p>
<p>           $this-&gt;_setAdapter('db_write');<br />
            $return = parent::delete($where);<br />
            $this-&gt;_setAdapter('db_read');</p>
<p>            return $return;<br />
          }</p>
<p>}</code></p>
<p>Now, all my models extend ZendExt_Table. So every time I do an insert,update or delete on a model, the database connection is switched to $write and then back to $read. This is 100% sure. Unfortunately this solution works only when you use models. The Zend_Db_Table proxys it&#8217;s methods to Zend_Db_Adapter,<br />
$write or $read. Now you could implement the above setup for models in Zend_Db_Adapter, but that would mean to patch the ZF code, and I didn&#8217;t want that. And also I couldn&#8217;t find any other solution at that time.</p>
<p>So in conclusion when you will use models you are 100% safe. But when you use the Zend_Db_Adapter class directly for example:</p>
<p><code>$read-&gt;fetchAll(....)<br />
$write-&gt;insert(....)</code><br />
etc., then it&#8217;s your responsability to choose correctly between $read and $write.<br />
Hope I make myself clear&#8230;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=13&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/05/29/zend-framework-with-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend Framework exam</title>
		<link>http://zendstyle.wordpress.com/2009/05/28/zend-framework-exam/</link>
		<comments>http://zendstyle.wordpress.com/2009/05/28/zend-framework-exam/#comments</comments>
		<pubDate>Thu, 28 May 2009 20:06:42 +0000</pubDate>
		<dc:creator>zendstyle</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[zf]]></category>
		<category><![CDATA[ZF exam]]></category>

		<guid isPermaLink="false">http://zendstyle.wordpress.com/2009/05/28/zend-framework-exam/</guid>
		<description><![CDATA[I have passed the ZF exam on 19/05/2009 and i&#8217;m very proud about that. And yes, i like to brag about that a lot!:) For all of you who want to pass this exam I advise you to take it very seriously. It&#8217;s not an easy exam. You&#8217;ll have to learn a  lot, because you&#8217;ll [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=3&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>       I have passed the ZF exam on 19/05/2009 and i&#8217;m very proud about that. And yes, i like to brag about that a lot!:)</p>
<p>       For all of you who want to pass this exam I advise you to take it very seriously. It&#8217;s not an easy exam. You&#8217;ll have to learn a  lot, because you&#8217;ll be asked a lot of questions, from the entire ZF API. The ZF exam will ask you &#8220;shameless&#8221; questions as I like to say.  Prior to take the exam, I had like 6 months of experience working in ZF, from which 4 months of hard work, creating a new website(refactoring an old one) and intense study.</p>
<p>      I think that&#8217;s about all for the moment. For all the IT professionals out there, who want to take this exam, Good Luck!</p>
<p>ps: I hope I didn&#8217;t scared you very hard. It&#8217;s not an impossible exam, it&#8217;s just a serious one!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zendstyle.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zendstyle.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zendstyle.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zendstyle.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zendstyle.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zendstyle.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zendstyle.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zendstyle.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zendstyle.wordpress.com&amp;blog=7941233&amp;post=3&amp;subd=zendstyle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zendstyle.wordpress.com/2009/05/28/zend-framework-exam/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53eba8e37e8c3be591623b2358d31158?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zendstyle</media:title>
		</media:content>
	</item>
	</channel>
</rss>
