diff options
author | Silvio <silvio@devlet.com.br> | 2010-08-16 15:37:31 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-08-16 15:37:31 -0300 |
commit | 2ec3b3c05e535ffacb1e10a64aa62ad057499d47 (patch) | |
tree | db24e16e84c4d8f14d157e632d7d989aa3ba58b3 /tests | |
parent | 73731fa698fd658985cabeb202f3e6218931641f (diff) | |
download | cinisis-2ec3b3c05e535ffacb1e10a64aa62ad057499d47.tar.gz cinisis-2ec3b3c05e535ffacb1e10a64aa62ad057499d47.tar.bz2 |
Adding helper classes and repetition finder
Diffstat (limited to 'tests')
-rw-r--r-- | tests/index.php | 48 | ||||
-rw-r--r-- | tests/read.php | 14 | ||||
-rw-r--r-- | tests/repetition.php | 45 | ||||
-rw-r--r-- | tests/test.php | 14 |
4 files changed, 64 insertions, 57 deletions
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. */ -?> - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - </head> - <body> - -<form action="index.php" method="get"> -Entry: <input name="entry" type="text" /> -<input type="submit" /> -</form> -<br /> -<?php - -// Import Cinisis Library. +// Import requisites. require_once '../index.php'; -// Get the query parameter. -if (isset($_GET["entry"]) && ! empty($_GET["entry"])) { - $entry = (int) $_GET["entry"]; -} -else { - $entry = 1; -} +// Draw the document. +$display = new CinisisDisplayHelper('Isis Navigator'); +$display->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 '<a href="index.php?entry=1">first</a> '; - echo '<a href="index.php?entry='. $prev .'">< prev</a> '; - } - - // Next / last links. - if ($entry < $entries) { - $next = $entry + 1; - echo '<a href="index.php?entry='. $next .'">next ></a> '; - echo '<a href="index.php?entry='. $entries .'">last</a>'; - } + $display->navbar($entry, $entries); // Format output. echo "<pre>\n"; @@ -68,5 +38,5 @@ if ($isis->db) { echo '</pre>'; } +$display->footer(); ?> -</body> 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 @@ */ ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - </head> - <body> +<?php +// Import requisites. +require_once '../index.php'; +require_once 'includes/header.inc.php'; +?> <table><tr> <?php -// Import Cinisis Library. -require_once '../index.php'; - $configs = array( 0 => 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 @@ +<?php +/** + * Cinisis - Isis db reading tool. + */ + +// Import requisites. +require_once '../index.php'; + +// Draw the document. +$display = new CinisisDisplayHelper('Repetition finder'); +$display->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 "<pre>\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 '</pre>'; +} + +$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 @@ */ ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - </head> - <body> - <?php - -// Import Cinisis Library. +// Import requisites. require_once '../index.php'; +require_once 'includes/header.inc.php'; +?> + +<?php // Get a db instance. $isis = new CinisisDb(); |