Exemple #1
0
    function convert_finisher(&$body)
    {
        static $uniqueid = 0;
        $uniqueid++;
        // Ť¤±Ñ¿ô¤òÀÞ¤êÊÖ¤¹
        if ($this->root->word_break_limit && HypCommonFunc::get_version() >= '20080217') {
            HypCommonFunc::html_wordwrap($body, $this->root->word_break_limit, $this->root->word_breaker);
        }
        // cont['USER_NAME_REPLACE'] ¤Ê¤É¤ò ÃÖ´¹
        // '_uNIQUEiD_' : Unique ID (Inreger)
        $bef = array($this->cont['USER_NAME_REPLACE'], $this->cont['USER_CODE_REPLACE'], '_uNIQUEiD_');
        $aft = array($this->root->userinfo['uname_s'], $this->root->userinfo['ucd'], $uniqueid);
        if ($this->root->replaces_finish) {
            foreach ($this->root->replaces_finish as $key => $val) {
                if ($key[0] === '_') {
                    $bef[] = $key;
                    $aft[] = $val;
                }
            }
        }
        $body = str_replace($bef, $aft, $body);
        // For Safari
        if ($this->cont['UA_NAME'] === 'Safari') {
            $body = preg_replace('/(<form)([^>]*>)/', '$1 accept-charset="UTF-8"$2', $body);
        }
        if ($this->root->viewmode === 'popup') {
            $body = preg_replace('/(<form[^>]*?>)/', '$1<input type="hidden" name="popup" value="1" />', $body);
        }
        if ($this->cont['PageForRef'] !== $this->cont['PAGENAME']) {
            $body = preg_replace('/(<form[^>]*?>)/', '$1<input type="hidden" name="uploadpage" value="' . htmlspecialchars($this->cont['PageForRef']) . '" />', $body);
        }
        // TextArea id
        if (strpos($body, '<textarea') !== FALSE) {
            $_func = <<<EOD
static \$i = 0;
if (strpos(\$match[2], ' id="') !== FALSE) {
\tif (strpos(\$match[2], ' id="{$this->root->mydirname}:') === FALSE) {
\t\t\$match[2] = str_replace(' id="', ' id="{$this->root->mydirname}:', \$match[2]);
\t}
\treturn \$match[1] . \$match[2] . '>';
} else {
\t\$i++;
\t\$id = '{$this->root->mydirname}:xpwiki_txtarea_' . \$i;
\treturn \$match[1] . \$match[2] . ' id="' . \$id . '">';
}
EOD;
            $body = preg_replace_callback('/(<textarea)([^>]*?)>/', create_function('$match', $_func), $body);
        }
    }