aboutsummaryrefslogtreecommitdiff
path: root/classes/IsisConnector.php
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-07-19 18:04:40 -0300
committerSilvio <silvio@devlet.com.br>2010-07-19 18:04:40 -0300
commit1d84217ed97be237d2696c85a997c9e52114b984 (patch)
treee2b241be944cea023d89f785dfb97286cbd9be24 /classes/IsisConnector.php
parent2018efe9bd583378e11e7998070221faa92890b4 (diff)
downloadcinisis-1d84217ed97be237d2696c85a997c9e52114b984.tar.gz
cinisis-1d84217ed97be237d2696c85a997c9e52114b984.tar.bz2
Lots of API changes at IsisConnector and iterators
Diffstat (limited to 'classes/IsisConnector.php')
-rw-r--r--classes/IsisConnector.php66
1 files changed, 59 insertions, 7 deletions
diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php
index da19fde..c82d479 100644
--- a/classes/IsisConnector.php
+++ b/classes/IsisConnector.php
@@ -47,7 +47,7 @@ class IsisConnector {
* @return
* Main field name.
*/
- public function getMainFieldName($field) {
+ public function getMainItemName($field) {
$key = $this->getFieldKey($field);
return $this->isis->db->main_field_name($key);
}
@@ -108,8 +108,8 @@ class IsisConnector {
* @return
* Field data.
*/
- public function getMainField($field, $row = 0) {
- $name = $this->getMainFieldName($field);
+ public function getMainItem($field, $row = 0) {
+ $name = $this->getMainItemName($field);
if (isset($this->result[$field['name']][$row][$name])) {
return $this->result[$field['name']][$row][$name];
@@ -125,9 +125,9 @@ class IsisConnector {
* @return
* Field data.
*/
- public function getMainFields($field) {
+ public function getMainItems($field) {
foreach (new IsisRowIterator($this, $field) as $row) {
- $values[$row] = $this->getMainField($field, $row);
+ $values[$row] = $this->getMainItem($field, $row);
}
return $values;
@@ -182,6 +182,58 @@ class IsisConnector {
}
/**
+ * Get both main field or subfields from a given field and row.
+ *
+ * @param $field
+ * field array.
+ *
+ * @param $item
+ * item name (field or subfield).
+ *
+ * @param $row
+ * row number.
+ *
+ * @return
+ * Item data.
+ */
+ public function getItem($field, $item, $row) {
+ $main_field = $this->getMainItemName($field);
+
+ if ($field == $main_field) {
+ return $this->getMainItem($field, $row);
+ }
+ else {
+ return $this->getSubfield($field, $item, $row);
+ }
+ }
+
+ /**
+ * Get all rows both main field or subfields from a given field.
+ *
+ * @param $field
+ * field array.
+ *
+ * @param $item
+ * item name (field or subfield).
+ *
+ * @param $row
+ * row number.
+ *
+ * @return
+ * Item data.
+ *
+ * @todo
+ * Rename to getItem?
+ */
+ public function getItems($field, $item) {
+ foreach (new IsisRowIterator($this, $field) as $row) {
+ $values[$row] = $this->getItem($field, $item, $row);
+ }
+
+ return $values;
+ }
+
+ /**
* Get the list of subfields from a given field.
*
* @param $field
@@ -582,7 +634,7 @@ class IsisConnector {
}
/**
- * Deal with special subfields.
+ * Deal with special items.
*
* @param $field
* Field data from ISIS database schema.
@@ -596,7 +648,7 @@ class IsisConnector {
* @return
* True if special subfield, false otherwise of special return type
*/
- public function specialSubfield($field, $subfield, $return = 'boolean') {
+ public function specialItem($field, $subfield, $return = 'boolean') {
if (isset($field['special'])) {
$field_key = $this->getFieldKey($field);
$subfield_key = $this->getSubfieldKey($field, $subfield);