aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-08-16 16:27:28 -0300
committerSilvio <silvio@devlet.com.br>2010-08-16 16:27:28 -0300
commit60befe06f34c447fe601374d5e61c3e365ace8c5 (patch)
tree2f5211f8a2f252ad20461130973b3a2e76e18772
parentdcef8a2705b90366ba32f6a97626b358fab88ae9 (diff)
downloadcinisis-60befe06f34c447fe601374d5e61c3e365ace8c5.tar.gz
cinisis-60befe06f34c447fe601374d5e61c3e365ace8c5.tar.bz2
Enhanced input
-rw-r--r--classes/helpers/CinisisDisplayHelper.php14
-rw-r--r--tests/index.php8
-rw-r--r--tests/repetition.php15
3 files changed, 24 insertions, 13 deletions
diff --git a/classes/helpers/CinisisDisplayHelper.php b/classes/helpers/CinisisDisplayHelper.php
index 8a795e8..72e51b2 100644
--- a/classes/helpers/CinisisDisplayHelper.php
+++ b/classes/helpers/CinisisDisplayHelper.php
@@ -70,11 +70,18 @@ class CinisisDisplayHelper {
* @param $name
* Input name.
*
+ * @param $default
+ * Default value.
+ *
* @return
* Rendered text input.
*/
- function form_input_text($name) {
- return ucfirst($name) .': <input name="'. $name .'" type="text" />';
+ function form_input_text($name, $default = null) {
+ if ($default) {
+ $default = 'value="'. $default .'"';
+ }
+
+ return ucfirst($name) .': <input name="'. $name .'" type="text" '. $default .'/>';
}
/**
@@ -88,6 +95,9 @@ class CinisisDisplayHelper {
*
* @param $action
* Page action.
+ *
+ * @param $extra
+ * Extra parameters.
*/
function navbar($entry, $entries, $action = 'index.php', $extra = NULL) {
// First / prev links.
diff --git a/tests/index.php b/tests/index.php
index 50c36f6..b395b80 100644
--- a/tests/index.php
+++ b/tests/index.php
@@ -6,13 +6,13 @@
// Import requisites.
require_once '../index.php';
-// Draw the document.
-$display = new CinisisDisplayHelper('Isis Navigator');
-$display->form($display->form_input_text('entry'));
-
// Get entry number.
$entry = CinisisHttpHelper::get_numeric_arg('entry');
+// Draw the document.
+$display = new CinisisDisplayHelper('Isis Navigator');
+$display->form($display->form_input_text('entry', $entry));
+
// Get a db instance.
$isis = new CinisisDb();
diff --git a/tests/repetition.php b/tests/repetition.php
index f778275..8bc6388 100644
--- a/tests/repetition.php
+++ b/tests/repetition.php
@@ -6,14 +6,15 @@
// Import requisites.
require_once '../index.php';
+// Get input data.
+$code = CinisisHttpHelper::get_numeric_arg('code');
+$entry = CinisisHttpHelper::get_numeric_arg('entry');
+
// Draw the document.
$display = new CinisisDisplayHelper('Repetition finder');
-$form = $display->form_input_text('code') . $display->form_input_text('entry');
+$form = $display->form_input_text('code', $code) . $display->form_input_text('entry', $entry);
$display->form($form, 'repetition.php');
-// Get field code.
-$code = CinisisHttpHelper::get_numeric_arg('code');
-
// Get a db instance.
$isis = new CinisisDb();
@@ -22,7 +23,7 @@ if ($isis->db) {
// Get the number of entries.
$field = $isis->db->format['fields'][$code]['name'];
$entries = $isis->db->entries();
- $entry = CinisisHttpHelper::get_numeric_arg('entry') - 1;
+ $entry--;
// Query database.
do {
@@ -37,11 +38,11 @@ if ($isis->db) {
// Format output.
echo "<pre>\n";
+ echo "Selected field: $code: $field.\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);
+ print_r($result[$field]);
echo '</pre>';
}