2007-08-31

PHP errors and debugs in Firebug

Do you know Firebug? It is perfect for debugging webpages. I got the idea to use it for my php error and debug outputs as well. The error handler / debug functions in papaya CMS can now use the Firebug console.log() function.


Nice detail: It works in other browsers using Firebug Lite.

Formatting a select


The list of page and box modules grows and grows. Now we added some style to keep it usable. This is pure html+css, without any javascript. It uses the optgroup tag.

If the list grows to large, we have to rethink the form concept.

2007-08-27

TinyMCE TabJump Extension

Here's is a nice plugin for TinyMCE called TabJump. It allows you to leave a TinyMCE editor area using the tab key (like other edit fields). In the first version by Jan Lenhardt you had to define the id of the next html element in the TinyMCE configuration. I added some code to detect the next element and sent it to Jan. Now it is a Google Code project. :-)

2007-08-14

FrOSCon Talk

I will talk about generating PDF with XSLT and FPDF on the FrOSCon in Sankt Augustin next week. It is the first talk of the day in the PHP Room.

2007-08-09

Problem with libxslt

If you use the current PHP 5.2 with libxslt, libxml will add CDATA sections to your XHTML script tags. The W3C suggests the use of a CDATA section (less escaping for special chars needed), but the most browsers will not support this. Firefox supports it, if you send the mimetype application/xhtml+xml. To avoid the problem make your script section a html comment. Here a sample:
<xsl:template match="script">
<script type="{@type}"><xsl:comment>
  <xsl:copy-of select="text()"/>
//</xsl:comment></script>
</xsl:template>
This is a generic match for all script elements in the xml tree. But will take care of xslt generated script elements, too.
<script type="text/javascript"><xsl:comment>
myLittleJSCall();
//</xsl:comment></script>
Here is a bug reported for libxml. But it is closed. :-(

2007-08-08

papaya CMS on Lighttpd

Our current development system is Apache httpd. But it can run on Lighttpd, too. First you need to activate the mod_rewrite and define a set of rewrite rules in the configuration file.
url.rewrite-once = (
# admin pages
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?papaya/module\_([a-z\_]+)\.[a-z]{3,4}(?:\?(.+))?$" => "/papaya/module.php?p_module=$1&$2",
# pages
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?[a-zA-Z0-9_-]+(?:(?:\.[0-9]+)?\.[0-9]+)(?:(?:\.[a-z]{2,5})?\.[a-z]+)(?:(?:\.[0-9]+)?.preview)?(\?.+)?$" => "/index.php$1",
# index page
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?index(?:(?:\.[a-z]{2,5})?\.[a-z]+)(?:(?:\.[0-9]+)?.preview)?(\?.+)?$" => "/index.php$1",
# media files
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?[a-zA-Z0-9_-]+\.(?:media|thumb|download|popup|image)(?:\.(preview))?(?:(?:\.(?:[a-zA-Z0-9_]+))?(?:\.[a-zA-Z0-9_]+))(\?.+)?$" => "/index.php$1",
# sid only
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40}))(/.*)(\?.+)?$" => "$1$2"
)
Next you need to define the 404 handler for alias handling:
server.error-handler-404   = "/index.php"
The last step is a little bugfix in ~/papaya/inc.conf.php. Lighttpd sets $_SERVER['PATH_TRANSLATED'], but it is empty. So this check needs a little patch:
if (isset($_SERVER['PATH_TRANSLATED']) && $_SERVER['PATH_TRANSLATED'] != '') {
This way papaya CMS will use $_SERVER['SCRIPT_FILENAME']. We fixed this in the development version already. It will be included in the next public version.

2007-08-06

Last PHPUG Meeting

At the last PHPUG Meeting I talked about file delivery with PHP-Scripts. Here are the slides: PDF

2007-08-02

Optimizing Backend

We are currently optimizing the backend performance. With Firebug we could get all requests for a page and optimize the caching.

First a result with an empty browser cache. It loads about 60 files and takes some time. Because some of the images are module files and can be outside the document root, they need to be send using a php script.

A second click on the same button shows a nice result. Most of the files, including the module images, are cached. Only 13 requests for the page now.

We are still trying to improve that result. But I think it is a good start.
x