<?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>PHP, CSS, HTML, Web &#38; beyond</title>
	<atom:link href="http://www.joseairosa.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joseairosa.com</link>
	<description>Programming Tips &#38; Tricks</description>
	<lastBuildDate>Wed, 01 Sep 2010 19:32:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>WP-RESTful WordPress Plugin</title>
		<link>http://www.joseairosa.com/2010/06/29/wp-restful-wordpress-plugin/</link>
		<comments>http://www.joseairosa.com/2010/06/29/wp-restful-wordpress-plugin/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 10:56:51 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[restful]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=246</guid>
		<description><![CDATA[Hello! I&#8217;m 99% sure that you already heard about APIs or REST APIs, it&#8217;s what Twitter, flickr and a lot more companies use to share they&#8217;re resources with a consumer. A consumer can be anything from a website (for example, showing your Twitter updates on your blog or personal website) to a desktop / mobile [...]]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>I&#8217;m 99% sure that you already heard about APIs or REST APIs, it&#8217;s what Twitter, flickr and a lot more companies use to share they&#8217;re resources with a consumer.<br />
A consumer can be anything from a website (for example, showing your Twitter updates on your blog or personal website) to a desktop / mobile application (iPhone, Android, Windows Mobile, &#8230;).<br />
This is possible because all information sent to and from the API is encoded in either two common, inter-platform language, XML and JSON.<br />
The difference between a regular API and a REST API is on the way they work. A REST API requires two entities to work, a client and a server.</p>
<h3><a title='Original Link: http://wordpress.org/extend/plugins/wp-restful/'  href="http://www.joseairosa.com/?Ndwkpfbo" target="_blank">Download WP-RESTful</a> <em>(Version 0.1)</em></h3>
<h3><a title='Original Link: http://wordpress.org/extend/plugins/wp-restful-users-plugin/'  href="http://www.joseairosa.com/?MHcP7Ghn" target="_blank">Download WP-RESTful Users Plugin</a> <em>(Version 0.1)</em></h3>
<h3><a title='Original Link: http://wordpress.org/extend/plugins/wp-restful-categories-plugin/'  href="http://www.joseairosa.com/?EyjonMf1" target="_blank">Download WP-RESTful Categories Plugin</a> <em>(Version 0.1)</em></h3>
<h3><a title='Original Link: http://wordpress.org/extend/plugins/wp-restful-tags-plugin/'  href="http://www.joseairosa.com/?tKIJ3z9F" target="_blank">Download WP-RESTful Tags Plugin</a> <em>(Version 0.1)</em></h3>
<h2 style="margin-top: 15px;"><em><strong>Follow me for  real-time updates</strong></em></h2>
<p><a title='Original Link: http://twitter.com/joseairosa'  href="http://www.joseairosa.com/?cXam8aSF">Twitter</a></p>
<h2 style="margin-top: 15px;"><em><strong>How does it work?</strong></em></h2>
<p>WP-RESTful uses OAuth, a widely, commonly and open source API implementation used all over the World (Wide Web).<br />
The way it work is fairly simple.</p>
<p>First a Consumer registers with a Server. At this point the Server will provide the Consumer with 2 tokens, a public and a private token. The public token will be used to communicate and identify the Consumer with the Server while the private token will be stored locally for security and integrity reasons.<br />
After this the Consumer will request the Server with a Request Token. This Request Token will be used to initiate the Authentication Protocol in where the Consumer will be required to authorize the Server.<br />
The Server will create 2 new token (definitive tokens). They will be our authentication tokens.</p>
<p>I know this sounds and seems complicated but you won&#8217;t need to do anything as the Plugin will do almost everything for you (Registration and Authentication process are manual).</p>
<h2 style="margin-top: 15px;"><em><strong>Plugin features</strong></em></h2>
<ul>
<li>Add new Plugins to API Plugin to extend functionalities to any way you want/need. (See next group)</li>
<li>Fully manageable Client and Server side.</li>
<li>Ability to choose what fields are allowed to be returned to the consumer.</li>
<li>Ability to restrict modules to OAuth authentication process or liberated them and make them open.</li>
<li>Load balance system where you can specify how many requests a given consumer is allowed in a 60 minute timeframe.</li>
<li>Out of the box Post and Comments management.</li>
<li>And much more&#8230;</li>
</ul>
<h2 style="margin-top: 15px;"><em><strong>Plugins</strong></em></h2>
<p>As stated on &#8220;Plugin Features&#8221; you have the ability to develop and/or add new modules to your REST API. This means, for example, if you use a plugin like WP E-Commerce, you can develop a plugin for the REST API in order to provide support for WP E-Commerce resources.<br />
The way these plugins are developed is very similar to how plugins for WordPress are developed.<br />
You can see this video that explains how plugins work and how you can develop them.</p>
<h2 style="margin-top: 15px;"><em><strong>Requirements?</strong></em></h2>
<p>All requirements for the plugin  to work properly are addressed by the plugin itself, upon activation.  You can see your system status on WP-RESTful link after activation the  plugin.</p>
<h2 style="margin-top: 15px;"><em><strong>How to install?</strong></em></h2>
<p>This plugin is installed like any other WordPress plugin out there.</p>
<ol>
<li>First you need to download it from WordPress Plugin Repository.</li>
<li>Upload the contents of the compacted file to your plugin folder on  your WordPress installation.</li>
<li>Go to your WordPress Administration page and activate the Plugin (Plugins → Installed → WP-RESTful → Activate)</li>
<li>Create a new page, name it API, set the permalink to /api and set the content as &#91;REST_return&#93; and save the page.</li>
<li>Go to WP-RESTful → WP-RESTful to check your system status.</li>
</ol>
<h2 style="margin-top: 15px;"><em><strong><em><strong>I need  help!</strong></em></strong></em></h2>
<p>Check these two videos. They will help you starting up.</p>
<div style="margin: 10px 0;"><object width="556" height="438"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=12940958&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=12940958&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="556" height="438"></embed></object>
<p><a title='Original Link: http://vimeo.com/12940958'  href="http://www.joseairosa.com/?byFNurYF">WP-RESTful &#8211; Starting and setting up</a> from <a title='Original Link: http://vimeo.com/joseairosa'  href="http://www.joseairosa.com/?QcbEwEWF">José Airosa</a> on <a title='Original Link: http://vimeo.com'  href="http://www.joseairosa.com/?tz2GLZGJ">Vimeo</a>.</p>
</div>
<div style="margin: 10px 0;"><object width="556" height="438"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=12941005&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=12941005&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="556" height="438"></embed></object>
<p><a title='Original Link: http://vimeo.com/12941005'  href="http://www.joseairosa.com/?TljfG9PY">WP-RESTful &#8211; Working with Plugins</a> from <a title='Original Link: http://vimeo.com/joseairosa'  href="http://www.joseairosa.com/?QcbEwEWF">José Airosa</a> on <a title='Original Link: http://vimeo.com'  href="http://www.joseairosa.com/?tz2GLZGJ">Vimeo</a>.</p>
</div>
<p>This post will be updated, if needed, to reflect changes made to the  plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2010/06/29/wp-restful-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>BarCampPT Talk</title>
		<link>http://www.joseairosa.com/2010/06/06/barcamppt-talk/</link>
		<comments>http://www.joseairosa.com/2010/06/06/barcamppt-talk/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 00:38:40 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[barcamppt]]></category>
		<category><![CDATA[slideshow]]></category>
		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=238</guid>
		<description><![CDATA[Hello! Today I presented a talk at BarCampPT about WordPress and its Plugins. The reactions wore fantastic and I would like to share the presentation documents. Warning: The presentation was made in Portuguese.]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>Today I presented a talk at <a title='Original Link: http://barcamppt.org/wiki/index.php/Primavera10'  href="http://www.joseairosa.com/?hnKvIb_e">BarCampPT</a> about WordPress and its Plugins. The reactions wore fantastic and I would like to share the presentation documents.</p>
<p>Warning: The presentation was made in <span style="text-decoration: underline;">Portuguese</span>.</p>
<object width="550" height="451"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=apresentacaobarcamppt-100605124633-phpapp02"/><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=apresentacaobarcamppt-100605124633-phpapp02"  type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="550" height="451"></embed></object>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2010/06/06/barcamppt-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin &#8211; Parallel Loading System</title>
		<link>http://www.joseairosa.com/2010/05/17/wordpress-plugin-parallel-loading-system/</link>
		<comments>http://www.joseairosa.com/2010/05/17/wordpress-plugin-parallel-loading-system/#comments</comments>
		<pubDate>Mon, 17 May 2010 17:04:21 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[image optimization]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[speed improve]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=138</guid>
		<description><![CDATA[The WP-PLS (short for Parallel Loading System) is a WordPress plugin that will enhance the loading efficiency of your Blog. It's very simple to use and it will require a small amount of time to configure in the start.]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>The WP-PLS (short for Parallel Loading System) is a WordPress plugin that will enhance the loading efficiency of your Blog. It&#8217;s very simple to use and it will only require a small amount of time to configure at the start.</p>
<h3><a title='Original Link: http://wordpress.org/extend/plugins/parallel-loading-system/'  href="http://www.joseairosa.com/?aLdgCt33" target="_blank">Download from WordPress Plugin Repository</a> <em>(Updated to version 0.1.7)</em></h3>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>Follow me for real-time updates</strong></em></h2>
<p><a title='Original Link: http://twitter.com/joseairosa'  href="http://www.joseairosa.com/?cXam8aSF">Twitter</a></p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>Why use it?</strong></em></h2>
<p>If you have an image intensive Blog, or even if you don&#8217;t, this plugin will boost the loading time of your Blog. The more images you have the more it will improve.</p>
<p>The amount of people that will visit your website for the first time or visit with an empty cache or disabled cache is huge, therefore, the best your website performs on that first visit the more chances that person will remain to view your website.</p>
<p>It is also known that nowadays, Google (and other search engines), are taking into account, for ranking purposes, your website page speed. Google Bot does not conserve a cache when it visits your website, so, the faster your website loads the more chances you have to rank higher.</p>
<p>This plug will <strong><span style="text-decoration: underline;">not</span></strong> change anything on your Blog. Every change that it makes will be processed in real time, right before the HTML code of your Blog is sent to the browser.</p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>How does it work?</strong></em></h2>
<p>Standard HTTP v1.1 requests only allow 2 connections, at the same time, from the same  domain.</p>
<p>This plugin will virtualize connections, through defined  subdomains. You can have as many subdomains as you like, but I do  recomend using a maximum of 5.</p>
<p style="text-align: center;"><a href="http://www.joseairosa.com/wp-content/uploads/2010/05/plugin1-e1274117124373.jpg"><img class="size-full wp-image-156 aligncenter" title="WP-PLS Comparison" src="http://www.joseairosa.com/wp-content/uploads/2010/05/plugin1-e1274117124373.jpg" alt="WP-PLS Comparison" width="551" height="223" /></a></p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>Requirements?</strong></em></h2>
<p>The plugin is programmed to be aware of this requirements, and if not fulfilled it will not change anything on your Blog.<br />
<span style="text-decoration: underline;">It will not break your Blog code!</span></p>
<ul>
<li>Your server needs to have a working <a title='Original Link: http://php.net/manual/en/book.image.php'  href="http://www.joseairosa.com/?tjCK3N_W">GD Library</a> module for  PHP.</li>
<li>You should have a PHP installation with a minimum version of <strong>5.1.3</strong></li>
<li>Access to your server Administration Painel (cPanel, DirectAdmin, Plesk) in order to create new sub-domains for your domain.<br />
Lets say your domain is <strong>wp-pls.com</strong>. You will need to create domains like<br />
image1.<strong>wp-pls.com</strong><br />
image2.<strong>wp-pls.com</strong><br />
&#8230;</li>
</ul>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>How to install?</strong></em></h2>
<p>This plugin is installed like any other WordPress plugin out there.</p>
<ol>
<li>First you need to download it from WordPress Plugin Repository.</li>
<li>Upload the contents of the compacted file to your plugin folder on your WordPress installation.</li>
<li>Go to your WordPress Administration page and activate the Plugin (Plugins → Installed → WP-PLS → Activate)</li>
<li>Go to Settings → Parallel Loading System</li>
</ol>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>Plugin features?</strong></em></h2>
<p>Some of the features that you can expect when using this plugin:</p>
<ul>
<li>Automatic Image Optimization.</li>
<li>Parallelize HTTP connections.</li>
<li>Page speed improvement.</li>
<li>Auto-Path find (Automatically find server root path, sub-domain path, plugin resources path&#8230;).</li>
<li>Cache loss minimization.</li>
<li>Sub-domain real-time health tracking.</li>
<li>Auto recovery from resource files bad sync.</li>
<li>Ability to activate / deactivate sub-domains</li>
<li>Plugin Updates aware. (automatically re-sync files and database after an update)</li>
</ul>
<h2 id="whats-in-the-cooking-pan" style="margin-top: 30px; margin-bottom: 10px;"><em><strong>What&#8217;s in the cooking pan?</strong></em></h2>
<p>This was only the first release of the plugin. I&#8217;ve got a lot of new ideas that I would like to see implemented on next releases.<br />
Some of them are:</p>
<ul>
<li>Also parallelize CSS and JavaScript loading.</li>
<li>Add support to also load external images. At the moment it will only load locally stored images.</li>
<li>Add real-time rewrite functions to CSS and JavaScript. That way, images that have been called from the CSS file will also be parallelized.</li>
<li>Overall improve of the code.</li>
<li>Add options to manage image quality rendering.</li>
<li>Bug fixes (when found or reported).</li>
<li>And much more&#8230;</li>
</ul>
<p>If you have any features that you would like to see implemented, please don&#8217;t hesitate to <a title='Original Link: #comments'  href="http://www.joseairosa.com/?SLazTfgR">comment this post</a>, <a title='Original Link: http://twitter.com/joseairosa'  href="http://www.joseairosa.com/?cXam8aSF" target="_blank">tweet me</a> or <a title='Original Link: mailto:me@joseairosa.com'  href="http://www.joseairosa.com/?gfylCmKb" target="_blank">mail me</a> <img src='http://www.joseairosa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong><em><strong>I need help!</strong></em></strong></em></h2>
<p>It&#8217;s normal if you run into problems and I&#8217;m here to tell you how to fix them.</p>
<p>If for any reason the plugin is telling you that it doesn&#8217;t have permissions to alter a given file you will need to access your server, using your favorite FTP Client (Filezilla, Cyberduck, FlashFXP&#8230;) and change the permissions of the file to <strong>777</strong>. You can revert them back to <strong>644</strong> (normal permissions of a file) after the plugin finishes the modifications.</p>
<p>If you get a sub-domain health notification stating that your sub-domain is returning a 500 HTTP error code the most probable explanation is that your sub-domain folder has <strong>777</strong> permissions. Revert them back to <strong>755</strong> and you should be fine.</p>
<p>If you have any further questions please don&#8217;t hesitate to <a title='Original Link: mailto:me@joseairosa.com'  href="http://www.joseairosa.com/?gfylCmKb">send me an email</a> or add a comment on this post.</p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong>Creating sub-domains on cPanel?</strong></em></h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/-6NeRF_G8EQ&amp;hl=pt_PT&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/-6NeRF_G8EQ&amp;hl=pt_PT&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong><em><strong>Creating  sub-domains on Plesk?</strong></em></strong></em></h2>
<ol>
<li>Log in to Plesk</li>
<li>Once logged in, click the &#8216;Home&#8217; button in the left navigation  frame.</li>
<li>Click on the domain name you wish to create a subdomain for.</li>
<li>Click on the ‘Subdomains’ button. This will take you to the  subdomain manager.</li>
<li>Add a new subdomain by clicking the corresponding button (Add New  Subdomain).</li>
<li>Enter the subdomain in the associated field. The SSL support  checkbox is optional, and should be used if you intend on using SSL with  your subdomain.</li>
<li>If you’d like to use the same FTP information as your main domain to  access the subdomain, skip down to the ‘Services’ section. If not,  select the checkbox ‘Create a separate FTP user account for this  subdomain’. Enter an FTP username and password, along with a hard disk  quota. If you do not enter a hard disk quota, the subdomain will be  allowed to use all resources included with your main domain.</li>
<li>In the ‘Services’ section, it is advised to check all services. This  will ensure that your subdomain can support all the features our  hosting accounts offer.</li>
<li>Click the ‘OK’ button to create the subdomain.</li>
</ol>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong><em><strong>Creating  sub-domains on DirectAdmin?</strong></em></strong></em></h2>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/wUgb7KkKaiA&amp;hl=pt_PT&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/wUgb7KkKaiA&amp;hl=pt_PT&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2 style="margin-top: 30px; margin-bottom: 10px;"><em><strong><em><strong>Creating  sub-domains on manually on your server?</strong></em></strong></em></h2>
<p>To create a sub-domain, if don&#8217;t use a Control Panel, edit your http.conf file (normally located on <em>/etc/http/conf/http.conf</em>) and add the following at the end:</p>
<p><code>NameVirtualHost *:443</code></p>
<p><code>&lt;VirtualHost *:80&gt;<br />
ServerName YOUR SUBDOMAIN<br />
DocumentRoot ROOT TO SUBDOMAIN PATH<br />
ErrorLog ROOT TO SUBDOMAIN LOG<br />
&lt;/VirtualHost&gt;</code></p>
<p><code>&lt;VirtualHost *:443&gt;<br />
ServerName YOUR SUBDOMAIN<br />
DocumentRoot ROOT TO SUBDOMAIN PATH (SSL)<br />
ErrorLog ROOT TO SUBDOMAIN LOG (SSL)<br />
&lt;/VirtualHost&gt;</code></p>
<p>This post will be updated, if needed, to reflect changes made to the plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2010/05/17/wordpress-plugin-parallel-loading-system/feed/</wfw:commentRss>
		<slash:comments>107</slash:comments>
		</item>
		<item>
		<title>WP e-commerce SKU on variations</title>
		<link>http://www.joseairosa.com/2010/03/30/wp-e-commerce-sku-on-variations/</link>
		<comments>http://www.joseairosa.com/2010/03/30/wp-e-commerce-sku-on-variations/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 21:30:52 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[sku]]></category>
		<category><![CDATA[wordpress plugin]]></category>
		<category><![CDATA[wp e-commerce]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=124</guid>
		<description><![CDATA[UPDATE &#8211; 01/09/2010 If you need additions that are not contemplated in this fix package you can email me for a specific quote. UPDATE &#8211; 18/05/2010 There has been an update on wp-e-commerce a few days ago and if you have applied my add-on you&#8217;ll probably have problems with the plugin. Post a comment or [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>UPDATE &#8211; 01/09/2010</strong></h2>
<p>If you need additions that are not contemplated in this fix package you can email me for a specific quote.<br />
<br/></p>
<h2><i>UPDATE &#8211; 18/05/2010</i></h2>
<p>There has been an update on wp-e-commerce a few days ago and if you have applied my add-on you&#8217;ll probably have problems with the plugin. Post a comment or <a title='Original Link: mailto:me@joseairosa.com'  href="http://www.joseairosa.com/?gfylCmKb">email me</a> if you&#8217;re having problems.</p>
<p>===============================</p>
<p>If you are using wp-ecommerce plugin for wordpress and you ran into some missing functionalities this might help you.</p>
<p>The specific mod I&#8217;ll show you today will enable you to specify SKU to any variation on any product on your system.</p>
<p>I don&#8217;t know how proficient your are on programming WordPress, but let me know if you run into any difficulty.</p>
<p>So, first of all you need to add a new field on your database on table <strong>wp_wpsc_variations_properties</strong> called &#8220;sku&#8221;. I added this field as <strong>varchar</strong> with a length of <strong>64 characters</strong>, but do adapt this one to fit your needs.</p>
<p><strong>Backup your e-commerce plugin folder.</strong></p>
<p>Now, open file /wp-content/plugins/wp-e-commerce/wpsc-includes/variations.class.php.</p>
<p>After line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code17'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12417"><td class="code" id="p124code17"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;
&quot;</span><span style="color: #339933;">.</span>TXT_WPSC_VARIATION<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
&nbsp;
<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>add,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12418"><td class="code" id="p124code18"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;
&quot;</span><span style="color: #339933;">.</span>TXT_WPSC_SKU<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
&nbsp;
<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Change line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code19'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12419"><td class="code" id="p124code19"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$unindexed_variation_properties_data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_results<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT `id`, `stock`, `price`, `weight`,`weight_unit`, `file` FROM `&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_PROPERTIES<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` WHERE `id` IN(<span style="color: #006699; font-weight: bold;">{$priceandstock_id_string}</span>)&quot;</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>to,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12420"><td class="code" id="p124code20"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$unindexed_variation_properties_data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_results<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT `id`, `stock`, `sku`, `price`, `weight`,`weight_unit`, `file` FROM `&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_PROPERTIES<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` WHERE `id` IN(<span style="color: #006699; font-weight: bold;">{$priceandstock_id_string}</span>)&quot;</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>After line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12421"><td class="code" id="p124code21"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$product_price</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$variation_properties_data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$variation_set</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'priceandstock_id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'price'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>add,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code22'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12422"><td class="code" id="p124code22"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$product_sku</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$variation_properties_data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$variation_set</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'priceandstock_id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>After line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code23'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12423"><td class="code" id="p124code23"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$product_price</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$product_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'price'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>add,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12424"><td class="code" id="p124code24"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$product_sku</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>After line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12425"><td class="code" id="p124code25"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$variation_names</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>add,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code26'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12426"><td class="code" id="p124code26"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;
&lt;input name=&quot;</span>variation_priceandstock<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$variation_ids</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>sku<span style="color: #009900;">&#93;</span><span style="color: #0000ff;">&quot; size=&quot;</span><span style="color: #cc66cc;">8</span><span style="color: #0000ff;">&quot; type=&quot;</span>text<span style="color: #0000ff;">&quot; value=&quot;</span><span style="color: #000088;">$product_sku</span><span style="color: #0000ff;">&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>After line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12427"><td class="code" id="p124code27"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$variation_price</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$variation_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'price'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>add,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code28'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12428"><td class="code" id="p124code28"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$variation_sku</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$variation_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>After line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code29'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12429"><td class="code" id="p124code29"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$variation_sql</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// return the sql array to null for each trip round the loop</span></pre></td></tr></table></div>

<p>add,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code30'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12430"><td class="code" id="p124code30"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variation_stock_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$variation_sku</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$variation_sql</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;`sku` = '<span style="color: #006699; font-weight: bold;">{$variation_sku}</span>'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This should enable you fill the sku field we added before. Now to get the info of the sku on the order page.</p>
<p>Open file /wp-content/plugins/wp-e-commerce/wpsc-includes/purchaselogs.class.php.</p>
<p>On line,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code31'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12431"><td class="code" id="p124code31"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> wpsc_purchaselog_details_SKU<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

<p>Change all function to,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code32'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12432"><td class="code" id="p124code32"><pre class="php" style="font-family:monospace;">purchitem<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>prodid<span style="color: #339933;">,</span> <span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$variation_name</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$purchlogitem</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>purchitem<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$associated_variations</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_col<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT `variation_id` FROM `&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_ASSOC<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` WHERE `type` IN ('product') AND `associated_id` = '{<span style="color: #006699; font-weight: bold;">$purchlogitem</span>-&amp;gt;purchitem-&amp;gt;prodid}' ORDER BY `id` ASC&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$variation_count</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$associated_variations</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<a href="http://www.php.net/asort"><span style="color: #990000;">asort</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$associated_variations</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variation_count</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//stripslashes($purchlogitem-&amp;gt;purchitem-&amp;gt;name);</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span><span style="color: #000088;">$associated_variations</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$variation</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$variation</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$variation</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$excluded_value_sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$purchlogitem</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>purchitem<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>prodid <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$included_values</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_col<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT `value_id` FROM `&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_VALUES_ASSOC<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` WHERE `product_id` IN('{<span style="color: #006699; font-weight: bold;">$purchlogitem</span>-&amp;gt;purchitem-&amp;gt;prodid}') AND `variation_id` IN ('<span style="color: #006699; font-weight: bold;">{$variation}</span>') AND `visible` IN ('1')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$included_values_sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;AND `a<span style="color: #006699; font-weight: bold;">{$variation}</span>`.`id` IN('&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;','&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$included_values</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;')&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #666666; font-style: italic;">//else if(count($variation_values) &amp;gt; 0) {</span>
			<span style="color: #666666; font-style: italic;">//$included_values_sql = &quot;AND `a{$variation}`.`id` IN('&quot;.implode(&quot;','&quot;, $variation_values).&quot;')&quot;;</span>
			<span style="color: #666666; font-style: italic;">//}</span>
&nbsp;
			<span style="color: #000088;">$join_selected_cols</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;`a<span style="color: #006699; font-weight: bold;">{$variation}</span>`.`id` AS `id_<span style="color: #006699; font-weight: bold;">{$variation}</span>`, `a<span style="color: #006699; font-weight: bold;">{$variation}</span>`.`name` AS `name_<span style="color: #006699; font-weight: bold;">{$variation}</span>`&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$join_subselect_cols</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;`a<span style="color: #006699; font-weight: bold;">{$variation}</span>`.`id`&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$join_tables</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;`&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_VALUES<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` AS `a<span style="color: #006699; font-weight: bold;">{$variation}</span>`&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$join_conditions</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;`a<span style="color: #006699; font-weight: bold;">{$variation}</span>`.`variation_id` = '<span style="color: #006699; font-weight: bold;">{$variation}</span>' <span style="color: #006699; font-weight: bold;">$included_values_sql</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$variation_count</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$associated_variations</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$all_variation_ids</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$associated_variations</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$join_subselect_cols</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$join_subselect_cols</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$join_selected_cols</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;(
SELECT `priceandstock_id`
FROM `&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_COMBINATIONS<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;`
WHERE `product_id` = '{<span style="color: #006699; font-weight: bold;">$purchlogitem</span>-&amp;gt;purchitem-&amp;gt;prodid}'
AND `value_id`
IN ( <span style="color: #006699; font-weight: bold;">{$join_subselect_cols}</span> )
AND `all_variation_ids`
IN ( '<span style="color: #006699; font-weight: bold;">{$all_variation_ids}</span>'	)
GROUP BY `priceandstock_id`
HAVING COUNT( `priceandstock_id` ) = '<span style="color: #006699; font-weight: bold;">{$variation_count}</span>'
LIMIT 1
) AS `priceandstock_id`&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// implode the SQL statment segments into bigger segments</span>
	<span style="color: #000088;">$join_selected_cols</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$join_selected_cols</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$join_tables</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>JOIN &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$join_tables</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$join_conditions</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>AND &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$join_conditions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Assemble and execute the SQL query</span>
	<span style="color: #000088;">$associated_variation_values</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_results<span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;SELECT <span style="color: #006699; font-weight: bold;">{$join_selected_cols}</span>
FROM <span style="color: #006699; font-weight: bold;">{$join_tables}</span>
WHERE <span style="color: #006699; font-weight: bold;">{$join_conditions}</span>
ORDER BY <span style="color: #006699; font-weight: bold;">{$join_subselect_cols}</span>&quot;</span>
	<span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//print_r($associated_variation_values);</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span><span style="color: #000088;">$associated_variation_values</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$variation_set</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$variation_id_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$variation_names</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$associated_variations</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$variation_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$variation_id_array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$variation_set</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id_<span style="color: #006699; font-weight: bold;">{$variation_id}</span>&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$variation_names</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$variation_set</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name_<span style="color: #006699; font-weight: bold;">{$variation_id}</span>&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$variation_names</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$variation_names</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$variation_ids</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$variation_id_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variation_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$variation_names</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$variation_sku</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_row<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT `sku` FROM `&quot;</span><span style="color: #339933;">.</span>WPSC_TABLE_VARIATION_PROPERTIES<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;` WHERE `id` = '<span style="color: #006699; font-weight: bold;">{$variation_set['priceandstock_id']}</span>' LIMIT 1&quot;</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variation_sku</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$meta_value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$variation_sku</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$meta_value</span> <span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'N/A'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$meta_value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This should get you up and running. Let me know if you need anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2010/03/30/wp-e-commerce-sku-on-variations/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Screencast 1 &#8211; mod_rewrite and PHP</title>
		<link>http://www.joseairosa.com/2009/08/03/screencast-1-mod_rewrite-and-php/</link>
		<comments>http://www.joseairosa.com/2009/08/03/screencast-1-mod_rewrite-and-php/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 15:43:07 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Screencast]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=101</guid>
		<description><![CDATA[<object width="550" height="312"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5910332&#38;server=vimeo.com&#38;show_title=1&#38;show_byline=1&#38;show_portrait=0&#38;color=&#38;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5910332&#38;server=vimeo.com&#38;show_title=1&#38;show_byline=1&#38;show_portrait=0&#38;color=&#38;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="550" height="312"></embed></object><p><a href="http://vimeo.com/5910332">Screencast - mod_rewrite and PHP</a> from <a href="http://vimeo.com/user2086629">José Airosa</a> on <a href="http://vimeo.com">Vimeo</a>.</p>]]></description>
			<content:encoded><![CDATA[<p><object width="550" height="312"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5910332&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5910332&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="550" height="312"></embed></object>
<p><a title='Original Link: http://vimeo.com/5910332'  href="http://www.joseairosa.com/?BQM9HrN0">Screencast &#8211; mod_rewrite and PHP</a> from <a title='Original Link: http://vimeo.com/user2086629'  href="http://www.joseairosa.com/?WpMUt2Gj">José Airosa</a> on <a title='Original Link: http://vimeo.com'  href="http://www.joseairosa.com/?tz2GLZGJ">Vimeo</a>.</p>
<p>Hello folks!</p>
<p>This time, and for the first time, I bring you a screencast! It&#8217;s all about mod_rewrite and PHP. What it is, how can we use it and how can we integrate it to be used with PHP.</p>
<p>Below are the functions that i talked about in the screencast. Use them, or not, as you please.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p101code33'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10133"><td class="code" id="p101code33"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Get current page URL
 * 
 * @return string with paeg name
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> curPageURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$pageURL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTPS&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTPS&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$pageURL</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$pageURL</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;://&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PORT&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;80&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$pageURL</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_NAME&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PORT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;REQUEST_URI&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$pageURL</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_NAME&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;REQUEST_URI&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$pageURL</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Get current page script name
 * 
 * @return string with page script name
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> curPageScriptName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">return</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SCRIPT_NAME&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><a href="http://www.php.net/strrpos"><span style="color: #990000;">strrpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SCRIPT_NAME&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Get current page name
 * 
 * @return string with page script name
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> curPageName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">return</span> <a href="http://www.php.net/end"><span style="color: #990000;">end</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span>curPageURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Hope you&#8217;ll enjoy as much as I did making it <img src='http://www.joseairosa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let me know your feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2009/08/03/screencast-1-mod_rewrite-and-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy CSS Star Rating Layout</title>
		<link>http://www.joseairosa.com/2009/07/24/easy-css-star-rating-layout/</link>
		<comments>http://www.joseairosa.com/2009/07/24/easy-css-star-rating-layout/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 22:53:59 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=80</guid>
		<description><![CDATA[<img src="http://www.joseairosa.com/wp-content/uploads/2009/07/post_stars.jpg" alt="post_stars" title="post_stars" width="559" height="57" class="alignnone size-full wp-image-92" />

Today I bring you an easy and quick CSS tip for making Star Rating layouts, only with the use of CSS. The great thing about this one that I'm about to show you, is the fact that it's continuous, meaning, it will work with percentage.
Confused?

- Let me show you an example!]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.joseairosa.com/wp-content/uploads/2009/07/post_stars.jpg" alt="post_stars" title="post_stars" width="559" height="57" class="alignnone size-full wp-image-92" /></p>
<p>Today I bring you an easy and quick CSS tip for making Star Rating layouts, only with the use of CSS. The great thing about this one that I&#8217;m about to show you, is the fact that it&#8217;s continuous, meaning, it will work with percentage.<br />
Confused?</p>
<p>- Let me show you an example!</p>
<p><img class="alignnone size-full wp-image-81" title="stars1" src="http://www.joseairosa.com/wp-content/uploads/2009/07/Imagem-3.png" alt="stars1" width="99" height="28" style="margin-left: 3px;" /><br />
<img class="alignnone size-full wp-image-82" title="Imagem 4" src="http://www.joseairosa.com/wp-content/uploads/2009/07/Imagem-4.png" alt="Imagem 4" width="102" height="24" /></p>
<p>As you can see they&#8217;re not just full or not full, they&#8217;re half full, 1/4 full, etc&#8230;</p>
<p>To achieve this you only need to have 2 images, them being:<img src="http://www.joseairosa.com/wp-content/uploads/2009/07/stars.png" alt="stars_empty" title="stars_empty" width="91" height="17" class="alignnone size-full wp-image-86" /><img src="http://www.joseairosa.com/wp-content/uploads/2009/07/stars_full.png" alt="stars_full" title="stars_full" width="91" height="17" class="alignnone size-full wp-image-87" /></p>
<p>From now on it&#8217;s only CSS and a really simple HTML to call the code and inform the % that you would like to use.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p80code34'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8034"><td class="code" id="p80code34"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.classification</span> <span style="color: #00AA00;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">91px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">17px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.classification</span> <span style="color: #6666ff;">.cover</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/stars.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">91px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">17px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">101</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.classification</span> <span style="color: #6666ff;">.progress</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/stars_full.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">17px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">102</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Basically we overlap one image on top of the other and we control the amount of Star we want to show with a given width in percentage.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p80code35'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8035"><td class="code" id="p80code35"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;classification&quot;&gt;&lt;div class=&quot;cover&quot;&gt;&lt;/div&lt;div class=&quot;progress&quot; style=&quot;width: 27%;&quot;&gt;&lt;/div&gt;&lt;/div&gt;</pre></td></tr></table></div>

<p>Where you see <strong>style=&#8221;width: 27%;&#8221;</strong> just change to what ever % you would like to fill.</p>
<p>We&#8217;re done! Easy? No? Yes? Rocket Science Hard? Let me know what you think.</p>
<p>Best regards!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2009/07/24/easy-css-star-rating-layout/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Image Scale&amp;Crop with Cache support in PHP</title>
		<link>http://www.joseairosa.com/2009/07/21/image-scalecrop-with-cache-support-in-php/</link>
		<comments>http://www.joseairosa.com/2009/07/21/image-scalecrop-with-cache-support-in-php/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 18:25:52 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=70</guid>
		<description><![CDATA[<img src="http://www.joseairosa.com/wp-content/themes/BlueGrey/images/post_crop.jpg" alt="Image Scale&#038;Crop with Cache support in PHP" />

Hello fellow readers!

Sorry for not posting anything for so long, but my work has been taking me most of my time... anyway.

Today we'll go over on creating a PHP Script that will resize and crop (if wanted) an image with the added support of cache.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.joseairosa.com/wp-content/themes/BlueGrey/images/post_crop.jpg" alt="Image Scale&#038;Crop with Cache support in PHP" /></p>
<p>Hello fellow readers!</p>
<p>Sorry for not posting anything for so long, but my work has been taking me most of my time&#8230; anyway.</p>
<p>Today we&#8217;ll go over on creating a PHP Script that will resize and crop (if wanted) an image with the added support of cache.</p>
<p>PHP is not limited to creating just HTML output. It can also be used to create and manipulate image files in a variety of different image formats, including GIF, PNG, JPEG, WBMP, and XPM. Even more convenient, PHP can output image streams directly to a browser. You will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.</p>
<p>You can use the image functions in PHP to get the size of JPEG, GIF, PNG, SWF, TIFF and JPEG2000 images.</p>
<p>For this to work you&#8217;ll need a PHP 4.3.0 version or greater. Check <a title='Original Link: http://www.libgd.org/'  href="http://www.joseairosa.com/?lzKcT9qW">http://www.libgd.org/</a> for more information.</p>
<p>This script will work in stages.</p>
<ul>
<li><strong>Stage 1:</strong> Read the image and check if it is present on our cache folder. If so we&#8217;ll just use the cached version. Take in account that even if you supply an image on an external source it will not check the image itself but rather the link, thus, no external connection is made.</li>
<li><strong>Stage 2:</strong> Start reading the source image and do the required operations of cropping and scaling.</li>
<li><strong>Stage 3:</strong> Apply the changes and create image resource (new one).</li>
<li><strong>Stage 4:</strong> Save image in cache and return the new image.</li>
</ul>
<p>Ok, enough with all this &#8220;mumbo jumbo&#8221; an lets get to action:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p70code36'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7036"><td class="code" id="p70code36"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Created and developed by José P. Airosa
 * 
 * This file will enable you to automaticaly resize images without loosing quality.
 * It uses a simple math formulas to calculate the desired final size and then rerenders the image.
 * 
 * The usage is very simples. On you HTML code just create an image and replace the src with cropimage.php?src=img/myimage.jpg&amp;size=320x240
 * 
 * src - the source of the image itself
 * size - the size that the image should have. If the size is not directly compatible with the original size it will display a simple background and the image with
 * the correct size on top.
 * 
 * Example: &lt;img src=&quot;cropimage.php?src=img/myimage.jpg&amp;size=320x240&quot; alt=&quot;&quot; /&gt;
 * 
 * If it's a square image you can just use myimage.jpg&amp;size=320 and it will make a 320x320 image.
 * 
 */</span>
<a href="http://www.php.net/ini_set"><span style="color: #990000;">ini_set</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;memory_limit&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;64M&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> cropImage <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Initialize variables;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$imgSrc</span><span style="color: #339933;">,</span> <span style="color: #000088;">$myImage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cropHeight</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cropWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dif</span><span style="color: #339933;">;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Stage 2: Read the image and check if it is present on our cache folder. If so we'll just use the cached version. Take in account that even if you supply 
	 * an image on an external source it will not check the image itself but rather the link, thus, no external connection is made.
	 * 
	 * Also check what type of file we're working with. Different files, different methods.
	 * 
	 * @param $image The image that it's to crop&amp;scale
	 * @return nothing
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> setImage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Your Image</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Getting the image dimensions</span>
		<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/getimagesize"><span style="color: #990000;">getimagesize</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Check what file we're working with</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'png'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//create image png</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myImage</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefrompng"><span style="color: #990000;">imagecreatefrompng</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Error: Cannot find image!&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/imagealphablending"><span style="color: #990000;">imagealphablending</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myImage</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// setting alpha blending on</span>
			<a href="http://www.php.net/imagesavealpha"><span style="color: #990000;">imagesavealpha</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myImage</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// save alphablending setting (important)</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpg'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpeg'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpe'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//create image jpeg</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myImage</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span style="color: #990000;">imagecreatefromjpeg</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Error: Cannot find image!&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Find biggest length</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$width</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$height</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// This will zoom in to 50% zoom (crop!)</span>
		<span style="color: #000088;">$cropPercent</span> <span style="color: #339933;">=</span> <span style="color:#800080;">.5</span><span style="color: #339933;">;</span> 
		<span style="color: #666666; font-style: italic;">// Get the size that you submitted for resize on the URL</span>
		<span style="color: #000088;">$both_sizes</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Check if it was submited something like 50x50 and not only 50 (wich is also supported)</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// Apply the cropping formula</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropHeight</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">*</span> <a href="http://www.php.net/round"><span style="color: #990000;">round</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$cropPercent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropWidth</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$cropPercent</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// Apply the cropping formula</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropHeight</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$cropPercent</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropWidth</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">*</span> <a href="http://www.php.net/round"><span style="color: #990000;">round</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$cropPercent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropHeight</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$cropPercent</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropWidth</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$biggestSide</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$cropPercent</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">// Getting the top left coordinate</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropWidth</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$height</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropHeight</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * From a file get the extension
	 * 
	 * @param $filename The filename
	 * @return string file extension
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> getExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array_pop"><span style="color: #990000;">array_pop</span></a> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filename</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * For PNG files (and possibly GIF) add transparency filter
	 * 
	 * @param $new_image
	 * @param $image_source
	 * @return nothing
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> setTransparency<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image_source</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$transparencyIndex</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecolortransparent"><span style="color: #990000;">imagecolortransparent</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$image_source</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$transparencyColor</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'red'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'green'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'blue'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">255</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$transparencyIndex</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$transparencyColor</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecolorsforindex"><span style="color: #990000;">imagecolorsforindex</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$image_source</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transparencyIndex</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$transparencyIndex</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecolorallocate"><span style="color: #990000;">imagecolorallocate</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$new_image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transparencyColor</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'red'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transparencyColor</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'green'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transparencyColor</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'blue'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/imagefill"><span style="color: #990000;">imagefill</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$new_image</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transparencyIndex</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/imagecolortransparent"><span style="color: #990000;">imagecolortransparent</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$new_image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transparencyIndex</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Stage 3: Apply the changes and create image resource (new one).
	 * 
	 * @return nothing
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> createThumb<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$thumbSizex</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$thumbSizey</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$both_sizes</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$thumbSizex</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$thumbSizey</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatetruecolor"><span style="color: #990000;">imagecreatetruecolor</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$thumbSizex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbSizey</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$bg</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecolorallocate"><span style="color: #990000;">imagecolorallocate</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.php.net/imagefill"><span style="color: #990000;">imagefill</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bg</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/imagecopyresampled"><span style="color: #990000;">imagecopyresampled</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myImage</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbSizex</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbSizey</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cropHeight</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'png'</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'transparent'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'transparent'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTransparency</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">myImage</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * Stage 4: Save image in cache and return the new image.
	 * 
	 * @return nothing
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> renderImage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$image_created</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$size_string</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'png'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Content-type: image/png'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/imagepng"><span style="color: #990000;">imagepng</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009933; font-style: italic;">/**
			 * Save image to the cache folder
			 */</span>
			<a href="http://www.php.net/imagepng"><span style="color: #990000;">imagepng</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'img_cache/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$size_string</span><span style="color: #339933;">.</span><a href="http://www.php.net/end"><span style="color: #990000;">end</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpg'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpeg'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpe'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Content-type: image/jpeg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009933; font-style: italic;">/**
			 * Save image to the cache folder
			 */</span>
			<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'img_cache/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$size_string</span><span style="color: #339933;">.</span><a href="http://www.php.net/end"><span style="color: #990000;">end</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imgSrc</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
		<a href="http://www.php.net/imagedestroy"><span style="color: #990000;">imagedestroy</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumb</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// Some variables needed for this to work. We set $size_string as global in order to access it on renderImage()</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$size_string</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Initialize our Crop Image class</span>
<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> cropImage <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$both_sizes</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$both_sizes</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009933; font-style: italic;">/**
 * Atempt to load our cached image. If we can't that means there is no cache for that image. If we find 
 * we'll just load that one adn won't even think about cropping and scaling.
 * 
 * Stage 1: Read the image and check if it is present on our cache folder. If so we’ll just use the cached version. 
 * Take in account that even if you supply an image on an external source it will not check the image itself but rather the link, thus, no external connection is made.
 */</span>
<span style="color: #000088;">$img_cached</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'img_cache/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$size_string</span><span style="color: #339933;">.</span><a href="http://www.php.net/end"><span style="color: #990000;">end</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'src'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img_cached</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$img_cached</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'png'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$myImage</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefrompng"><span style="color: #990000;">imagecreatefrompng</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$img_cached</span> <span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Error: Cannot find image!&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Content-type: image/png'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/imagepng"><span style="color: #990000;">imagepng</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$myImage</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$img_cached</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpg'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$img_cached</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpeg'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExtension</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$img_cached</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'jpe'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$myImage</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span style="color: #990000;">imagecreatefromjpeg</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$img_cached</span> <span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Error: Cannot find image!&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Content-type: image/jpeg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$myImage</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<a href="http://www.php.net/imagedestroy"><span style="color: #990000;">imagedestroy</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$myImage</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setImage</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'src'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createThumb</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderImage</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>All the code is commented and I think anyone will understand it pretty well.</p>
<p>A few things to take it into account. There should be a folder called &#8220;img_cache&#8221; with write permissions otherwise cache won&#8217;t work.</p>
<p>While loading external files is normal for the image to take a few seconds to appear. That&#8217;s only on the first time you access it. Next times it will just load the cached version directly.</p>
<p>That&#8217;s about it. Really simple script.. oh yeh, i&#8217;ve only added support for jpg and png, but i think that from the code I&#8217;ve given you can easily add support for the others. But if someone requires and is not able to do it, please do ask me and I&#8217;ll do it <img src='http://www.joseairosa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope you enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2009/07/21/image-scalecrop-with-cache-support-in-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Create a simple TagCloud in PHP</title>
		<link>http://www.joseairosa.com/2009/07/09/create-a-simple-tagcloud-in-php/</link>
		<comments>http://www.joseairosa.com/2009/07/09/create-a-simple-tagcloud-in-php/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 21:41:45 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=51</guid>
		<description><![CDATA[<img src="http://www.joseairosa.com/wp-content/themes/BlueGrey/images/tagcloud_post.jpg" alt="Create a simple TagCloud in PHP" />

Ok, as for my first post after my away time I’ll be showing you how to make a… Yes you figured it out, a TagCloud.

A TagCloud is as you know a Cloud… with Tags… hum, for some reason I think you already knew that. Anyway, jokes aside, a TagCloud is one of the most powerful visual information display nowadays. It’s not a complex module, by the opposite, it’s very simple.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.joseairosa.com/wp-content/themes/BlueGrey/images/tagcloud_post.jpg" alt="Create a simple TagCloud in PHP" /></p>
<p>Ok, as for my first post after my away time I&#8217;ll be showing you how to make a&#8230; Yes you figured it out, a TagCloud.</p>
<p>A TagCloud is as you know a Cloud&#8230; with Tags&#8230; hum, for some reason I think you already knew that. Anyway, jokes aside, a TagCloud is one of the most powerful visual information display nowadays. It&#8217;s not a complex module, by the opposite, it&#8217;s very simple.</p>
<p>A normal TagCloud displays all tags, in alphabetic order and the font size varies in according to the amount of times that tag has been found in use. Imagine that you have &#8220;hello&#8221;, &#8220;this&#8221;, &#8220;is&#8221;, &#8220;jose&#8221;,&#8221;blog&#8221; as your tags. You would get something like:</p>
<div style="text-align: center; margin: 10px 0 10px 0;">
<p><span style="font-size: 12px;">hello</span> <span style="font-size: 8px;">this</span> <span style="font-size: 14px;">is</span> <span style="font-size: 22px;">jose</span> <span style="font-size: 18px;">blog</span></div>
<p>You would know that &#8220;jose&#8221; is the tag with most views (when we say views we can say records in a database).</p>
<div class="download_bt"><a title='Original Link: downloads/tagcloud.zip'  href="http://www.joseairosa.com/?YetJXmUt">Download source files and example</a></div>
<p>The installation of the module is very easy and all the required information can be found on the files that i provide.</p>
<p>Extra info:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code37'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5137"><td class="code" id="p51code37"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// This will create a TagCloud with default max font size and minimum font size. The default values can be set on file tagcloud.php in function create_tag_cloud($array,$limit_top_size = 38,$limit_low_size = 18)</span>
<span style="color: #000088;">$tag_size</span> <span style="color: #339933;">=</span> create_tag_cloud<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Or with specific values</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code38'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5138"><td class="code" id="p51code38"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$tag_size</span> <span style="color: #339933;">=</span> create_tag_cloud<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags_array</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">40</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Max font size will be 40 and minimum font size 10. (these are the max and min values allowed for TagCloud font fluctuation.</p>
<p>And there you go. Just style the code as you like.</p>
<p>PS: Yes, i know what you&#8217;re thinking, you can change the code as you please <img src='http://www.joseairosa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let me know if you have any issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2009/07/09/create-a-simple-tagcloud-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data lost! (Panic)</title>
		<link>http://www.joseairosa.com/2009/07/09/data-lost-panic/</link>
		<comments>http://www.joseairosa.com/2009/07/09/data-lost-panic/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 21:05:05 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joseairosa.com/?p=48</guid>
		<description><![CDATA[Well&#8230; as some that might visited my blog noticed I had a small problem&#8230; yes yes&#8230; NO, it was not the Aliens&#8230; well ok, some might&#8217;ve helped, but&#8230; I lost most of my posts! Yes, it&#8217;s true, but now it&#8217;s not time to get upset. New posts are on the making Until then.]]></description>
			<content:encoded><![CDATA[<p>Well&#8230; as some that might visited my blog noticed I had a small problem&#8230; yes yes&#8230; NO, it was not the Aliens&#8230; well ok, some might&#8217;ve helped, but&#8230; I lost most of my posts!</p>
<p>Yes, it&#8217;s true, but now it&#8217;s not time to get upset. New posts are on the making <img src='http://www.joseairosa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Until then.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2009/07/09/data-lost-panic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a pulldown website (like this one)</title>
		<link>http://www.joseairosa.com/2009/02/13/creating-a-pulldown-website-like-this-one/</link>
		<comments>http://www.joseairosa.com/2009/02/13/creating-a-pulldown-website-like-this-one/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 13:09:25 +0000</pubDate>
		<dc:creator>José P. Airosa</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.core-creations.pt/JP/Blog/?p=20</guid>
		<description><![CDATA[<img src="http://www.joseairosa.com/wp-content/themes/BlueGrey/images/post3.png" alt="Creating a pulldown website (like this one)" />

I had the idea of creating this style effect after seeing a similar one in other website, only it was pullup and not pulldown.

We'll be using JQuery Framework to produce the desired effect. JQuery by itself only enables the dropdown of one element, to make the desired output we need to do some modifications, and that's what we're gonna do now.

First of all we need to import the required JavaScript...]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.joseairosa.com/wp-content/themes/BlueGrey/images/post3.png" alt="Creating a pulldown website (like this one)" /></p>
<p>I had the idea of creating this style effect after seeing a similar one in other website, only it was pullup and not pulldown.</p>
<p>We&#8217;ll be using <a title='Original Link: http://jquery.com/'  href="http://www.joseairosa.com/?kcqz4FYI">JQuery Framework</a> to produce the desired effect. JQuery by itself only enables the dropdown of one element, to make the desired output we need to do some modifications, and that&#8217;s what we&#8217;re gonna go over on this post.</p>
<div class="download_bt"><a title='Original Link: downloads/drag_me.rar'  href="http://www.joseairosa.com/?Pw3VsE4E">Download Images used in this example</a></div>
<p>First of all we need to import the required JavaScript:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p20code39'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2039"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p20code39"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;http://ui.jquery.com/testing/jquery-1.3.1.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://ui.jquery.com/testing/ui/ui.core.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://ui.jquery.com/testing/ui/ui.draggable.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p>Place these lines after &lt;title&gt; <a title='Original Link: http://pt.wikipedia.org/wiki/Tag_(programa%C3%A7%C3%A3o)'  href="http://www.joseairosa.com/?4EHMDYyr">tag</a> on the HTML code.</p>
<p>A few styles need to be added for this to work properly:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p20code40'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2040"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p20code40"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.drag_top</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-380px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.conteudo_drag</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">380px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">1200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.hand_drag</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">s-resize</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Now we need to initialize JQuery Framework and tell it which element will be affected by the dropdown effect.</p>
<p>After the code you just entered add:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p20code41'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2041"><td class="code" id="p20code41"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#drag_top&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span>
	<span style="color: #009900;">&#123;</span>
		handle<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#hand_drag'</span><span style="color: #339933;">,</span>
		axis<span style="color: #339933;">:</span> <span style="color: #3366CC;">'y'</span><span style="color: #339933;">,</span>
		containment<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'100%'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">380</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		drag<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>even<span style="color: #339933;">,</span>ui<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;page&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">marginTop</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ui.<span style="color: #660066;">position</span>.<span style="color: #660066;">top</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The element we&#8217;ve chosen to be affected is &#8220;#drag_top&#8221;. </p>
<ul>
<li>&#8220;handle: &#8216;#hand_drag&#8217;&#8221; tells JQuery that only this element will activate the dropdown effect</li>
<li>we are going to lock it to the Y axis using &#8220;axis: &#8216;y&#8217;&#8221;</li>
<li>&#8220;containment: [0,0,'100%',380]&#8221; is where we specify the limits of movement of our dropdown, in this case we confine it to top 0, left 0, width 100% and height 380 from the top of the page</li>
<li>Finally we go over to the drag function, this is where we specify what will happen during the drag effect. The default drag function has 2 parameters; event and ui. Event has all event related information during the drag and ui has all changes that happen to the dragged element, so, in this case, we&#8217;re going to use that to update the rest of he page as the dragged element comes down.</li>
</ul>
<p>For this to happen we first need to put all &lt;body&gt; content inside a &lt;div&gt; element with the id &#8220;page&#8221;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p20code42'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2042"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p20code42"><pre class="html" style="font-family:monospace;">&lt;body&gt;
	&lt;div id=&quot;page&quot;&gt;
		&lt;!-- page content --&gt;
	&lt;/div&gt;
&lt;/body&gt;</pre></td></tr></table></div>

<p>We still haven&#8217;t add the content of our dropdown element. Before &lt;div id=&#8221;page&#8221;&gt; and after &lt;body&gt; type</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p20code43'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2043"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p20code43"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;drag_top&quot; class=&quot;drag_top&quot;&gt;
	&lt;div id=&quot;conteudo_drag&quot; class=&quot;conteudo_drag&quot; align=&quot;center&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;hand_drag&quot; class=&quot;hand_drag&quot;&gt;
		&lt;img style=&quot;margin-left:99px;&quot; src=&quot;/images/drag_me.jpg&quot; alt=&quot;Drag Me!&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>And that&#8217;s it. Everything should be working. If not, go over the steps once again and check that everything has been added properly.<br />
If you still can&#8217;t get it to work <a title='Original Link: mailto://joseairosa@core-creations.pt'  href="http://www.joseairosa.com/?2R0P4K8d">send me an email</a> or <a title='Original Link: #respond'  href="http://www.joseairosa.com/?MnDGTqdx">comment this post</a> in order, for me, to help.</p>
<p>See you on the next post <img src='http://www.joseairosa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.joseairosa.com/2009/02/13/creating-a-pulldown-website-like-this-one/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
