4 This plugin allows to generate text database entries for static/internal
5 pages, so those can later be found by the PageSearch or PowerSearch
6 functions. It may be useful to run it on a regular time period. You
7 certainly need to set 'max_execution_time' limit in the php.ini up.
9 The function is crippled to run in $ewiki_ring==0 only (if an admin is
10 logged in). Either edit yoursite.php to detect the admin user or change
11 that line of code herein to make this admin function available to the
16 $ewiki_plugins["page"]["SearchCache"] = "ewiki_cache_generated_pages";
19 function ewiki_cache_generated_pages($id, &$data, $action) {
21 global $ewiki_plugins, $ewiki_ring;
23 $o = ewiki_make_title($id, $id, 1);
25 if (empty($_REQUEST["generate_cache"])) {
27 $o .= "Use this page plugin/tool to generate text database entries for
28 all generated ('internal' or 'static') pages available, so those can later
29 be found using the search functions.<br /><br />";
31 $o .= '<form action="'.ewiki_script("",$id).'" method="POST" enctype="text/html">'
32 . '<input type="hidden" name="id" value="'.$id.'">'
33 . '<input type="submit" value="generate cache" name="generate_cache">'
37 elseif (!ewiki_auth($id, $data, $action, $ring=0, "_FORCE_AUTH=1") || !isset($ewiki_ring) || ($ewiki_ring > 0)) {
39 if (is_array($data)) {
40 $data = "You'll need to be admin. See ewiki_auth() and _PROTECTED_MODE in the README.";
46 unset($_REQUEST["generate_cache"]);
48 $o .= "generating cache versions from:<ul>\n";
50 foreach ($ewiki_plugins["page"] as $pid=>$pf) {
54 $d = ewiki_db::GET($pid);
55 if (empty($d) || empty($d["content"])) {
59 "flags" => EWIKI_DB_F_TEXT,
68 $d["last_modified"] = time();
70 $d["content"] = $pf($pid, $d, "view");
72 //@ADD - transform <html> back to wikimarkup
75 if (ewiki_db::WRITE($d, true)) {
76 $o .= "<li>$pid</li>\n";
83 ewiki_log("page search cache was updated", 2);