I’m doing some XSL transformations in a project I’m involved in right now. The XML documents that are beeing transformed all include a xml-stylesheet processing instruction that I need to read in order to know what stylesheet to use for a specfic document. To my surprise, reading processing instructions from a DOMDocument in PHP was not so easy as one might assume.

Read the rest of this entry »

0

Don’t miss Ubiquity

Posted in misc at August 29th, 2008 / No Comments »

I installed the Ubiquity browser plugin yesterday and I’ve had some time to play around with it. Without a doubt Ubiquity is the most exceting thing that has happend to web browsers in years. I’m not going to rant about all the things this browser plugin can do for you, instead see for yourself at Ubiquity project at Mozilla Labs.

I’ve been playing around with Zend_Form and Zend Framework 1.5 these last couple of days. Like most people I hade some trouble getting used to the decorator part of the form API. Decorators are used to style form elements for rendering in the browser, adding tags before, after and wrapping the form element itself. After much swearing I finally found this article in the Zend Developer forums that did a pretty good job explaining it.

The next problem I ran into was customizing the form error messages, not just customizing the messages but also localizing them. The framework has default error messages defined for all validators you can use with your form elements but they are kind of stiff and I doubt anyone really want’s to use them. It turns out the solution is really simple.

To attach a validator to a form element you normally write something like this:

$textField = new Zend_Form_Element_Text("myField");
$textField->addValidator(new Zend_Validate_NotEmpty());

If you want to customize the message and maybe even localize it you simply init a validator and manuelly set the message via the setMessage method, like this:

$notEmpty = new Zend_Validate_NotEmpty();
$notEmpty->setMessage("You have to enter a value");
$textField = new Zend_Form_Element_Text("myField");
$textField->addValidator($notEmpty);

If you like to localize the error message, replace the setMessage call with:

$notEmpty->setMessage($this->getView()->translate("You have to enter a value"));

It’s just that simple ;-)

2

Google Maps Cluster markers

Posted in javascript at June 18th, 2008 / 2 Comments »

I’m working on a project right now where we make use of the Google Maps API to display various information on Google Maps. One page calls for a view of all golf courses in Sweden. To my surprice there are actually quite a few of them, closer to 500 golf courses. When you position lots and lots of markers in a small area of a map it can get quite cluttered and eventually the map starts to load painfully slow.

So with this in mind I set out to find a way to avoid this problem. I’ve seen on other sites markers that change depending on what level of zoom you’re currently in and a quick search on Google gave me the answer I was looking for. Cluster markers. Cluster markers is not a part of the Google Maps API but are supplied by third party developers. I went through a couple of different solutions but finally choose to use ClusterMarker by Martin Pearman.

ClusterMarker detects any group(s) of two or more markers whose icons visually intersect when displayed. Each group of intersecting markers is then replaced with a single cluster marker. The cluster marker, when clicked, simply centers and zooms the map in on the markers whose icons previously intersected.

The ClusterMarker API is well documented and really easy to implement and use.

2

Finally got sound in Vista X64

Posted in mac, windows at June 11th, 2008 / 2 Comments »

Apple MacBook (black)Back in april I bough a MacBook to use at home and in the office. I installed Windows Vista X64 via BootCamp to use mostly at work (I do some programing in Visual Studio). I read about the many problems with drivers and was a bit anxious but to my surprise everything except the audio worked. I spent some time trying to resolve the issue, trying all kinds of different driver. Microsoft High Definition Audio (default driver choosen by Vista), Sigmatel and Realtek. None worked. I finally gave up and decided I didn’t need audio support while working in Vista.

Some time went by and I soon realized I really did need audio support. Not so much for the work I do but for listening to music while doing it. So I gave it another try and now I actually got it working. Since my last attempt it seems new versions of the Realtek drivers must have been released and it installed with any fuzz.

So now I’m writing this post so that others in the same situation might find a solution to their Vista X64 audio problems as well. The drivers that finally worked was Realtek High Definition Audio Codecs R1.94 Vista.

There’s a lot more to localizing a web site then just replacing strings with diffrent languages (for an exelent introduction read the ZF documentation on Zend_Locale). But in this post I will talk about string localization, and especially string localization using gettext and .mo-files with Zend Framework. Read the rest of this entry »

4

ASP.NET anchor link in user control

Posted in asp.net at February 20th, 2008 / 4 Comments »

Ran into a strange bug today while trying to make an anchor link inside a user control i ASP.NET. The obvious way to do it would be to just to put the anchor ID inside the NavigateUrl attribute of the HyperLink control like NavigateUrl=”#anchor”. That however resulted in the link and anchor pointing to the directory where the user control was located. Read the rest of this entry »

1

Classical ASP YouTube class

Posted in asp at February 12th, 2008 / 1 Comment »

Believe it or not but from time to time I actually get to do some programing with classical ASP, you know that stoneage technology that came before the .NET framework. Back in the days the concept of using classes was beyond me so when I got the chance the other day to do some ASP coding I decided to do it the OOP way. Read the rest of this entry »

0

Links on PNG backgrounds in IE6

Posted in css at January 20th, 2008 / No Comments »

Using transparent PNG background images is pretty standard these days with shadows and fading backgrounds on almost every site. PNG backgrounds even works with IE6 although it’s implementation is kind of buggy. In order to use it on IE6 you have to use the IE6 filter rule, as shown below. Read the rest of this entry »

0

Garbeled data using PDO and MySQL

Posted in databases, php at January 20th, 2008 / No Comments »

Ran into some trouble the other day while emigrating a PHP solution from our development server to the production server. The application was working fine on the development server but once moved to the production server it started to behave strangely. Read the rest of this entry »