Example #1
0
 function format_table($content, $headers)
 {
     //create table header cells
     foreach ($headers as $key => $val) {
         self::$table_header_cells .= '<th>' . $val . '</th>';
     }
     //create table headers row
     self::$table_headers = '<tr>' . self::$table_header_cells . '</tr>';
     //create content rows and cells
     foreach ($content as $key => $val) {
         //get array of filename details - filename and extension...
         $fileinfo = pathinfo($val);
         $filename = $fileinfo['filename'];
         $fileext = $fileinfo['extension'];
         //set link for file
         $filelink = '<a href="content.php?name=' . $filename . '&type=' . $fileext . '">view file</a>';
         self::$table_rows .= '<tr><td>' . str_replace('_', ' ', $filename) . '</td><td>' . $fileext . '</td><td>' . $filelink . '</td></tr>';
     }
     //concatenate formatted content to create table
     self::$viewer_content = '<table class="table table-bordered">' . self::$table_headers . self::$table_rows . '</table>';
 }
Example #2
0
<?php

/**
 * 402mini - framework for rapid, simple publication
 */
//load directory loader class
require_once "dirLoader.php";
//require content format class
require_once "contentFormat.php";
//specify test directory
$txt_dir = 'txt';
//set headers for content table
$table_headers = ['filename', 'filetype', 'link'];
//instantiate directory loader object
$dir = new DirLoader();
//get text directory contents
$texts = $dir->get_dir_content($txt_dir);
//instantiate content format object
$format = new ContentFormat();
//get formatted table content
$texts_table = $format->get_table_content($texts, $table_headers);
//require html header
require_once "htmlHeader.php";
//output text table
echo '<div id="content">' . $texts_table . '</div>';
//require html footer
require_once "htmlFooter.php";
Example #3
0
<?php

/**
 * 402mini - framework for rapid, simple publication
 */
//load constants
require_once "constants.php";
//load directory loader class
require_once "dirLoader.php";
//require content format class
require_once "contentFormat.php";
//set headers for content table
$table_headers = ['filename', 'filetype', 'link'];
//instantiate directory loader object
$dir = new DirLoader();
//get content directory contents
$content = $dir->get_dir_content(MEDIA_DIR);
//instantiate content format object
$format = new ContentFormat();
//get formatted table content
$content_table = $format->get_table_content($content, $table_headers);
//require html header
require_once "htmlHeader.php";
//output content table
echo '<div id="content"><h4>Content</h4>' . $content_table . '</div>';
//require html footer
require_once "htmlFooter.php";