public function testFTPGetNonExisting() { $prep = [0 => 'a - odd,first', 1 => 'b - even', 2 => 'c - odd', 3 => 'd - even,last']; $list = array('a', 'b', 'c', 'd'); $le = ar::listExpression($list)->pattern('(odd even?)*', " single | first .* last "); foreach ($list as $position => $value) { $line = $value . " - " . implode(',', $le->item($position)); $this->assertEquals($prep[$position], $line); } }
public function call($template, $args = null) { global $store; if ($template instanceof ar_listExpression_Pattern) { $template = ar::listExpression($this->count())->pattern($template); } if (ar_store::$rememberShortcuts) { $path = ar_store::makePath($this->path); $realpath = ar_store::makeRealPath($this->path); if ($realpath != $path) { // must do a call for each seperate path. $list = array(); $parent = $path; while ($realpath != $this->top && $parent != $this->top && end($list) != $realpath) { $list[$parent] = $realpath; $parent = ar_store::makePath($parent . '../'); $realpath = ar_store::makeRealPath($parent); } if ($realpath == $this->top || $parent == $this->top) { $list[$parent] = $realpath; } $list = array_reverse($list); $result = array(); foreach ($list as $virtualpath => $path) { $result[$virtualpath] = current($store->call($template, $args, $store->get($path), array('usePathAsKey' => true))); } return $result; } } return $store->call($template, $args, $store->parents($this->path, $this->top), array('usePathAsKey' => true)); }
private function _runPatterns($value) { if ($value instanceof ar_listExpression_Pattern) { $count = 0; foreach ($this as $key => $node) { if ($node instanceof ar_xmlElement) { $count++; } } $value = ar::listExpression($count)->pattern($value->patterns); } else { if (is_array($value)) { $newvalue = array(); foreach ($value as $key => $subvalue) { $newvalue[$key] = $this->_runPatterns($subvalue); } $value = $newvalue; } } return $value; }
public static function _listExpression($list) { return ar::listExpression($list); }