function validate_page($page) { global $FlgChr; $p = parse_wikiname($page, 1); if (preg_match('/^' . $FlgChr . '\\d+' . $FlgChr . '$/', $p)) { return 1; } $p = parse_freelink('[' . $page . ']', 1); if (preg_match('/^' . $FlgChr . '\\d+' . $FlgChr . '$/', $p)) { return 2; } return 0; }
function validate_page($page) { global $FlgChr; $page = get_title($page); $p = parse_wikiname($page, 1); if (preg_match('/^' . $FlgChr . '\\d+' . $FlgChr . '$/', $p)) { return 1; } $p = parse_freelink('((' . $page . '))', 1); if (preg_match('/^' . $FlgChr . '\\d+' . $FlgChr . '$/', $p)) { return 2; } //echo "<p>parse/transforms::validdate_page('$page')==0</p>\n"; return 0; }
function parse_odt_macros($text) { global $DiffScript, $page, $ViewBase, $ViewMacroEngine; // support for images with Attach macro $text = preg_replace('/\\[\\[Attach image ([^]]+)]]/e', "new_entity(array('raw', odt_image('attachments/'.trim(q1('\\1')))))", $text, -1); // support for RevisionHistory if (preg_match('/\\[\\[RevisionHistory( [^]]*)?]]/', $text, $matches)) { $text = $ViewMacroEngine['RevisionHistory']->parse($matches[1], $page); if ($text) { // convert table html to wiki markup $text = str_replace("<table>\n", '', $text); $text = str_replace('</table>', '', $text); $text = str_replace('<td></td>', '<td> </td>', $text); $text = str_replace('<tr><td>', '||', $text); $text = str_replace('</td><td>', '||', $text); $text = str_replace('</td></tr>', '||', $text); // misc cleanup $text = str_replace('<div align="right">', '', $text); $text = str_replace('</div>', '', $text); $text = str_replace(' ', '', $text); // clean history links $re = '/<a href="' . preg_quote($ViewBase) . '[^"]+?&version=' . '[^"]+?">(.+?)<\\/a>/'; $text = preg_replace($re, "\\1", $text); $re = '/<a href="' . preg_quote($DiffScript) . '[^"]+?">(.+?)<\\/a>/'; $text = preg_replace($re, "\\1", $text); // convert author links $re = '/<a href="' . preg_quote($ViewBase) . '[^"]+?">(.+?)<\\/a>/e'; $text = preg_replace($re, "wikiname_token(q1('\\1'), '')", $text); $odt = ''; foreach (explode("\n", $text) as $line) { $line = parse_wikiname($line); $line = parse_odt_table($line); $line = parse_odt_bold($line); $odt .= $line; } $text = $odt; } } // ignores any other macro return preg_replace('/(\\[\\[([^] ]+( [^]]+)?)]])/e', "new_entity(array('raw', q1('\\1')))", $text, -1); }