add cms, add todo
[ssproject1617.git] / testcms-final-anon / system / classes / items.php
diff --git a/testcms-final-anon/system/classes/items.php b/testcms-final-anon/system/classes/items.php
new file mode 100644 (file)
index 0000000..b6714ac
--- /dev/null
@@ -0,0 +1,46 @@
+<?php defined('IN_CMS') or die('No direct access allowed.');\r
+\r
+class Items implements Iterator {\r
+\r
+       private $position = 0;\r
+       private $items = array();   \r
+\r
+       public function __construct($array) {\r
+               $this->position = 0;\r
+               $this->items = $array;\r
+       }\r
+\r
+       public function rewind() {\r
+               $this->position = 0;\r
+       }\r
+\r
+       public function current() {\r
+               return $this->items[$this->position];\r
+       }\r
+\r
+       public function key() {\r
+               return $this->position;\r
+       }\r
+\r
+       public function next() {\r
+               ++$this->position;\r
+       }\r
+\r
+       public function valid() {\r
+               return isset($this->items[$this->position]);\r
+       }\r
+       \r
+       public function length() {\r
+               return count($this->items);\r
+       }\r
+\r
+       public function first() {\r
+               return isset($this->items[0]) ? $this->items[0] : false;\r
+       }\r
+\r
+       public function last() {\r
+               $index = count($this->items) - 1;\r
+               return isset($this->items[$index]) ? $this->items[$index] : false;\r
+       }\r
+\r
+}\r