<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Sandbox Web Solutions</title>
	
	<link>http://sandbox-ws.com</link>
	<description>Sandbox Web Solutions</description>
	<lastBuildDate>Mon, 23 Aug 2010 11:33:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SandboxWebSolutions" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="sandboxwebsolutions" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>How to Install Oracle EBS R12 on Redhat Enterprise Linux 5.5</title>
		<link>http://sandbox-ws.com/oracle/how-to-install-oracle-ebs-r12-on-redhat-enterprise-linux-5-5</link>
		<comments>http://sandbox-ws.com/oracle/how-to-install-oracle-ebs-r12-on-redhat-enterprise-linux-5-5#comments</comments>
		<pubDate>Sun, 22 Aug 2010 18:16:54 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=464</guid>
		<description><![CDATA[Before we begin the wild ride, there a few modifications that needs to be done to the system, a few packages need to be installed. I&#8217;ll assume that you have searched for quite a while and maybe you even tried to install the damn thing and ran into errors, so I&#8217;ll get right into the [...]]]></description>
			<content:encoded><![CDATA[<p>Before we begin the wild ride, there a few modifications that needs to be done to the system, a few packages need to be installed. I&#8217;ll assume that you have searched for quite a while and maybe you even tried to install the damn thing and ran into errors, so I&#8217;ll get right into the process. Here what we&#8217;re going to do:</p>
<ol>
<li>Install Development Tools</li>
<li>Install required packages</li>
<li>Modify the System Configuration and Kernel (don&#8217;t panic)</li>
<li>Create Required Users</li>
<li>Install Oracle Apps</li>
</ol>
<p><span id="more-464"></span></p>
<h3>Install Development Tools</h3>
<pre class="brush: bash;">
yum groupinstall &quot;Development Tools&quot;
</pre>
<h3>Install required packages</h3>
<p>You can either install the following packages using yum or download <a href="http://sandbox-ws.com/wp-content/uploads/2010/08/rhel-ebs.zip">this</a> file which include all the files.</p>
<ol>
<li><a href="http://oss.oracle.com/projects/compat-oracle/dist/files/Enterprise_Linux/openmotif21-2.1.30-11.EL5.i386.rpm">openmotif21-2.1.30-11.EL5.i386.rpm</a></li>
<li><a href="http://oss.oracle.com/projects/compat-oracle/dist/files/Enterprise_Linux/xorg-x11-libs-compat-6.8.2-1.EL.33.0.1.i386.rpm">xorg-x11-libs-compat-6.8.2-1.EL.33.0.1.i386.rpm</a></li>
<li>elfutils-libelf-devel-0.125</li>
<li>elfutils-libelf-devel-static-0.125</li>
<li>libaio-devel-0.3.106</li>
<li>unixODBC-2.2.11</li>
<li>unixODBC-devel-2.2.11</li>
</ol>
<blockquote><p><strong>Note:</strong> You need to make the following modifications after installing openmotif</p>
<pre class="brush: php;">
$ unlink /usr/lib/libXtst.so.6
$ ln -s /usr/X11R6/lib/libXtst.so.6.1 /usr/lib/libXtst.so.6
</pre>
</blockquote>
<h3>Modify the System Configuration and Kernel</h3>
<p>Open /etc/sysctl.conf as root</p>
<pre class="brush: php;">
$ su - root
$ vi  /etc/sysctl.conf
</pre>
<p>then add the following lines at the end of the file</p>
<pre class="brush: bash;">
#Oracle EBS R12.1.1 Kernel Settings
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 256 32000 100 142
fs.file-max = 327679
net.ipv4.ip_local_port_range = 10000 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=4194304
</pre>
<p>Now lets apply the new settings</p>
<pre class="brush: php;">
$ /sbin/sysctl –p
</pre>
<p>Add the following lines to the /etc/security/limits.conf file:</p>
<pre class="brush: php;">
* hard nofile 65535

* soft nofile 4096

* hard nproc 16384

* soft nproc 2047
</pre>
<p>Add the following lines to the /etc/resolv.conf file:</p>
<pre class="brush: php;">
options attempts:5
options timeout:15
</pre>
<blockquote><p>Now we need to restart the system so the above modifications gets applied.</p></blockquote>
<h3>Create Required Users</h3>
<p>We&#8217;ll need to create one group <strong>dba</strong> and two users, <strong>oracle</strong> and <strong>applmgr</strong>. The <strong>oracle</strong> users will be the owner of the database tier folders and services, while the <strong>applmgr</strong> user will be the owner of the applications tier.</p>
<p>You can either create the group and the users using GUI or use the following commands:</p>
<pre class="brush: php;">
$ su - root
$ groupadd dba
$ useradd –g dba  –d  /home/oracle oracle
$ useradd –g dba  –d  /home/applmgr applmgr
</pre>
<h3>Install Oracle Apps</h3>
<p>Before we start the installation we need first to create the installation directory. We will name the directory <strong>ebs</strong> and create at root /.</p>
<pre class="brush: php;">
$ su - root
$ cd /
$ mkdir ebs
$ chown oracle:dba ebs
$ chmod 777 ebs
</pre>
<p>Now we can start the rapid install wizard. I&#8217;ll not be using a staging area but the following applies to both installing from a staging area or from Oracle&#8217;s EBS media pack DVDs.<br />
I&#8217;ll assume that the DVD-Rom is mounted at /media/cdrom.</p>
<pre class="brush: php;">
// run the following as the oracle user, not root
$ cd /media/cdrom/Disk/rapidwiz
$ ./rapidwiz
</pre>
<p>That&#8217;s it, below are some screen shots of the installation using a fresh database. Have fun.</p>
<div id="attachment_484" class="wp-caption aligncenter" style="width: 605px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/1.png"><img class="size-full wp-image-484 " title="Installation Screen 01" src="http://sandbox-ws.com/wp-content/uploads/2010/08/1.png" alt="Installation Screen 01" width="595" height="363" /></a><p class="wp-caption-text">Installation Screen 01</p></div>
<p style="text-align: center;">
<div id="attachment_485" class="wp-caption aligncenter" style="width: 597px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/2.png"><img class="size-full wp-image-485" title="Installation Screen 02" src="http://sandbox-ws.com/wp-content/uploads/2010/08/2.png" alt="Installation Screen 02" width="587" height="359" /></a><p class="wp-caption-text">Installation Screen 02</p></div>
<p style="text-align: center;">
<div id="attachment_486" class="wp-caption aligncenter" style="width: 600px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/3.png"><img class="size-full wp-image-486" title="Installation Screen 03" src="http://sandbox-ws.com/wp-content/uploads/2010/08/3.png" alt="Installation Screen 03" width="590" height="360" /></a><p class="wp-caption-text">Installation Screen 03</p></div>
<p style="text-align: center;">
<div id="attachment_487" class="wp-caption aligncenter" style="width: 599px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/4.png"><img class="size-full wp-image-487" title="Installation Screen 04" src="http://sandbox-ws.com/wp-content/uploads/2010/08/4.png" alt="Installation Screen 04" width="589" height="361" /></a><p class="wp-caption-text">Installation Screen 04</p></div>
<p style="text-align: center;">
<div id="attachment_488" class="wp-caption aligncenter" style="width: 598px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/5.png"><img class="size-full wp-image-488" title="Installation Screen 05" src="http://sandbox-ws.com/wp-content/uploads/2010/08/5.png" alt="Installation Screen 05" width="588" height="361" /></a><p class="wp-caption-text">Installation Screen 05</p></div>
<p style="text-align: center;">
<div id="attachment_489" class="wp-caption aligncenter" style="width: 602px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/6.png"><img class="size-full wp-image-489" title="Installation Screen 06" src="http://sandbox-ws.com/wp-content/uploads/2010/08/6.png" alt="Installation Screen 06" width="592" height="360" /></a><p class="wp-caption-text">Installation Screen 06</p></div>
<p style="text-align: center;">
<div id="attachment_490" class="wp-caption aligncenter" style="width: 599px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/7.png"><img class="size-full wp-image-490" title="Installation Screen 07" src="http://sandbox-ws.com/wp-content/uploads/2010/08/7.png" alt="Installation Screen 07" width="589" height="361" /></a><p class="wp-caption-text">Installation Screen 07</p></div>
<p style="text-align: center;">
<div id="attachment_491" class="wp-caption aligncenter" style="width: 600px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/8.png"><img class="size-full wp-image-491" title="Installation Screen 08" src="http://sandbox-ws.com/wp-content/uploads/2010/08/8.png" alt="Installation Screen 08" width="590" height="361" /></a><p class="wp-caption-text">Installation Screen 08</p></div>
<p style="text-align: center;">
<div id="attachment_492" class="wp-caption aligncenter" style="width: 601px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/9.png"><img class="size-full wp-image-492" title="Installation Screen 09" src="http://sandbox-ws.com/wp-content/uploads/2010/08/9.png" alt="Installation Screen 09" width="591" height="359" /></a><p class="wp-caption-text">Installation Screen 09</p></div>
<p style="text-align: center;">
<div id="attachment_493" class="wp-caption aligncenter" style="width: 601px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/10.png"><img class="size-full wp-image-493" title="10" src="http://sandbox-ws.com/wp-content/uploads/2010/08/10.png" alt="Installation Screen 10" width="591" height="365" /></a><p class="wp-caption-text">Installation Screen 10</p></div>
<p style="text-align: center;">
<div id="attachment_494" class="wp-caption aligncenter" style="width: 602px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/11.png"><img class="size-full wp-image-494" title="Installation Screen 11" src="http://sandbox-ws.com/wp-content/uploads/2010/08/11.png" alt="Installation Screen 11" width="592" height="360" /></a><p class="wp-caption-text">Installation Screen 11</p></div>
<p style="text-align: center;">
<div id="attachment_495" class="wp-caption aligncenter" style="width: 602px"><a href="http://sandbox-ws.com/wp-content/uploads/2010/08/12.png"><img class="size-full wp-image-495" title="Installation Screen 12" src="http://sandbox-ws.com/wp-content/uploads/2010/08/12.png" alt="Installation Screen 12" width="592" height="360" /></a><p class="wp-caption-text">Installation Screen 12</p></div>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/oracle/how-to-install-oracle-ebs-r12-on-redhat-enterprise-linux-5-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox Extensions Every Developer Should Use</title>
		<link>http://sandbox-ws.com/firefox/firefox-extensions-every-developer-should-use</link>
		<comments>http://sandbox-ws.com/firefox/firefox-extensions-every-developer-should-use#comments</comments>
		<pubDate>Wed, 26 Aug 2009 22:46:07 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=427</guid>
		<description><![CDATA[There are a lot of factors that makes Firefox the best browser currently available, but what makes Firefox really stands out is it support for extensions. A Firefox extension is an addon feature to the browser. There are thousands of available addons and in this post I&#8217;ll list some of the most used extensions by [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of factors that makes Firefox the best browser currently available, but what makes Firefox really stands out is it support for extensions. A Firefox extension is an addon feature to the browser. There are thousands of available addons and in this post I&#8217;ll list some of the most used extensions by developers, in fact every developer should be using them.<br />
<span id="more-427"></span></p>
<h2><a href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a></h2>
<p>Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.</p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/inspect.png" alt="inspect" title="inspect" width="440" height="335" class="aligncenter size-full wp-image-432" /></p>
<p>As you can see in the above image Firebug adds the option &#8220;Inspect Element&#8221; which appears when you right click on any element in a web page. When clicked it will display the source code of the select item along with the css styles applied on that element (see below).</p>
<p><a class="img" href="http://sandbox-ws.com/wp-content/uploads/2009/08/firebug.png"><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/firebug_thumb.jpg" alt="firebug_thumb" title="firebug_thumb" width="610" height="183" class="aligncenter size-full wp-image-435" /></a></p>
<h2><a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer</a></h2>
<p>The Web Developer extension adds a menu and a toolbar to the browser with various web developer tools. It is designed for Firefox, Flock  and Seamonkey, and will run on any platform that these browsers support including Windows, Mac OS  X and Linux. </p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/toolbar.png" alt="toolbar" title="toolbar" width="333" height="204" class="aligncenter size-full wp-image-441" /></p>
<h2><a href="https://addons.mozilla.org/en-US/firefox/addon/6683">Firecookie</a></h2>
<p>Firecookie is a an extension for Firebug that makes possible to view and manage cookies in your browser. Apart from all the other cookie managers and viewers available as Firefox extensions, this one is made as an extension for Firebug, so web developer has the functionality accessible within familiar Firebug&#8217;s UI.</p>
<p><a class="img" href="http://sandbox-ws.com/wp-content/uploads/2009/08/scr-overview.png"><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/scr-overview-thumb.png" alt="scr-overview-thumb" title="scr-overview-thumb" width="520" height="179" class="aligncenter size-full wp-image-443" /></a></p>
<h2><a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a></h2>
<p>View HTTP headers of a page and while browsing.</p>
<p><a class="img" href="http://sandbox-ws.com/wp-content/uploads/2009/08/live_http_headers.png"><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/live_http_headers.png" alt="live_http_headers" title="live_http_headers" width="610" height="387" class="aligncenter size-full wp-image-446" /></a></p>
<h2><a href="http://code.google.com/speed/page-speed/">Page Speed</a></h2>
<p>Page Speed is an open-source Firefox/Firebug Add-on. Webmasters and web developers can use Page Speed to evaluate the performance of their web pages and to get suggestions on how to improve them.</p>
<p><a class="img" href="http://sandbox-ws.com/wp-content/uploads/2009/08/page_speed.jpg"><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/page_speed_thumb.jpg" alt="page_speed_thumb" title="page_speed_thumb" width="610" height="183" class="aligncenter size-full wp-image-448" /></a></p>
<h2><a href="https://addons.mozilla.org/en-US/firefox/addon/11905/">Firefinder</a></h2>
<p>Firefinder is an extension to Firebug (in Firefox) and offers the functionality to, in a quick way, find HTML elements matching chosen CSS selector(s) or XPath expression. It allows you to instantly test your CSS selectors in the page while seeing the content at the same time, and matching elements will be highlighted.</p>
<p><a class="img" href="http://sandbox-ws.com/wp-content/uploads/2009/08/firefinder.jpg"><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/firefinder_thumb.jpg" alt="firefinder_thumb" title="firefinder_thumb" width="610" height="183" class="aligncenter size-full wp-image-451" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/firefox/firefox-extensions-every-developer-should-use/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery Facebook Plugins</title>
		<link>http://sandbox-ws.com/jquery/jquery-facebook-plugins</link>
		<comments>http://sandbox-ws.com/jquery/jquery-facebook-plugins#comments</comments>
		<pubDate>Mon, 24 Aug 2009 14:05:17 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Facebook]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=412</guid>
		<description><![CDATA[Facebook interface is as simple as it gets, and yet many of the elements that define this interface are very powerful and have proven to be very popular, so popular that jQuery developers created plugins to imitate those elements. In this post I&#8217;ll introduce you to two jQuery plugins that imitate facebook elements. FCBKcomplete Fancy [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook interface is as simple as it gets, and yet many of the elements that define this interface are very powerful and have proven to be very popular, so popular that jQuery developers created plugins to imitate those elements. In this post I&#8217;ll introduce you to two jQuery plugins that imitate facebook elements.<br />
<span id="more-412"></span></p>
<h2><a href="http://www.emposha.com/javascript/jquerymultiselect.html">FCBKcomplete</a></h2>
<p>Fancy facebook-like dynamic inputs with auto complete &#038; pre added values. If you have any comments or requests, please post them and I will try to include all the requested features in the upcoming release.</p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/fcbk_complete.png" alt="fcbk_complete" title="fcbk_complete" width="626" height="345" class="aligncenter size-full wp-image-415" /></p>
<h4>Usage</h4>
<pre class="brush: jscript;">
&lt;script language=&quot;JavaScript&quot;&gt;
$(document).ready(function() {
$.facebooklist('#elem', '#list', '#complete',{url:'ajax-url',cache:1}, height, {userfilter:1,casesensetive:0});
});
&lt;/script&gt;
</pre>
<p>elem – input element id or object<br />
list – preadded elements<br />
complete – autocomplete div id or object<br />
ajax – object with two parametrs a) url to fetch json object b) use cache<br />
height – maximum number of element shown before scroll will apear<br />
filter – object with two parametrs a)case sensitive b) show/hide filtered items<br />
newel – show typed text like a element</p>
<h2><a href="http://famspam.com/facebox">Facebox</a></h2>
<p> Facebox is a jQuery-based, Facebook-style lightbox which can display images, divs, or entire remote pages.<br />
It&#8217;s simple to use and easy on the eyes. Download the tarball, view the examples, then start enjoying the curves.<br />
<img src="http://sandbox-ws.com/wp-content/uploads/2009/08/facebox.jpg" alt="facebox" title="facebox" width="541" height="459" class="aligncenter size-full wp-image-423" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/jquery/jquery-facebook-plugins/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Create Your First WordPress Plugin</title>
		<link>http://sandbox-ws.com/wordpress/how-to-create-your-first-wordpress-plugin</link>
		<comments>http://sandbox-ws.com/wordpress/how-to-create-your-first-wordpress-plugin#comments</comments>
		<pubDate>Mon, 10 Aug 2009 21:49:17 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=399</guid>
		<description><![CDATA[WordPress is a very powerful and popular blogging platform. Once you start using it you will fall in love with it and sooner or later you&#8217;d want to create your own plugin to extend its functionality. So if you want to learn how to create your own WordPress plugin then you have come to the [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress is a very powerful and popular blogging platform. Once you start using it you will fall in love with it and sooner or later you&#8217;d want to create your own plugin to extend its functionality. So if you want to learn how to create your own WordPress plugin then you have come to the right place.</p>
<p>A WordPress plugin is simply one or more <strong>PHP</strong> files that adhere to certain rules and conventions. All you need to understand and complete this tutorial is a basic understanding of PHP programming.</p>
<p>Before we get started, let me explain what does the plugin we&#8217;re going to write will do. It simply displays the most commented 5 posts. Pretty simple and straight forward plugin which makes it an ideal example to explore the concept behind a WordPress plugin. We will call the plugin <strong>&#8220;WP Most Commented&#8221;</strong>.</p>
<p><span id="more-399"></span></p>
<h2>Plugin Folder Structure</h2>
<p>WordPress doesn&#8217;t enforce a strict folder structure unlike most frameworks available, basically all you have to do is create a folder with the desired name (wp_most_commented in our case) under the <em><strong>plugins</strong></em> folder located in <em><strong>/wp-content/</strong></em></p>
<p>Let&#8217;s create the plugin folder:<br />
<img src="http://sandbox-ws.com/wp-content/uploads/2009/08/folder_structure.png" alt="folder_structure" title="folder_structure" width="286" height="554" class="aligncenter size-full wp-image-403" /></p>
<p>In this folder we will create the plugin main PHP file, let&#8217;s call it <em><strong>&#8220;wp-most-commented.php&#8221;</strong></em>.</p>
<h2>Activating/Deactivating the Plugin</h2>
<p>In order for WordPress to be able to activate/deactivate a plugin, we need to add PHP comments to the main file that tells WordPress about our plugin. Just copy and paste the following in the main file.</p>
<pre class="brush: php;">
&lt;?php
/*
Plugin Name: WP Most Commented
Plugin URI: http://sandbox-ws.com
Description: Displays Most Commented Posts
Version: 1.0
Author: Ahmed El.Hussaini
Author URI: http://sandbox-ws.com
*/
?&gt;
</pre>
<p>As you can see that the above comments tells WordPress some meta data about the plugin like the plugin&#8217;s name, author, version, and so on. Those meta data are used to display some info about the plugin in the Admin panel of WordPress. After saving the main file goto WordPress&#8217; admin panel, then click &#8220;Plugins&#8221; in the left side bar and you should find that our plugin was detected by WordPress.</p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/plugins_page.png" alt="plugins_page" title="plugins_page" width="616" height="48" class="aligncenter size-full wp-image-405" /></p>
<p>Now you can activate and deactivate the plugin, although it will make no difference since we haven&#8217;t added any logic to the plugin main file.</p>
<h2>Most Commented SQL Query</h2>
<p>The MySQL query we will use to retrieve the most commented 5 posts is:</p>
<pre class="brush: sql;">
SELECT ID, post_title, comment_count FROM $wpdb-&gt;posts WHERE post_status = 'publish' and comment_count &gt; 0 ORDER BY comment_count DESC LIMIT 5
</pre>
<p>You can test the query if you like but make sure to replace <em><strong>$wpdb->posts</strong></em> with your post&#8217;s table which is probably <em><strong>wp_posts</strong></em>.</p>
<p>Let&#8217;s add the function that will retrieve the most commented posts and displays them in a list. Just copy and paste the following to the plugin&#8217;s main file.</p>
<pre class="brush: php;">
function wp_most_commented() {
	global $wpdb;

	// select top most commented posts that have comment count &gt; 0 and are published
	$sql = &quot;SELECT ID, post_title, comment_count FROM $wpdb-&gt;posts WHERE post_status = 'publish' and comment_count &gt; 0 ORDER BY comment_count DESC LIMIT 5&quot;;

	// execute query
	$posts = $wpdb-&gt;get_results($sql);

	$html = '';

	$html .= '&lt;ul&gt;';

	foreach ($posts as $post) {

		$title = $post-&gt;post_title;

		$permalink = get_permalink($post-&gt;ID);

		$comment_count = $post-&gt;comment_count;

		$html .= '&lt;li&gt;';

		$html .= '&lt;a href=&quot;'.$permalink.'&quot; title=&quot;'.$title.'&quot;&gt;'.$title.'&lt;/a&gt;';

		$html .= '&lt;/li&gt;';

	}

	$html .= '&lt;/ul&gt;';

	echo $html;

}
</pre>
<h2>Testing the Plugin</h2>
<p>Open the sidebar.php file in your current active theme and place the following snippet:</p>
<pre class="brush: php;">
&lt;?php if(function_exists('wp_most_commented')): ?&gt;
	&lt;div id=&quot;most_commented&quot;&gt;
		&lt;h3&gt;Most Commented Posts&lt;/h3&gt;
		&lt;?php wp_most_commented() ?&gt;
	&lt;/div&gt;
&lt;?php endif; ?&gt;
</pre>
<p>In your sidebar you should see something similar to the following screenshot:</p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/08/plugin_sc.png" alt="plugin_sc" title="plugin_sc" width="314" height="139" class="aligncenter size-full wp-image-406" /></p>
<p>You&#8217;d probably want to customize the plugin main function to allow users to specify the number of posts to be displayed instead of the hard coded 5 limit, also you can add the ability to pass css classes, but I&#8217;ll this task to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/wordpress/how-to-create-your-first-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Textmate Ruby on Rails 2 and CSS Bundles Imported into Intype</title>
		<link>http://sandbox-ws.com/general/textmate-ruby-on-rails-2-and-css-bundles-imported-into-intype</link>
		<comments>http://sandbox-ws.com/general/textmate-ruby-on-rails-2-and-css-bundles-imported-into-intype#comments</comments>
		<pubDate>Sun, 22 Mar 2009 21:50:23 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bundles]]></category>
		<category><![CDATA[intype]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=361</guid>
		<description><![CDATA[I&#8217;ve converted Textmate Ruby on Rails 2 and CSS Bundles Imported into Intype. I&#8217;ve tested both of them but if find any errors please notify me by leaving a commend or sending me an email at eng.ahmed.elhussaini@sandbox-ws.com Use the links below to download the bundles: CSS Bundle Ruby on Rails 2 Bundle]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve converted Textmate Ruby on Rails 2 and CSS Bundles Imported into Intype. I&#8217;ve tested both of them but if find any errors please notify me by leaving a commend or sending me an email at eng.ahmed.elhussaini@sandbox-ws.com</p>
<p>Use the links below to download the bundles:</p>
<ul>
<li><a href="http://sandbox-ws.com/wp-content/uploads/2009/03/CSS.itBundle.rar">CSS Bundle</a></li>
<li><a href="http://sandbox-ws.com/wp-content/uploads/2009/03/RubyOnRails2.itBundle.rar">Ruby on Rails 2 Bundle</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/general/textmate-ruby-on-rails-2-and-css-bundles-imported-into-intype/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add Tomcat6 Support to Oracle Workshop for Weblogic 10gR3</title>
		<link>http://sandbox-ws.com/general/add-tomcat6-support-to-oracle-workshop-for-weblogic-10gr3</link>
		<comments>http://sandbox-ws.com/general/add-tomcat6-support-to-oracle-workshop-for-weblogic-10gr3#comments</comments>
		<pubDate>Wed, 28 Jan 2009 16:30:38 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=349</guid>
		<description><![CDATA[First of all I&#8217;d like to thank myloon for this guide, all I did was translating it to English and included a direct link to the files needed. Files Needed Tomcat6 for Oracle Workshop After downloading the above file, extract it and copy the contents of the debugger folder to BEA_WORKSHOP_HOMEworkshop_10.3workshop4WPeclipsepluginscom.m7.nitrox.debugger_3.5.100.200807251738 and the contents of [...]]]></description>
			<content:encoded><![CDATA[<p>First of all I&#8217;d like to thank <a href="http://blog.csdn.net/myloon/archive/2008/09/20/2956763.aspx">myloon</a> for this guide, all I did was translating it to English and included a direct link to the files needed.</p>
<h5>Files Needed</h5>
<ul>
<li><a href="http://sandbox-ws.com/wp-content/uploads/2009/01/tomcat6_oracle_workshop.zip">Tomcat6 for Oracle Workshop</a></li>
</ul>
<p><span id="more-349"></span></p>
<p>After downloading the above file, extract it and copy the contents of the <strong>debugger</strong> folder to <strong>BEA_WORKSHOP_HOMEworkshop_10.3workshop4WPeclipsepluginscom.m7.nitrox.debugger_3.5.100.200807251738</strong> and the contents of the <strong>serverdef</strong> folder to <strong>BEA_WORKSHOP_HOMEworkshop_10.3workshop4WPeclipsepluginscom.m7.nitrox.serverdef_3.5.100.200807251738</strong></p>
<div class="note">
<p>Make sure to backup any file before replacement.</p>
</div>
<p>Now open the <strong>cmd</strong> and change to the directory <strong>BEA_WORKSHOP_HOMEworkshop_10.3</strong> and run the following command</p>
<pre class="brush: plain;">
workshop.exe -clean
</pre>
<p>Now you can create dynamic web projects and add JSF 1.2 support to it with Apache Tomcat 6 as the run time server.</p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/01/tomcat6_workshop_1.jpg" alt="tomcat6_workshop_1" title="tomcat6_workshop_1" width="519" height="541" class="aligncenter size-full wp-image-356" /></p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/01/tomcat6_workshop_2.jpg" alt="tomcat6_workshop_2" title="tomcat6_workshop_2" width="619" height="571" class="aligncenter size-full wp-image-357" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/general/add-tomcat6-support-to-oracle-workshop-for-weblogic-10gr3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Subversion</title>
		<link>http://sandbox-ws.com/subversion/introduction-to-subversion</link>
		<comments>http://sandbox-ws.com/subversion/introduction-to-subversion#comments</comments>
		<pubDate>Fri, 23 Jan 2009 18:41:30 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[Subversion]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=320</guid>
		<description><![CDATA[Before I started using subversion I used to make backup of my projects on regular basis and I can&#8217;t emphasis enough how this process was so boring and tedious, and every know and then I forget to make a backup or maybe replace files by accident. Actually I don&#8217;t know how I survived without using [...]]]></description>
			<content:encoded><![CDATA[<p>Before I started using subversion I used to make backup of my projects on regular basis and I can&#8217;t emphasis enough how this process was so boring and tedious, and every know and then I forget to make a backup or maybe replace files by accident. Actually I don&#8217;t know how I survived without using some kind of <a href="http://en.wikipedia.org/wiki/Revision_control">version control</a>.</p>
<p><span id="more-320"></span></p>
<p>I&#8217;m assuming that because you&#8217;re reading this article then you probably have some general info about Subversion and maybe some other version control system like <a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System">CVS</a>. If not, then no problem, this article will still help you to get started using Subversion.</p>
<p>This article assumes that you&#8217;re running windows xp/vista, but the concept is the same and should work just fine on linux and mac os x systems as well, the only difference will be in the installation which you&#8217;ll find a lot of guides on the internet.</p>
<p>So lets get started, here is an overview of the guide:</p>
<ol>
<li><a href="#Downloading">Downloading and Installing Subversion for Windows</a></li>
<li><a href="#CreatingRepo">Creating a Repository</a></li>
<li><a href="#Initializing ">Initializing Repository Structure</a></li>
<li><a href="#CreatingProject">Creating A New Project</a></li>
<li><a href="#CheckingOut">Checking Out a Project</a></li>
<li><a href="#Adding">Adding Files to the Working Copy</a></li>
<li><a href="#Committing">Committing Changes</a></li>
</ol>
<h5 id="Downloading">Downloading Subversion for Windows</h5>
<p>Subversion for windows can be downloaded from <a href="http://subversion.tigris.org/files/documents/15/43360/Setup-Subversion-1.5.1.en-us.msi">here</a>. After downloading is finished, install the package. If it asks to restart, please do so. In order to verify that the installation was successful open the <strong>command line prompt</strong> and type <strong>svn</strong> then hit <strong>enter</strong> on the keyboard. If you get an output similar to the following then the installation was successful.</p>
<pre class="brush: plain;">
Type 'svn help' for usage.
</pre>
<h5 id="CreatingRepo">Creating a Repository</h5>
<p>Now that we have subversion installed we want to create out first repository. Normally you&#8217;ll want to store the repository on the root of a drive, for example <strong>c:\repo</strong>, so lets use this path to store our repository.</p>
<p>To create a new repository we use the following command:</p>
<pre class="brush: plain;">
cd c:\
svnadmin create repo
</pre>
<h5 id="Initializing">Initializing Repository Structure</h5>
<p>Defining the structure of your repository is completely up to you, there&#8217;s no restrictions in subversion that forces you to structure your repository in a certain way but most developers around the world uses the same structure as a global convention. This structure states that the repository will be divided into three main folders: <strong>Tags</strong>, <strong>Branches</strong>, and <strong>Trunk</strong>. I&#8217;ll not dive into why this structure was agreed upon between developers around the world. I&#8217;ll leave that for another article. Maybe that reason will make you visit my blog again <img src='http://sandbox-ws.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>So lets create the repository initial structure.</p>
<pre class="brush: plain;">
svn mkdir file:///c:/repo/tags file:///c:/repo/trunk file:///c:/repo/branches -m &quot;initialized repo structure&quot;
</pre>
<p>The above command should result in the following output</p>
<pre class="brush: plain;">
Committed out revision 1.
</pre>
<p>Lets explain what happened now, first we used the svn command <strong>mkdir</strong> to create three folders and we also added a message using the parameter <strong>-m</strong>.</p>
<div class="note">
<p>Most svn commands require adding a message while running the command. Those messages are helpful for viewing the history of your repository.</p>
</div>
<p>After running the <strong>mkdir</strong> command <strong>svn</strong> reports that the repository revision number is now <strong>(1)</strong>. Each time you modify the repository whether by adding, modifying, or deleting, the revision number increase by one. So the repo revision number is an indication of the number of changes made to the repository since it was created.</p>
<h5 id="CreatingProject">Creating A New Project</h5>
<p>Now that our repo structure is ready lets create our first version controlled project. For sake of testing we will name the project <strong>sandbox-ws</strong>. The sandbox-ws project will be added to the trunk folder. We will use the same mkdir command</p>
<pre class="brush: plain;">
svn mkdir file:///c:/repo/trunk/sandbox-ws -m &quot;created sandbox-ws project&quot;
</pre>
<h5 id="CheckingOut">Checking Out a Project</h5>
<p>The figure below outlines the basic operations done on a subversion repository. First we create the repository, then initialize the project structure, then create one or more projects in the repository, and last but not least, the developers checks out a project, modifies it, and then commits the changes back to the repository so other developers can update their working copies to reflect those changes.</p>
<p>If sandbox-ws was a PHP project for example, then the working copy will be in your web server&#8217;s documents root, <strong>htdocs</strong> for example if you&#8217;re using <strong>Apache</strong>. But for sake of testing we will create our working copy on the <strong>Desktop</strong>.</p>
<p>To check out the sandbox-ws project run the following command(NOTE: I assume that you&#8217;ve changes the cmd path to your desktop):</p>
<pre class="brush: plain;">
svn co file:///c:/repo/trunk/sandbox-ws
</pre>
<p>The above command should result in the following output</p>
<pre class="brush: plain;">
Checked out revision 1.
</pre>
<p>Now we move to the sandbox-ws project:</p>
<pre class="brush: plain;">
cd sandbox-ws
</pre>
<h5 id="Adding">Adding Files to the Working Copy</h5>
<p>Now that we have checked out the sandbox-ws project, it&#8217;s time to add some files to it. We will start with a simple php file, see below</p>
<pre class="brush: plain;">
// index.php
&lt;?php echo 'Hello World!' ?&gt;
</pre>
<p>What we have done by adding a new file to the working copy is that we simply modified it. Lets see what subversion have to say now, run the following command from the sandbox-ws project folder</p>
<pre class="brush: plain;">
svn status
</pre>
<p>The above command output should be similar to the following:</p>
<pre class="brush: plain;">
?     index.php
</pre>
<p>The <strong>(?)</strong> next to the <strong>index.php</strong> file indicates that <strong>svn</strong> detected that the <strong>index.php</strong> status is unknown i.e. it&#8217;s new and has not been added to the working copy yet.</p>
<div class="note">
<p>Most new developers to subversion get confused at this point, adding a file/folder to a working copy doesn&#8217;t mean that <strong>svn</strong> will also add the new file/folder to the repository as well, that is done by committing the file/folder to the repository as we will see in the next section.</p>
</div>
<p>Since svn doesn&#8217;t know the status of the index.php file, we should add it to the working copy, to do this run the following command:</p>
<pre class="brush: plain;">
svn add index.php
</pre>
<p>The output of the following command should be similar to the following:</p>
<pre class="brush: plain;">
A      index.php
</pre>
<p>As you may have guessed, <strong>(A)</strong> means that the file has been added to the working copy, the next step would be committing the changes to the repository which would result in incrementing the repository revision number by one.</p>
<h5 id="Committing">Committing Changes</h5>
<p>After adding new the index.php file to the repository, we&#8217;ll want to commit it to the repository for other developers to be able to update their working copies and take advantage of our newly added file. To do so run the following command:</p>
<pre class="brush: plain;">
svn ci -m &quot;added index.php&quot;
</pre>
<p>The output of the following command should be similar to the following:</p>
<pre class="brush: plain;">
Adding         index.php
Transmitting file data .
Committed revision 2.
</pre>
<p>I think that the above doesn&#8217;t need any explanation, but the following does, run the following command:</p>
<pre class="brush: plain;">
svn info
</pre>
<p>The output of the following command should be similar to the following:</p>
<pre class="brush: plain;">
Path: .
URL: file:///c:/repo/trunk/sandbox-ws
Repository Root: file:///c:/repo
Repository UUID: 50729929-acbb-d647-b00b-4f3555a6f6a3
Revision: 1
Node Kind: directory
Schedule: normal
Last Changed Author: Sandbox
Last Changed Rev: 1
Last Changed Date: 2009-01-23 16:52:06 +0200 (Fri, 23 Jan 2009)
</pre>
<p>Of course some of the data displayed by the following command will differ between you and me but what is interesting about the command is that it indicates that the revision number of the working copy is less than the current revision number of the repository which is currently is 2. The reason of this is that after our commit the repository revision number as we have said increments by one but the our working copy is now out dated, we need to update it so the revision number of the working copy is similar to the repository. To do so run the following command:</p>
<pre class="brush: plain;">
svn update
</pre>
<p>The output of the following command should be similar to the following:</p>
<pre class="brush: plain;">
At revision 2.
</pre>
<p>I hope that this article successfully cleared what subversion is and how to start using it, in upcoming articles we will dive into more advanced topics.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/subversion/introduction-to-subversion/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Embed Forms in Symfony 1.2 Admin Generator Part 3</title>
		<link>http://sandbox-ws.com/frameworks/symfony-frameworks/how-to-embed-forms-in-symfony-12-admin-generator-part-3</link>
		<comments>http://sandbox-ws.com/frameworks/symfony-frameworks/how-to-embed-forms-in-symfony-12-admin-generator-part-3#comments</comments>
		<pubDate>Sun, 18 Jan 2009 22:13:28 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[admin generator]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=294</guid>
		<description><![CDATA[In the last part of this series of articles we introduced the ability to edit multiple child models in the edit screen of the parent model. In this part we will take it a step further by adding I18N behavior to the child models. To make things a little bit clear before we start coding [...]]]></description>
			<content:encoded><![CDATA[<p>In the last <a href="http://sandbox-ws.com/how-to-embed-forms-in-symfony-12-admin-generator-part-2">part</a> of this series of articles we introduced the ability to edit multiple child models in the edit screen of the parent model. In this part we will take it a step further by adding I18N behavior to the child models. To make things a little bit clear before we start coding please take a look at the result we want to achieve below.</p>
<p><span id="more-294"></span></p>
<p><img src="http://sandbox-ws.com/wp-content/uploads/2009/01/embed_i18n.png" alt="embed_i18n" title="embed_i18n" width="540" height="330" class="aligncenter size-full wp-image-295" /></p>
<p>Before starting I strongly recommend reading part <a href="http://sandbox-ws.com/how-to-embed-forms-in-symfony-12-admin-generator">one</a>, and <a href="http://sandbox-ws.com/how-to-embed-forms-in-symfony-12-admin-generator-part-2">two</a> if you haven&#8217;t done so already. OK lets get started, we will be modifying the following files:</p>
<ul>
<li><strong>CategoryForm.class.php</strong> which represents the parent model</li>
<li><strong>SubcategoryI18nForm.class.php</strong> which represents the form of the i18n model of the child model</li>
<li><strong>Subcategory.class.php</strong> which represents the child model</li>
</ul>
<h3>Files need for this article</h3>
<ul>
<li><a href="http://sandbox-ws.com/wp-content/uploads/2009/01/sfWidgetFormInputDelete.class.php.zip">sfWidgetFormInputDelete</a></li>
</ul>
<h4>Schema</h4>
<pre class="brush: php;">
  category:
      _attributes: { phpName: Category }
      id: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true }
      name: { type: VARCHAR, size: '255', required: true }
      created_at: { type: TIMESTAMP, required: false }
      updated_at: { type: TIMESTAMP, required: false }
  subcategory:
      _attributes: { phpName: Subcategory, isI18N: true, i18nTable: subcategory_i18n }
      id:          { type: integer, required: true, primaryKey: true, autoincrement: true }
      category_id: { type: INTEGER, size: '11', required: true, foreignTable: category, foreignReference: id, onDelete: CASCADE}
      created_at: { type: TIMESTAMP, required: false }
      updated_at: { type: TIMESTAMP, required: false }

  subcategory_i18n:
    _attributes: { phpName: SubcategoryI18n }
    id:          { type: integer, required: true, primaryKey: true, foreignTable: subcategory, foreignReference: id, onDelete: CASCADE }
    culture:     { isCulture: true, type: varchar, size: 7, required: true, primaryKey: true }
    name:        { type: varchar, size: 50 }
</pre>
<h4>SubcategoryI18nForm</h4>
<pre class="brush: php;">
public function configure() {
    unset($this['culture'], $this['id']);
}
</pre>
<h4>Subcategory</h4>
<pre class="brush: php;">
public function getI18nObject($culture = 'en') {

    $this-&gt;setCulture($culture);

    $i18ns = $this-&gt;getSubcategoryI18ns();

    if (isset($i18ns[0])) {

        return $i18ns[0];

    }

    return null;

}
</pre>
<h4>CategoryForm</h4>
<pre class="brush: php;">
public function configure() {

// remove timestamps
unset($this['created_at'], $this['updated_at']);

	// embed forms only when editing
	if (!$this-&gt;isNew()) {

		$user_culture = sfContext::getInstance()-&gt;getUser()-&gt;getCulture();

		// embed all subcategory forms
		foreach ($this-&gt;getObject()-&gt;getSubcategorys() as $subcategory) {

			// get the subcategory_i18n model object relative to the current user culture
			$subcategory_i18n_object = $subcategory-&gt;getI18nObject($user_culture);

			// create a new subcategory_i18n form for the current subcategory model object
			$subcategory_i18n_form = new SubcategoryI18nForm($subcategory-&gt;getI18nObject('en'));

			// get widget schema of subcategory_i18n form
			$subcategory_i18n_form_widget_schema = $subcategory_i18n_form-&gt;getWidgetSchema();

			// set the input delete widget
			$subcategory_i18n_form_widget_schema['name'] = new sfWidgetFormInputDelete(array(
			'url' =&gt; 'category/deleteSubcategory',      // required
			'model_id' =&gt; $subcategory-&gt;getId(),        // required
			'confirm' =&gt; 'Sure???',                     // optional
			));

			// create a new subcategory form for the current subcategory model object
			$subcategory_form = new SubcategoryForm($subcategory);

			// embed the i18n form
			$subcategory_form-&gt;embedForm('subcategory_i18n'.$subcategory_i18n_object-&gt;getId(), $subcategory_i18n_form);

			// subcategory form widget schema
			$subcategory_form_widget_schema = $subcategory_form-&gt;getWidgetSchema();

			// disable label
			$subcategory_form_widget_schema['subcategory_i18n'.$subcategory_i18n_object-&gt;getId()]-&gt;setLabel(false);

			// embed the subcategory form in the main category form
			$this-&gt;embedForm('subcategory'.$subcategory-&gt;getId(), $subcategory_form);

			// set a custom label for the embedded form
			$this-&gt;widgetSchema['subcategory'.$subcategory-&gt;getId()]-&gt;setLabel('Subcategory: '.$subcategory-&gt;getName());

		}

		// create a new subcategory form for a new subcategory model object
		$subcategory_form = new SubcategoryForm();

		// create a new subcategory form for a new subcategory_i18n model object
		$subcategory_i18n_form = new SubcategoryI18nForm();

		// embed the subcategory_i18n form in the parent subcategory form
		$subcategory_form-&gt;embedForm('subcategory_i18n', $subcategory_i18n_form);

		// subcategory form widget schema
		$subcategory_form_widget_schema = $subcategory_form-&gt;getWidgetSchema();

		// disable label
		$subcategory_form_widget_schema['subcategory_i18n']-&gt;setLabel(false);

		// embed the subcategory form in the main category form
		$this-&gt;embedForm('subcategory', $subcategory_form);

		// set a custom label for the embedded form
		$this-&gt;widgetSchema['subcategory']-&gt;setLabel('New Subcategory');

	}
}
public function bind(array $taintedValues = null, array $taintedFiles = null) {

		if(!$this-&gt;isNew()) {

			$user_culture = sfContext::getInstance()-&gt;getUser()-&gt;getCulture();

			// remove the embedded new form if the name field was not provided
			if (is_null($taintedValues['subcategory']['subcategory_i18n']['name']) || strlen($taintedValues['subcategory']['subcategory_i18n']['name']) === 0 ) {

				unset($this-&gt;embeddedForms['subcategory'], $taintedValues['subcategory']);

				// pass the new form validations
				$this-&gt;validatorSchema['subcategory'] = new sfValidatorPass();

			} else {

				// set the category of the new subcategory form object
				$this-&gt;embeddedForms['subcategory']-&gt;getObject()-&gt;setCategory($this-&gt;getObject());

				// get subcategory embedded forms
				$subcategory_embedded_forms = $this-&gt;embeddedForms['subcategory']-&gt;getEmbeddedForms();

				// set subcategory parent of the subcategory_i18n model object
				$subcategory_embedded_forms['subcategory_i18n']-&gt;getObject()-&gt;setSubcategory($this-&gt;embeddedForms['subcategory']-&gt;getObject());

				// set the culture of the subcategory_i18n model object
				$subcategory_embedded_forms['subcategory_i18n']-&gt;getObject()-&gt;setCulture($user_culture);
			}

		}

		// call parent bind method
		parent::bind($taintedValues, $taintedFiles);

	}
</pre>
<p>As you can see this is a lot of code to copy and paste every time you need the functionality, that&#8217;s why I&#8217;m currently working on extending the Admin Generator in order to have this functionality available when you generate an admin module by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/frameworks/symfony-frameworks/how-to-embed-forms-in-symfony-12-admin-generator-part-3/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Embed Forms in Symfony 1.2 Admin Generator Part 2</title>
		<link>http://sandbox-ws.com/frameworks/symfony-frameworks/how-to-embed-forms-in-symfony-12-admin-generator-part-2</link>
		<comments>http://sandbox-ws.com/frameworks/symfony-frameworks/how-to-embed-forms-in-symfony-12-admin-generator-part-2#comments</comments>
		<pubDate>Wed, 07 Jan 2009 12:13:50 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[admin generator]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=261</guid>
		<description><![CDATA[In part one of this article we saw how to embed forms in a one-to-one relationship. But I often run into a situation where I want to edit a parent model, it&#8217;s children models, and maybe add a new child model while I&#8217;m at it, greedy I know, but isn&#8217;t that the reason why we [...]]]></description>
			<content:encoded><![CDATA[<p>In part <a href="http://sandbox-ws.com/how-to-embed-forms-in-symfony-12-admin-generator">one</a> of this article we saw how to embed forms in a one-to-one relationship. But I often run into a situation where I want to edit a parent model, it&#8217;s children models, and maybe add a new child model while I&#8217;m at it, greedy I know, but isn&#8217;t that the reason why we use the admin generator. Anyway in this article we will examine the one-to-many relationship.<br />
<span id="more-261"></span></p>
<p style="text-align: center;">Before we get started here&#8217;s a sneak peak of the <strong>CategoryForm</strong> after the modifications to be done.<br />
<img class="aligncenter size-full wp-image-269" title="embed_2" src="http://sandbox-ws.com/wp-content/uploads/2009/01/embed_2.png" alt="embed_2" width="600" height="343" /></p>
<h3>Files need for this article</h3>
<ul>
<li><a href="http://sandbox-ws.com/wp-content/uploads/2009/01/sfWidgetFormInputDelete.class.php.zip">sfWidgetFormInputDelete</a></li>
</ul>
<p>Ok, lets get started, consider the following schema:</p>
<pre class="brush: php;">category:
    _attributes: { phpName: Category }
    id: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true }
    name: { type: VARCHAR, size: '255', required: true }
    created_at: { type: TIMESTAMP, required: false }
    updated_at: { type: TIMESTAMP, required: false }
subcategory:
    _attributes: { phpName: Subcategory }
    id: { type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true }
    name: { type: VARCHAR, size: '255', required: true }
    category_id: { type: INTEGER, size: '11', required: true, foreignTable: category, foreignReference: id, onDelete: CASCADE, onUpdate: RESTRICT }
    created_at: { type: TIMESTAMP, required: false }
    updated_at: { type: TIMESTAMP, required: false }</pre>
<h3>Steps needed to achieve the required result</h3>
<ol>
<li>Modify the <strong>CategoryForm</strong> to include embedded forms for all available subcategories of the current category.</li>
<li>Modify the widget of the <strong>name</strong> field in the subcategory</li>
<li>Modify the CategoryForm to add a new blank subcategory form</li>
<li>Override the <strong>bind</strong> method of the <strong>sfForm</strong> class to skip saving and validating the new subcategory form if the <strong>name</strong> field was left blank</li>
<li>Remove fields from <strong>SubcategoryForm</strong></li>
</ol>
<h4>Embedded forms for all available subcategories of the current category [step 1, 2, and 3]</h4>
<pre class="brush: php;">// lib/forms/CategoryForm.class.php
public function configure() {

  // remove timestamps
  unset($this['created_at'], $this['updated_at']);

  // embed forms only when editing
  if (!$this-&gt;isNew()) {

    // embed all subcategory forms
    foreach ($this-&gt;getObject()-&gt;getSubcategorys() as $subcategory) {

    // create a new subcategory form for the current subcategory model object
    $subcategory_form = new SubcategoryForm($subcategory);

    // embed the subcategory form in the main category form
    $this-&gt;embedForm('subcategory'.$subcategory-&gt;getId(), $subcategory_form);

    // set a custom label for the embedded form
    $this-&gt;widgetSchema['subcategory'.$subcategory-&gt;getId()]-&gt;setLabel('Subcategory: '.$subcategory-&gt;getName());

    // change the name widget to sfWidgetFormInputDelete
    $this-&gt;widgetSchema['subcategory'.$subcategory-&gt;getId()]['name'] = new sfWidgetFormInputDelete(array(
    'url' =&gt; 'category/deleteSubcategory',      // required
    'model_id' =&gt; $subcategory-&gt;getId(),        // required
    'confirm' =&gt; 'Sure???',                     // optional
    ));

  }

  // create a new subcategory form for a new subcategory model object
  $subcategory_form = new SubcategoryForm();

  // embed the subcategory form in the main category form
  $this-&gt;embedForm('subcategory', $subcategory_form);

  // set a custom label for the embedded form
  $this-&gt;widgetSchema['subcategory']-&gt;setLabel('New Subcategory');

  }
}</pre>
<h4>Override the bind method</h4>
<pre class="brush: php;">public function bind(array $taintedValues = null, array $taintedFiles = null) {

	// remove the embedded new form if the name field was not provided
	if (is_null($taintedValues['subcategory']['name']) || strlen($taintedValues['subcategory']['name']) === 0 ) {

		unset($this-&gt;embeddedForms['subcategory'], $taintedValues['subcategory']);

		// pass the new form validations
		$this-&gt;validatorSchema['subcategory'] = new sfValidatorPass();

	} else {

		// set the category of the new subcategory form object
		$this-&gt;embeddedForms['subcategory']-&gt;getObject()-&gt;
                setCategory($this-&gt;getObject());

	}

	// call parent bind method
	parent::bind($taintedValues, $taintedFiles);

}</pre>
<h4>Remove fields from SubcategoryForm</h4>
<pre class="brush: php;">public function configure(){
  unset($this['created_at'], $this['updated_at'], $this['category_id']);
}</pre>
<h4>Now we create the action <em>deleteSubcategory</em> in <strong>category module</strong></h4>
<pre class="brush: php;">
// apps/backend/modules/category/actions/actions.class.php
public function executeDeleteSubcategory(sfWebRequest $request) {
  $sub_category = SubcategoryPeer::retrieveByPk($request-&gt;getParameter('id'));
  $sub_category-&gt;delete();
  $this-&gt;redirect('@category_edit?id='.$sub_category-&gt;getCategory()-&gt;getId());
}
</pre>
<p>That&#8217;s it, I hop that you enjoyed this article.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/frameworks/symfony-frameworks/how-to-embed-forms-in-symfony-12-admin-generator-part-2/feed</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Functional Testing a Secured Module</title>
		<link>http://sandbox-ws.com/frameworks/symfony-frameworks/functional-testing-a-secured-module</link>
		<comments>http://sandbox-ws.com/frameworks/symfony-frameworks/functional-testing-a-secured-module#comments</comments>
		<pubDate>Mon, 05 Jan 2009 16:08:32 +0000</pubDate>
		<dc:creator>Ahmed El.Hussaini</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[lime]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://sandbox-ws.com/?p=244</guid>
		<description><![CDATA[Most of the modules we work on in symfony are secured with the popular sfGuardPlugin, but by default you can&#8217;t test a secured module each time you will try to access an action from your functional testing file will result in failure of the test. To make my point a little bit clear consider that [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the modules we work on in <a href="http://symfony-project.org/" target="_blank">symfony</a> are secured with the popular <a href="http://www.symfony-project.org/plugins/sfGuardPlugin" target="_blank">sfGuardPlugin</a>, but by default you can&#8217;t test a secured module each time you will try to access an action from your functional testing file will result in failure of the test. To make my point a little bit clear consider that we have a module called <b>foobar</b> in an application called <b>backend</b>. Of course as you know that when you create the module, automatically a file called <b>foobarActionsTest.php</b> is created in <b>test/functional/backend</b>.<br />
<span id="more-244"></span><br />
So we edit the <b>foobarActionsTest.php</b> contents to match the following snippet:</p>
<pre class="brush: php;">
// test/functional/backend/foobarActionsTest.php
include(dirname(__FILE__).'/../../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());
$browser-&gt;get('foobar/index')-&gt;isStatusCode(200);
</pre>
<p>Now we run the following command to test the module:</p>
<pre class="brush: php;">
php symfony test:functional backend foobarActions
</pre>
<p>Since the backend application is secured, the above test will result in the following error:<br />
<img src="http://sandbox-ws.com/wp-content/uploads/2009/01/test_1.png" alt="test_1" title="test_1" width="630" height="126" class="aligncenter size-full wp-image-248" /></p>
<p>The 401 response code we got means Unauthorized access, since the user isn&#8217;t logged, so this is what we need to make the test successful, we need the user to login first before we try to access the foobar/index action.</p>
<p>The solutions is rather simple, first we create a file called <b>sf_guard.php</b>:</p>
<pre class="brush: php;">
// test/functional/sf_guard.php
function signin($username, $password, $browser) {
  $browser = new sfTestFunctional(new sfBrowser());
  return $browser-&gt;
    info(sprintf('Signin user using username &quot;%s&quot; and password &quot;%s&quot;', $username, $password))-&gt;
    post('/sfGuardAuth/signin', array('signin' =&gt; array('username' =&gt; $username, 'password' =&gt; $password,)))-&gt;
    isRedirected()
  ;
}
</pre>
<p>Next we modify the <b>foobarActionsTest.php</b>:</p>
<pre class="brush: php;">
include(dirname(__FILE__).'/../sf_guard.php');
include(dirname(__FILE__).'/../../bootstrap/functional.php');

$username = 'admin';
$password = 'admin';
$browser = new sfTestFunctional(new sfBrowser());
signin($username, $password, $browser)-&gt;get('/foobar/index')-&gt;isStatusCode(200);
</pre>
<p>Now we run the test again, and it passes gracefully<br />
<img src="http://sandbox-ws.com/wp-content/uploads/2009/01/test_2.png" alt="test_2" title="test_2" width="590" height="128" class="aligncenter size-full wp-image-250" /></p>
<p>Now as <a href="http://prendreuncafe.com/">Niko</a> mentioned in his comment, her is another better and simpler way:<br />
 First we create a class <b>sfGuardTestFunctional</b> in <b>lib</b> folder</p>
<pre class="brush: php;">
class sfGuardTestFunctional extends sfTestFunctional {

	public function signin($username, $password) {
		return $this-&gt;
			info(sprintf('Signin user using username &quot;%s&quot; and password &quot;%s&quot;', $username, $password))-&gt;
			post('/sfGuardAuth/signin', array('signin' =&gt; array('username' =&gt; $username, 'password' =&gt; $password,)))-&gt;
			isRedirected()
		;
	}
}
</pre>
<p>Next we modify the <b>foobarActionsTest.php</b></p>
<pre class="brush: php;">
include(dirname(__FILE__).'/../../bootstrap/functional.php');

$username = 'admin';
$password = 'admin';

$browser = new sfGuardTestFunctional(new sfBrowser());
$browser-&gt;
	get('/foobar/index')-&gt;
	isStatusCode(401)-&gt;
	signin($username, $password)-&gt;
	get('/foobar/index')-&gt;
	isStatusCode(200)
;
</pre>
<p>That way it&#8217;s much simpler and more efficient, thanks again <a href="http://prendreuncafe.com/">Niko</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox-ws.com/frameworks/symfony-frameworks/functional-testing-a-secured-module/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
