From 6491b4a4dc9257348fdb3674cffb7b9fc89f40d0 Mon Sep 17 00:00:00 2001 From: Silvio Date: Fri, 2 Jul 2010 15:05:09 -0300 Subject: Adding IsisValueIterator --- classes/IsisValueIterator.php | 73 +++++++++++++++++++++++++++++++++++++++++++ schemas/fbe.yaml | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 classes/IsisValueIterator.php diff --git a/classes/IsisValueIterator.php b/classes/IsisValueIterator.php new file mode 100644 index 0000000..04b3d92 --- /dev/null +++ b/classes/IsisValueIterator.php @@ -0,0 +1,73 @@ +rows = $class->getRows($field); + $this->valueset = $class->getValues($field); + $this->keys = array_keys($this->valueset); + $this->values = count($this->keys); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->row = 0; + $this->value = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + return $this->row; + } + + /** + * Return the current element. + */ + function current() { + return $this->valueset[$this->keys[$this->value]]; + } + + /** + * Move forward to next element. + */ + function next() { + if ($this->value >= $this->values) { + $this->value = 0; + ++$this->row; + } + else { + ++$this->value; + } + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->row <= $this->rows; + } +} diff --git a/schemas/fbe.yaml b/schemas/fbe.yaml index c05bd01..f498cc1 100644 --- a/schemas/fbe.yaml +++ b/schemas/fbe.yaml @@ -93,7 +93,7 @@ fields: name: Sinopse/Enredo repeat: Yes map: - type: Plot + type: FilmPlots 26: name: Assuntos/Voc. Controlado repeat: Yes -- cgit v1.2.3