>> TIC – Text Image Converter  (117 views)

This is a php5 library (two classes) I wrote to convert TrueType Font text into an image, using the GD library.
Download here: Text Image Converter (213.33 KB) (includes an example, documentation and some free fonts).
or from svn (read only): svn co svn://byteset.com/tic
Documentation is also available online here: http://www.andreabelvedere.com/docs/tic/

See the library in action here: http://whatshouldidonow.eu/ (The site is still a work in progress)

To extend the library to add support for other Font types just extend the TIC abstract class and implement the create and dimension methods.

See example below on how to use it:

<?php
/**
 * @file image.php
 */
require_once 'lib/tic.php';
 
TIC::factory('fonts/AAJAX.TTF')
    ->setText('Hello World !')
    ->setBackground(0x00, 0xff, 0xff)
    ->setColor(0x00, 0x00, 0x00)
    ->setSize(24)->create(true);

Than in your html:

<img src="image.php" alt="TIC" />

That will output the following image:

TIC

The library is under the LGPL license, which means you can freely use it for commercial and non commercial applications, please post a comment for feedbacks, bugs, or links of projects where you have use it.

This is a quick self-reminder on propset svn:ignore command.

To ignore all content in directory foo but not the directory:
svn propset svn:ignore '*' foo
To ignore the directory and its content:
svn propset svn:ignore 'foo' .

>> Zend_Layout example  (2,934 views)

Table of contents for Zend Framework

  1. Zend Framework and Smarty integration
  2. A better Zend Framework & Smarty integration
  3. Zend_Layout example

This example focuses on 3 aspects of the Zend Framework (v1.6):
the Zend_Layout mechanism, modules and helpers, including the ActionStack helper and a custom helper. (Please note that there is no Smarty involved in this example).

The main objective of this post is to demonstrate how components of ZF work together to produce a simple application, for this reason I will focus on the code that holds things together rather than going through line by line.

If you have any questions or things are not clear please leave a comment.

As in the previous posts in the series you can download the full working example here: zend_layout_example.zip (3.36 MB). (Note: the compressed file includes the ZF library hence about 3MB)
Please glance at the previous post on this series for hints on how to set up this example on your working server.

Lets start where all begins: bootstrap.php (more…)


I am developing a site and on one of the pages I added an updateable (from a custom CMS) scrolling text banner.
The client was really impressed and asked me to make one on the front page as well.

I thought of sharing this because although to make a scrolling text banner in javascript is quite easy is still producing a good effect (when not overused) specially when the text can be updated at will from a CMS.

Here is the code that does most of the work:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * @param elem Element (div) containing the text to scroll
 */
function scrollText(elem)
{
    if (elem) {
        var str = elem.innerHTML;
        // get the first character of the string
        var firstChar = str.substr(0,1);
        // get the whole text except the first character
        var sub = elem.innerHTML.substr(1);
        // attach the first character at the end of the string and replace the element content
        elem.innerHTML = sub.concat(firstChar);
    }
}

The above function is called at regular intervals using the following line of code:

setInterval('scrollText(document.getElementById("text-to-scroll"))', 333);

Unzip the following file: scrolling.html.zip (999 bytes) to see the complete example.

Table of contents for Zend Framework

  1. Zend Framework and Smarty integration
  2. A better Zend Framework & Smarty integration
  3. Zend_Layout example

Since the first post on this series I have been working with the Zend Framework and Smarty extensively and I have greatly improved my previous integration between Smarty template engine and ZF.

I have prepared and example that you can download from the following link:
zend.zip (3.5 MB) the compressed file includes the ZF and Smarty packages.
The zip file should unpack as follow: (more…)


>> Linux pipe find with rm  (1,266 views)

find /path/to/dir -name name_of_file_to_match | xargs /bin/rm

I use often the above command to clean a directory from all the back up files created by emacs, so for example if I am developing a site at: /var/www/a-site/ then at the end of the day or at the beginning of a new one I clean up the directory as follow:
find /var/www/a-site -name '*~' | xargs rm
Be careful with the above command, specially if you run it as root and you get wrong the regex you could delete things you didn’t mean to !

>> Gallery2 Forum module update  (275 views)

With the help of Serban Constantinescu (that recently joined the project) the forum module for gallery 2 is at its second (but still rather beta) release, we are now at version 0.1.6.

Please find the new project page here: http://galleryforum.sourceforge.net/
and an experimental demo site here: http://galleryforum.abelvedere.com/main.php

Occasionally I want to compile a new mode for emacs but I can never remember the command so here it is:

M-x byte-compile-file [RET]
This is: press the “Esc” key (top left on my keyboard), then the letter x, then type “byte-compile-file” and press the return key.

or to compile all .el files in a directory:

[ESC] x byte-recompile-directory [RET]

Table of contents for Zend Framework

  1. Zend Framework and Smarty integration
  2. A better Zend Framework & Smarty integration
  3. Zend_Layout example

I have been using Smarty (php template engine) for quite some time but I am really new to Zend Framework, in fact I started using it for the first time yesterday.

To do the integration i found two very good articles:

  1. http://devzone.zend.com/node/view/id/120
  2. http://kpumuk.info/php/zend-framework-using-smarty-as-template-engine/

However both articles refer to an older version of Zend Framework and they are a bit confusing if you are a Zend beginner like me. On this post i assume Zend Framework version 1.5 and Smarty 2.6.19 (but should work with older Smarty too). (more…)


Generally users of the Gallery2 photo gallery that want to have a discussion forum on their site have to embed the whole gallery into a 3rd party forum or find other solutions, this module, currently in beta version, provides an alternative for all the gallery2 purist that don’t want to embed their gallery.

I am releasing it today, I hope you will find it useful.
Find more details: here