aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-08-20 16:55:05 -0300
committerSilvio <silvio@devlet.com.br>2010-08-20 16:55:05 -0300
commit29e055f10a5ddf6424415c9cd9265d9d38e46ab3 (patch)
tree81c335672c2e4452e0ae0b6354565e7fa2e55a00
parentbf67bc20b46f3e464a21ca618e367efa503c6df6 (diff)
downloadcinisis-29e055f10a5ddf6424415c9cd9265d9d38e46ab3.tar.gz
cinisis-29e055f10a5ddf6424415c9cd9265d9d38e46ab3.tar.bz2
Code cleanup
-rw-r--r--apps/audit.php2
-rw-r--r--apps/field.php16
-rw-r--r--apps/index.php7
-rw-r--r--apps/repetition.php16
-rw-r--r--apps/subfield.php18
-rw-r--r--classes/helpers/CinisisDisplayHelper.php38
6 files changed, 62 insertions, 35 deletions
diff --git a/apps/audit.php b/apps/audit.php
index 0bd560b..10e6dd6 100644
--- a/apps/audit.php
+++ b/apps/audit.php
@@ -19,7 +19,7 @@ if ($isis) {
// Display log messages.
foreach ($isis->log as $message) {
- $display->pre(print_r($message));
+ $display->pre($message);
}
}
diff --git a/apps/field.php b/apps/field.php
index 6c7662e..09a2016 100644
--- a/apps/field.php
+++ b/apps/field.php
@@ -14,7 +14,8 @@ $fid = CinisisHttpHelper::getNumericArg('fid');
$display = new CinisisDisplayHelper('Field finder');
$form = $display->formInputText('entry', $entry);
$form .= $display->formInputText('fid', $fid);
-$display->form($form, basename(__FILE__));
+$script = basename(__FILE__);
+$display->form($form, $script);
// Get a db instance.
$isis = new IsisFinder();
@@ -26,16 +27,13 @@ if ($isis) {
list($entry, $result) = $isis->nextField($field, $entry);
// Navigation bar.
- $display->navbar($entry, $isis->entries, 'field.php', '&fid='. $fid);
+ $display->navbar($entry, $isis->entries, $script, '&fid='. $fid);
// Format output.
- echo "<pre>\n";
- echo "Selected field: $fid: ". $field['name'] ."\n";
- echo "Showing entry ". $display->entryLink($entry) ." from ". $isis->entries ." total entries.\n";
- echo "Repetitions found: ". count($result[$field['name']]) .".\n";
- echo "\n";
- print_r($result[$field['name']]);
- echo '</pre>';
+ $display->pre("Selected field: $fid: ". $field['name'] .".");
+ $display->pre("Showing entry ". $display->entryLink($entry) ." from ". $isis->entries ." total entries.");
+ $display->pre("Repetitions found: ". count($result[$field['name']]) .".");
+ $display->dump($result[$field['name']]);
}
$display->footer();
diff --git a/apps/index.php b/apps/index.php
index c34d4c3..0d88fd5 100644
--- a/apps/index.php
+++ b/apps/index.php
@@ -31,11 +31,8 @@ if ($isis->db) {
$display->navbar($entry, $entries);
// Format output.
- echo "<pre>\n";
- echo "Showing entry $entry from $entries total entries.\n";
- echo "\n";
- print_r($result);
- echo '</pre>';
+ $display->pre("Showing entry $entry from $entries total entries.");
+ $display->dump($result);
}
$display->footer();
diff --git a/apps/repetition.php b/apps/repetition.php
index 4eb3e7b..66d153f 100644
--- a/apps/repetition.php
+++ b/apps/repetition.php
@@ -14,7 +14,8 @@ $fid = CinisisHttpHelper::getNumericArg('fid');
$display = new CinisisDisplayHelper('Repetition finder');
$form = $display->formInputText('entry', $entry);
$form .= $display->formInputText('fid', $fid);
-$display->form($form, basename(__FILE__));
+$script = basename(__FILE__);
+$display->form($form, $script);
// Get a db instance.
$isis = new IsisFinder();
@@ -26,16 +27,13 @@ if ($isis) {
list($entry, $result) = $isis->nextRepetition($field, $entry);
// Navigation bar.
- $display->navbar($entry, $isis->entries, 'repetition.php', '&fid='. $fid);
+ $display->navbar($entry, $isis->entries, $script, '&fid='. $fid);
// Format output.
- echo "<pre>\n";
- echo "Selected field: $fid: ". $field['name'] ."\n";
- echo "Showing entry ". $display->entryLink($entry) ." from ". $isis->entries ." total entries.\n";
- echo "Repetitions found: ". count($result[$field['name']]) .".\n";
- echo "\n";
- print_r($result[$field['name']]);
- echo '</pre>';
+ $display->pre("Selected field: $fid: ". $field['name'] .".");
+ $display->pre("Showing entry ". $display->entryLink($entry) ." from ". $isis->entries ." total entries.");
+ $display->pre("Repetitions found: ". count($result[$field['name']]) .".");
+ $display->dump($result[$field['name']]);
}
$display->footer();
diff --git a/apps/subfield.php b/apps/subfield.php
index 8d58661..919e0b6 100644
--- a/apps/subfield.php
+++ b/apps/subfield.php
@@ -16,7 +16,8 @@ $display = new CinisisDisplayHelper('Subfield finder');
$form = $display->formInputText('entry', $entry);
$form .= $display->formInputText('fid', $fid);
$form .= $display->formInputText('sid', $sid);
-$display->form($form, basename(__FILE__));
+$script = basename(__FILE__);
+$display->form($form, $script);
// Get a db instance.
$isis = new IsisFinder();
@@ -29,17 +30,14 @@ if ($isis) {
list($entry, $result) = $isis->nextSubfield($field, $subfield, $entry);
// Navigation bar.
- $display->navbar($entry, $isis->entries, 'subfield.php', '&fid='. $fid . '&sid='. $sid);
+ $display->navbar($entry, $isis->entries, $script, '&fid='. $fid . '&sid='. $sid);
// Format output.
- echo "<pre>\n";
- echo "Selected field: $fid: ". $field['name'] .".\n";
- echo "Selected subfield: $sid: $subfield.\n";
- echo "Showing entry ". $display->entryLink($entry) ." from ". $isis->entries ." total entries.\n";
- echo "Repetitions found: ". count($result[$field['name']]) .".\n";
- echo "\n";
- print_r($result[$field['name']]);
- echo '</pre>';
+ $display->pre("Selected field: $fid: ". $field['name'] .".");
+ $display->pre("Selected subfield: $sid: $subfield.");
+ $display->pre("Showing entry ". $display->entryLink($entry) ." from ". $isis->entries ." total entries.");
+ $display->pre("Repetitions found: ". count($result[$field['name']]) .".");
+ $display->dump($result[$field['name']]);
}
$display->footer();
diff --git a/classes/helpers/CinisisDisplayHelper.php b/classes/helpers/CinisisDisplayHelper.php
index 468beb1..0a4b7f7 100644
--- a/classes/helpers/CinisisDisplayHelper.php
+++ b/classes/helpers/CinisisDisplayHelper.php
@@ -299,7 +299,21 @@ class CinisisDisplayHelper {
* Inner text.
*/
protected static function webPre($text) {
- echo "<pre>\n$text</pre>";
+ echo "<pre>$text</pre>";
+ }
+
+ /**
+ * Draws a pre open element.
+ */
+ protected static function webPreOpen() {
+ echo "<pre>";
+ }
+
+ /**
+ * Draws a pre open element.
+ */
+ protected static function webPreClose() {
+ echo "</pre>";
}
/**
@@ -311,4 +325,26 @@ class CinisisDisplayHelper {
protected static function cliPre($text) {
echo "$text\n";
}
+
+ /**
+ * Dump value.
+ *
+ * @param $var
+ * Variable to dump.
+ */
+ protected static function webDump($var) {
+ self::preOpen();
+ print_r($var);
+ self::preClose();
+ }
+
+ /**
+ * Dump value.
+ *
+ * @param $var
+ * Variable to dump.
+ */
+ protected static function cliDump($var) {
+ print_r($var);
+ }
}