<?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>Julian Castaneda &#187; Frameworks and API&#8217;s</title>
	<atom:link href="http://www.smooka.com/blog/category/frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.smooka.com/blog</link>
	<description>From programming to music!</description>
	<lastBuildDate>Fri, 21 May 2010 14:12:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Working with Google Charts and Visualization API</title>
		<link>http://www.smooka.com/blog/2009/11/09/working-with-google-charts-and-visualization-api/</link>
		<comments>http://www.smooka.com/blog/2009/11/09/working-with-google-charts-and-visualization-api/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 11:00:58 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Frameworks and API's]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=232</guid>
		<description><![CDATA[This week I had the chance to play around with Google&#8217;s charts API, and let me tell you that I&#8217;m loving it. In the past couple of [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.smooka.com/blog/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/blog/wp-content/thumbnails/232.jpg&amp;w=70&amp;h=70&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p><img alt="Red line chart with pale gray background" src="http://chart.apis.google.com/chart?cht=lc&amp;chd=s:pqokeYONOMEBAKPOQVTXZdecaZcglprqxuux393ztpoonkeggjp&amp;chco=FF0000&amp;chls=4.0,3.0,0.0&amp;chs=200x125&amp;chxt=x,y&amp;chxl=0:|Jun|July|Aug|1:||20|30|40|50&amp;chf=bg,s,EFEFEF" align="left"/>This week I had the chance to play around with Google&#8217;s charts API, and let me tell you that I&#8217;m loving it. In the past couple of years I&#8217;ve had to integrate charts into the different projects. I have used everything from Fusion Charts, to PHP/SWF Charts, and DOJO&#8217;s charting engine. But, since I learned that Google provided developers with an API to create charts on the fly, I wanted to give it a try. <span id="more-232"></span></p>
<p><b>To create static bart chart is as simple as:</b></p>
<pre class="brush: xml; light: true;">
&lt;img src=&quot;http://chart.apis.google.com/chart?
cht=bvs
&amp;chs=200x125
&amp;chd=t:10,50,60,80,40|50,60,100,40,20
&amp;chco=4d89f9,c6d9fd
&amp;chbh=20&amp;chds=0,160&quot;/&gt;
</pre>
<p><b>Let me break out the parameters for you into:</b><img src="http://chart.apis.google.com/chart?cht=bvs&#038;chs=200x125&#038;chd=t:10,50,60,80,40|50,60,100,40,20&#038;chco=4d89f9,c6d9fd&#038;chbh=20&#038;chds=0,160" align="right"/><br />
// this is the chart type<br />
<code>cht=bvs </code><br />
//this is the bar colors<br />
<code>chco=4D89F9,C6D9FD</code><br />
//this is the chart values<br />
<code>chd=t:10,50,60,80,40|50,60,100,40,20</code><br />
//chart dimensions<br />
<code>chds=0,160</code></p>
<p>In  the <a href="http://code.google.com/apis/chart/types.html" rel="nofollow" target="_blank">Google Charts API</a> website you can find more info regarding this simple but useful chart api. But, that&#8217;s not all. They also have the <a href="http://code.google.com/apis/visualization/" rel="nofollow" target="_blank">Google Visualization API</a> where they actually give you more advanced and dynamic set of visualization tools. They pretty much opened their entire library of data visualization helpers to allow developers like yourself create user interfaces that contain elements that some of your users will be used to seeing, since graphs, charts and other elements you will find in this API is already being implemented in google products.</p>
<p>I encourage you to check both, the more simple and straight forward <a href="http://code.google.com/apis/chart/types.html" rel="nofollow" target="_blank">Charts API</a>, or the more advanced and dynamic <a href="http://code.google.com/apis/visualization/" rel="nofollow" target="_blank">Visualtization API</a>. </p>
<p>Feel free to let me and the readers know on the exiting ways you are utilizing those API&#8217;s</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2009/11/09/working-with-google-charts-and-visualization-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework and Firebug &#8211; Log and Debug your Projects</title>
		<link>http://www.smooka.com/blog/2009/08/21/zend-framework-firebug-log-debug/</link>
		<comments>http://www.smooka.com/blog/2009/08/21/zend-framework-firebug-log-debug/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 12:53:57 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Frameworks and API's]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[wildfire]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=162</guid>
		<description><![CDATA[When developing an application there are some important factors that you have to pay close attention to avoid problems in the future. I think one of the [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.smooka.com/blog/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/blog/wp-content/thumbnails/162.jpg&amp;w=70&amp;h=70&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p><img src="http://www.smooka.com/blog/wp-content/uploads/firebug.jpg" alt="firebug" title="firebug" width="162" height="162" class="alignleft size-full wp-image-167" />When developing an application there are some important factors that you have to pay close attention to avoid problems in the future. I think one of the most important is logging information on how your application is working and when it fails.</p>
<p>Must of us like to log only big exceptions and fatal errors, but the truth is, that when you are in the development process it&#8217;s very important to keep track of not just errors, but important information of when something gets executed. As a web developer one of the most important tools to have is <a href="http://getfirebug.com/">FireBug</a>. If you didn&#8217;t know, FireBug has an API that you can use to send console messages for logging purposes, when debugging JavaScript. But, did you know you can use FireBug to debug your php applications?<span id="more-162"></span></p>
<p>Through <a href="http://www.wildfirehq.org/">Wildfire</a>, a project that was created to help developers have a standard way for sending messages between different programming languages and scripts. The <a href="http://framework.zend.com/">Zend Framework</a> is now able to communicate to the Firebug console in order to display logging messages injected by PHP.</p>
<p>Using this component is pretty straight forward if you are using Zend_Controller_Front (MVC) with zend Framework.</p>
<p>Place this in your bootstrap file before dispatching your front controller</p>
<pre class="brush: php;">
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
</pre>
<p>Then whenever you want to log something to Firebug just use it in your model, view, or controller like this.</p>
<pre class="brush: php;">
$logger-&gt;log('This is an INFORMATIONAL log message!', Zend_Log::INFO);
$logger-&gt;log('This is a WARNING log message!', Zend_Log::WARN);
$logger-&gt;log('This is an ERROR log message!', Zend_Log::ERROR);
</pre>
<p>If you notice in the example above, you can specify the type of message you want to log (INFO, WARN, etc..). This is helpful when you want to clearly identify what type of message you are viewing since it will apply a special formatting and in some instances provide more information.</p>
<p>If you want to use the <a href="http://framework.zend.com/manual/en/zend.log.writers.html#zend.log.writers.firebug">Zend_Log_Writer_Firebug </a>as a stand alone here is the sample code you can use:</p>
<pre class="brush: php;">
//Instantiate the Firebug Writer
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);

//start the wildfire component
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel-&gt;setRequest($request);
$channel-&gt;setResponse($response);

// Start output buffering
ob_start();

// Now you can make calls to the logger

$logger-&gt;log('This is a log message!', Zend_Log::INFO);

// Flush log data to browser
$channel-&gt;flush();
$response-&gt;sendHeaders();
</pre>
<p>If you don&#8217;t use ZendFramework there is another alternative to php developers. FirePhp, will also enable you to send log messages to Firebug by using php method calls. Be sure to check <a href="http://www.firephp.org/">FirePhp website</a> to get more information.</p>
<p>So remember that this is just one easy and great way to debug your projects, there are many other tools and methods you can incorporate into your projects. If you want to share other ways or simply just want to ask a question regarding this post, feel free to leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2009/08/21/zend-framework-firebug-log-debug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend Cache and Zend Feed Problem</title>
		<link>http://www.smooka.com/blog/2009/04/22/zend-cache-and-zend-feed-problem/</link>
		<comments>http://www.smooka.com/blog/2009/04/22/zend-cache-and-zend-feed-problem/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 17:23:00 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Frameworks and API's]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Cache]]></category>
		<category><![CDATA[Zend_Feed]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=88</guid>
		<description><![CDATA[Today I ran into a problem while caching feeds using Zend_Cache. I decided that I wanted to cache the returned object by the Zend_Feed. 

While iterating through the feed, the script would output the following message "Warning: Invalid argument supplied for foreach()", under, "Zend/Feed/Element.php on line 322" on an empty cache.]]></description>
			<content:encoded><![CDATA[<p>Today I ran into a problem while caching feeds using Zend_Cache. I decided that I wanted to cache the returned object by the Zend_Feed. I had something like this:</p>
<pre class="brush: php;">
$rssFeedLink = 'http://www.smooka.com/blog/';
$cacheId = 'rss_feed';

$frontendOptions = array(
		   	'lifetime' =&gt; 1800, // cache lifetime of 30 mins
		   	'automatic_serialization' =&gt; true);

$backendOptions = array(
		    	// Directory where to put the cache files
		    	'cache_dir' =&gt; '/cache/'
			);

// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory('Core','File', $frontendOptions, $backendOptions);

if (!$rss = $cache-&gt;load($cacheId)) {
	try {
		$rss = Zend_Feed::import($rssFeedLink);
	} catch (Exception $e) {
		$feedError = true;
	}

	//check to see if it did not fail
	if (!$feedError &amp;&amp; is_object($rss))
	{
		$cache-&gt;save($rss, $cacheId);
	}
}

//assuming that everything went right while fetching the feed
foreach ($rss as $item) {
	$channel['items'][] = array(
		'title'       =&gt; $item-&gt;title(),
		'link'        =&gt; $item-&gt;link(),
		'description' =&gt; $item-&gt;description()
	);
}
</pre>
<p><span id="more-88"></span><br />
While iterating through the feed, the script would output the following message &#8220;Warning: Invalid argument supplied for foreach()&#8221;, under, &#8220;Zend/Feed/Element.php on line 322&#8243; on an empty cache.</p>
<p>It appears that Zend_Feed and Zend_Cache do not get along, I&#8217;m pretty sure it&#8217;s a bug since it looks like Zend_Feed_Rss is sent to sleep by the $cache->save() call and it&#8217;s not waking up automatically. The solution that I found it&#8217;s pretty straight forward. Just modify the following piece of code.</p>
<pre class="brush: php;">
if (!$feedError &amp;&amp; is_object($rss))
{
	$cache-&gt;save($rss, $cacheId);
	//ADD a wakeup call to the RSS object
	$rss-&gt;__wakeup();
}
</pre>
<p>That should do the trick!</p>
<p>After I fixed the issue, I went back to the drawing board and decided that it was more efficient to cache the actual HTML output, instead of the returned object by Zend_Feed. That seems to work just fine, since the call to $cache->save() is done after the iteration of the feed items. That fixes the issue and at the same time you are eliminating the need to iterate and re-build the HTML every time the page is loaded.</p>
<p>Hope this information helps you, and if you have any questions or comments be sure to post them here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2009/04/22/zend-cache-and-zend-feed-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>5 Things: Working with Zend Framework and Ajax</title>
		<link>http://www.smooka.com/blog/2009/04/17/5-things-working-with-zend-framework-and-ajax/</link>
		<comments>http://www.smooka.com/blog/2009/04/17/5-things-working-with-zend-framework-and-ajax/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:02:09 +0000</pubDate>
		<dc:creator>Julian</dc:creator>
				<category><![CDATA[Frameworks and API's]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.smooka.com/blog/?p=60</guid>
		<description><![CDATA[Today I wanted to write about 5 awesome Zend Framework components/helpers that can help you when working with ajax.
<ul>
	<li>isXmlHttpRequest()</li>
	<li>JSON action helper</li>
	<li>AutoComplete</li>
	<li>ContextSwitch &#038; AjaxContext</li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Today I wanted to write about 5 awesome Zend Framework components/helpers that can help you when working with ajax.</p>
<ul>
<li><a href="http://framework.zend.com/manual/en/zend.controller.request.html#zend.controller.request.http.ajax" target="blank">isXmlHttpRequest()</a></li>
<li><a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.json" target="blank">JSON action helper</a></li>
<li><a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.autocomplete">AutoComplete</a></li>
<li><a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch">ContextSwitch</a></li>
<li><a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch">AjaxContext</a></li>
</ul>
<h2>isXmlHttpRequest()</h2>
<p>This handy little method can eliminate the need to send extra parameters such as /ajax/true/ to let the controller know it&#8217;s an Ajax request. <span id="more-60"></span>Most standard JavaScript frameworks (jQuery, YUI, Prototype) pass the X-Requested-With HTTP header with the value &#8216;XMLHttpRequest&#8217; when doing an Ajax request. isXmlHttpRequest() basically just checks to see if that header is set and if it is, then execute the code that needs to be executed if it&#8217;s an Ajax call.</p>
<pre class="brush: php;">
/**
* myAction from myController
*/
function myAction()
{
if  ($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
// do the handling of your ajax request
}
else {
// if it's not an ajax request then do regular handling here
}
}
</pre>
<h2>JSON action helper</h2>
<p>I was surprised when I found this action helper in the framework. The JSON helper is pretty slick. It does 5 things that usually I had to do myself.</p>
<ul>
<li>It Disables layouts if currently enabled.</li>
<li>Disables the ViewRenderer if currently enabled.</li>
<li>Sets the &#8216;Content-Type&#8217; response header to &#8216;application/json&#8217;.</li>
<li>Immediately returns the response, without waiting for the action to finish execution.</li>
<li>Array passed as argument will be returned as a json formatted response.</li>
</ul>
<p>So if you use this helper along with the isXmlHttpRequest() method you can easily handle any Ajax request and return a response with minimum amount of programming.</p>
<pre class="brush: php;">
/**
* myAction from myController
*/
function myAction()
{
if ($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
// do the handling of your ajax request

$myArrayofData = array('a','b','c');

//encode your data into JSON and send the response
$this-&gt;_helper-&gt;json($myArrayofData);
//nothing else will get executed after the line above

}
else {
// if it's not an ajax request then do regular handling here
}
}
</pre>
<h2>AutoComplete</h2>
<p>This helper is currently supported only by Dojo and Scriptaculous AJAX libraries, so if you are working with any of those libraries, Zend&#8217;s AutoComplete will make your life a little bit easier. AutoComplete will do the same actions as the JSON helper (disable layout, sent appropriate content type, etc&#8230;) but will do the extra step to make sure your data is formatted correctly to use with the auto complete feature of the previously mentioned libraries. Definitely check this helper out if you are working with auto complete functionality.<br />
To read more and see examples <a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.autocomplete">click here</a>.</p>
<h2>ContextSwitch and AjaxContext</h2>
<p>These last two are very similar, If I&#8217;m not mistaken AjaxContext extends ContextSwitch to contain all the functionality of ContextSwitch, but, there are a couple of key differences that you must know! ContextSwitch is a great way to direct a request to it&#8217;s appropiate response. Let&#8217;s say you have a page that is meant to list information. With ContextSwitch you can make the action output a regular page for it&#8217;s regular call, but, if the user switched the request to ?request=xml. The user will now get the xml version! You only need to create a view script like this: myaction.xml.phtml, and handle the display there.<br />
AjaxContext it&#8217;s essentially a wrapper to  ContextSwitch that it&#8217;s only triggered if an XmlHttpRequest is sent in the headers. I suggest you head over to the ZendFramework&#8217;s Official documentation to read in depth on how <a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch">ContextSwitch</a> &amp; <a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch.ajaxcontext">AjaxContext</a> work since there is a a lot to cover, and there is really no point in repeating was is already in the FrameWork docs.</p>
<p>I hope this post helps you, and if you have any more interesting or helpful Zend Framework tips, you are invited to post them in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smooka.com/blog/2009/04/17/5-things-working-with-zend-framework-and-ajax/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
