From 2ec3b3c05e535ffacb1e10a64aa62ad057499d47 Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 16 Aug 2010 15:37:31 -0300 Subject: Adding helper classes and repetition finder --- tests/index.php | 48 +++++++++--------------------------------------- tests/read.php | 14 +++++--------- tests/repetition.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/test.php | 14 +++++--------- 4 files changed, 64 insertions(+), 57 deletions(-) create mode 100644 tests/repetition.php (limited to 'tests') diff --git a/tests/index.php b/tests/index.php index ae12134..50c36f6 100644 --- a/tests/index.php +++ b/tests/index.php @@ -2,33 +2,16 @@ /** * Cinisis - Isis db reading tool. */ -?> - - - - - - - - -
-Entry: - -
-
-form($display->form_input_text('entry')); + +// Get entry number. +$entry = CinisisHttpHelper::get_numeric_arg('entry'); // Get a db instance. $isis = new CinisisDb(); @@ -45,20 +28,7 @@ if ($isis->db) { // Query database. $result = $isis->db->read($entry); - - // First / prev links. - if ($entry != 1) { - $prev = $entry - 1; - echo 'first '; - echo '< prev '; - } - - // Next / last links. - if ($entry < $entries) { - $next = $entry + 1; - echo 'next > '; - echo 'last'; - } + $display->navbar($entry, $entries); // Format output. echo "
\n";
@@ -68,5 +38,5 @@ if ($isis->db) {
   echo '
'; } +$display->footer(); ?> - diff --git a/tests/read.php b/tests/read.php index 1235c25..5281335 100644 --- a/tests/read.php +++ b/tests/read.php @@ -4,20 +4,16 @@ */ ?> - - - - - - + array( 'implementation' => 'PhpIsis', diff --git a/tests/repetition.php b/tests/repetition.php new file mode 100644 index 0000000..7555016 --- /dev/null +++ b/tests/repetition.php @@ -0,0 +1,45 @@ +form($display->form_input_text('code'), 'repetition.php'); + +// Get field code. +$code = CinisisHttpHelper::get_numeric_arg('code'); + +// Get a db instance. +$isis = new CinisisDb(); + +// Setup database and entry number. +if ($isis->db) { + // Get the number of entries. + $field = $isis->db->format['fields'][$code]['name']; + $entries = $isis->db->entries(); + $entry = 1; + + // Query database. + do { + $result = $isis->db->read($entry++); + if ($entry == $entries) { + break; + } + } while (!isset($result[$field]) || count($result[$field]) < 2); + + // Format output. + echo "
\n";
+  echo "Showing entry $entry from $entries total entries.\n";
+  echo "Selected field: $field.\n";
+  echo "Repetitions found: ". count($result[$field]) ."\n";
+  echo "\n";
+  print_r($result);
+  echo '
'; +} + +$display->footer(); +?> diff --git a/tests/test.php b/tests/test.php index ebd465f..fd2ac99 100644 --- a/tests/test.php +++ b/tests/test.php @@ -4,17 +4,13 @@ */ ?> - - - - - - - + +