dir = $dir; $this->exts = array(); if (is_array($exts)) { $this->exts = $exts; } else if (is_string($exts)) { $this->exts[] = $exts; } } public function getData() { $this->read(); return $this->data; } protected function read() { if ($this->dataReady) return; $this->rawData = array(); if ($handle = opendir($this->dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_file($this->dir.'/'.$file)) { $path_info = pathinfo($this->dir.'/'.$file); $ext = $path_info['extension']; $title = basename($file, '.' . $ext); if ((sizeof($this->exts) > 0) && (in_array($ext, $this->exts))) { $this->rawData[] = array( 'title' => $title, 'filename' => $file, 'ext' => $ext, ); } } } closedir($handle); } $this->processData(); $this->dataReady = true; } protected function processData() { $this->data = $this->rawData; } } class FileListNumbered extends FileList { public $num_patern = "|^(\d{1,5})[_-\s]+(.*)|"; protected function processData() { $arr = $this->rawData; $ret = array(); $res_ok = 0; $res_err = 0; for ($i=0; $inum_patern, $item['title'], $matches) == 1) { $num = intval($matches[1]); $item['num'] = $num; $item['usage'] = 0; $item['title'] = $matches[2]; if (!isset($ret[$num])) { $ret[$num] = $item; $res_ok++; } else { $res_err++; logWarn('File has duplicate number: ' . $filename . ' - ' . $num); } } else { $res_err++; logWarn('File do not match expected pattern: ' . $filename); } } logInfo("Processed numbered files in $this->dir folder: found: $res_ok, Errors: $res_err"); ksort($ret); $this->data = $ret; } } class MockupList extends FileListNumbered { public function getLink($num) { $ret = '';// echo $num; echo ' '; $m = NULL; if (isset($this->data[$num])) { $m =& $this->data[$num]; } if ($m) {//print_r( $m); $m['usage'] ++; $ret = 'mockup ' . $m['num'] . ''; } else { $ret = '!!! NO SUCH MOCKUP ' . $num . '!!!'; logWarn('Mockup number ' . $num . ' NOT FOUND'); } return $ret; } } class DocList extends FileList { } function vdie() { $vars = func_get_args(); foreach ($vars as $var) print(varDump($var)); exit(); } function varDump($var, $name = "", $funct = "") { $dump = ""; if ($name) { $dump .= "$name:
"; } $funct = $funct ? $funct : (is_scalar($var) || is_null($var) ? 'var_dump' : 'print_r'); ob_start(); print("
");
    $funct($var);
    print("
"); $dump .= ob_get_contents(); ob_end_clean(); return $dump; }