<?
/*
* Hello World 6
*
* Guess what again?
*
* There were even more simplier way to do things!
*
* I mentioned about CompleteArray. Using this class we can avoid using Container
* completely.
*/
include '../../trunk/loader.php';
/*
* We do not need a custom class anymore. Of course we could use one, but
* I wanted to show that our default classes can do a lot without customization
*/
$api = new ApiWeb('hw6');
$api->template = $api->add('SMlite')
->loadTemplate('hw')
->set('page_title','Hello world application')
;
/*
* Since we will be adding one sub-element into our hello world, we'll have
* to make it Container. Container introduces method "add()".
*
* We are going to put ArrayLister inside our container
*/
$list = $api->add('CompleteLister',null,'page_content',array('widgets','hw4'))
->setStaticSource(array(
array('name'=>'Janis','surname'=>'Lielmanis'),
array('name'=>'Juris','surname'=>'Pimanovs'),
array('name'=>'Aleksejs','surname'=>'Chizhevskis'),
array('name'=>'Viesturs','surname'=>'Zarinsh'),
))
->template->set('title','Hello to ..')
;
$api->main();
/*
* Conclusion:
*
* Inside hw4..6 we created a iterator to display table using template and values from array.
* We were able to simplify it so at the end it took only 3 lines: add, set title, set data.
*
* Also in this sample I used this form:
*
* $object = $this->add()
* ->doSomething()
* ->doSomethingElse()
* ->doOtherThing()
* ;
*
* You might find this in a many places all through the library. I think this way of writing things down
* is more logical and I suggest you to stick with it too.
*
* Knowing right classes allows you to do things much easily. But wait! Take a look again
* at HelloWorld class from hw4.php. It turns out we can use that class with different template
* and different data set! When i developed it I wasn't planing for writing it reusable, but
* it actually is. That would make our HelloWorld a good enough equivalent to exsiting Lister
* classes (except that our uses array and Listers are designed to work with database)
*
* What next? I could use that class inside many different applications, web portal,
* administration systems, it will fit perfectly anywhere.
*
*
* At this moment you should understand how objects are manipulated and how framework is
* constructed. It shouldn't be a problem for you to start using other classes.
*
*
* See 2nd tutorial if you want to learn how to use ApiAdmin.
*/