Few weeks ago, I participipated to the eZConference & Open Nordic 2008 in Skien in Norway. There's some things you must now about Norway :
- It's difficult to get there, even by plane, or car or camel...
- It's absurdly expensive (150€ to do 40km in cab)
- There's no night
- Most of Norvegian is speaking english, hopefully !
- They eat caviar for breakfast
- Salmon is absurdly cheap
By the way, as you can imagine, Norway is a big country with few persons in it. So there's a lot of space and they are very concerned by the quality of their life : cities are clean and services are perfect.
Open Nordic 2008
The conference stood in the Skien Ibsenhuset, a very large conference hall, where both conferences, eZConference and Open Nordic, happened.
The main subject on eZ were :
- Multiple file upload in 4.1 : it has been made in complement of the webdav feature which does not work on all platforms (Did I say Windows ???).
- OE 5 : integrating Tiny MCE, this WYSIWG editor rocks ! After having worked with HTMLArea, FCKEditor and the former OE, it seems to be the more powerfull and intuitive work ever done. At least, it is a very visible work.
- Support for OpenOffice.org and Microsoft Office document import and export in eZ via a nested toolbar in the editor : you can open content directly on an eZ instance via a Java connector and modify it as you want. When you save it, it will send the data to the eZ instance and update your website. Very powerfull and I guess very similar to the Sharepoint feature.
- Site factory and CSS Editor : two features which are made to ease the deployment and configuration of eZ websites. The first is a console tool allowing to deploy in one command an entire site with a specified configuration (it uses REST). The second one is a kind of webmaster gadget in full java which will allow people to modify their design in few clicks : you activate a design mode on your frontend and then you can select each element of the page and then change some defined css values, like background-color or what you want.
- ezComponents integration : eZGuys are close to completely lighten the kernel libs by integrating the eZComponents. The most important change will happen when the integration of the ezcTemplate will be effective. It's a big step for the eZCommunity because we will have to deal with a strict template engine (at last !).
- And some new components like Document and Search.
By the way, it was a great time, sharing our knowledge and drinking beers at the at the pub...
Oslo
And then I travelled a bit to reach Oslo... Country, sea and half-light :
Conclusion
It was a great trip, lot of emotions, lot of exchanges between people from different countries, and one pledge : next year I will be there, Monseigneur.
:-D
During a mission, I discovered jQuery : a javascript library providing facilities and strong functionnalities to static web pages.
jQuery
The use of this library is very simple. It has been made to use the developper's life and specially the maintenance of functionnalities. The javascript entered is shorter and more simple. It has few concepts so it is very quick to learn.
There is only one entry point in jQuery : the $ function. It allows you to access some standard functions to select nodes in the DOM, to manipulate them or to handle events.
The selectors are very useful because you can select almost every item in the DOM using id, css class or javascript variable name. Then, if there is more than one occurence, the function will result an array. Moreover, you can use XPath expression as filters, to reduce the number of object returned.
The strength of jQuery is the chainability of the functions. It allows to increase readability and maintenance of a javascript. You can also combine jQuery with classical JavaScript scripts.
The Challenge
To test this library, I've decided to develop an eZPublish extension integrating the jQuery library.
As a user case, I've chosen the Facebook tagging functionnality : you choose a picture, you tag your friends, you save it, hovering the head of a friend, the name is shown...
I have first worked offline to design the javascript. Here's a snapshot of what I have done : image gallery
Conclusion : it's very easy to come to grips with jQuery and a bit hard to debug. So I've searched and found a plugin to debug my script. See below.
Other interresting libraries...
I also heard about the ExtJS library which is a professional javascript library providing user interface components to build professional applications. jQuery is also experimenting this way by launching jQuery UI. It will be at the end equivalent I guess, but you will be able to still use the jQuery library as an independant library.
Ressources
Here's some ressource :
jQuery : http://www.jquery.com
Visual jQuery : http://www.visualjquery.com/1.1.2.html
Dump Plugin for jQuery : http://www.netgrow.com.au/files/javascript_dump.cfm
Javascript benchmark : http://flesler.blogspot.com/2008/04/benchmarking-javascript-variables-and.html
Still trying to find ways to improve eZPublish, I've thought about a simple process to resize pictures without having to download the picture, to resize in whatever image software and then, upload it again in eZPublish.
My aim is resizing and not scaling. It means that we are losing some information by cropping the picture that we are not losing by resizing. I'm just specifying this point because it's not a extension of the image.ini / image_class mechanism, but a new functionality which allow the user to cut himself a square in his picture. I guess a picture of the result is more obvious :
You can download it as usually on ez.no.
It uses a JavaScript library coded by David Spurr and the Scriptaculous library.
eZ Systems has included in their last release of eZ Publish a client for the Red5 video streaming server.
The documentation is a bit short and you don't necessary have all the elements to complete a full installation. After two hours of hanging about, I succeeded. :-D
Apache configuration
About the Apache configuration, you must add the following lines :
"Listen 100
NameVirtualHost *:100
<VirtualHost localhost:100>
<Directory path\to\Red5\webapps>
Options FollowSymLinks
AllowOverride None
Allow From All
</Directory>
DocumentRoot path\to\Red5\webapps
ServerName localhost
</VirtualHost>
"
The first two lines are declaring to Apache the use of port 100 and that some virtual host will listen to it.
The second part is the virtual host as well, what I've added is the "Allow From All" directive that forbidd everyone to access the video. We can tune that.
Content configuration
The Red5 flash client is set up with the content published. In the eZ Flow site package, you have a content named "Live Recorder" which will support the recoder and which can be configured by editing its content. We have three attributes:
- Name : the name of the content : whatever.
- Stream Server : it is the URL to the Red5 server. The protocole used is RTMP (watch out the spelling) and you must finish it by a slash :
"rtmp://localhost:1935/test/
"
- File Server : it is the URL of the Apache file server which deserves the saved files. It's not streams/streams like in the screenshot.
"http://localhost:100/test/streams/
"
And then you plug your webcam and you can start to make some funny films... live !
Conclusion
This feature is very powerful and stunning, however, I didn't find how we can put a live stream online and how we can list all the video we have taken.
Main concept
A year ago, I was working on a project where we were confronted to a certain problematic. We had a lot of classes which really looked like each other and had the same schema of class. So, when we had to modify a class because an attribute was missing or not in the right datatype, we have been obliged to modify all classes and it's very very long when you've got a lot of content types. We were thinking at a solution : creating a class wich willl be a parent class for all the other classes. For exemple, your customer is selling furniture products via the webshop and here is a detail of how this solution could be applied :
- You create a class Furniture Product with those very generic attributes : Name, Description and so on.
- Actually, you have three types of furniture products, Table, Cupboard, Settee. In the normal way, you will have to create three different classes with common generic attributes and specific attributes. There, you will just create a class with the specific attributes, and choose via a list of classes from wich one you would like to inherit.
- After that, when you are editing and publishing content, the content schema is based on the merge of the parent class attributes and the specific class attributes.
Implementation
To realize that, here's what I was thinking about :
- Modify the SQL schema of the ezcontentclass table to add a integer attribute called parentclass_id.
- Modify the kernel/classes/ezcontentclass.php file to add parentclass_id to the definition of the object.
- Modify the kernel/classes/ezcontentclass_attribute.php file to process all the attributes, main class and parent class attributes, when we use a function.
- Modify the design/admin/templates/class/edit.tpl file to add the list of classes who can be parent.
- Modify the kernel/class/edit.php file to save the information.
Here's the first release of eZDebug.
The functionnalities of this extension are to browse dynamically the debug of eZ publish. When you are developping you can have a lot of issues in one template and loose time seeking where is the problem. Of course, you will look at the debug but if there's a lot information, you won't be able to find it quickly.
So you can do it clicking on the right corner of Firefox or doing a CTRL + SHIFT + Q.
Another interesting functionnality is that you can flush the page, cleaning the debug. You just have to click on the clean checkbox and then the Go button.
You can also filter on the type of debug message you are seeking.
The next step it to do the same for the attribute(show) operator. It already works for a attribute(show,1), but I except some problems to create several levels in the tree.
Download available here :
http://ez.no/developer/contribs/3rd_party/firefox_ez_debug_extension
Here's a little comparison between a specific project designed in Java with some common framework and the same project realized with eZ publish.
Persistent layer
The persistent layer allows developper to use an abstract logical layer in their software to avoid manipulating specific instructions to get data from the data source. For example, you would like to access some data in a DB2 database. The first idea is to use APIs of your favorite language to access data through a SQL query, which means that if you decide to change your data source (another database or any storage system), you will have to change the access functions to your data. So, you can put a logical layer between your data source and your work oriented objects. By the way, you will avoid manipulating directly instructions to get your data (like SQL queries, file parsing, or whatever) and then only use objects instead of raw arrays of data.
The most common persistent layer for J2EE is Hibernate. The use of this one is really simple, you only have to set up a configuration file hibernate.cfg.xml and to indicate the mapping you would like to have between your data source and your objects. Then you have to create the classes you will use to access your data. All your relations will be managed by Hibernate. It's a bit restrictive because for complex applications because you will have a lot of classes to write. Fortunately, there's some software you can use to generate all directly.
In eZ publish, there's also a persistent layer which is divided in two parts. The first part is concerning the data connector eZ publish uses to get and store data from the data source : it's very similar to a JDBC connector. You have to specify some configuration in the site.ini.append.php for your site access like the DatabasImplementation (the connector) you would like to use. It allows you to access an object in your php file.
"include_once("lib/ezdb/classes/ezdb.php");
$db =& eZDB::instance();"
Then, you can run some queries like :
"$db->query("SELECT * FROM ezcontentobject");
"
To access the data you would like to get back.
But it's only relying on connectors and not on persistent layer. So, we can extend that using the eZPersistentObject class wich allows you to use several methods to access the objects stored in the database not only as array of data but as a complete object. You can find some examples on the way to design this here.
The MVC concept
The MVC (Model, View, Controler) concept is a design concept used to design any kind of software. The main goal of this concept is to separate the data and all the process you have done to get it and to display it. For HTML pages, it's easy to understand. For example, have a look this HTML page :
"<html>
<body>
<p>This is as message stored in the database</p>
<img src="/images/toto.jpg"/>
</body>
</html>"
The information content wich is important is the text nested in the paragraph and the path to the image. In an old school way to design website, we would have put the HTML page directly on the web server, but as we use dynamic technology such as J2EE or PHP or .NET, this page will be generated at the end of a very simple process for the most of the time. So, if you try to reach a page throught you browser typing an URL, if there is a dynamic server on the other side, your call will be transformed in a call to a certain method in a certain class somewhere on the server in order to generate HTML. And there is two points about that.
The first is, because to the use of a persistent layer, you won't put hard-coded data in your classes. And this matters in the two ways of sending data : from the server to the browser (Controler) and from the browser to the server (Model). In the Model, you will do the whole tests before saving, updating or removing your data.
The second is an extension of the first point, you will put all the data you would like to put in your classes in another object, and then in a data storage. For example, if you have some constants or messages not linked to the content but to the process you are running, you will keep them in some place and not necessary in the same than your content. You can also customize your code like adding some settings administrators can modify to change the behaviour of your application.
There is a direct impact in using this concept : your code is cleaner so you can modify it more quickly. The second point is very usefull too, because by this way you are adding some scalibility to the application and you improve it easily and quickly.
The other point on using an MVC framework is to separate the way you are displaying your information and the way you are controling it. Controling means running some tests on your data to decide wich view to display to the user.
For J2EE application, we use the Struts framework wich is the most advanced MVC framework developped in Java.
For eZ publish, a kind of MVC is defined through the use of modules and functions concepts but you can't use it for another application, its' nested in the eZ publish kernel. However, you can use it to design your own processes by creating some extensions for eZ publish.
And over all ?
And finally, I was wondering if another design concept / framework can be used in these kind of application.
In the Model layer of your MVC, you can divide this step in several steps.
It's common to use a DAO layer, static class, which will use the persistent layer to save / update your data or just store the queries. Then you can use a Services layer to separate the operations done on the data regardless to the way we are storing it.
For example, if I would like to save a User in my application, I will create a class for the User Object (with the attributes of the user and getter / setter methods), a static class for the Data Access Object (to store a user, modify it and search a specific one), and then a User Services static class to put my model processes and rules (if the user does not exist, I will create it).
We can go further and create a class to link your forms to an object and so reach directly all the data submited by the user in an object.
In eZ publish, the DAO Layer and the model class are merged due to the eZPersistentObject class. We don't have Services classes but for some kind of datatype, for example ezimage, we can have some classes to handle the data (ezimagealiashandler).
In J2EE application, the data entered by the user are stored in "Beans" object to ease the verification and process of the form.
Conclusion
Technologies are close due to the use of the same design concepts but the way it has been developped is a bit different and not with the same complexity or strictness.
By the way, designing a project in J2EE or in PHP would be conceptually the same but is easier with eZ publish due to the bundle functionnalities. Never the less, it's not fully exportable to another project which is demanding fewer functionnalities. This why eZ Systems is supporting the eZ Components project.
The other point which is very important is the integration with the application server which serves all this. Is there an asset to use a webapp server like TomCat to nest an application through servlets ? Or is it better to give full freedom with appliction "I'm running everywhere" with servers using PHP ? May we think to a PHP application server ?

Add comment