/** * ソースからひな形を作成 */ public function auto_template() { global $auto_template_func, $auto_template_rules; if (!$auto_template_func) { return ''; } $source = ''; $matches = array(); foreach ($auto_template_rules as $rule => $template) { $rule_pattrn = '/' . $rule . '/'; if (!preg_match($rule_pattrn, $this->page, $matches)) { continue; } $template_page = preg_replace($rule_pattrn, $template, $this->page); if (!is_page($template_page)) { continue; } // ソースを取得 $source = Factory::Wiki($template_page)->source(); // Remove fixed-heading anchors $source = Rules::removeHeading($source); // Remove '#freeze' $source = preg_replace('/^#freeze\\s*$/m', '', $source); $count = count($matches); for ($i = 0; $i < $count; $i++) { $source = str_replace('$' . $i, $matches[$i], $source); } break; } return $source; }
function plugin_bugtrack_list_pageinfo($page, $no = NULL, $recurse = TRUE) { global $_plugin_bugtrack; if ($no === NULL) { $no = preg_match('/\\/([0-9]+)$/', $page, $matches) ? $matches[1] : 0; } $source = Factory::Wiki($page)->get(); // Check 'moved' page _just once_ $regex = '/move\\s*to\\s*(' . RendererDefines::WIKINAME_PATTERN . '|' . RendererDefines::INTERWIKINAME_PATTERN . '|\\[\\[' . RendererDefines::BRACKETNAME_PATTERN . '\\]\\])/'; $match = array(); if ($recurse && preg_match($regex, $source[0], $match)) { return plugin_bugtrack_list_pageinfo(Utility::stripBracket($match[1]), $no, FALSE); } $body = join("\n", $source); foreach (array('summary', 'name', 'priority', 'state', 'category') as $item) { $regex = '/-\\s*' . preg_quote($_plugin_bugtrack[$item], '/') . '\\s*:(.*)/'; if (preg_match($regex, $body, $matches)) { if ($item == 'name') { ${$item} = Utility::stripBracket(trim($matches[1])); } else { ${$item} = trim($matches[1]); } } else { ${$item} = ''; // Data not found } } if (preg_match("/\\*([^\n]*)/", $body, $matches)) { $summary = Rules::removeHeading($matches[0]); } return array($page, $no, $summary, $name, $priority, $state, $category); }