page=str_replace(':', "",$page); if($subdir) { $subdir = trim($subdir,':\\\/'); $this->subdir ="/$subdir"; chdir($subdir); } if($exact == 'on') $this->exact_page_match = true; if($tm) { list($this->timestamp,$this->t_when) = explode(':',$tm); $this->dtype = $dtype; } if($search) { $this->search = $search; } else if($fuzzy) { $this->fuzzy = $this->get_regex($fuzzy); } if($search || $fuzzy) { if($ltype) $this->ltype = $ltype; } ob_start(); $this->recurse('.'); if(!$this->match){ if($page) $page = ":$page"; if($subdir) $subdir = "for $subdir"; echo "No match $subdir$page" ."\n"; } $contents = ob_get_contents(); ob_end_clean(); echo $contents; } function recurse($dir) { $dh = opendir($dir); if (!$dh) return; while (($file = readdir($dh)) !== false) { if ($file == '.' || $file == '..') continue; if (is_dir("$dir/$file")) $this->recurse("$dir/$file"); if (preg_match("/\.meta$/", $file)) { if($this->page && !preg_match("/" . $this->page ."/",$file)) continue; if($this->exact_page_match) { if(!preg_match("/^" . $this->page ."\.meta$/",$file)) continue; } $store_name = preg_replace('/^\./', $this->subdir, "$dir/$file"); $id_name = PAGES . preg_replace("/\.meta$/","",$store_name) . '.txt'; if(!file_exists($id_name)) continue; $success = $this->get_data("$dir/$file","$id_name",$store_name); if($success) { $this->match = true; echo "\n"; } } } closedir($dh); } /* @param string $file, the meta file @param string $id_path, path to dokuwiki page */ function get_data($file,$id_path,$store_name="") { global $current; $description = ""; $data = file_get_contents($file); $data_array = @unserialize(file_get_contents($file)); $creator =""; $creator_id=""; $contributors = array(); if ($data_array === false || !is_array($data_array)) return; if (!isset($data_array['current'])) return false; $current = $data_array['current']; if($this->t_when) { $tmstmp = $this->getcurrent('date', $this->dtype); if($this->t_when == 'b' && $tmstmp > $this->timestamp) { return false; } else if($this->t_when == 'a' && $tmstmp < $this->timestamp) { return false; } } $search = ""; $regex = ""; if($this->fuzzy) { $search = $this->fuzzy; $regex = '/(' . $search . ')/im'; } else if($this->search) { $search = $this->search; $regex = '/(' . $search . ')/m'; } if($regex) { if($this->ltype == 'descr') { $description = $this->getcurrent('description','abstract'); if(!preg_match($regex,$description)){ return false; } $description = preg_replace($regex,"$1",$description); } else if($this->ltype == 'media') { $media = $this->check_listtypes('media',$regex); if(!$media) return false; } else if($this->ltype == 'links') { $references = $this->check_listtypes('references',$regex); if(!$references) return false; } else if($this->ltype == 'contrib') { $contribs = $this->getcurrent('contributor', null); if(!$contribs) return false; if(!array_key_exists($search,$contribs)) return; $val = $contribs[$search]; unset($contribs[$search]); $search = "$search"; $contribs[$search] = $val; $contributors = $contribs; } else if($this->ltype == 'creator') { $creator = $this->getcurrent('creator', null); $creator_id = $this->getcurrent('user', null); if(!$creator && !$creator_id) return false; if(!preg_match($regex,$creator) && !preg_match($regex,$creator_id)) return; $creator=preg_replace($regex,"$1",$creator); $creator_id=preg_replace($regex,"$1",$creator_id); } } $this->match = true; echo "\n----------------\n$store_name"; echo "\n$id_path\n"; $keys = array('title','date','creator','last_change','relation', 'description','contributor'); foreach ($keys AS $header) { switch($header) { case 'title': $title = $this->getcurrent($header, null); echo "\n[Title: $title]"; break; case 'date': $this->process_dates($this->getcurrent('date', 'created'),$this->getcurrent('date', 'modified')); break; case 'user': if($creator || $creator_id) break; case 'creator': /* creator: string, full name of the user who created the page user: string, the login name of the user who created the page */ if(!$creator) { $creator = $this->getcurrent('creator', null); } if(!$creator_id) { $creator_id = $this->getcurrent('user', null); } $this->process_users($creator,$creator_id); break; case 'last_change': $last_change = $this->getSimpleKeyValue($this->getcurrent($header, null),"last_change"); if($last_change) { echo "[Last Change] \n$last_change\n"; } break; case 'contributor': if(empty($contributors)) { $contributors = $this->getcurrent($header, null); } if(!$contributors) break; echo "