Exemplo n.º 1
0
function addOpenIDPannel($comment, $prefix)
{
    $context = Model_Context::getInstance();
    if (!isActivePlugin('CL_OpenID')) {
        return $comment;
    }
    $openid_identity = Acl::getIdentity('openid');
    $whatisopenid = '<a target="_blank" href="' . _text('http://www.google.co.kr/search?q=OpenID&amp;lr=lang_ko') . '"><span style="color:#ff6200">' . _text('오픈아이디란?') . '</span></a>';
    //$lastcomment = ' | <a href="#" onClick="recallLastComment([##_article_rep_id_##]); return false"><span style="color:#ff6200">'._text('마지막 댓글로 채우기').'</span></a>';
    $lastcomment = '';
    $openidOnlySettingNotice = '';
    if ($context->getProperty('blog.AddCommentMode', '') == 'openid') {
        $openidOnlySettingNotice = "<b>" . _text('오픈아이디로만 댓글을 남길 수 있습니다') . "</b>";
    }
    $tag_login = '******' . $context->getProperty('uri.blog') . '/login/openid/guest?requestURI=' . urlencode($_SERVER["REQUEST_URI"]) . '"><span style="color:#ff6200">' . _text('로그인') . '</span></a>';
    $tag_logoff = '<a href="' . $context->getProperty('uri.blog') . '/login/openid?action=logout&requestURI=' . urlencode($_SERVER["REQUEST_URI"]) . '"><span style="">' . _text('로그아웃') . '</span></a>';
    $pannel = '<div class="commentOuterPannel">' . CRLF;
    $openid_input = 'OPENID_TAG_NEEDED';
    $cookie_openid = '';
    if (!empty($_COOKIE['openid'])) {
        $cookie_openid = $_COOKIE['openid'];
    }
    if ($openidOnlySettingNotice || $openid_identity) {
        $checked1 = 'checked="checked"';
        $checked2 = '';
        $disabled1 = '';
        $disabled2 = 'disabled="disabled"';
    } else {
        $checked1 = '';
        $checked2 = 'checked="checked"';
        $disabled1 = 'disabled="disabled"';
        $disabled2 = '';
    }
    $pannel_style = "style=\"width:100%; text-align:left\"";
    $radio_style = "style=\"width:15px;vertical-align:text-bottom;height:15px;border:0px;margin:0px;padding:0px;\"";
    $label_style = "style=\"display:inline;margin-top:0px;padding-left:0px;cursor:pointer\"";
    $openid_input_style = 'style="padding-left:21px;width:165px;background-image:url(' . $context->getProperty('service.path') . '/resources/image/icon_openid.gif' . ');' . 'background-repeat:no-repeat;background-position:0px center"';
    if ($openid_identity) {
        $openid_input = '<span><a href="' . $openid_identity . '">' . OpenID::getDisplayName($openid_identity) . '</a></span>' . CRLF;
        $openid_input .= '<input type="hidden" name="openid_identifier" id="openid_identifier_[##_article_rep_id_##]" value="' . htmlentities($openid_identity) . '" />';
        $openid_input = _text('현재 로그인한 오픈아이디') . ' ' . $openid_input;
        $_COOKIE['guestHomepage'] = $_SESSION['openid']['homepage'];
        $_COOKIE['guestName'] = $_SESSION['openid']['nickname'];
    } else {
        if (preg_match('/.*?(<input[^>]+_(?:guest|rp)_input_homepage_[^>]+>).*/sm', $comment, $match)) {
            $openid_input = $match[1];
            $openid_input = str_replace('homepage_[##', 'openid_identifier_[##', $openid_input);
            $openid_input = str_replace('[##_' . $prefix . '_input_homepage_##]', 'openid_identifier', $openid_input);
            $openid_input = preg_replace('/value=(?:"|\')?(?:[^"\']+)(?:"|\')?/', 'value="' . $cookie_openid . '"', $openid_input);
            $openid_input = preg_replace('/style=("|\')?([^"\']+)("|\')?/', '', $openid_input);
            $openid_input = preg_replace('/(value=(?:"|\'))/', $openid_input_style . ' $1', $openid_input);
        }
    }
    if ($disabled1) {
        $openid_input = preg_replace('/(name=(?:"|\'))/', $disabled1 . ' $1', $openid_input);
    }
    if ($disabled2) {
        $comment = preg_replace("/(.*)(<input)((?:[^>]+)name_\\[##_article_rep_id_##\\](?:[^>]+)>(?:.*))/sm", "\$1\$2 {$disabled2} \$3", $comment);
        $comment = preg_replace("/(.*)(<input)((?:[^>]+)password_\\[##_article_rep_id_##\\](?:[^>]+)>(?:.*))/sm", "\$1\$2 {$disabled2} \$3", $comment);
        $comment = preg_replace("/(.*)(<input)((?:[^>]+)\\[##_{$prefix}_input_name_##\\](?:[^>]+)>(?:.*))/sm", "\$1\$2 {$disabled2} \$3", $comment);
        $comment = preg_replace("/(.*)(<input)((?:[^>]+)\\[##_{$prefix}_input_password_##\\](?:[^>]+)>(?:.*))/sm", "\$1\$2 {$disabled2} \$3", $comment);
    }
    $pannel .= '<div class="commentTypeOpenid" ' . $pannel_style . '>' . '<input class="commentTypeCheckbox" ' . $checked1 . ' type="radio" ' . CRLF . $radio_style . CRLF . 'id="comment_type_[##_article_rep_id_##]_openid" ' . CRLF . 'name="comment_type" value="openid" ' . CRLF . 'onclick="this.form.[##_' . $prefix . '_input_name_##].disabled=this.form.[##_' . $prefix . '_input_password_##].disabled=true;this.form.openid_identifier.disabled=false;this.form.openid_identifier.disabled=false;"' . CRLF . '/> ' . CRLF . '<label for="comment_type_[##_article_rep_id_##]_openid" ' . $label_style . '>' . _text('오픈아이디로 글쓰기') . '</label> <span>[' . ($openid_identity ? $tag_logoff : $tag_login) . '][' . $whatisopenid . $lastcomment . ']</span></div>' . CRLF;
    /* Opera browser does not work with single 'this.form.openid_identifier.disabled=false;', is it a bug? */
    $pannel .= '<div style="padding:5px 0 5px 0px;width:100%;">' . $openid_input . '</div>' . CRLF;
    $pannel .= '<div class="commentTypeNamepassword" ' . $pannel_style . ' >' . CRLF . '<input class="commentTypeCheckbox" ' . $checked2 . ' type="radio" ' . CRLF . $radio_style . CRLF . 'id="comment_type_[##_article_rep_id_##]_idpwd" ' . CRLF . 'name="comment_type" value="idpwd" ' . CRLF . 'onclick="this.form.[##_' . $prefix . '_input_name_##].disabled=this.form.[##_' . $prefix . '_input_password_##].disabled=false;this.form.openid_identifier.disabled=true;this.form.openid_identifier.disabled=true;"' . CRLF . '/> ' . CRLF . '<label for="comment_type_[##_article_rep_id_##]_idpwd" ' . $label_style . '>' . _text('이름/비밀번호로 글쓰기') . '</label> ' . $openidOnlySettingNotice . '</div>' . CRLF;
    $comment = $pannel . $comment . "</div>";
    return $comment;
}