Building RIA's using SAP, Flex and Php


According to Wikipedia, "Rich Internet Applications 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". I don't think that this definition does do it any justice - I think that RIA's are:

  • Applications that offer a visually rich and engaging user interface
  • Applications that offer content richness and useful and diverse functionalities

In other words it has to deliver functionality and it has to do so in an engaging UI - the argument being that such applications will deliver a greater employee productivity and/or customer loyalty. I would certainly vouch for that - go see a demo of SAP Business Explorer to see what I mean (you can even
upload your own data and play around with that).

As a continuation to my experiments in marrying technologies such as Php, Pear & Ajax to query a SAP 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 "SAP FLEX" to see that there is
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.

So in this post I'll be looking at the following scenarios:

  • A sales application using SAP, Flex and Php (http service call method)
  • A production order application using SAP, Flex and Php (http service call method)
  • A sample sales application using SAP and Flex (web service call method)

The tools of choice for my experiments today are:

  • Adobe Flex (which is built on top of Eclipse - 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 - although I have not tried that).
  • Easyphp which is a nice WAMP (Windows Apache Mysql Php) package that I have been using for years - php in version 5.2.8
  • The SAPrfc extension module for Php
  • Of course SAP. The SAP backend system I'll be using is a SAP ECC 6.0 system.

Read more

Nice gallery thumbnails in PHP

Some time ago when I first started publishing photos to the web I used a php package called WihPhoto which used to be available form I say 'used to be' because that site now only displays a dull 'currently offline' 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.

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.

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.

  • 1 - Generate square thumbnails
  • 2 - Get rid of the 'jags' in the pictures

In this post I'll discuss how you can generate square thumbnails using php.

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 - 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:

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'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.

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' 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.

Now to be clear I'm not talking about taking 640*480 picture and resizing it to 100*100 either - we respect the original height to width ratio of the subject.

So here it goes. We'll start with the picture shown below. The original is a 640*480 picture.

The first step consists of reading the dimensions of the picture and figure out which of the height or width is the smallest dimension.

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're going to be be working with.

This generates thumbnails that have the same width and height and allows for a layout to look like so:

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's only coded once. Hope it helps someone out there!

The $ImageTool used is 'GD'.