<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>pascal renet &#187; PHP</title>
	<atom:link href="http://www.renet-web.net/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.renet-web.net</link>
	<description>The ramblings of a frog in Oz</description>
	<lastBuildDate>Mon, 31 Oct 2011 12:31:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<copyright>Copyright &#xA9; renet@web 2010 </copyright>
	<managingEditor>wordpress@renet-web.net (pascal renet)</managingEditor>
	<webMaster>wordpress@renet-web.net (pascal renet)</webMaster>
	<image>
		<url>http://www.renet-web.net/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>pascal renet</title>
		<link>http://www.renet-web.net</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>Just not another WordPress weblog</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Society &#38; Culture" />
	<itunes:author>pascal renet</itunes:author>
	<itunes:owner>
		<itunes:name>pascal renet</itunes:name>
		<itunes:email>wordpress@renet-web.net</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.renet-web.net/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>Building RIA&#8217;s using SAP, Flex and Php</title>
		<link>http://www.renet-web.net/2009/07/20/building-rias-using-sap-flex-and-php/</link>
		<comments>http://www.renet-web.net/2009/07/20/building-rias-using-sap-flex-and-php/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 12:00:39 +0000</pubDate>
		<dc:creator>Pascal</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[saprfc]]></category>

		<guid isPermaLink="false">http://www.renet-web.net/?p=427</guid>
		<description><![CDATA[<a href="http://www.renet-web.net/wp-content/uploads/2009/07/RIASMALL.jpg"><img src="http://www.renet-weAccording to <a href="http://en.wikipedia.org/">Wikipedia</a>, "<a href="http://en.wikipedia.org/wiki/Rich_Internet_application">Rich Internet Applications</a> are web applications that have most of the characteristics of desktop applications, typically delivered by way of standards based web browser plug-ins or independently via sandboxes or virtual machines". ]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.renet-web.net/wp-content/uploads/2009/07/ScreenShot028.jpg" alt="ScreenShot028" title="ScreenShot028" width="500" height="170" class="aligncenter size-full wp-image-475" /></p>
<p>According to <a href="http://en.wikipedia.org/">Wikipedia</a>, &#8220;<a href="http://en.wikipedia.org/wiki/Rich_Internet_application">Rich Internet Applications</a> are web applications that have most of the characteristics of desktop applications, typically delivered by way of standards based web browser plug-ins or independently via sandboxes or virtual machines&#8221;. I don&#8217;t think that this definition does do it any justice &#8211; I think that RIA&#8217;s are:</p>
<ul>
<li>Applications that offer a visually rich and engaging user interface</li>
<li>Applications that offer content richness and useful and diverse functionalities</li>
</ul>
<p>In other words it has to deliver functionality and it has to do so in an engaging UI &#8211; the argument being that such applications will deliver a greater employee productivity and/or customer loyalty. I would certainly vouch for that &#8211; go see <a href="https://create.ondemand.com/explorer">a demo</a> of <a href="http://www.sap.com/">SAP</a> <a href="http://www.sap.info/en/solutions/business_user_business_objects/neue_BI-Loesungen_en.html">Business Explorer </a>to see what I mean (you can even<br />
upload your own data and play around with that).</p>
<p>As a continuation to my <a href="http://www.renet-web.net/2006/05/22/re-writing-sap-with-php-part-15/">experiments</a> in marrying technologies such as <a href="http://www.php.net/">Php</a>, <a href="http://pear.php.net/">Pear</a> &#038; Ajax to query a <a href="http://www.sap.com/">SAP</a> database and expose the data to a user in a visually appealing form, it seemed only fitting that I would give this RIA thing a shot too. You only need to google terms such as &#8220;<a href="http://www.google.com.au/search?q=SAP+FLEX">SAP FLEX</a>&#8221; to see that there is<br />
a wealth of information out there on that topic showcasing these two platforms with plenty of whoa factor. Being from a logistics background I thought it would be appropriate to use logistics functions in my examples.</p>
<p>So in this post I&#8217;ll be looking at the following scenarios:</p>
<ul>
<li>A sales application using SAP, Flex and Php (http service call method)</li>
<li>A production order application using SAP, Flex and Php (http service call method)</li>
<li>A sample sales application using SAP and Flex (web service call method)</li>
</ul>
<p>The tools of choice for my experiments today are:</p>
<ul>
<li><a href="http://www.adobe.com/">Adobe</a> <a href="http://www.adobe.com/products/flex/">Flex</a> (which is built on top of <a href="http://www.eclipse.org/">Eclipse</a> &#8211; the same tool used to build the SAP Developer Studio). Adobe is very generously offering you the chance to download a try-before-you-buy fully functional demo version for 60 days (if you have already have Eclipse or SAP developer Studio you may elect to download the plug-in instead &#8211; although I have not tried that). </li>
<li><a href="http://www.easyphp.org/">Easyphp</a> which is a nice WAMP (Windows Apache Mysql Php) package that I have been using for years &#8211; php in version 5.2.8</li>
<li>The <a href="http://saprfc.sourceforge.net/">SAPrfc</a> extension module for Php</li>
<li>Of course SAP. The SAP backend system I&#8217;ll be using is a SAP ECC 6.0 system.</li>
</ul>
<p><span id="more-427"></span></p>
<p>In the first two scenarios, I&#8217;ll be using php as the go between Flex and SAP.<br />
<img src="http://www.renet-web.net/wp-content/uploads/2009/07/ScreenShot0221.jpg" alt="ScreenShot022" title="ScreenShot022" width="500" height="274" class="aligncenter size-full wp-image-471" /><br />
Essentially the Flex application will call an http service that is a php script to which we&#8217;ll be posting some variables. Php will then wrap those variables in an RF call to the SAP backend system. Assuming all goes well, SAP will send a response that needs to be formatted in a xml like structure so that that it can be properly interpreted by the Flex application &#8211; again php will take care of that.</p>
<pre class="brush: php; title: ; notranslate">
echo &quot;&lt;CUSTRECS&gt;\n&quot;;
		for($i=1; $i&lt;=$ADDRESSDATA ; $i++){
			$DATA = saprfc_table_read ($fce,&quot;ADDRESSDATA&quot;,$i);
			echo &quot;&lt;CUSTREC&gt;\n&lt;CUSTNUMB&gt;&quot; . $DATA[&quot;CUSTOMER&quot;] . &quot;&lt;/CUSTNUMB&gt;\n&quot;;
			echo &quot;&lt;CUSTADR&gt;&quot; . $DATA[&quot;STREET&quot;] . &quot;&lt;/CUSTADR&gt;\n&quot;;
			echo &quot;&lt;CUSTCOUNT&gt;&quot; . $DATA[&quot;COUNTRY&quot;] . &quot;&lt;/CUSTCOUNT&gt;\n&quot;;
			echo &quot;&lt;CUSTCITY&gt;&quot; . $DATA[&quot;CITY&quot;] . &quot;&lt;/CUSTCITY&gt;\n&quot;;
			echo &quot;&lt;CUSTNAME&gt;&quot; . $DATA[&quot;NAME&quot;] . &quot;&lt;/CUSTNAME&gt;\n&lt;/CUSTREC&gt;\n&quot;;
		}
echo &quot;&lt;/CUSTRECS&gt;&quot;;
</pre>
<p>will yield an xml response to the Flex application as below,</p>
<pre class="brush: xml; title: ; notranslate">
&lt;CUSTRECS&gt;
	&lt;CUSTREC&gt;
		&lt;CUSTNUMB&gt;0000100000&lt;/CUSTNUMB&gt;
		&lt;CUSTADR&gt;800 Gardiner Street&lt;/CUSTADR&gt;
		&lt;CUSTCOUNT&gt;AU&lt;/CUSTCOUNT&gt;
		&lt;CUSTCITY&gt;Darwin&lt;/CUSTCITY&gt;
		&lt;CUSTNAME&gt;Customer domestic 00&lt;/CUSTNAME&gt;
	&lt;/CUSTREC&gt;
&lt;/CUSTRECS&gt;
</pre>
<p>and in the Flex script below, on lines 5 and 6, you can see how I&#8217;ll be retrieving the customer number (CUSTNUMB) and customer name (CUSTNAME) in my Flex datagrid.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;mx:DataGrid dataProvider=&quot;{srv3.lastResult.CUSTRECS.CUSTREC}&quot;
width=&quot;368&quot; height=&quot;119&quot; y=&quot;10&quot; x=&quot;10&quot; id=&quot;dg1&quot;
change=&quot;dgChangeHandler()&quot; dropShadowEnabled=&quot;true&quot;&gt;
	&lt;mx:columns&gt;
		&lt;mx:DataGridColumn dataField=&quot;CUSTNUMB&quot; headerText=&quot;Customer Number&quot;/&gt;
		&lt;mx:DataGridColumn dataField=&quot;CUSTNAME&quot; headerText=&quot;Customer Name&quot; textAlign=&quot;left&quot;/&gt;
	&lt;/mx:columns&gt;
&lt;/mx:DataGrid&gt;
</pre>
<p>So, without further adue, below are explanations and swf animations for each process.</p>
<h3>A simple sales order application</h3>
<p><img src="http://www.renet-web.net/wp-content/uploads/2009/07/ScreenShot023.jpg" alt="ScreenShot023" title="ScreenShot023" width="500" height="384" class="aligncenter size-full wp-image-472" /><br />
This application uses multiple http service calls and its key elements are:</p>
<ul>
<li>An http service calling BAPI_CUSTOMER_GETLIST is used to populate one datagrid</li>
<li>An http service calling BAPI_MATERIAL_GETLIST  is used to populate another datagrid. The product pictures are stored locally on the web server, and the picture filename corresponds to the material number in SAP (eg if the material is called Y126, we have a picture file called Y126.jpg)</li>
<li>The user will then pick the customer expected delivery date, the required quantity and indicate a selling price</li>
<li>The Order button will then post the data to another http service in order to create the sales order (by calling the FM CREATE_SD_ORDERDAT1) in SAP. If all goes well a response with the sales order number will be issued to the user.</li>
</ul>
<p>* Note that some values have been hard-coded in the php files (but they could just as well have come from posted variables). Also, the user will be required to type in his SAP credentials (the SAP server information has been hardcoded in the php file, but we are passing the SAP username and password to the script).</p>
<p>Here is a swf example of this application.<br />
<a href="http://www.renet-web.net/wp-content/uploads/2009/07/sales_demo.swf" lightbox.[width]="1131"  lightbox.height="743"  title="Give it time to load - Wait a few seconds" class="lightbox"><img src="http://www.renet-web.net/wp-content/uploads/2009/07/prodsales.jpg" width="500" height="236" /></a></p>
<h3>A simple production order application</h3>
<p><img src="http://www.renet-web.net/wp-content/uploads/2009/07/ScreenShot025.jpg" alt="ScreenShot025" title="ScreenShot025" width="500" height="269" class="aligncenter size-full wp-image-474" /><br />
This application uses multiple http service calls and its key elements are:</p>
<ul>
<li>There are two tabs in this application. One tab will show the data in a tabular form whilst the other tab is geared toward delivering the information graphically.</li>
<li>An initial http service calling BAPI_PRODORD_GET_LIST is used to populate a datagrid containing production order header details. The response provided by SAP is first interpreted and transformed into xml by Php.</li>
<li>The same http service above will not only deliver production order header data, but also aggregated data that will be used to drive some of the charts in the graphical dashboards. All this data is delivered in one xml formatted stream.</li>
<li>Whenever a line is selected in the production order header datagrid, it will trigger for another service call to be executed and this time call BAPI_PRODORD_GET_DETAIL in order to retrieve the production order component and operation details.</li>
</ul>
<p><img src="http://www.renet-web.net/wp-content/uploads/2009/07/ScreenShot024.jpg" alt="ScreenShot024" title="ScreenShot024" width="500" height="266" class="aligncenter size-full wp-image-473" /></p>
<p>Here is a swf example of this application.<br />
<a href="http://www.renet-web.net/wp-content/uploads/2009/07/prod_order_demo.swf" rev="width:1131, height:743"  rel="milkbox[gall3]" title="Give it time to load - Wait a few seconds" class="lightbox" ><img src="http://www.renet-web.net/wp-content/uploads/2009/07/prodsales.jpg" width="500" height="236" /></a></p>
<h3> A very simple production order header report</h3>
<p>In this last example, similar to the one above we will consume a web service calling BAPI_PRODORD_GET_LIST and populate the retrieved data in a Flex datagrid &#8211; nothing more here &#8211; if just to show another method to get the production order header information.</p>
<p>The corresponding Flex Project can be downloaded <a href="http://www.renet-web.net/mint/pepper/orderedlist/downloads/download.php?file=http://www.renet-web.net/wp-content/uploads/2009/07/SAP_BAPI_TST.zip">here</a>. Remember to change your server name and port before using it.</p>
<p>Here is a swf example of this application.<br />
<a href="http://www.renet-web.net/wp-content/uploads/2009/07/web_service.swf" rev="width:1131, height:743"  rel="milkbox[gall4]" title="Give it time to load - Wait a few seconds" class="lightbox" ><img src="http://www.renet-web.net/wp-content/uploads/2009/07/webserv.jpg" width="500" height="234" /></a></p>
<h3>Recommended readings</h3>
<p><a href="https://forums.sdn.sap.com:443/forum.jspa?forumID=272&#038;start=0"><br />
Rich Internet Application Development on SDN</a></br><br />
<a href="https://forums.sdn.sap.com:443/forum.jspa?forumID=124&#038;start=0">PHP Development on SDN</a></br><br />
<a href="https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/7130">Engaging User Interfaces with Adobe Flex</a><br />
<a href="https://wiki.sdn.sap.com/wiki/display/EmTech/Consuming+ABAP+Web+Services+using+Flex">Consuming ABAP Web Services using Flex</a> a hands-on tutorial given by <a href="http://matthiaszeller.com/blog/">Matthias Zeller</a>, <a href="http://blog.ewherrmann.com/">Ed Herrmann</a>, and <a href="http://blog.danmcweeney.com/">Dan McWeeney</a> </p>
<p>I hope you find these examples interesting and if you do find them useful and if there is anything you&#8217;d like to share, then please do leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.renet-web.net/2009/07/20/building-rias-using-sap-flex-and-php/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>&#8230;slick slide and fade effects AJAXified</title>
		<link>http://www.renet-web.net/2006/03/09/slick-slide-and-fade-effects-ajaxified/</link>
		<comments>http://www.renet-web.net/2006/03/09/slick-slide-and-fade-effects-ajaxified/#comments</comments>
		<pubDate>Thu, 09 Mar 2006 05:48:48 +0000</pubDate>
		<dc:creator>Pascal</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.renet-web.net/?p=140</guid>
		<description><![CDATA[<p>Following on my last <a href="http://www.renet-web.net/?p=139" title="link to post: Adding slick slide and fade effects">post</a> for which I got some encouraging <a href="http://www.renet-web.net/?p=139#comments">comments</a> and suggestions I thought I’d try to make the tabbed navigation better. I’ll let you be the&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Following on my last <a href="http://www.renet-web.net/?p=139" title="link to post: Adding slick slide and fade effects">post</a> for which I got some encouraging <a href="http://www.renet-web.net/?p=139#comments">comments</a> and suggestions I thought I’d try to make the tabbed navigation better. I’ll let you be the judge of that.<br />
This evolution still uses the <a href="http://script.aculo.us/">script.aculo.us</a> javascript libraries. You can download them <a href="http://script.aculo.us/downloads">here</a>. Once you have done that you can copy the ‘
<pre class="brush: plain; title: ; notranslate">c3Jj</pre>
<p>’ and ‘
<pre class="brush: plain; title: ; notranslate">bGli</pre>
<p>’ directories into your working directory.<span id="more-140"></span></p>
<p>The main points of this version are:<br />
- The solution has been AJAXified. The content of the tabs (except for <strong>tab 1</strong> which is loaded with the page) is only fetched if a visitor clicks on the appropriate tab. The main advantages I see here, are that content is only loaded if the visitor wants to see it and the content of each tab is maintained in its own separate file (easier to maintain).<br />
- The ‘back’ button issue. That is partially fixed. If you navigate through several tabs, you still have to click the ‘back’ button twice (maximum) in order to really step back a page (funnily enough, in Internet Explorer one click suffices no matter how many tabs you go through!). If anyone out there can fix it…I’m all ears.</p>
<p>So let&#8217;s look at the code  : </p>
<p>This will correspond to the tabs:</p>
<pre class="brush: plain; title: ; notranslate">PHVsIGlkPSJtYWlubmF2Ij4=</pre>
<pre class="brush: plain; title: ; notranslate">CTxsaT48YSBocmVmPSIjIiBuYW1lPSIjdGFiMSIgIG9uY2xpY2s9InNob3codGhpcyk7Ij5UYWIgMTwvYT48L2xpPg==</pre>
<pre class="brush: plain; title: ; notranslate">CTxsaT48YSBocmVmPSIjIiBuYW1lPSIjdGFiMiIgIG9uY2xpY2s9InNob3codGhpcyk7Ij5UYWIgMjwvYT48L2xpPg==</pre>
<pre class="brush: plain; title: ; notranslate">CTxsaT48YSBocmVmPSIjIiBuYW1lPSIjdGFiMyIgIG9uY2xpY2s9InNob3codGhpcyk7Ij5UYWIgMzwvYT48L2xpPg==</pre>
<pre class="brush: plain; title: ; notranslate">CTxsaT48YSBocmVmPSIjIiBuYW1lPSIjdGFiNCIgIG9uY2xpY2s9InNob3codGhpcyk7Ij5UYWIgNDwvYT48L2xpPg==</pre>
<pre class="brush: plain; title: ; notranslate">PC91bD4=</pre>
<p>As opposed to the previous version, the
<pre class="brush: plain; title: ; notranslate">YSBocmVm</pre>
<p> link is now
<pre class="brush: plain; title: ; notranslate">PSIjIg==</pre>
<p>. However I have added a
<pre class="brush: plain; title: ; notranslate">bmFtZQ==</pre>
<p> tag attribute. Each tab has its own name (<strong>#tab1</strong>, <strong>#tab2</strong>, etc&#8230;). We can also this see that every time I click on a tab I will execute the
<pre class="brush: plain; title: ; notranslate">c2hvdyh0aGlzKQ==</pre>
<p> function.</p>
<p>The following will correspond to the part where the contents of each tab will be loaded:</p>
<pre class="brush: plain; title: ; notranslate">PGRpdiBpZD0idGFiMSIgY2xhc3M9InRhYm94IiBzdHlsZT0iZGlzcGxheTogbm9uZTsiPjxpbWcgc3JjPSIuL3NwaW5uZXIuZ2lmIiAvPjwvZGl2Pg==</pre>
<pre class="brush: plain; title: ; notranslate">PGRpdiBpZD0idGFiMiIgY2xhc3M9InRhYm94IiBzdHlsZT0iZGlzcGxheTogbm9uZTsiPjxpbWcgc3JjPSIuL3NwaW5uZXIuZ2lmIiAvPjwvZGl2Pg==</pre>
<pre class="brush: plain; title: ; notranslate">PGRpdiBpZD0idGFiMyIgY2xhc3M9InRhYm94IiBzdHlsZT0iZGlzcGxheTogbm9uZTsiPjxpbWcgc3JjPSIuL3NwaW5uZXIuZ2lmIiAvPjwvZGl2Pg==</pre>
<pre class="brush: plain; title: ; notranslate">PGRpdiBpZD0idGFiNCIgY2xhc3M9InRhYm94IiBzdHlsZT0iZGlzcGxheTogbm9uZTsiPjxpbWcgc3JjPSIuL3NwaW5uZXIuZ2lmIiAvPjwvZGl2Pg==</pre>
<p>In other words, if I click on <strong>TabX</strong>, then the contents of it will be loaded in
<pre class="brush: plain; title: ; notranslate">ZGl2IGlkPSJ0YWJYIg==</pre>
<p>.</p>
<p>All the tabs need to be hidden when I load the page. Remember, we only want to show them if the visitor wants to see them. To do so, each
<pre class="brush: plain; title: ; notranslate">ZGl2</pre>
<p> has a
<pre class="brush: plain; title: ; notranslate">c3R5bGU9ImRpc3BsYXk6IG5vbmU7Ig==</pre>
<p> attribute. Also, note that the content of each
<pre class="brush: plain; title: ; notranslate">ZGl2</pre>
<p> is an image (to show whilst the page loads). I could just as easily have put nothing.</p>
<p>So now that I have my tabs and my
<pre class="brush: plain; title: ; notranslate">ZGl2</pre>
<p>&#8216;s we need some magic to make it all happen.</p>
<p>The first thing we want (and this is optional) is to load and show the content of  <strong>tab1</strong> (you&#8217;ll remember that <strong>tab1</strong>, along with all the other tabs has been hidden). So what we need to do, is add an
<pre class="brush: plain; title: ; notranslate">b25sb2Fk</pre>
<p> command to the
<pre class="brush: plain; title: ; notranslate">PGJvZHk+</pre>
<p> tag of the page. It should look something like this.</p>
<pre class="brush: plain; title: ; notranslate">PGJvZHkgb25sb2FkPSJzdGFydCgpIj4=</pre>
<p>Basically we&#8217;re saying, when you load the
<pre class="brush: plain; title: ; notranslate">PGJvZHk+</pre>
<p>, execute the function
<pre class="brush: plain; title: ; notranslate">c3RhcnQoKQ==</pre>
<p>.<br />
This is what the
<pre class="brush: plain; title: ; notranslate">c3RhcnQoKQ==</pre>
<p> function looks like.</p>
<pre class="brush: plain; title: ; notranslate">ZnVuY3Rpb24gc3RhcnQoKQ==</pre>
<pre class="brush: plain; title: ; notranslate">CQl7</pre>
<pre class="brush: plain; title: ; notranslate">CQkJbmV3IEFqYXguVXBkYXRlcigndGFiMScsICd0YWIxLnBocCcsIHthc3luY2hyb25vdXM6dHJ1ZX0pOw==</pre>
<pre class="brush: plain; title: ; notranslate">CQkJbmV3IEVmZmVjdC5CbGluZERvd24oJ3RhYjEnICx7ZHVyYXRpb246MS4wfSk7</pre>
<pre class="brush: plain; title: ; notranslate">CQl9</pre>
<p><em>In the first line</em><br />
We are saying that we want to update the content of
<pre class="brush: plain; title: ; notranslate">ZGl2IGlkPSJ0YWIxIg==</pre>
<p> with the contents of a file called
<pre class="brush: plain; title: ; notranslate">dGFiMS5waHA=</pre>
<p>.</p>
<p><em>In the second line</em><br />
We are just revealing
<pre class="brush: plain; title: ; notranslate">ZGl2IGlkPSJ0YWIxIg==</pre>
<p> by using a <a href="http://wiki.script.aculo.us/scriptaculous/show/Effect.BlindDown">BlindDown</a> effect. Now we need a function that will do the same thing for all the other tabs.</p>
<p>Earlier on we saw that every tab is declared like so:</p>
<pre class="brush: plain; title: ; notranslate">PGxpPjxhIGhyZWY9IiMiIG5hbWU9IiN0YWJYIiAgb25jbGljaz0ic2hvdyh0aGlzKTsiPlRhYiBYPC9hPjwvbGk+</pre>
<p>I&#8217;m referencing a
<pre class="brush: plain; title: ; notranslate">c2hvdyh0aGlzKQ==</pre>
<p> function. This is what that function looks like.</p>
<pre class="brush: plain; title: ; notranslate">ZnVuY3Rpb24gc2hvdyhsKQ==</pre>
<pre class="brush: plain; title: ; notranslate">CQl7</pre>
<pre class="brush: plain; title: ; notranslate">CQkJaGlkZW0oKTs=</pre>
<pre class="brush: plain; title: ; notranslate">CQkJdmFyIGlkPWwubmFtZS5tYXRjaCgvIyhcdy4rKS8pWzFdOw==</pre>
<pre class="brush: plain; title: ; notranslate">CQkgICAgbmV3IEVmZmVjdC5CbGluZERvd24oaWQgLHtkdXJhdGlvbjoxLjB9KTs=</pre>
<pre class="brush: plain; title: ; notranslate">CQkgICAgbmV3IEFqYXguVXBkYXRlcihpZCwgaWQrJy5waHAnLCB7YXN5bmNocm9ub3VzOnRydWV9KTs=</pre>
<pre class="brush: plain; title: ; notranslate">CQl9</pre>
<p><em>The first line:</em><br />
The function
<pre class="brush: plain; title: ; notranslate">aGlkZW0oKQ==</pre>
<p> was already explained in my previous <a href="http://www.renet-web.net/?p=139">post</a>. All it does, is hide all the
<pre class="brush: plain; title: ; notranslate">ZGl2</pre>
<p>&#8216;s that have a
<pre class="brush: plain; title: ; notranslate">ZGl2IGlkPSJ0YWIuLiI=</pre>
<p> 1 to 4.</p>
<p><em>The second line:</em><br />
Each tab has a name attribute (
<pre class="brush: plain; title: ; notranslate">bmFtZT0iI3RhYlgi</pre>
<p>). In that line I&#8217;m getting rid of the
<pre class="brush: plain; title: ; notranslate">Iw==</pre>
<p> character. In other words I have
<pre class="brush: plain; title: ; notranslate">I3RhYlg=</pre>
<p> coming in and
<pre class="brush: plain; title: ; notranslate">dGFiWA==</pre>
<p> coming out. The variable
<pre class="brush: plain; title: ; notranslate">aWQ=</pre>
<p> will now have that value assigned to it.</p>
<p>The last two lines are identical to those found in the function
<pre class="brush: plain; title: ; notranslate">c3RhcnQoKQ==</pre>
<p>, except that here we are using the variable
<pre class="brush: plain; title: ; notranslate">aWQ=</pre>
<p> (because
<pre class="brush: plain; title: ; notranslate">aWQ=</pre>
<p> could be <strong>tab1</strong>, <strong>tab2</strong>, <strong>tab3</strong> or <strong>tab4</strong>).
<pre class="brush: plain; title: ; notranslate">aWQ=</pre>
<p> will be replaced by the value <strong>tabX</strong> when the function is called. You&#8217;ll also notice that to keep things simple the scripts I call up are named
<pre class="brush: plain; title: ; notranslate">dGFiMS5waHA=</pre>
<p>,
<pre class="brush: plain; title: ; notranslate">dGFiMi5waHA=</pre>
<p> (
<pre class="brush: plain; title: ; notranslate">aWQrJ3BocCc=</pre>
<p>).</p>
<p>This <a href="http://www.renet-web.net/maxex/index.php">link</a> will bring you to a page where you can test the <a href="http://www.renet-web.net/maxex/script2.php">new</a> and <a href="http://www.renet-web.net/maxex/script1.php">old</a> version.</p>
<p>That&#8217;s it. As usual, your  comments and suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.renet-web.net/2006/03/09/slick-slide-and-fade-effects-ajaxified/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Nice gallery thumbnails in PHP</title>
		<link>http://www.renet-web.net/2005/09/28/nice-gallery-thumbnails-in-php/</link>
		<comments>http://www.renet-web.net/2005/09/28/nice-gallery-thumbnails-in-php/#comments</comments>
		<pubDate>Tue, 27 Sep 2005 21:55:43 +0000</pubDate>
		<dc:creator>Pascal</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.renet-web.net/?p=61</guid>
		<description><![CDATA[<p>Some time ago when I first started publishing photos to the web I used a <a href="http://www.php.net/">php</a> package called WihPhoto which used to be available form <a href="http://www.wihsy.com/">wihsy.com</a>. I say &#8216;used to be&#8217; because that site now only displays a&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Some time ago when I first started publishing photos to the web I used a <a href="http://www.php.net/">php</a> package called WihPhoto which used to be available form <a href="http://www.wihsy.com/">wihsy.com</a>. I say &#8216;used to be&#8217; because that site now only displays a dull &#8216;currently offline&#8217; page. I used a very early version of it and I believe that follow-on versions got a lot of flack because there was a security hole in them. Anyway, I think that it is a shame that it does no longer seem to be updated as it is a great package.</p>
<p>That said, with time I became more and more demanding in terms of what functionalities I wanted it to have and in terms of integration with the general layout of my site. With no ongoing development I had no choice but to add those functionalities myself.</p>
<p>Amongst the various enhancements that I added to it was the ability to generate square thumbnails and I guess you could say that it was a two step process. </p>
<ul>
<li>1 &#8211; Generate square thumbnails</li>
<li>2 &#8211; Get rid of the &#8216;jags&#8217; in the pictures</li>
</ul>
<p>In this post I&#8217;ll discuss how you can generate square thumbnails using <a href="http://www.php.net/">php</a>.</p>
<p>The first reason for which I wanted to generate square thumbnails is because I used to post digital pictures that were both in landscape and portrait mode. The thumbnails generated were just resized versions of the larger pictures &#8211; so I ended up with landscape and portrait mode thumbnails. This causes some issues in terms of layout because the width of a portrait mode picture is obviously less than that of landscape mode pictures. This means that your page could have thumbnails arranged as below:<br />
<img src="/wp-content/iimages/tutorialthumbs/screen001.jpg" width="301" height="174" alt="" title="" /></p>
<p>That does not look very nice. With a bit of simple code you could  have your page look something like that shown below. I.e you could centre align all you thumbnails. It&#8217;s better, but it is not good enough. Also you could have a mix of portrait and landscape mode thumbnails on a line. You layout could look like this.<br />
<img src="/wp-content/iimages/tutorialthumbs/screen002.jpg" width="329" height="226" alt="" title="" /></p>
<p>Everything is nicely centered, but it is not visually appealing. So in came the idea of square thumbnails. What I find great with square thumbnails is that you do not use the complete picture to generate the thumbnails, i.e you call on your visitors&#8217; curiosity to show them part of the picture. Another great advantage of square thumbnails is control: If you generate thumbnails that are 100*100 pixels you know exactly how much space you are going to need if you put 5 of them on a line.</p>
<p>Now to be clear I&#8217;m not talking about taking 640*480 picture and resizing it to 100*100 either &#8211; we respect the original height to width ratio of the subject.</p>
<p>So here it goes. We&#8217;ll start with the picture shown below. The original is a 640*480 picture.<br />
<img src="/wp-content/iimages/tutorialthumbs/152-5210_IMG.jpg" width="400" height="300" alt="" title="" /></p>
<p>The first step consists of reading the dimensions of the picture and figure out which of the height or width is the smallest dimension.</p>
<p>Depending on which of the two is the smallest dimension I make them both equal and from then on we can work out the square are we&#8217;re going to be be working with.<br />
<img src="/wp-content/iimages/tutorialthumbs/exclude_area_wcross.jpg" width="400" height="300" alt="" title="" /></p>
<p>This generates thumbnails that have the same width and height and allows for a layout to look like so:<br />
<img src="/wp-content/iimages/tutorialthumbs/screen003.jpg" width="243" height="151" alt="" title="" /></p>
<p>And here is the code that I use to generate those thumbnails. Basically I use a function because the thumbnail creation process can happen in numerous places, but it&#8217;s only coded once.  Hope it helps someone out there!</p>
<p>The $ImageTool used is &#8216;GD&#8217;.</p>
<pre class="brush: php; title: ; notranslate">
function CreateSquareThumb($source,$dest,$border=0) {

    $new_width = 100; //
    $new_height = 100; //
    $sourcedate = 0;
    $destdate = 0;
    global $convert;
    if (file_exists($dest)) {
       clearstatcache();
       $sourceinfo = stat($source);
       $destinfo = stat($dest);
       $sourcedate = $sourceinfo[10];
       $destdate = $destinfo[10];
    }
    if (!file_exists(&quot;$dest&quot;) or ($sourcedate &gt; $destdate)) {
       global $ImageTool;
       $imgsize = GetImageSize($source);
       $width = $imgsize[0];
       $height = $imgsize[1];

      if ($width &gt; $height) { // If the width is greater than the height it's a horizontal picture
        $xoord = ceil(($width - $height) / 2 );
        $width = $height;      // Then we read a square frame that  equals the width
      } else {
        $yoord = ceil(($height - $width) / 2);
        $height = $width;
      }
         $new_im = ImageCreatetruecolor($new_width,$new_height);
         $im = ImageCreateFromJPEG($source);
         imagecopyresampled($new_im,$im,0,0,$xoord,$yoord,$new_width,$new_height,$width,$height);
         ImageJPEG($new_im,$dest,90);

    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.renet-web.net/2005/09/28/nice-gallery-thumbnails-in-php/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

