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 --- classes/helpers/CinisisDisplayHelper.php | 96 ++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 23 deletions(-) (limited to 'classes/helpers/CinisisDisplayHelper.php') 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
"; + } } } -- cgit v1.2.3