Beispiel #1
0
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);
            }
        }
    }
}
Beispiel #2
0
 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;
 }
Beispiel #3
0
 function setParam($page, $name, $body, $type = '', $alias = '')
 {
     static $converter = NULL;
     $this->page = $page;
     $this->name = $name;
     $this->body = $body;
     $this->type = $type;
     $this->is_image = FALSE;
     $this->use_lightbox = FALSE;
     if ($this->type === 'url' && !$this->cont['PKWK_DISABLE_INLINE_IMAGE_FROM_URI'] && $this->func->is_url($alias) && preg_match('/\\.(gif|png|jpe?g)$/i', $alias)) {
         $this->is_image = TRUE;
         if ($this->cont['SHOW_EXTIMG_BY_REF'] && !$this->func->refcheck(0, $alias) && !preg_match($this->cont['NO_REF_EXTIMG_REG'], $alias)) {
             $alias = $this->func->do_plugin_inline('ref', $alias);
             $alias = preg_replace('#</?a[^>]*?>#i', '', $alias);
             $alias = preg_replace('/\\s*title="[^"]*"/', '', $alias);
             $this->use_lightbox = FALSE;
         } else {
             $alias = '<img src="' . htmlspecialchars($alias) . '" alt="' . $name . '" />';
             $this->use_lightbox = TRUE;
         }
         //if ($alias === $name) {
         //	$this->is_image = TRUE;
         //} else {
         //	$alias = preg_replace('/\s*title="[^"]*"/', '', $alias);
         //}
     } else {
         if ($alias !== '') {
             if ($converter === NULL) {
                 $converter = new XpWikiInlineConverter($this->xpwiki, array('plugin'));
             }
             $alias = $this->func->make_line_rules($converter->convert($alias, $page));
             // BugTrack/669: A hack removing anchor tags added by AutoLink
             $alias = preg_replace('#</?a[^>]*>#i', '', $alias);
             // Is image only? (on render mode)
             if ($this->root->render_mode === 'render' || $this->root->use_root_image_manager) {
                 if (strpos($this->name, $this->root->siteinfo['rooturl']) === 0 && preg_match('/^<img[^>]+>$/s', trim($alias)) && preg_match('/(?:jpe?g|png|gif)$/i', $this->name)) {
                     $this->is_image = TRUE;
                     $this->use_lightbox = TRUE;
                     $alias = preg_replace('/\\s*title="[^"]*"/', '', $alias);
                 }
             }
         }
     }
     $this->alias = $alias;
     return TRUE;
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 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 . ');';
     }
 }