Category Archives: web development

Zend_Controller_Front plugins

Една от особеностите на Zend Framework Front Controller е фактът, че може лесно да се напишат и ползват plugins към него. Колкото до официалната документация на ZF, поне според мен, не е достатъчно описателна и не дава ясна представа какво точно правят тези plugins и колкото и добре да е показано как се пишат и как са замислени не става известно какво предимство дават на приложението.

Добра статия за това как да се напише plugin и какви предимства дава може да се намери в една статия, която намерих днес.

Ето и някои от предимствата на плъгините:

  1. Инициализация на приложението
  2. Кеширане
  3. Инициализация на router-а
  4. Authentication и Authorization
  5. Филтриране на изходния XHTML

Perl Regular Expressions

For everyone who did write a code someday comes the question of using regular expressions. Almost everybody has heart about automatic and regular languages. Assume you have all word for a given languages, which means all possible combination between the letters of a given alphabet. For all these possible word only few construct the “language” as we know this term. Of course there’s also need of grammatic, etc. But however we have the set of words in a given language.

Than comes the task to find those of the words of the language that match a given condition. In fact the regular expressions are a powerful tool to do this job.

Using PHP you can use preg_ functions, which will perform a perl regular expressions match. In my case I had to find in about 180 .html files specific words.

Assume the files contain something like:

<!-- wellformed html comment -->
<tr>
<td class="classname1"><img ...></td>

<td class="classname2">

<a ... >

Word to match

</a>

</td>

</tr>

<tr>

<td ...></td>

<td ...></td>

</tr>

<!--wellformed html comment-->

The regular expressions for preg_replace function I used was something like this:

'/^[t|s]*<tr>.*?$n^.*?<td.*?</td>.*?$n.*?
<td.*?$n.*?<a.*?>.*?$n.*?Word  to  match.*?$n.*?</a>.*$n.*?</td>.*$n.*?
</tr>.*$n.*?<tr.*$n.*?<td.*$n.*?<td.*$n.*?</tr>/m'

… and it worked for me. In fact if you use ‘s’ instead of ‘m’ modifier that’s gonna be you mistake cause of the multiple matches before the current tag you want to match.

amarok plays mp3

I’m on Fedora 7. Due to lack of free time I just saw the Amarok is not playing mp3 files and solved the problem simply by installing the XMMS. Today, realizing that I’m using Konqueror all the day long and almost everything related to the file system, browsing etc. is performed by Konqueror, I decided to configure lastly my Amarok.

And as it appears I had good luck. I found this lovely article which I recommend to everyone who’s gonna configure his own player.