a programmer's best friend :: Entries from July 2004 |
Thursday, July 29. 2004Brisbane Backpacker
Well, backpacker's live is hard! Sightseeing every day, getting up early for tourist tours, watching wales and dolphins, hanging around on beautiful beaches, walking through faszinating rain forests, visiting art galleries, going out at night and having weekend every day - that 's really hard work.
Therefore I'm looking for a job in Brisbane (QLD). So if you are in Brisbane and look for a system administrator or web developer, I will be glad hearing from you. Just send me an email and I'll call you for a chat. Sunday, July 25. 2004Up, up and away (to OSCON)
I'll be in Portland/Oregon next week, doing a talk on PEAR at the OSCON. Afterwards we'll fly to San Francisco and take some time off. That means I will not be able to work on my projects or answer to all mails during the next two weeks.
Friday, July 23. 2004New issue of German "PHP Magazin"
This week the new issue of the German PHP Magazin has been published. Aside from the cover article on Eclipse, an introductory article on PHP5 OO and a simpleXML tutorial it features three articles that have been written by our very-own schst.
There's one introductory article on using PHP on the commandline, one article on generating XUL with PHP (using the PEAR package XML_XUL) and an article on PHP5's newest XML extension xmlReader. Tuesday, July 20. 2004Started working on patPortal
Due to popular demand, we started working on patPortal, again.
patPortal is (or better will be) a framework that helps you creating websites. It will be based on patConfiguration, patTemplate, patForms and tons of PEAR packages. Some first steps of the component-based project are availalable in CVS, but you should not expect too much from it until now, I just devoted two evenings to the project. I'll be mostly working on the general architecture that will manage data-interchange between the compontents using events and on a plugin system whereas Sebastian will focus on some components that you may actually use in your site, like views on database content, auto-generated navigations, etc. The framwork will not only aid you in the creation of web-applications, but also in any other field, where you may use PHP, as the request will be encapsulated in objects. If you decide to try the current CVS snapshot (which is not recommended, yet), make sure that you've got the latest versions of patTemplate and patConfiguration (from snaps.php-tools.net) installed. Thursday, July 15. 2004Tutorials for patXMLRenderer available
Vikram Vaswani (author of XML and PHP as well as MySQL: The Complete Reference) wrote two tutorials on patXMLRenderer.
patXMLRenderer allows you to transform XML documents to whatever you like (XML, HTML, PDF) by simply using patTemplate and PHP. You may bind namespaced tags to PHP objects to inject any dynamically generated content. If you ever worked with Sebastian's XML_Transformer, you probably already are aware of the technique. patBBCode nearing release
patBBCode is our custom pat BBCode parser, with a slightly different syntax than the widely known BBCode. pat BBCode features tags with attributes, empty tags and even tags with custom namespaces. Tag filters enable mapping classes to tags with a very simple to use API for quick development.
patBBCode uses a sax-based parser to parse the tags, so that developers who want to add their own tags need not worry about that part. A filter class only needs to implement the createContent() method, and gets the content and attributes of the tag to work with. A small, custom template class makes it very easy to generate the needed content from any number of tag template files. Simple tags that need not be mapped to a class are stored in .bbt (patBBCode templates) files used to render the content of the tag, e.g. the tag template for the [B] tag could look like this: <b>%s</b>, where %s stands for the content of the tag. The first available version of patBBCode still used rather unflexible tag configuration files, and on Stephan's advice I implemented tag configuration readers. The main patBBCode class takes care of parsing the tags and rendering them from the tag template files, while the tag configuration readers are used to determine wether a tag exists and is allowed. Currently two readers are available:
You can have a look at the CVS tree for this project at cvs.php-tools.net, and grab the current CVS snapshot from snaps.php-tools.net. Wednesday, July 14. 2004It's here!
After years of waiting, PHP 5.0.0 finally has been released and is available for download.
Read the release anouncement or download it. Friday, July 9. 2004Rapid page development with patTemplate
Recently I added a new custom function to patTemplate, that pushes unifying site design to a new level. In most sites, you have a set of design compontents, that you use in many pages to build headlines, information boxes, news entries, etc.
These should look the same on all pages to give the site a unified look and feel. To achieve this, you could either use XML and XSLT or you try to use a templating engine. This has the drawback that the designer, who creates the static pages of the site is not able to access the components in the template. It would be great if he could just say "hey, use the template for a box with this headline and that content" and it would automatically be replaced with the correct layout. Well, patTemplate 3.0 can do this for you, all I had to do was create a custom function with about 10 lines of code. To ease your designers life, you can do the following: 1. Create a template file with all re-usable components you need in your site. 2. Get the latest version of patTemplate from CVS 3. Re-use the components in the pages by using <patTemplate:Call/> The best way to show what I'm talking about is an example: File "compontents.tmpl": <patTemplate:tmpl name="hint">This file defines two templates, hint and news which we will re-use in the pages of our site. A news consists of a title, date, author and content, wheras a hint only has a title and content. File "page.tmpl: <patTemplate:tmpl name="page">PHP Code: <?PHP require_once '../patTemplate.php';When executing the page, the result will look like this: patTemplate goes Randy By Stephan Schmidt on 2004-07-08 By using the new <patTemplate:Call/> function, it is possible to define often used design elements in one template file and then re-use these components to display any information you need. The Function allows you to pass any number of attributes as variables of your component templates. Calls may be nested. You may nest the Call tags as deep as you like, this brings most of patXMLRenderers functionality to patTemplate. Been to the Spidey-Night. By Stephan Schmidt on 2004-07-07 This shows you ho to reuse the templates. If you need the change the layout of this news block, you only need to change it once and all news entries will have the design you created. As you can easily see, it's quite easy for a designer to use the predefined elements in the pages. All he has to do is using the <pattemplate:Call> tag and passing the name of the desired element to the template attribute. All other attributes will be passed as variables to the template. The content of the tag will go into the {CONTENT} variable. The example is included in the distribution and available online. In the templates, you may use any of patTemplate's features, like variable modifiers or conditions. As patTemplate features a template cache that caches the resulting file with all components expanded, performance will not be an issue. Monday, July 5. 2004PHP meets ASP.NET WebControls
After the interesting Christian's and Tobias' interesting talk at LinuxTag about the advantages and disadvantages of ASP.NET in comparison to PHP, Christian and I had a short chat about patForms and the parser we are using for rapid development.
IN ASP.NET, webcontrols allow you to add an additional attribute runat="server" to your HTML elements, which makes them available as variables in your script. This is extremely interesting when used with forms, as validation may be easily added and the elements automatically keep their values after submitting the form. Tobias and Christian thought, this was a huge advantage of ASP but then mentioned HTML_QuickForm. But using Quickform forces you to build your form in an object-oriented way by creating instances, setting properties and then combining all elements to a form wich you may then serialize to HTML. This is a boring and tedious task. I told Christian about patForms_Parser, which is able to extract special tags from any HTML page and build a patForms object from it, which can be validated and then sent back to the user with about 7 lines of PHP code, independent of your form. But still, you need to create a HTML page, that contains special tags and that your designer is not able to view in his favourite HTML editor, which definitely is a drawback when it comes to rapidly creating form based applications. Last week I wrote a very simple subclass of the parser, which is able to read plain HTML forms, and give you a form object back that you may modify, validate and then send it back to the browser. All you need is the following code:
$parser = &patForms_Parser::createParser( 'Html' );You may use this code with any HTML page that contains a form and you will get an form element object for all elements that you added to the HTML page. The steps where a form template is written, can basically be left out, these just create the HTML pages with the special <patForms:Foo/> tags. To include special validation rules you may add attributes like required="true", format="email", etc. to your standard HTML elements. Of course you may easily modify the form from PHP, as patForms provides a DOM-like API. To add a new custom validation rule to an element, you just had to get the element and modify it:
$name = &$form->getElementById( 'name' );You may also use all other features of patForms, like filtering user-input (to avoid XSS attacks), observers which allow to modify elements on certain events (e.g. changing the CSS class on error), javascript validation or storage container, which automically write the user input to a datasource or file. You may also specify a cache file which enables you to speed up your form-based applications. The code and a simple example is available in CVS or can be downloaded as a snapshot. |
php_network_getaddresses: getaddrinfo failed: Name or service not knownphp_network_getaddresses: getaddrinfo failed: Name or service not known |