aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/field.php16
-rw-r--r--apps/repetition.php16
-rw-r--r--apps/search.php21
-rw-r--r--apps/subfield.php19
-rw-r--r--classes/IsisMap.php35
-rw-r--r--classes/helpers/CinisisDisplayHelper.php59
-rw-r--r--config/config.yaml2
7 files changed, 131 insertions, 37 deletions
diff --git a/apps/field.php b/apps/field.php
index 09a2016..2829421 100644
--- a/apps/field.php
+++ b/apps/field.php
@@ -10,18 +10,18 @@ require_once '../index.php';
$entry = CinisisHttpHelper::getNumericArg('entry');
$fid = CinisisHttpHelper::getNumericArg('fid');
-// Draw the document.
-$display = new CinisisDisplayHelper('Field finder');
-$form = $display->formInputText('entry', $entry);
-$form .= $display->formInputText('fid', $fid);
-$script = basename(__FILE__);
-$display->form($form, $script);
-
// Get a db instance.
$isis = new IsisFinder();
-// Setup database and entry number.
if ($isis) {
+ // Draw the document.
+ $display = new CinisisDisplayHelper('Field finder');
+ $form = $display->formInputText('entry', $entry);
+ //$form .= $display->formInputText('fid', $fid);
+ $form .= $display->radios('fid', $isis->getFieldNames(), $fid);
+ $script = basename(__FILE__);
+ $display->form($form, $script);
+
// Query database.
$field = $isis->getFieldArray($fid);
list($entry, $result) = $isis->nextField($field, $entry);
diff --git a/apps/repetition.php b/apps/repetition.php
index 66d153f..6706162 100644
--- a/apps/repetition.php
+++ b/apps/repetition.php
@@ -10,18 +10,18 @@ require_once '../index.php';
$entry = CinisisHttpHelper::getNumericArg('entry');
$fid = CinisisHttpHelper::getNumericArg('fid');
-// Draw the document.
-$display = new CinisisDisplayHelper('Repetition finder');
-$form = $display->formInputText('entry', $entry);
-$form .= $display->formInputText('fid', $fid);
-$script = basename(__FILE__);
-$display->form($form, $script);
-
// Get a db instance.
$isis = new IsisFinder();
-// Setup database and entry number.
if ($isis) {
+ // Draw the document.
+ $display = new CinisisDisplayHelper('Repetition finder');
+ $form = $display->formInputText('entry', $entry);
+ //$form .= $display->formInputText('fid', $fid);
+ $form .= $display->radios('fid', $isis->getFieldNames(), $fid);
+ $script = basename(__FILE__);
+ $display->form($form, $script);
+
// Query database.
$field = $isis->getFieldArray($fid);
list($entry, $result) = $isis->nextRepetition($field, $entry);
diff --git a/apps/search.php b/apps/search.php
index cd75339..a66e80f 100644
--- a/apps/search.php
+++ b/apps/search.php
@@ -15,20 +15,21 @@ $fid = CinisisHttpHelper::getNumericArg('fid');
$sid = CinisisHttpHelper::getTextualArg('sid');
$text = CinisisHttpHelper::getTextualArg('text');
-// Draw the document.
-$display = new CinisisDisplayHelper('Text finder');
-$form = $display->formInputText('entry', $entry);
-$form .= $display->formInputText('fid', $fid);
-$form .= $display->formInputText('sid', $sid);
-$form .= $display->formInputText('text', $text);
-$script = basename(__FILE__);
-$display->form($form, $script);
-
// Get a db instance.
$isis = new IsisFinder();
-// Setup database and entry number.
if ($isis) {
+ // Draw the document.
+ $display = new CinisisDisplayHelper('Text finder');
+ $form = $display->formInputText('entry', $entry);
+ $form .= $display->radios('fid', $isis->getFieldNames(), $fid);
+ $form .= $display->radios('sid', $isis->getSubFieldNames($fid), $sid);
+ //$form .= $display->formInputText('fid', $fid);
+ //$form .= $display->formInputText('sid', $sid);
+ $form .= $display->formInputText('text', $text);
+ $script = basename(__FILE__);
+ $display->form($form, $script);
+
// Query database.
$field = $isis->getFieldArray($fid);
$item = ($sid == 'main') ? 'main' : $isis->getSubfieldName($fid, $sid);
diff --git a/apps/subfield.php b/apps/subfield.php
index 919e0b6..dac04d4 100644
--- a/apps/subfield.php
+++ b/apps/subfield.php
@@ -11,19 +11,20 @@ $entry = CinisisHttpHelper::getNumericArg('entry');
$fid = CinisisHttpHelper::getNumericArg('fid');
$sid = CinisisHttpHelper::getTextualArg('sid');
-// Draw the document.
-$display = new CinisisDisplayHelper('Subfield finder');
-$form = $display->formInputText('entry', $entry);
-$form .= $display->formInputText('fid', $fid);
-$form .= $display->formInputText('sid', $sid);
-$script = basename(__FILE__);
-$display->form($form, $script);
-
// Get a db instance.
$isis = new IsisFinder();
-// Setup database and entry number.
if ($isis) {
+ // Draw the document.
+ $display = new CinisisDisplayHelper('Subfield finder');
+ $form = $display->formInputText('entry', $entry);
+ $form .= $display->radios('fid', $isis->getFieldNames(), $fid);
+ $form .= $display->radios('sid', $isis->getSubFieldNames($fid), $sid);
+ //$form .= $display->formInputText('fid', $fid);
+ //$form .= $display->formInputText('sid', $sid);
+ $script = basename(__FILE__);
+ $display->form($form, $script);
+
// Query database.
$field = $isis->getFieldArray($fid);
$subfield = $isis->getSubfieldName($fid, $sid);
diff --git a/classes/IsisMap.php b/classes/IsisMap.php
index e73e178..05c7ae9 100644
--- a/classes/IsisMap.php
+++ b/classes/IsisMap.php
@@ -279,6 +279,25 @@ class IsisMap extends IsisReader {
}
/**
+ * Get all subfield names.
+ *
+ * @param $field_key
+ * Field key.
+ *
+ * @return
+ * Array with subfield names.
+ */
+ public function getSubfieldNames($field_key) {
+ $subfields = array();
+
+ foreach ($this->format['fields'][$field_key]['subfields'] as $key => $value) {
+ $subfields[$key] = $value;
+ }
+
+ return $subfields;
+ }
+
+ /**
* Get a field name.
*
* @param $field_key
@@ -290,4 +309,20 @@ class IsisMap extends IsisReader {
public function getFieldName($field_key) {
return $this->format['fields'][$field_key]['name'];
}
+
+ /**
+ * Get all field names.
+ *
+ * @return
+ * Array with field names.
+ */
+ public function getFieldNames() {
+ $fields = array();
+
+ foreach ($this->format['fields'] as $key => $field) {
+ $fields[$key] = $field['name'];
+ }
+
+ return $fields;
+ }
}
diff --git a/classes/helpers/CinisisDisplayHelper.php b/classes/helpers/CinisisDisplayHelper.php
index 2f8fa65..0eb8d28 100644
--- a/classes/helpers/CinisisDisplayHelper.php
+++ b/classes/helpers/CinisisDisplayHelper.php
@@ -407,7 +407,7 @@ class CinisisDisplayHelper {
* @param $items
* Array with items to be merged.
*/
- protected function webMergeCsvItems($items) {
+ protected static function webMergeCsvItems($items) {
if (!empty($items)) {
self::csv(implode(';', $items));
}
@@ -415,4 +415,61 @@ class CinisisDisplayHelper {
self::csv();
}
}
+
+ /**
+ * Renders a radio button.
+ *
+ * @param $name
+ * Radio name.
+ *
+ * @param $value
+ * Radio value.
+ *
+ * @param $caption
+ * Radio caption.
+ *
+ * @param $checked
+ * Whether the radio is checked.
+ *
+ * @return
+ * HTML rendered radio button.
+ */
+ protected static function webRadio($name, $value, $caption, $checked = NULL) {
+ return '<input type="radio" name="'. $name .'" value="'. $value .'" '. $checked .' > '. $caption .'<br />';
+ }
+
+ /**
+ * Draws a combination of radio buttons.
+ *
+ * @param $name
+ * Radio names.
+ *
+ * @param $data
+ * Array with values and captions.
+ *
+ * @param $checked
+ * Index of the selected option.
+ */
+ protected static function webRadios($name, $data, $checked = NULL) {
+ $radios = '<table><tr><td>';
+ $count = 0;
+
+ foreach ($data as $key => $value) {
+ if ($count++ > 5) {
+ $count = 0;
+ $radios .= '</td><td>';
+ }
+
+ if ($key == $checked) {
+ $radios .= self::webRadio($name, $key, $value, 'checked');
+ }
+ else {
+ $radios .= self::webRadio($name, $key, $value);
+ }
+ }
+
+ $radios .= '</td></tr></table>';
+
+ return $radios;
+ }
}
diff --git a/config/config.yaml b/config/config.yaml
index a8ab772..0f81b48 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -1,3 +1,3 @@
---
implementation: BiblioIsis
-database: poster
+database: film