From 9d6df04cfa4f4afb8e4d3bfadfefc02ff84607f2 Mon Sep 17 00:00:00 2001 From: Silvio Date: Fri, 20 Aug 2010 14:56:33 -0300 Subject: CLI support at CinisisDisplayHelper --- apps/audit.php | 4 +- classes/helpers/CinisisDisplayHelper.php | 96 ++++++++++++++++++++++++-------- config/config.yaml | 2 +- 3 files changed, 75 insertions(+), 27 deletions(-) diff --git a/apps/audit.php b/apps/audit.php index 28237b0..9863e2d 100644 --- a/apps/audit.php +++ b/apps/audit.php @@ -18,9 +18,7 @@ if ($isis) { $result = $isis->run(); // Format output. - echo "
\n";
-  print_r($result);
-  echo '
'; + $display->pre(print_r($result)); } $display->footer(); diff --git a/classes/helpers/CinisisDisplayHelper.php b/classes/helpers/CinisisDisplayHelper.php index 48db6ea..d00ad20 100644 --- a/classes/helpers/CinisisDisplayHelper.php +++ b/classes/helpers/CinisisDisplayHelper.php @@ -22,7 +22,12 @@ class CinisisDisplayHelper { * Page title; */ static function title($title) { - echo "

$title

\n"; + if (php_sapi_name() == "cli") { + echo "$title\n"; + } + else { + echo "

$title

\n"; + } } /** @@ -32,20 +37,27 @@ class CinisisDisplayHelper { * Page title; */ static function header($title) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''. $title .''; - echo ''; - echo ''; + if (php_sapi_name() == "cli") { + echo "$title\n"; + } + else { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''. $title .''; + echo ''; + echo ''; + } } /** * Draws the page footer. */ static function footer() { - echo ''; + if (php_sapi_name() != "cli") { + echo ''; + } } /** @@ -61,11 +73,13 @@ class CinisisDisplayHelper { * Form method. */ static function form($content, $action = 'index.php', $method = 'get') { - echo '
'; - echo $content; - echo ''; - echo '
'; - echo '
'; + if (php_sapi_name() != "cli") { + echo '
'; + echo $content; + echo ''; + echo '
'; + echo '
'; + } } /** @@ -81,6 +95,10 @@ class CinisisDisplayHelper { * Rendered text input. */ static function form_input_text($name, $default = null) { + if (php_sapi_name() == "cli") { + return; + } + if ($default) { $default = 'value="'. $default .'"'; } @@ -104,6 +122,10 @@ class CinisisDisplayHelper { * Extra parameters. */ static function navbar($entry, $entries, $action = 'index.php', $extra = NULL) { + if (php_sapi_name() == "cli") { + return; + } + // First / prev links. if ($entry != 1) { $prev = $entry - 1; @@ -135,7 +157,9 @@ class CinisisDisplayHelper { * Formatted link. */ static function link($action, $args, $title) { - return ''. $title .''; + if (php_sapi_name() != "cli") { + return ''. $title .''; + } } /** @@ -148,21 +172,27 @@ class CinisisDisplayHelper { * Formatted link. */ static function entry_link($entry) { - return self::link('index.php', '?entry='. $entry, $entry); + if (php_sapi_name() != "cli") { + return self::link('index.php', '?entry='. $entry, $entry); + } } /** * Draws tags for opening a table. */ static function open_table() { - echo ''; + if (php_sapi_name() != "cli") { + echo '
'; + } } /** * Draws tags for closing a table. */ static function close_table() { - echo '
'; + if (php_sapi_name() != "cli") { + echo ''; + } } /** @@ -172,7 +202,12 @@ class CinisisDisplayHelper { * Inner text. */ static function h2($text) { - echo "

$text

"; + if (php_sapi_name() == "cli") { + echo "$text\n"; + } + else { + echo "

$text

"; + } } /** @@ -182,14 +217,24 @@ class CinisisDisplayHelper { * Inner text. */ static function h3($text) { - echo "

$text

"; + if (php_sapi_name() == "cli") { + echo "$text\n"; + } + else { + echo "

$text

"; + } } /** * Draws a line break element. */ - static function br($text) { - echo "
"; + static function br() { + if (php_sapi_name() == "cli") { + echo "\n"; + } + else { + echo "
"; + } } /** @@ -199,6 +244,11 @@ class CinisisDisplayHelper { * Inner text. */ static function pre($text) { - echo "
$text
"; + if (php_sapi_name() == "cli") { + echo "$text\n"; + } + else { + echo "
\n$text
"; + } } } diff --git a/config/config.yaml b/config/config.yaml index 0f81b48..a8ab772 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,3 +1,3 @@ --- implementation: BiblioIsis -database: film +database: poster -- cgit v1.2.3