> > Topic (new)

Handling Pages

Dec 14, 2006 / pixtur
Jan 5, 2009 / phsouzacruz
 

Attached files

No files uploaded
 
Different from Netoffice 2.x the prototype is driven by a single controller-page: index.php. Therefore this is a good start to read it. The interfaces is split into pages (like 'home', 'taskEdit', 'projDelete'). Pages are defined through a PageHandle and a function. All PageHandles are defined at the beginning of the script (in a file called pages/_handles.inc) like this:

  new PageHandle(array('id'=>'home', 'req'=>'pages/home.php', 'title'=>'Home'));

PageHandles are been used through the PageHandler and its global intance $PH. All internal linking and parameter-passing between pages should be done by methods provided by the pageHandler. This will ensure that links and parameters are valid:

  $PH->show('home');
  $PH->show('heim'); // causes 'undefined'-error and relinks to error-page
  
  $PH->getUrl('taskEdit', array('tsk'=>23));
  $PH->getUrl('taskEdit', array('task'=>23)); // Error: 'invalid attribute task'
  $PH->getUrl('taskEdit'); // Error: 'requires tsk'.

The PageHandler can also create handles for returning to a certain page. This allows to edit a task and return to the original task-list afterwards. With netoffice2.x this wasn't possible.

The code for actually rendering the pages is only included if needed. The source-location is passed to the PageHandle-constructor by the 'req'-attribute.

The necessary files for the pages are located in the 'pages/'-directory.

The name-attribute is used if $PH->getLink() is called without the name-parameter. This mostly gives reasonable link-names.

  $PH->getLink('home'); # will something like <a href="index.php?go=home">Home view</a>




In the long-term the pageHandle-list could be used for a unit-test of all pages: This can be done by a list of tests (pageId,Parameter,testType). Than we could call/render all tested pages, log the potential errors and tell if the page was rendered without warnings or errors. In netoffice2.x rendering all potential pages was a really tedious task.

No Comments