function xpwiki_onPageWriteAfter_tag(&$xpwiki_func, &$page, &$postdata, &$notimestamp, &$mode, &$diffdata) { // ページのtagデータファイルがある || tagプラグインらしき記述がある? $do = is_file($xpwiki_func->cont['CACHE_DIR'] . $xpwiki_func->encode($page) . '_page.tag'); if ($do || preg_match("/&tag\\([^)]*\\)(\\{.*?\\})?;/", $postdata)) { $params = array(); if ($mode !== 'delete') { $ic = new XpWikiInlineConverter($xpwiki_func->xpwiki, array('plugin')); $data = explode("\n", $postdata); while (!empty($data)) { $line = array_shift($data); if (!$line) { continue; } // 空行 // The first character $head = $line[0]; if (substr($line, 0, 2) === '//' || substr($line, 0, 4) === '----' || $head === ' ' || $head === "\t") { continue; } // Multiline-enabled block plugin if (!$xpwiki_func->cont['PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK'] && preg_match('/^#[^{]+(\\{\\{+)\\s*$/', $line, $matches)) { $len = strlen($matches[1]); while (!empty($data)) { $next_line = preg_replace("/[\r\n]*\$/", '', array_shift($data)); if (preg_match('/^\\}{' . $len . '}/', $next_line)) { break; } } } // tagプラグインのパラメータを抽出 $arr = $ic->get_objects($line, $page); while (!empty($arr)) { $obj = array_shift($arr); if ($obj->name === 'tag') { $do = TRUE; $params = array_merge($params, $xpwiki_func->csv_explode(',', $obj->param)); } } } } if ($do) { $plugin =& $xpwiki_func->get_plugin_instance('tag'); if ($plugin !== FALSE) { $params = array_unique($params); $_params = array(); foreach ($params as $prm) { if ($prm) { $_params[] = $prm; } } $_aryargs = array($page, $_params); call_user_func_array(array($xpwiki_func->root->plugin_tag, 'renew_tagcache'), $_aryargs); } } } }
function plugin_areaedit_collect($page, $postdata_old) { $str_areaedit = 'areaedit'; $len_areaedit = strlen($str_areaedit) + 1; $ic = new XpWikiInlineConverter(array('plugin')); $outputs = array(); $areaedit_ct = 0; foreach ($postdata_old as $line) { if (substr($line, 0, 1) == ' ' || substr($line, 0, 2) == '//') { continue; } $match = array(); if (!preg_match("/&{$str_areaedit}/", $line, $match)) { continue; } $pos = 0; $arr = $ic->get_objects($line, $page); while (count($arr)) { $obj = array_shift($arr); if ($obj->name != $str_areaedit) { continue; } $pos = strpos($line, '&' . $str_areaedit, $pos); $pos += $len_areaedit; $outputs[] = "+" . $obj->body; $areaedit_ct++; } } return $outputs; }
function &links_get_objects($page, $refresh = FALSE) { static $obj; if (!isset($obj) || $refresh) { $obj = new XpWikiInlineConverter($this->xpwiki, NULL, array('note')); } $result = $obj->get_objects(join('', preg_grep('/^(?!\\/\\/|\\s)./', $this->get_source($page))), $page); return $result; }
function set_tags(&$postdata, $page, $tags) { // Tag の抽出とマージ $old_tags = $this->func->csv_explode(',', $this->get_tags($postdata, $page)); $new_tags = $this->func->csv_explode(',', $tags); $tags = array_unique(array_map('trim', array_merge($old_tags, $new_tags))); $tags = array_diff($tags, array('')); $tags = join(',', $tags); $set = FALSE; $ic = new XpWikiInlineConverter($this->xpwiki, array('plugin')); $data = explode("\n", $postdata); $res = array(); while (!empty($data)) { $line = array_shift($data); if (!$line) { $res[] = "\n"; // 空行 continue; } // The first character $head = $line[0]; if (substr($line, 0, 2) === '//' || substr($line, 0, 4) === '----' || $head === ' ' || $head === "\t") { $res[] = $line . "\n"; continue; } // Multiline-enabled block plugin if (!$this->cont['PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK'] && preg_match('/^#[^{]+(\\{\\{+)\\s*$/', $line, $matches)) { $len = strlen($matches[1]); $res[] = $line . "\n"; while (!empty($data)) { $next_line = preg_replace("/[\r\n]*\$/", '', array_shift($data)); $res[] = $next_line . "\n"; if (preg_match('/^\\}{' . $len . '}/', $next_line)) { break; } } } // tagプラグインのパラメータを抽出 if (!$set && preg_match("/&tag\\([^)]*\\)(\\{.*?\\})?;/", $line)) { $arr = $ic->get_objects($line, $page); while (!empty($arr)) { $obj = array_shift($arr); if ($obj->name === 'tag') { $set = TRUE; } } if ($set) { $line = preg_replace("/(&tag\\()[^)]*(\\)(\\{.*?\\})?;)/", '$1' . $tags . '$2', $line, 1); } } $res[] = $line . "\n"; } if ($set) { $postdata = join('', $res); } else { $postdata .= "\n\n" . '&tag(' . $tags . ');'; } }