<?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>A Coding Fool &#187; Programming</title>
	<atom:link href="http://blog.acodingfool.com/topics/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.acodingfool.com</link>
	<description></description>
	<lastBuildDate>Fri, 22 Jan 2010 00:32:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>jQuery and Reddits Pics</title>
		<link>http://blog.acodingfool.com/2010/01/21/jquery-and-reddits-pics/</link>
		<comments>http://blog.acodingfool.com/2010/01/21/jquery-and-reddits-pics/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 00:32:13 +0000</pubDate>
		<dc:creator>acodingfool</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[reddit]]></category>

		<guid isPermaLink="false">http://blog.acodingfool.com/?p=715</guid>
		<description><![CDATA[With the recent release of jQuery 1.4, I decided to play with it and ended up with a site that can be used to browse pictures submitted to Reddit.com. Obviously inspired by CoolIris, I built it using jQuery 1.4, the jQuery Lightbox and Reflection plugins, JSON2, and JSONRPC. On the server side, data is pulled from Reddit in JSON format and deserialized into PHP objects and arrays. In particular, I only accept items that have thumbnails and have URLs that point to the images themselves. Data is then compressed and cached on the server with XCache for an hour at [...]]]></description>
			<content:encoded><![CDATA[<p>With the recent release of <a href="http://jquery14.com/">jQuery 1.4</a>, I decided to play with it and <a href="http://redditpics.acodingfool.com">ended up with a site</a> that can be used to browse pictures submitted to Reddit.com.</p>
<p>Obviously inspired by <a href="http://www.cooliris.com">CoolIris</a>, I built it using jQuery 1.4, the jQuery <a href="http://leandrovieira.com/projects/jquery/lightbox/">Lightbox</a> and <a href="http://plugins.jquery.com/project/reflect">Reflection</a> plugins, <a href="http://www.json.org/js.html">JSON2</a>, and <a href="http://groups.google.com/group/json-rpc/web/json-rpc-1-2-proposal">JSONRPC</a>.</p>
<p>On the server side, data is pulled from Reddit in JSON format and deserialized into PHP objects and arrays. In particular, I only accept items that have thumbnails and have URLs that point to the images themselves. Data is then compressed and cached on the server with XCache for an hour at a time (which is pulled during each AJAX JSON RPC request for any given subreddit and item ID number).</p>
<p>Enjoy the site.</p>


]]></content:encoded>
			<wfw:commentRss>http://blog.acodingfool.com/2010/01/21/jquery-and-reddits-pics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My &#8220;Super Sexy&#8221; Mortgage Calculator</title>
		<link>http://blog.acodingfool.com/2009/09/05/my-super-sexy-mortgage-calculator/</link>
		<comments>http://blog.acodingfool.com/2009/09/05/my-super-sexy-mortgage-calculator/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 06:40:59 +0000</pubDate>
		<dc:creator>acodingfool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.acodingfool.com/?p=671</guid>
		<description><![CDATA[A couple months ago I received, as I'm sure as did many others, an email about the $10,000 MortgageLoanPlace.com "Super Sexy" Mortgage Calculator contest. I decided that I'd be worth a shot and it'd give me a good opportunity to dig a bit more in depth into jQuery. Also, and this is something I've always loved about programming aside from the actual coding, it gave me the opportunity to work with something that I've never had the chance to tackle (in this case mortgage calculations). I've worked on payroll and timekeeping projects before but I've never worked on anything that [...]]]></description>
			<content:encoded><![CDATA[<p>A couple months ago I received, as I'm sure as did <a href="http://www.nearlyanerd.com/2009/06/15/make-the-best-mortgage-calculator-win-10000/" target="_blank">many</a> <a href="http://www.webdevelopmentblog.net/post/2009/06/27/The-Super-Sexy-Mortgage-Calculator-Contest.aspx" target="_blank">others</a>, an email about the $10,000 <a href="http://www.mortgageloanplace.com" target="_blank">MortgageLoanPlace.com</a> "Super Sexy" Mortgage Calculator contest. I decided that I'd be worth a shot and it'd give me a good opportunity to dig a bit more in depth into jQuery.</p>
<p>Also, and this is something I've always loved about programming aside from the actual coding, it gave me the opportunity to work with something that I've never had the chance to tackle (in this case mortgage calculations). I've worked on payroll and timekeeping projects before but I've never worked on anything that had to do with finance and loans. I've found that writing the software isn't as always as interesting as what you're writing the software for. I've helped to write software to track the radiation readings for building decommisioning and deconstruction at a DOE nuclear site. I've written software to track patient information for people with Tuberculosis and Hepatitis B. And now I'm writing a mortgage calculator.</p>
<p>I am pleased to announce that, as of a month ago, my entry was chosen as the <a href="http://www.mortgageloanplace.com/mortgage-calculator.php" target="_blank">winning submission</a>.</p>
<hr/>
<p>My calculator was completely written in JavaScript and jQuery and consists of a single 22K packed script. I used a simplified version of the code mentioned in an <a href="http://blog.acodingfool.com/2009/07/20/jquery-xcss-plugin-part-2/" target="_blank">earlier post</a> to embed the CSS directly within the script (I hate all of the baggage that comes with most scripts you want to add to your pages; scripts, stylesheets, and images).</p>
<p>It was also designed to be infinitely configurable. The logo, colors, fields, labels, and default values can all be modified (you can check out the Mortgage Loan Place's custom mortgage calculator page <a href="http://www.mortgageloanplace.com/custom-mortgage-calculator.html" target="_blank">here</a>).</p>
<p>Lastly, the calculator is capable of rendering two different layouts: the standard one and a widget calculator. The standard layout is intended to be placed on a regular page and the widget calculator consists of a compact layout to be placed within sidebars.</p>
<hr/>
<p>Here is an example of this calculator (be sure to check out <a href="http://www.mortgageloanplace.com/mortgage-calculator.php" target="_blank">MortgageLoanPlace.com</a> if you'd like further details or would like to include this calculator on your site):</p>
<script type="text/javascript" src="http://www.mortgageloanplace.com/scripts/mortgage-calculator.pack.js"></script>
<script type="text/javascript">
  $(function() { $('#calculator-normal').MortgageCalculator({ mode: 'normal', animate: false, logo: { path: 'http://www.mortgageloanplace.com/images/logo_small2.gif', url: 'http://www.mortgageloanplace.com', target: '_blank' } }) });
</script>
<div style="margin: 2em 0;"><center><div id="calculator-normal"></div></center></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.acodingfool.com/2009/09/05/my-super-sexy-mortgage-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework and Stored Procedures</title>
		<link>http://blog.acodingfool.com/2009/08/21/zend-framework-and-stored-procedures/</link>
		<comments>http://blog.acodingfool.com/2009/08/21/zend-framework-and-stored-procedures/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 15:49:09 +0000</pubDate>
		<dc:creator>acodingfool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Stored Procedures]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.acodingfool.com/?p=620</guid>
		<description><![CDATA[<p>I'm been playing with the Zend Framework and, whenever I'm faced with a new data abstraction layer [Zend_Db in this case], I cannot help but rethink the <a href="http://www.codinghorror.com/blog/archives/000117.html" target="_blank">great debate over whether to use (or not use) stored procedures</a> [<a href="http://stackoverflow.com/questions/216569/are-the-days-of-the-stored-procedure-numbered" target="_blank">more</a>].</p>]]></description>
			<content:encoded><![CDATA[<a class="download alignright" href="http://blog.acodingfool.com/wp-content/uploads/2009/08/Procedures.txt" target="_blank">Download</a>
<p>I'm been playing with the Zend Framework and, whenever I'm faced with a new data abstraction layer [Zend_Db in this case], I cannot help but rethink the <a href="http://www.codinghorror.com/blog/archives/000117.html" target="_blank">great debate over whether to use (or not use) stored procedures</a> [<a href="http://stackoverflow.com/questions/216569/are-the-days-of-the-stored-procedure-numbered" target="_blank">more</a>].</p>
<p>I must admit that I've been predominantly in the "stored procedure" camp (and I won't even consider embedding a query into my code). But ever since I started to use LINQ to SQL (in C# and .NET), I've begun to rethink this philosophy and have begun to find a place for data abstraction layers (DALs) and object relational mappings (ORMs). And while I find that Zend_Db covers 95% of my database needs, it is still very difficult to perform very complex queries or any sort of complex data manipulation (ones that are best done in the database than in code).</p>
<p>And while it is possible to execute stored procedures using the underlying database adapters within Zend_Db, Zend_Db itself does not contain any classes for use with stored procedures. As a result, I have created one and would like to share it with you.</p>

<div class="code" style="white-space: wrap;"><span style="color: #0000ff;">&lt;?php</span><br />
<br />
abstract <span style="color: #0000ff;">class</span> App_Db_Procedures<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//==============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures variables</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//==============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">static</span> <span style="color: #000000;">$_instances</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">static</span> <span style="color: #000000;">$_defaultDb</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">static</span> <span style="color: #000000;">$_defaultCache</span> = <span style="color: #0000ff;">null</span>;<br />
<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_db</span> = <span style="color: #0000ff;">null</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_cache</span> = <span style="color: #0000ff;">null</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_metadata</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_prefix</span> = <span style="color: #ac1515;">''</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_query</span> = <span style="color: #0000ff;">null</span>;<br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: getDefaultAdapter()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Gets the default database adapter</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> getDefaultAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> self::<span style="color: #000000;">$_defaultDb</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: setDefaultAdapter()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $db: The database adapter to set</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Sets the default database adapter</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> setDefaultAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span> = <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; self::<span style="color: #000000;">$_defaultDb</span> = self::_setupAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; getAdapter()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Gets the database adapter</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> getAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>-&gt;_db === <span style="color: #0000ff;">null</span> &amp;&amp; self::<span style="color: #000000;">$_defaultDb</span> !== <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> self::<span style="color: #000000;">$_defaultDb</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$this</span>-&gt;_db;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; setAdapter()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $db: The database adapter to set</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Sets the database adapter</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> setAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_db = self::_setupAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$this</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: _setupAdapter()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $db: The database adapter to be set up</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Sets up the database adapter</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> _setupAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span> === <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">is_string</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">$db</span> = Zend_Registry::<span style="color: #000000;">get</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$db</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>!<span style="color: #000000;">$db</span> instanceof Zend_Db_Adapter_Abstract<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'Argument must be of type Zend_Db_Adapter_Abstract, '</span> . <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'or a Registry key where a Zend_Db_Adapter_Abstract '</span> .<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'object is stored'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$db</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: getDefaultMetadataCache()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Gets the default metadata cache</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> getDefaultMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> self::<span style="color: #000000;">$_defaultCache</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: setDefaultMetadataCache()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $cache: The cache to set</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Sets the default metadata cache</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> setDefaultMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> = <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; self::<span style="color: #000000;">$_defaultCache</span> = self::_setupMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; getMetadataCache()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Gets the metadata cache</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> getMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>-&gt;_cache === <span style="color: #0000ff;">null</span> &amp;&amp; self::<span style="color: #000000;">$_defaultCache</span> !== <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> self::<span style="color: #000000;">$_defaultCache</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$this</span>-&gt;_cache;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; setMetadataCache()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $cache: The cache to set</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Sets the metadata cache</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> setMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> = <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_cache = self::_setupMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$this</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: _setupMetadataCache()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $cache: The cache to be set up</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Sets up the metadata cache</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> _setupMetadataCache<span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> = <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> === <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">is_string</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">$cache</span> = Zend_Registry::<span style="color: #000000;">get</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>!<span style="color: #000000;">$cache</span> instanceof Zend_Cache_Core<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'Argument must be of type Zend_Cache_Core, '</span> .<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'or a Registry key where a Zend_Cache_Core '</span> .<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'object is stored'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$cache</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span>&nbsp;<br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; _setupMetadata()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Discovers metadata (from the cache or retrieved and added to the cache)</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">function</span> _setupMetadata<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>-&gt;_metadata<span style="color: #000000;">&#41;</span> &gt; <span style="color: #ff8000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">return</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">$cache</span> = <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getMetadataCache</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> !== <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">$id</span> = <span style="color: #0000ff;">get_class</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> . <span style="color: #ac1515;">'_'</span> . <span style="color: #0000ff;">md5</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">&quot;$this-&gt;_prefix&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> === <span style="color: #0000ff;">null</span> || <span style="color: #000000;">&#40;</span>!<span style="color: #000000;">$meta</span> = <span style="color: #000000;">$cache</span>-&gt;<span style="color: #000000;">load</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$id</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$meta</span> = <span style="color: #0000ff;">array_merge</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getAdapter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">fetchAll</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'SHOW PROCEDURE STATUS'</span>, <span style="color: #0000ff;">null</span>, Zend_Db::<span style="color: #000000;">FETCH_OBJ</span><span style="color: #000000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getAdapter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">fetchAll</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'SHOW FUNCTION STATUS'</span>, <span style="color: #0000ff;">null</span>, Zend_Db::<span style="color: #000000;">FETCH_OBJ</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> !== <span style="color: #0000ff;">null</span> &amp;&amp; !<span style="color: #000000;">$cache</span>-&gt;<span style="color: #000000;">save</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$meta</span>, <span style="color: #000000;">$id</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'Failed saving metadata to metadataCache'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_metadata = <span style="color: #000000;">$meta</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; _setupMetadataParams()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Discovers the number of parameters for the specified procedure and adds it </span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// to the cache</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">function</span> _setupMetadataParams<span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>!<span style="color: #0000ff;">isset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$query</span> = <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getAdapter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">prepare</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">&quot;SHOW CREATE $proc-&gt;Type $proc-&gt;Name&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$query</span>-&gt;<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$query</span>-&gt;<span style="color: #000000;">bindColumn</span><span style="color: #000000;">&#40;</span><span style="color: #ff8000;">3</span>, <span style="color: #000000;">$procBody</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$query</span>-&gt;<span style="color: #000000;">fetch</span><span style="color: #000000;">&#40;</span>Zend_Db::<span style="color: #000000;">FETCH_BOUND</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$query</span>-&gt;<span style="color: #000000;">closeCursor</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$procBody</span> === <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'Unable to cache stored procedure parameters'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">preg_match</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'/(?:'</span> . <span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">Type</span> . <span style="color: #ac1515;">'.+<span style="color: #008080; font-weight: bold;">\(</span>(.*)<span style="color: #008080; font-weight: bold;">\)</span><span style="color: #008080; font-weight: bold;">\s</span>BEGIN)/msU'</span>, <span style="color: #000000;">$procBody</span>, <span style="color: #000000;">$matches</span><span style="color: #000000;">&#41;</span>;&nbsp;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$matches</span><span style="color: #000000;">&#41;</span> != <span style="color: #ff8000;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'Unable to cache stored procedure parameters'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$params</span> = <span style="color: #0000ff;">trim</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$matches</span><span style="color: #000000;">&#91;</span><span style="color: #ff8000;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">empty</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span> = <span style="color: #ff8000;">0</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">$params</span> = <span style="color: #0000ff;">explode</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">','</span>, <span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span> = <span style="color: #0000ff;">count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$cache</span> = <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getMetadataCache</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$cache</span> !== <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span>&nbsp;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">$id</span> = <span style="color: #0000ff;">md5</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">&quot;procedures.$this-&gt;_prefix&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>!<span style="color: #000000;">$cache</span>-&gt;<span style="color: #000000;">save</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>-&gt;_metadata, <span style="color: #000000;">$id</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'Failed saving metadata to metadataCache'</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; _getProcedure()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $name: The name of the procedure to get</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Search the metadata for a procedure with the specified name</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">function</span> _getProcedure<span style="color: #000000;">&#40;</span><span style="color: #000000;">$name</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_setupMetadata<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>-&gt;_metadata <span style="color: #0000ff;">as</span> <span style="color: #000000;">$proc</span><span style="color: #000000;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">Name</span> == <span style="color: #000000;">$name</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_setupMetadataParams<span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$proc</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;&nbsp; &nbsp; <br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures -&gt; __call()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $method: The name of the method to call</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $params: An array of parameter used to invoke the method</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Calls the specified method</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> __call<span style="color: #000000;">&#40;</span><span style="color: #000000;">$method</span>, <span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">method_exists</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>, <span style="color: #000000;">$method</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">call_user_func_array</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$this</span>, <span style="color: #000000;">$method</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">$name</span> = <span style="color: #000000;">$this</span>-&gt;_prefix . <span style="color: #0000ff;">strtolower</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">preg_replace</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">'/([A-Z][a-z0-9]+)/U'</span>, <span style="color: #ac1515;">'_$1'</span>, <span style="color: #000000;">$method</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">$proc</span> = <span style="color: #000000;">$this</span>-&gt;_getProcedure<span style="color: #000000;">&#40;</span><span style="color: #000000;">$name</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span> === <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; throw <span style="color: #0000ff;">new</span> Zend_Db_Exception<span style="color: #000000;">&#40;</span><span style="color: #ac1515;">&quot;The requested procedure '$name' is not found&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">$count</span> = <span style="color: #0000ff;">count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">$binds</span> = <span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span> == <span style="color: #ff8000;">0</span> ? <span style="color: #ac1515;">''</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">implode</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">', '</span>, <span style="color: #0000ff;">array_fill</span><span style="color: #000000;">&#40;</span><span style="color: #ff8000;">0</span>, <span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span>, <span style="color: #ac1515;">'?'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$count</span> &lt; <span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$params</span> = <span style="color: #0000ff;">array_merge</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$params</span>, <span style="color: #0000ff;">array_fill</span><span style="color: #000000;">&#40;</span><span style="color: #ff8000;">0</span>, <span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">ParamCount</span> - <span style="color: #000000;">$count</span>, <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">$proc</span>-&gt;<span style="color: #000000;">Type</span> == <span style="color: #ac1515;">'PROCEDURE'</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_query = <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getAdapter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">prepare</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">&quot;call $name($binds)&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_query-&gt;<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$this</span>-&gt;_query;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">else</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_query = <span style="color: #000000;">$this</span>-&gt;<span style="color: #000000;">getAdapter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">prepare</span><span style="color: #000000;">&#40;</span><span style="color: #ac1515;">&quot;SELECT $name($binds)&quot;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">$this</span>-&gt;_query-&gt;<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #000000;">$this</span>-&gt;_query-&gt;<span style="color: #000000;">fetchColumn</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: __callStatic()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $method: The name of the method to call</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// $params: An array of parameter used to invoke the method</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Calls the specified method on the current instance of the object</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> __callStatic<span style="color: #000000;">&#40;</span><span style="color: #000000;">$method</span>, <span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">call_user_func_array</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">array</span><span style="color: #000000;">&#40;</span>self::<span style="color: #000000;">getInstance</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">$method</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">$params</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span>&nbsp;<br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// App_Db_Procedures :: getInstance()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Gets the current instance of the object</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">$child</span> = get_called_class<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>!<span style="color: #0000ff;">isset</span><span style="color: #000000;">&#40;</span>self::<span style="color: #000000;">$_instances</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">$child</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> self::<span style="color: #000000;">$_instances</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">$child</span><span style="color: #000000;">&#93;</span> = <span style="color: #0000ff;">new</span> <span style="color: #000000;">$child</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> self::<span style="color: #000000;">$_instances</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">$child</span><span style="color: #000000;">&#93;</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0000ff;">?&gt;</span></div>

<p>This class is designed to automatically discover and cache the available stored procedure definitions and allows these procedures to be executed without the need to explicitly define a function for each (but you will still need to set up the default database adapter and cache in your bootstrap). Through the use of PHP's __call magic function, the class will attempt to execute the stored procedure matching the called function (in addition, it ensures that the count of parameters matches that of the stored procedure). All you need to do it create a class that extends this class in order to begin using your stored procedures.</p>

<div class="code" style="white-space: wrap;"><span style="color: #0000ff;">class</span> Public_Model_Procedures_Auth <span style="color: #0000ff;">extends</span> App_Db_Procedures<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//==============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Public_Model_Procedures_Auth variables</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//==============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_prefix</span> = <span style="color: #ac1515;">'auth_'</span>;<br />
<span style="color: #000000;">&#125;</span></div>

<p>Child classes may define a $_prefix variable to indicate any prefix you may use in your stored procedure names. In addition, the class will convert the called camel-cased method name to a lowercased underscored-delimited stored procedure name (this is my preferred naming convention for database entities). Therefore, functions will be mapped to stored procedure like so:</p>

<div class="code" style="white-space: wrap;">Public_Model_Procedures_Auth::<span style="color: #000000;">getUserCredentials</span><span style="color: #000000;">&#40;</span>...<span style="color: #000000;">&#41;</span> =&gt; auth_get_user_credentials<span style="color: #000000;">&#40;</span>...<span style="color: #000000;">&#41;</span><br />
Public_Model_Procedures_Auth::<span style="color: #000000;">authenticateUser</span><span style="color: #000000;">&#40;</span>...<span style="color: #000000;">&#41;</span> =&gt; auth_authenticate_user<span style="color: #000000;">&#40;</span>...<span style="color: #000000;">&#41;</span></div>

<p>It should be noted, that this file is designed to use PHP 5.3 as it utilizes both the __callStatic() and get_called_class() functions. This allows stored procedures to be called via static methods and allows singleton instances to be created from within the abstract parent class. In older versions of PHP, you will need to make the following changes to your child classes:</p>

<div class="code" style="white-space: wrap;"><span style="color: #0000ff;">class</span> Public_Model_Procedures_Auth <span style="color: #0000ff;">extends</span> App_Db_Procedures<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//==============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Public_Model_Procedures_Auth variables</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//==============================================================================</span><br />
<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">static</span> <span style="color: #000000;">$_instance</span> = <span style="color: #0000ff;">null</span>;<br />
&nbsp; <span style="color: #0000ff;">protected</span> <span style="color: #000000;">$_prefix</span> = <span style="color: #ac1515;">'auth_'</span>;<br />
<br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Public_Model_Procedures_Auth :: getInstance()</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//----------------------------------------------------------------------------</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">// Gets the current instance of the object</span><br />
&nbsp; <span style="color: #008000; font-style: italic;">//============================================================================</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span> getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>self::<span style="color: #000000;">$_instance</span> == <span style="color: #0000ff;">null</span><span style="color: #000000;">&#41;</span> self::<span style="color: #000000;">$_instance</span> = <span style="color: #0000ff;">new</span> self<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">return</span> self::<span style="color: #000000;">$_instance</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>

<p>With this modification, stored procedures must be executed like so:</p>

<div class="code" style="white-space: wrap;">Public_Model_Procedures_Auth::<span style="color: #000000;">getInstance</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">getUserCredentials</span><span style="color: #000000;">&#40;</span>...<span style="color: #000000;">&#41;</span><br />
Public_Model_Procedures_Auth::<span style="color: #000000;">getInstance</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>-&gt;<span style="color: #000000;">authenticateUser</span><span style="color: #000000;">&#40;</span>...<span style="color: #000000;">&#41;</span></div>

<p>While I may do most of my database work with DALs (and the debate over stored procedures still rages on), I still find the need to stored procedures now and then and this class will give you a very simple interface to your procedures.</p>
<p>I hope you find it helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.acodingfool.com/2009/08/21/zend-framework-and-stored-procedures/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery Prototype Library &#8211; A Polygamous Affair</title>
		<link>http://blog.acodingfool.com/2009/07/30/jquery-prototype-library/</link>
		<comments>http://blog.acodingfool.com/2009/07/30/jquery-prototype-library/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 19:33:43 +0000</pubDate>
		<dc:creator>acodingfool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://blog.acodingfool.com/?p=588</guid>
		<description><![CDATA[I have something that I must confess... I'm in love with two JavaScript frameworks at the same time. Yep, I'm in love with both jQuery and Prototype. Each has qualities that I like and each some that I don't. jQuery, for instance, is almost beautiful in its design and how such a simplistic approach can be made so powerful. Prototype, on the other hand, adds so much that is missing in JavaScript and makes an already capable language much more usable. In a perfect world, I'd want to use both of them. The problem is that there is too much [...]]]></description>
			<content:encoded><![CDATA[<p>I have something that I must confess... I'm in love with two JavaScript frameworks at the same time.</p>
<p>Yep, I'm in love with both jQuery and Prototype. Each has qualities that I like and each some that I don't. jQuery, for instance, is almost beautiful in its design and how such a simplistic approach can be made so powerful. Prototype, on the other hand, adds so much that is missing in JavaScript and makes an already capable language much more usable.</p>
<p>In a perfect world, I'd want to use both of them. The problem is that there is too much overlap in the capabilities of these frameworks to warrant using both of them on the same project.</p>
<hr/>
<p>I have decided recently that I cannot live without both frameworks. I love jQuery but I also want Prototype's additions to the language. I finally figured out that what I wanted was a stripped down version of Prototype; one that is specifically designed to play nice with jQuery.</p>
<h1>Downloads</h1>
<p>The following links are the result of this attempt to add Prototype-like functionality to the jQuery framework (removing anything resembling any functionality that is already available in jQuery). And not bad too, the end result came in at about 20KB (as compared to the 120K for a copy of an unpacked and unminified Prototype).</p>
<ul>
  <li><a href="http://blog.acodingfool.com/wp-content/uploads/2009/07/jquery.prototype-1.0.js">jQuery Prototype Library (v1.0)</a> (21KB)</li>
  <li><a href="http://blog.acodingfool.com/wp-content/uploads/2009/07/jquery.prototype-1.0.min.js">jQuery Prototype Library (v1.0 - minified)</a> (15KB)</li>
  <li><a href="http://blog.acodingfool.com/wp-content/uploads/2009/07/jquery.prototype-1.0.pack.js">jQuery Prototype Library (v1.0 - packed)</a> (10KB)</li>
</ul>
<h1>Caveats</h1>
<p>Though most of the remaining methods are largely unchanged, I took the liberty to remove any of the objects or methods that I did not want (or were redundant aliases). In addition, I took the liberty to make a few minor changes to a few things that I'd prefer named or written another way (you'll have to review the library yourself as I did not take the time to document these). For example, I changed the name of the 'initialize' method utilized by the Class object to '_init'. A breaking change for anyone wanting to use this as a direct replacement to Prototype, but it is something that I wanted named differently.</p>
<p>I hope you find it useful... and many thanks to the Prototype and jQuery devs for creating two outstanding pieces of code (your efforts are greatly appreciated).</p>




]]></content:encoded>
			<wfw:commentRss>http://blog.acodingfool.com/2009/07/30/jquery-prototype-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery XCSS Plugin &#8211; In Depth</title>
		<link>http://blog.acodingfool.com/2009/07/20/jquery-xcss-plugin-part-2/</link>
		<comments>http://blog.acodingfool.com/2009/07/20/jquery-xcss-plugin-part-2/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 20:11:31 +0000</pubDate>
		<dc:creator>acodingfool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.acodingfool.com/?p=543</guid>
		<description><![CDATA[XCSS is a jQuery plugin that is used to generate CSS from a JavaScript object (via code, an external file, or using AJAX). This is the second post in a two-part series where I will go into more detail as to how the plugin is used and what kinds of things you can do with XCSS.]]></description>
			<content:encoded><![CDATA[<a class="download alignright" href="http://blog.acodingfool.com/wp-content/uploads/2009/07/jquery.xcss.js" target="_blank">Download</a>
<p>XCSS is a jQuery plugin that is used to generate CSS from a JavaScript object (via code, an external file, or using AJAX). This is the second post in a two-part series where I will go into more detail as to how the plugin is used and what kinds of things you can do with XCSS.</p>

<h2>The Plugin</h2>
<p>The XCSS plugin contains only a single function 'loadXCSS' that is used to process XCSS objects and loads the resulting stylesheet into the page.</p>
<div class="code" style="white-space: wrap;">$.<span style="color: #000000;">loadXCSS</span><span style="color: #000000;">&#40;</span>data, <span style="color: #000000;">&#91;</span>callback<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
<p>The 'data' argument must either be an XCSS object, a string containing an XCSS object, or a string containing the URL to a file containing an XCSS object (note that loading from a URL is done asynchronously). The argument can also be an array containing one or more of the aforementioned types.</p>
<p>The 'callback' argument is optional and, if specified, must be a function. The callback function is executed upon successful completion after the XCSS object has been processed and a stylesheet created. Note that, if the 'data' argument is an array, the callback function is executed once for each item.</p>

<h2>The XCSS Object</h2>
<p>The XCSS object is a JavaScript object that contains all of the definitions and the structure of the stylesheet you would like to create. The following illustrates the basic structure of the XCSS object:</p>
<div class="code" style="white-space: wrap;"><span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #ac1515;">'variable'</span>: <span style="color: #ac1515;">'string'</span> | number | <span style="color: #0000ff;">function</span>,<br />
&nbsp; <span style="color: #ac1515;">'selector'</span>: object | <span style="color: #ac1515;">'string'</span> | <span style="color: #0000ff;">function</span>,<br />
&nbsp; <span style="color: #ac1515;">'property'</span>: <span style="color: #ac1515;">'string'</span> | number | <span style="color: #0000ff;">function</span><br />
<span style="color: #000000;">&#125;</span></div>

<h3>Variables</h3>
<p>XCSS variables must begin with a dollar sign ($) and their values must be a string, a number, or a function that returns a string/number. Also, variables must be placed in the object higher or above where they are to be used.</p>
<div class="code" style="white-space: wrap;"><span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #ac1515;">'$borderColor'</span>: <span style="color: #ac1515;">'#f0f0f0'</span>,<br />
&nbsp; <span style="color: #ac1515;">'$borderWidth'</span>: <span style="color: #0000ff;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0000ff;">return</span> $.<span style="color: #000000;">browser</span>.<span style="color: #000000;">msie</span> ? <span style="color: #ff8000;">0</span>: <span style="color: #ac1515;">'1px'</span>; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>

<h3>Selectors</h3>
<p>XCSS selectors may use any of the standard CSS2/3 selectors (with the exception of descendant selectors) and are applicable to the XCSS object they are contained within. Descendant selectors use the pseudo-combinator '>>' to indicate that you want to select the specified elements that are descendants of the current XCSS selector (note that in CSS this is indicated with whitespace and didn't translate well into XCSS).</p>
<div class="code" style="white-space: wrap;"><span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #ac1515;">'div'</span>:<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'#tab'</span>: ... &nbsp; &nbsp;<span style="color: #008000; font-style: italic;">/* Generates div#tab { ... } */</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'.tab'</span>: ... &nbsp; &nbsp;<span style="color: #008000; font-style: italic;">/* Generates div.tab { ... } */</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'&gt;&gt; .tab'</span> ... &nbsp;<span style="color: #008000; font-style: italic;">/* Generates div .tab { ... } */</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'&gt; .tab'</span> ... &nbsp; <span style="color: #008000; font-style: italic;">/* Generates div &gt; .tab { ... } */</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'+ .tab'</span>: ... &nbsp;<span style="color: #008000; font-style: italic;">/* Generates div + .tab { ... } */</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'~ .tab'</span>: ... &nbsp;<span style="color: #008000; font-style: italic;">/* Generates div ~ .tab { ... } */</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>

<h3>Properties</h3>
<p>XCSS properties may use any of the standard CSS2/3 properties (and any of the Mozilla- and WebKit-specific properties) and are applicable to the XCSS object they are contained within. Their values must be a string, a number, or a function that returns a string/number.</p>
<div class="code" style="white-space: wrap;"><span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #ac1515;">'.tab'</span>:<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'$tabText'</span>: <span style="color: #ac1515;">'#000000'</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'$tabBack'</span>: <span style="color: #ac1515;">'#fafafa'</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'color'</span>: <span style="color: #ac1515;">'$tabText'</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'background'</span>: <span style="color: #ac1515;">'$tabBack'</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'border'</span>: <span style="color: #0000ff;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0000ff;">return</span> $.<span style="color: #000000;">browser</span>.<span style="color: #000000;">msie</span> ? <span style="color: #ac1515;">'0'</span>: <span style="color: #ac1515;">'1px solid #808080'</span>; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>
<p>Alternatively, if an XCSS selector does not contain any additional selectors or if its properties do not use any functions, you can use a much simpler shortcut like so:</p>
<div class="code" style="white-space: wrap;"><span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #ac1515;">'$tabText'</span>: <span style="color: #ac1515;">'#000000'</span>,<br />
&nbsp; <span style="color: #ac1515;">'$tabBack'</span>: <span style="color: #ac1515;">'#fafafa'</span>,<br />
&nbsp; <span style="color: #ac1515;">'.tab'</span>: <span style="color: #ac1515;">'color: $tabText; background: $tabText;'</span><br />
<span style="color: #000000;">&#125;</span></div>

<h2>Conclusion</h2>
<p>I devised the XCSS plugin to be a quick-and-dirty method to add styles to a page without the need for an external stylesheet. Certainly this plugin isn't going to replace stylesheets, and I wouldn't recommend using this plugin as an alternative, but it does allow you to quickly add styles to a page for small things like other jQuery plugins and widgets.</p>
<p>I hope you find it useful.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.acodingfool.com/2009/07/20/jquery-xcss-plugin-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery XCSS Plugin &#8211; Generate CSS Using jQuery and JavaScript</title>
		<link>http://blog.acodingfool.com/2009/07/19/jquery-xcss-plugin/</link>
		<comments>http://blog.acodingfool.com/2009/07/19/jquery-xcss-plugin/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 13:49:37 +0000</pubDate>
		<dc:creator>acodingfool</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.acodingfool.com/?p=485</guid>
		<description><![CDATA[XCSS is a JQuery plugin that is used to generate CSS from a JavaScript object (via code, an external file, or using AJAX).]]></description>
			<content:encoded><![CDATA[<script type="text/javascript" src="http://blog.acodingfool.com/wp-content/uploads/2009/07/jquery.xcss.js"></script>
<script type="text/javascript">
  $(function()
  {
    $.loadXCSS('http://blog.acodingfool.com/wp-content/uploads/2009/07/tabs.xcss', function()
    {
      $('.tab-nav li').click(function()
      {
        var t = $(this);

        $('.tab-nav li').removeClass('selected');
        t.addClass('selected');
        $('.tab-panel').removeClass('selected');
        $(t.find('a').attr('href')).addClass('selected');

        return false;
      });
				
      $('.tab-container').show();				
    });
  });
</script>

<a class="download alignright" href="http://blog.acodingfool.com/wp-content/uploads/2009/07/jquery.xcss.js" target="_blank">Download</a>
<p>XCSS is a jQuery plugin that is used to generate CSS from a JavaScript object (via code, an external file, or using AJAX).</p>

<p>A month ago, I had come across an interesting <a href="http://lesscss.org" target="_blank">site</a> that offers a Ruby program called LESS that is used to compile 'less' files into CSS. It features a syntax similar to CSS but also includes variables, mixins, nested classes, and operations. I wondered if you could so something like this using JavaScript.</p>

<p>Around the same time, I was working on a jQuery widget and was trying to figure out ways that I could slim it down (both in size and in the number of files needed). I toyed with the idea about incorporating my stylesheet directly into my code, as that would eliminate one external dependency, and decided to try and see if I could represent my CSS inheritance structures as a JavaScript object. It worked and I decided to expand on that idea in creating XCSS.</p>

<p>Below is a sample widget that I created whose styles are generated using XCSS:</p>

<div class="tab-container aligncenter" style="display: none;">
  <ul class="tab-nav">
    <li class="selected"><a href="#panel1"><span>Tab 1</span></a></li>
    <li><a href="#panel2"><span>Tab 2</span></a></li>
    <li><a href="#panel3"><span>Tab 3</span></a></li>
  </ul>
  <div id="panel1" class="tab-panel selected">
    <div>This is the first panel.</div>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor hendrerit dolor, non sagittis quam facilisis laoreet. Praesent felis magna, cursus vitae luctus et, consequat ut nisi. Phasellus a tellus libero. Pellentesque id elit urna. Mauris pretium urna ac velit pharetra scelerisque. Phasellus lobortis blandit neque sed tempor. Suspendisse nisl enim, adipiscing at porttitor non, sodales quis nisi. Donec nec ante odio.</p>
  </div>
  <div id="panel2" class="tab-panel">
    <div>This is the second panel.</div>
    <p>Fusce in quam nunc. Suspendisse vitae ipsum leo, nec sodales tortor. Aliquam erat volutpat. Integer quis orci sem. Curabitur mollis viverra turpis facilisis consequat. Nulla a ullamcorper tortor. Maecenas ultricies iaculis cursus. Sed pulvinar pretium lobortis. Aliquam erat volutpat. Donec vitae risus ac nunc bibendum adipiscing id eget justo. In at sagittis lacus. Curabitur malesuada, mi gravida dignissim vulputate, ante risus accumsan mauris, non ultricies enim quam non purus.</p>
  </div>
  <div id="panel3" class="tab-panel">
    <div>This is the third panel.</div>
    <p>Aliquam mollis, elit eget sodales tempor, nisl elit mattis neque, et blandit nisi justo non odio. Nullam ac dui sit amet mauris pellentesque facilisis. Vivamus tincidunt enim eget nulla porta at varius nisi tincidunt. Aliquam ultrices, felis id aliquet viverra, dolor elit mollis dolor, eu dictum sapien massa nec metus. Aliquam facilisis egestas odio, et elementum turpis aliquet at. Integer in nulla nisi, sed congue ligula.</p>
  </div>
</div>

<p>And this is the JavaScript object that represents the CSS structure for the above widget (in this demonstration it is contained in a <a href="http://blog.acodingfool.com/wp-content/uploads/2009/07/tabs.xcss" target="_blank">file</a> and is loaded using AJAX):</p>

<div class="code" style="white-space: wrap;"><span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #ac1515;">'$backColor'</span>: <span style="color: #ac1515;">'#eee'</span>,<br />
&nbsp; <span style="color: #ac1515;">'$inactiveColor'</span>: <span style="color: #ac1515;">'#ccc'</span>,<br />
&nbsp; <span style="color: #ac1515;">'$foreColor'</span>: <span style="color: #ac1515;">'#000'</span>,<br />
&nbsp; <span style="color: #ac1515;">'$borderColor'</span>: <span style="color: #ac1515;">'#aaa'</span>,<br />
&nbsp; <span style="color: #ac1515;">'$borderRadius'</span>: <span style="color: #ac1515;">'5px'</span>,<br />
&nbsp; <span style="color: #ac1515;">'.tab-container'</span>:<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ac1515;">'margin'</span>: <span style="color: #ac1515;">'30px 0 56px 0'</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'width'</span>: <span style="color: #ac1515;">'600px'</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'&gt;&gt; .tab-nav'</span>:<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'position'</span>: <span style="color: #ac1515;">'absolute'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'z-index'</span>: <span style="color: #ac1515;">'1000'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'margin'</span>: <span style="color: #ac1515;">'0 0 0 10px'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'padding'</span>: <span style="color: #ac1515;">'0'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'list-style-type'</span>: <span style="color: #ac1515;">'none'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'&gt;&gt; li'</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'float'</span>: <span style="color: #ac1515;">'left'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'margin'</span>: <span style="color: #ac1515;">'0 5px 0 0'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'min-width'</span>: <span style="color: #ac1515;">'75px'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'background'</span>: <span style="color: #ac1515;">'$inactiveColor'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'border'</span>: <span style="color: #ac1515;">'1px solid $borderColor'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'-moz-border-radius-topleft'</span>: <span style="color: #ac1515;">'$borderRadius'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'-moz-border-radius-topright'</span>: <span style="color: #ac1515;">'$borderRadius'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'-webkit-border-top-left-radius'</span>: <span style="color: #ac1515;">'$borderRadius'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'-webkit-border-top-right-radius'</span>: <span style="color: #ac1515;">'$borderRadius'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'font-family'</span>: <span style="color: #ac1515;">'Verdana, Arial, sans-serif'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'font-size'</span>: <span style="color: #ac1515;">'10pt'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'text-align'</span>: <span style="color: #ac1515;">'center'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'&gt;&gt; a'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'display'</span>: <span style="color: #ac1515;">'block'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'padding'</span>: <span style="color: #ac1515;">'0 10px'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'color'</span>: <span style="color: #ac1515;">'$foreColor'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'outline'</span>: <span style="color: #ac1515;">'0'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'line-height'</span>: <span style="color: #ac1515;">'25px'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'text-decoration'</span>: <span style="color: #ac1515;">'none'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'.selected'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'background'</span>: <span style="color: #ac1515;">'$backColor'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'border-bottom'</span>: <span style="color: #ac1515;">'1px solid $backColor'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'font-weight'</span>: <span style="color: #ac1515;">'bold'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #ac1515;">'&gt;&gt; .tab-panel'</span>:<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'display'</span>: <span style="color: #ac1515;">'none'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'position'</span>: <span style="color: #ac1515;">'relative'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'top'</span>: <span style="color: #ac1515;">'26px'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'padding'</span>: <span style="color: #ac1515;">'10px'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'background'</span>: <span style="color: #ac1515;">'$backColor'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'border'</span>: <span style="color: #ac1515;">' 1px solid $borderColor'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'-moz-border-radius'</span>: <span style="color: #ac1515;">'$borderRadius'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'-webkit-border-radius'</span>: <span style="color: #ac1515;">'$borderRadius'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'clear'</span>: <span style="color: #ac1515;">'both'</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'.selected'</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ac1515;">'display'</span>: <span style="color: #ac1515;">'block'</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>

<p>As you can see, the object nearly resembles the structure and inheritance that you'd use in CSS; the only exception being the use of the '>>'.</p>

<p>In CSS, the valid combinators are white-space, greater-than sign (>), plus sign (+), and tilda (~). XCSS exchanges the white-space combinator, which is used to select descendents, with the double greater-than signs (>>). This allows XCSS to distinguish between intending to select something like 'li .selected', which would match LI elements whose descendants have the class 'selected', and 'li.selected', which would match LI elements who have the 'selected' class.</p>

<p>XCSS parses the object and places the following rules into a new stylesheet on the page.</p>

<div class="code" style="white-space: wrap;"><span style="color: #6666ff;">.tab-container</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">margin</span>: <span style="color: #933;">30px</span> <span style="color: #933;">0</span> <span style="color: #933;">56px</span> <span style="color: #933;">0</span>;<br />
&nbsp; <span style="color: #000000;">width</span>: <span style="color: #933;">600px</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.tab-container</span> <span style="color: #6666ff;">.tab-nav</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">position</span>: <span style="color: #0000ff;">absolute</span>;<br />
&nbsp; <span style="color: #000000;">z-index</span>: <span style="color: #933;">1000</span>;<br />
&nbsp; <span style="color: #000000;">margin</span>: <span style="color: #933;">0</span> <span style="color: #933;">0</span> <span style="color: #933;">0</span> <span style="color: #933;">10px</span>;<br />
&nbsp; <span style="color: #000000;">padding</span>: <span style="color: #933;">0</span>;<br />
&nbsp; <span style="color: #000000;">list-style-type</span>: <span style="color: #0000ff;">none</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.tab-container</span> <span style="color: #6666ff;">.tab-nav</span> li<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">float</span>: <span style="color: #000000;">left</span>;<br />
&nbsp; <span style="color: #000000;">margin</span>: <span style="color: #933;">0</span> <span style="color: #933;">5px</span> <span style="color: #933;">0</span> <span style="color: #933;">0</span>;<br />
&nbsp; <span style="color: #000000;">padding</span>: <span style="color: #933;">0</span>;<br />
&nbsp; <span style="color: #000000;">min-width</span>: <span style="color: #933;">75px</span>;<br />
&nbsp; <span style="color: #000000;">background</span>: <span style="color: #cc00cc;">#ccc</span>;<br />
&nbsp; <span style="color: #000000;">border</span>: <span style="color: #933;">1px</span> <span style="color: #0000ff;">solid</span> <span style="color: #cc00cc;">#aaa</span>;<br />
&nbsp; <span style="color: #000000;">-moz-border-radius-topleft</span>: <span style="color: #933;">5px</span>;<br />
&nbsp; <span style="color: #000000;">-moz-border-radius-topright</span>: <span style="color: #933;">5px</span>;<br />
&nbsp; <span style="color: #000000;">-webkit-border-top-left-radius</span>: <span style="color: #933;">5px</span>;<br />
&nbsp; <span style="color: #000000;">-webkit-border-top-right-radius</span>: <span style="color: #933;">5px</span>;<br />
&nbsp; <span style="color: #000000;">font-family</span>: <span style="color: #0000ff;">Verdana</span>, <span style="color: #0000ff;">Arial</span>, <span style="color: #0000ff;">sans-serif</span>;<br />
&nbsp; <span style="color: #000000;">font-size</span>: <span style="color: #933;">10pt</span>;<br />
&nbsp; <span style="color: #000000;">text-align</span>: <span style="color: #0000ff;">center</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.tab-container</span> <span style="color: #6666ff;">.tab-nav</span> li a <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">display</span>: <span style="color: #0000ff;">block</span>;<br />
&nbsp; <span style="color: #000000;">padding</span>: <span style="color: #933;">0</span> <span style="color: #933;">10px</span>;<br />
&nbsp; <span style="color: #000000;">color</span>: <span style="color: #cc00cc;">#<span style="color: #933;">000</span></span>;<br />
&nbsp; <span style="color: #000000;">outline</span>: <span style="color: #933;">0</span>;<br />
&nbsp; <span style="color: #000000;">line-height</span>: <span style="color: #933;">25px</span>;<br />
&nbsp; <span style="color: #000000;">text-decoration</span>: <span style="color: #0000ff;">none</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.tab-container</span> <span style="color: #6666ff;">.tab-nav</span> li<span style="color: #6666ff;">.selected</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">background</span>: <span style="color: #cc00cc;">#eee</span>;<br />
&nbsp; <span style="color: #000000;">border-bottom</span>: <span style="color: #933;">1px</span> <span style="color: #0000ff;">solid</span> <span style="color: #cc00cc;">#eee</span>;<br />
&nbsp; <span style="color: #000000;">font-weight</span>: <span style="color: #0000ff;">bold</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.tab-container</span> <span style="color: #6666ff;">.tab-panel</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">display</span>: <span style="color: #0000ff;">none</span>;<br />
&nbsp; <span style="color: #000000;">position</span>: <span style="color: #0000ff;">relative</span>;<br />
&nbsp; <span style="color: #000000;">top</span>: <span style="color: #933;">26px</span>;<br />
&nbsp; <span style="color: #000000;">margin</span>: <span style="color: #933;">0</span> <span style="color: #933;">0</span> <span style="color: #933;">26px</span> <span style="color: #933;">0</span>;<br />
&nbsp; <span style="color: #000000;">padding</span>: <span style="color: #933;">10px</span>;<br />
&nbsp; <span style="color: #000000;">background</span>: <span style="color: #cc00cc;">#eee</span>;<br />
&nbsp; <span style="color: #000000;">border</span>: <span style="color: #933;">1px</span> <span style="color: #0000ff;">solid</span> <span style="color: #cc00cc;">#aaa</span>;<br />
&nbsp; <span style="color: #000000;">-moz-border-radius</span>: <span style="color: #933;">5px</span>;<br />
&nbsp; <span style="color: #000000;">-webkit-border-radius</span>: <span style="color: #933;">5px</span>;<br />
&nbsp; <span style="color: #000000;">clear</span>: <span style="color: #0000ff;">both</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.tab-container</span> <span style="color: #6666ff;">.tab-panel</span><span style="color: #6666ff;">.selected</span> <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #000000;">display</span>: <span style="color: #0000ff;">block</span>;<br />
<span style="color: #000000;">&#125;</span></div>

<p>That's it for now... later I'll go into more detail about how to use the XCSS plugin and how the XCSS objects must be structured and what kinds of things you can do with it.<p>

<p>Enjoy.</p> ]]></content:encoded>
			<wfw:commentRss>http://blog.acodingfool.com/2009/07/19/jquery-xcss-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
