Viewing Source of Example: list


<?php

/*
* List Example
*
* This example simply lists all of the boxes and forms in the example app.
*/

loader_import ('saf.File.Directory');

// get list of boxes
$d = new Dir ('inc/app/example/boxes');
$boxes = array ();

foreach (
$d->readAll () as $file) {
    if (
strpos ($file, '.') === 0 || ! @is_dir ('inc/app/example/boxes/' . $file) || $file == 'CVS') {
        continue;
    }
    
$box = array ('file' => $file);
    if (@
file_exists ('inc/app/example/html/' . $file . '.spt')) {
        
$box['template'] = true;
    }
    
$boxes[] = $box;
}

// get list of forms
$d = new Dir ('inc/app/example/forms');
$forms = array ();

foreach (
$d->read_all () as $file) {
    if (
strpos ($file, '.') === 0 || ! @is_dir ('inc/app/example/forms/' . $file) || $file == 'CVS') {
        continue;
    }
    
$form = array ('file' => $file);
    if (@
file_exists ('inc/app/example/html/' . $file . '.spt')) {
        
$form['template'] = true;
    }
    
$forms[] = $form;
}

echo
template_simple (
    
'list.spt',
    array (
        
'boxes' => $boxes,
        
'forms' => $forms,
    )
);

?>

Back