⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 context.pm

📁 1. 记录每个帖子的访问人情况
💻 PM
📖 第 1 页 / 共 5 页
字号:
    my $tb = MT::Trackback->load({ entry_id => $e->id })        or return '';    my $cfg = MT::ConfigMgr->instance;    my $path = $cfg->CGIPath;    $path .= '/' unless $path =~ m!/$!;    $path . $cfg->TrackbackScript . '/' . $tb->id;}sub _hdlr_entry_tb_data {    my($ctx, $args) = @_;    my $e = $ctx->stash('entry')        or return $ctx->_no_entry_error('MTEntryTrackbackData');    require MT::Trackback;    my $tb = MT::Trackback->load({ entry_id => $e->id })        or return '';    return '' if $tb->is_disabled;    my $cfg = MT::ConfigMgr->instance;    my $path = $cfg->CGIPath;    $path .= '/' unless $path =~ m!/$!;    $path .= $cfg->TrackbackScript . '/' . $tb->id;    my $url;    if (my $at = $_[0]->{current_archive_type}) {        $url = $e->archive_url($at);        $url .= '#' . sprintf("%06d", $e->id)            unless $at eq 'Individual';    } else {        $url = $e->permalink;    }    my $rdf = '';    my $comment_wrap = defined $args->{comment_wrap} ?        $args->{comment_wrap} : 1;    $rdf .= "<!--\n" if $comment_wrap;    ## SGML comments cannot contain double hyphens, so we convert    ## any double hyphens to single hyphens.    my $strip_hyphen = sub {        (my $s = $_[0]) =~ tr/\-//s;        $s;    };    $rdf .= <<RDF;<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"         xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"         xmlns:dc="http://purl.org/dc/elements/1.1/"><rdf:Description    rdf:about="$url"    trackback:ping="$path"    dc:title="@{[ encode_xml($strip_hyphen->($e->title), 1) ]}"    dc:identifier="$url"    dc:subject="@{[ encode_xml($e->category ? $e->category->label : '', 1) ]}"    dc:description="@{[ encode_xml($strip_hyphen->(_hdlr_entry_excerpt(@_)), 1) ]}"    dc:creator="@{[ encode_xml(_hdlr_entry_author(@_), 1) ]}"    dc:date="@{[ _hdlr_date($_[0], { 'format' => "%Y-%m-%dT%H:%M:%S" }) .                 _hdlr_blog_timezone($_[0]) ]}" /></rdf:RDF>RDF    $rdf .= "-->\n" if $comment_wrap;    $rdf;}sub _hdlr_entry_tb_id {    my($ctx, $args) = @_;    my $e = $ctx->stash('entry')        or return $ctx->_no_entry_error('MTEntryTrackbackID');    require MT::Trackback;    my $tb = MT::Trackback->load({ entry_id => $e->id })        or return '';    $tb->id;}sub _hdlr_entry_link {    my $args = $_[1];    my $e = $_[0]->stash('entry')        or return $_[0]->_no_entry_error('MTEntryLink');    my $arch = $_[0]->stash('blog')->archive_url;    $arch .= '/' unless $arch =~ m!/$!;    my $archive_filename = $e->archive_file($args->{archive_type}					    ? $args->{archive_type} : ());    if ($archive_filename) {	return $arch . $archive_filename;    } else {	return "";    }}sub _hdlr_entry_basename {    my $args = $_[1];    my $e = $_[0]->stash('entry')        or return $_[0]->_no_entry_error('MTEntryBasename');    return $e->basename();}sub _hdlr_entry_permalink {    my $args = $_[1];    my $e = $_[0]->stash('entry')        or return $_[0]->_no_entry_error('MTEntryLink');    $e->permalink($args ? $args->{archive_type} : undef, 		  { valid_html => $args->{valid_html} });}sub _hdlr_entry_category {    my($ctx) = @_;    my $e = $ctx->stash('entry')        or return $ctx->_no_entry_error('MTEntryCategory');    my $cat = $e->category;    $cat ? $cat->label : '';}sub _hdlr_entry_categories {    my($ctx, $args, $cond) = @_;    my $e = $ctx->stash('entry')        or return $ctx->_no_entry_error('MTEntryCategories');    my $cats = $e->categories;    return '' unless $cats && @$cats;    my $builder = $ctx->stash('builder');    my $tokens = $ctx->stash('tokens');    my @res;    for my $cat (@$cats) {        local $ctx->{__stash}->{category} = $cat;        defined(my $out = $builder->build($ctx, $tokens, $cond))            or return $ctx->error( $builder->errstr );        push @res, $out;    }    my $sep = $args->{glue} || '';    join $sep, @res;}sub _hdlr_typekey_token {    my ($ctx, $args, $cond) = @_;    my $blog_id = $ctx->stash('blog_id');    my $blog = MT::Blog->load($blog_id);    my $tp_token = $blog->effective_remote_auth_token();    return $tp_token;}sub _hdlr_remote_sign_in_link {    my ($ctx, $args) = @_;    my $cfg = MT::ConfigMgr->instance;    my $blog = $ctx->stash('blog_id');    $blog = MT::Blog->load($blog) if defined $blog && !(ref $blog);    my $rem_auth_token = $blog->effective_remote_auth_token();    die MT->translate("To enable comment registration, you " .                      "need to add a TypeKey token in your " .                       "weblog config or author profile.")        unless $rem_auth_token;    my $needs_email = $blog->require_comment_emails ? "&need_email=1" : "";    my $signon_url = $cfg->SignOnURL;    my $path = $cfg->CGIPath;    $path =~ s|([^/])$|$1/|g;    my $comment_script = $cfg->CommentScript;    my $static_arg = $args->{static} ? "static=1" : "static=0";    my $e = $_[0]->stash('entry');    my $tk_version = $cfg->TypeKeyVersion ? "&v=" . $cfg->TypeKeyVersion : "";    my $language = "&lang=".$blog->language;    return "$signon_url$needs_email$language&t=$rem_auth_token$tk_version&_return=$path$comment_script%3f__mode=handle_sign_in%26$static_arg" .        ($e ? "%26entry_id=" . $e->id : '');}sub _hdlr_remote_sign_out_link {    my ($ctx, $args) = @_;    my $cfg = MT::ConfigMgr->instance;    my $path = $cfg->CGIPath;    $path =~ s|([^/])$|$1/|g;    my $comment_script = $cfg->CommentScript;    my $static_arg = $args->{static} ? "static=1" : "static=0";    my $e = $_[0]->stash('entry');    "$path$comment_script?__mode=handle_sign_in&$static_arg&logout=1" .        ($e ? "&entry_id=" . $e->id : '');}sub _hdlr_comment_fields {    my ($ctx, $args, $cond) = @_;    my $blog = $ctx->stash('blog_id');    $blog = MT::Blog->load($blog) if defined $blog && !(ref $blog);     return unless $blog->allow_reg_comments || $blog->allow_unreg_comments;    my $cfg = MT::ConfigMgr->instance;    my $path = $cfg->CGIPath;    $path =~ s|([^/])$|$1/|g;    my $comment_script = $cfg->CommentScript;    my $e = $_[0]->stash('entry')        or return $_[0]->_no_entry_error('MTEntryID');    my $entry_id = $e->id();    my $signon_url = $cfg->SignOnURL;    my $allow_comment_html_note = (($blog->allow_comment_html)				   ? ($args->{html_ok_msg} ||                                       MT->translate("(You may use HTML tags for style)")) : "");    my $needs_email = $blog->require_comment_emails ? "&need_email=1" : "";    my $registration_required = ($blog->allow_reg_comments 				 && !$blog->allow_unreg_comments);    my $registration_allowed = $blog->allow_reg_comments;    my $unregistered_allowed = $blog->allow_unreg_comments;    my $static_arg = $args->{static} ? "static=1" : "static=0";    my $static_field = ($args->{static} || !defined($args->{static}))			? (q{<input type="hidden" name="static" value="1" />})			: (q{<input type="hidden" name="static" value="0" />});    my $typekey_version = $cfg->TypeKeyVersion;    my $comment_author = "";    my $comment_email = "";    my $comment_text = "";    my $comment_url = "";    if ($args->{preview}) {	local $ctx->{__stash}->{tag} = 'Preview';        $comment_author = encode_html($ctx->_hdlr_comment_author()) || "";        $comment_email = encode_html($ctx->_hdlr_comment_email()) || "";        $comment_text = encode_html($ctx->_hdlr_comment_body({convert_breaks=>0}), 1) || "";	$comment_url = encode_html($ctx->_hdlr_comment_url()) || "";    }    my $rem_auth_token = $blog->effective_remote_auth_token() || "";    die "To enable comment registration, you need to add a TypeKey token "	. "in your weblog config or author profile."	if !$rem_auth_token && $registration_required;        my $tk_version = $cfg->TypeKeyVersion;    my $javascript = "";    if ($registration_allowed || $unregistered_allowed) {        $javascript = <<JAVASCRIPT;<script language="javascript">function getCookie (name) {    var prefix = name + \'=\';    var c = document.cookie;    var nullstring = \'\';    var cookieStartIndex = c.indexOf(prefix);    if (cookieStartIndex == -1)        return nullstring;    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);    if (cookieEndIndex == -1)        cookieEndIndex = c.length;    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));}</script>JAVASCRIPT    }    if ($registration_required) {	return MT->translate_templatized(<<HTML);$javascript<div id="thanks"><p><MT_TRANS phrase="Thanks for signing in,"><script>document.write(getCookie("commenter_name"))</script>.<MT_TRANS phrase="Now you can comment."> (<a href="$path$comment_script?__mode=handle_sign_in&$static_arg&entry_id=$entry_id&logout=1"><MT_TRANS phrase="sign out"></a>)</p><MT_TRANS phrase="(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)"><form method="post" action="$path$comment_script" name="comments_form" onsubmit="if (this.bakecookie[0].checked) rememberMe(this)">$static_field<input type="hidden" name="entry_id" value="$entry_id" /><p><label for="url">URL:</label><br /><input tabindex="1" type="text" name="url" id="url" value="$comment_url" /><MT_TRANS phrase="Remember me?"><input type="radio" id="remember" name="bakecookie" /><label for="bakecookie"><label for="remember"><MT_TRANS phrase="Yes"></label><input type="radio" id="forget" name="bakecookie" onclick="forgetMe(this.form)" value="Forget Info" style="margin-left: 15px;" /><label for="forget"><MT_TRANS phrase="No"></label><br style="clear: both;" /></p><p><label for="text"><MT_TRANS phrase="Comments:"></label><br /><textarea tabindex="2" id="text" name="text" rows="10" cols="50" id="text">$comment_text</textarea></p><div align="center"><input type="submit" name="preview" value="&nbsp;<MT_TRANS phrase="Preview">&nbsp;" /><input style="font-weight: bold;" type="submit" name="post" value="&nbsp;<MT_TRANS phrase="Post">&nbsp;" /></div></form></div><script language="javascript" type="text/javascript"><!--if (getCookie("commenter_name")) {    document.getElementById('thanks').style.display = 'block';} else {    document.write('<MT_TRANS phrase="You are not signed in. You need to be registered to comment on this site." escape="singlequotes"> <a href="$signon_url$needs_email&t=$rem_auth_token&v=$tk_version&_return=$path$comment_script%3f__mode=handle_sign_in%26$static_arg%26entry_id=$entry_id"><MT_TRANS phrase="Sign in" escape="singlequotes"></a>');    document.getElementById('thanks').style.display = 'none';}// --></script><script type="text/javascript" language="javascript"><!--if (document.comments_form.email != undefined)    document.comments_form.email.value = getCookie("mtcmtmail");if (document.comments_form.author != undefined)    document.comments_form.author.value = getCookie("mtcmtauth");if (document.comments_form.url != undefined)    document.comments_form.url.value = getCookie("mtcmthome");if (getCookie("mtcmtauth") || getCookie("mtcmthome")) {    document.comments_form.bakecookie[0].checked = true;} else {    document.comments_form.bakecookie[1].checked = true;}//--></script>HTML    ;    } else {        my $result = "";        if ($rem_auth_token && $registration_allowed) {            $result .= $javascript;            $result .= MT->translate_templatized(<<HTML);<script language="javascript" type="text/javascript"><!--if (getCookie("commenter_name")) {    document.write('<MT_TRANS phrase="Thanks for signing in,"> ', getCookie("commenter_name"), '<MT_TRANS phrase=". Now you can comment."> (<a href="$path$comment_script?__mode=handle_sign_in&$static_arg&entry_id=$entry_id&logout=1"><MT_TRANS phrase="sign out"></a>)');} else {    document.write('<MT_TRANS phrase="If you have a TypeKey identity, you can " escape="singlequotes"><a href="$signon_url$needs_email&t=$rem_auth_token&v=$tk_version&_return=$path$comment_script%3f__mode=handle_sign_in%26$static_arg%26entry_id=$entry_id"> <MT_TRANS phrase="sign in" escape="singlequotes"></a> <MT_TRANS phrase="to use it here." escape="singlequotes">');}// --></script>HTML        };        $result .= MT->translate_templatized(<<HTML);<form method="post" action="$path$comment_script" name="comments_form" onsubmit="if (this.bakecookie[0].checked) rememberMe(this)">$static_field<input type="hidden" name="entry_id" value="$entry_id" /><div id="name_email"><p><label for="author"><MT_TRANS phrase="Name:"></label><br /><input tabindex="1" name="author" id="author" value="$comment_author" /></p><p><label for="email"><MT_TRANS phrase="Email Address:"></label><br /><input tabindex="2" name="email" id="email" value="$comment_email" /></p></div>HTML        if ($rem_auth_token && $registration_allowed) {	    $result .= MT->translate_templatized(<<HTML)<script language="javascript" type="text/javascript"><!--if (getCookie("commenter_name")) {    document.getElementById('name_email').style.display = 'none';}// --></script>HTML	}        $result .= MT->translate_templatized(<<HTML);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -