Archive - Nov 13, 2006

Date
  • All
  • Jan
  • Feb
  • Mar
  • Apr
  • May
  • Jun
  • Jul
  • Aug
  • Sep
  • Oct
  • Nov
  • Dec

TinyMCE

Nothing is better in explaining what TinyMCE does than by the official site's own words:

TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances. TinyMCE is very easy to integrate into other Content Management Systems.

TinyMCE ScreenShot

There is an incredible amount of WYSIWYG HTML editors out there, TinyMCE is one of those that stands out. Here are some of the features made it well known:
1. Open Source
2. Multilingual
3. Cross-Browser
4. Skinnable
6. Unobtrusive
7. Easily configurable
TinyMCE appears in these projects: Wordpress, PHPnuke, e107. There are plugins that can make TinyMCE work for XOOPS, Typo3, Plone, Drupal, Mambo and Xaraya, all of these are in the list of Most popular CMS out there.
According to Sourceforge, TinyMCE have been downloaded 570,523 times in the time of writing. That does not include the TinyMCE system inside Wordpress, PHPnuke and e107, where all of those combines have more than 1 million downloads.

Editor Comment:

I have feelings toward TinyMCE. I mean FEELINGS. TinyMCE isn't the only choice. There is a very alike WYSIWYG editor, FCKeditor(I know the name make people relate it to an "F" word). FCKeditor is more toward higher level users--users that will use the WYSIWYG editor make forms.

GeSHi - Generic Syntax Highlighter

GeSHI stands for Generic Syntax Highlighter. It is spelled the same with the PinYin for Chinese word "Format" and the offical FAQ said "GeSHi stands for "Summer Solstice" in Chinese - appropriate, considering the colourful output of GeSHi." GeSHi should be the most widely used PHP syntax highlighter after PHP's built in Highlight function and PEAR's Text_Highlighter Package. There are plugins for e107, Wordpress, Dokuwiki, Mambo and phpbb. In fact, GeSHi was made for phpbb before the author Nigel McNie decide to generalize the idea for create highlighter that can be easily intergrated in any website. Till today, GeSHi is 133 weeks old and downloaded for more than 30000 times.
GeSHi Highlighted Codes
Editor Comment:

I was never a PEAR fun, so I have chosed to use GeSHi. GeSHi is super easy. you can use 3 lines of code and it is part of your program! But the speed of GeSHi is not impressive, sometimes a large amount of code takes an amazing amount of time. 3.957 seconds is the result for a 24 KB html file. so it's about 0.17 second per 1KB of file. This is a bit stressing if you have huge amount of code need highlight. But if you got a good cache system, there won't be much a problem. But as you can see, this website use dp.SyntaxHighlighter(yep, Yahoo! uses it too), a javascript highlighter. This is a good choice, instead of using server's CPU, we use Client's

Serializing Objects in PHP

Title :Serializing Objects in PHP
Full Article: http://www.phphacks.com/content/view/34/33/

Recommended to : Beginner PHPer and PHPer just starting OO

Introduction: Object serialization is a technique to turn an object's properties and methods into a string. It is then stored in flatfile or database. Unserialize them will turn the object into the original state and can be processed in PHP. This article from phphacks.com shows how to build a class that can self serialize and unserialize.

Abstract:
To serialize a object, use serialize($object). To unserialize, use unserialize($object). The writer demonstrate the usage by making a simple class that simply store data into file. Then, adding a new function in the original class that allow serialization the object itself by this code serialize($this). The serialized object is then stored into a file. Restoration of the file needs another function. The function called fetch() fetches the file and unserialize it. "$newObj = $objSaver-> fetch();" will create an object that's same as the $objSaver.

Facts from Conclusion:

  • Serialization turns a object into string for storage.
  • Unserialization restores a string into an object for PHP script to use.
  • Self-serializing and unserializing objects can be a root class for all classes that need to serialized.

Editor Comment:

Serialize is a practice quite popular around the OO PHPers. The popular CMS e107 uses Serialized object to store settings in the database.

Introduction to Abstract classes in PHP

Title :Introduction to Abstract classes in PHP
Full Article: http://www.phphacks.com/content/view/35/33/

Recommended to : Beginner PHPer

Introduction: An abstract class is a class that cannot(or should not) be instantiated. This is an example of how to create an abstract class by the guy(s) from phphacks.com

Abstract:
Like the introduction said, you only need to ensure this class can't be instantiated. The first version is make an class with a prototype function. The prototype function contains die() command, so when the class it's called, the script simply dies. To improve the code, trigger error is used instead of die. A new conditional test tests if the class called is the abstract class by using a constant _CLASS_. Now this class can't be instantiated by anything other than its subclass. In the final script, a conditional check for the subclass is added. _CLASS_ is replaced with get_class($this).

Facts from Conclusion:

  • Abstract class are classes can't be instantiated.
  • Use get_class($this) insted of the _CLASS_ constant.

Editor Comment:

What's the point of making a class can't be instantiated? I don't know. I was never in a position where I have to organize a well-structured hierarchy. Will you ever need to use abstract classes? I don't know :) But you could learn something about improving coding though this tutorial

There is no place like 127.0.0.1

in

This is some Geek Joke hang around for some time. 127.0.0.1 is the loopback network connection address. For our PHPers, it is mostly known as Localhost. It can be thought as "home" because normally use it in HTTP, it goes into the home directory.

Honey Pot that kill bots