Menu

The go!Johnny PHP Class Library

go!Johnny is a collection of classes designed to help in the creation of HTML5 content and web pages. Each class represents an HTML5 tag, with some extra classes for related useful tools such as database access.

The ideas behind the library are:
-a web page is an application
-the user is enabled to write in a single programming language (php), without mixing programming code and HTML/CSS markup.
-even if you have to write different languages (e.g. javascript, css), each one will be in a separate file.
-the classes are highly flexible, so you can find the most comfortable way to work with them.
-default options should always be the most meaningful ones.

Let's see a quick example of a go!Johnny class in use. If you want to add e.g. a <div> element, containing some text, to the content that you are including in a page, you just have to do this:

$content .= new TDiv("Some text.");

which can be shortened to:

$content .= TDiv("Some text.");

By doing this, you are adding the following markup to the $content variable:

<div>Some text</div>

While in a case such as this one there is not much advantage, considering e.g. creating a link (<a> tag):

$content .= TA('http://sourceforge.net', 'Sourceforge');

which will be translated to this:

<a href="http://sourceforge.net" title="Sourceforge">Sourceforge</a>

Or an unordered list:

$content .= TUl('1|2|3|4|5');

or using an alias:

$content .= TList('1|2|3|4|5');

any of which will generate this:

<ul>
 <li>
  1
 </li>
 <li>
  2
 </li>
 <li>
  3
 </li>
 <li>
  4
 </li>
 <li>
  5
 </li>
</ul>

But the advantages of using this library instead of writing HTML markup goes beyond the amount of text you have to type:
-the resulting markup is valid, beautifully indented HTML5 code.
-you can write exclusively oop programming code.
-each object representing an HTML element can be manipulated in several ways. Ex.:

$message = TDiv('Welcome!');
$message->p('class', 'friendly');
$message->p('onclick', "$('#message').hide();");

When added to the content, this object will generate this:

<div id="message" class="friendly" onclick="$('#message').hide();">
Welcome!
</div>

There is much more to go!Johnny. Keep tuned to see what it can do for you.

Posted by panglossa 2013-04-07 Labels: about

Log in to post a comment.