Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r20572: LJSUP-10442 (create a widget for a part ...

Committer: ailyin
LJSUP-10442 (create a widget for a part of editjournal.bml): revert 20570 because I didn't mean to commit to this branch
D   branches/commenting-form/cgi-bin/LJ/Widget/EntryChooser.pm
U   branches/commenting-form/htdocs/editjournal.bml
D   branches/commenting-form/templates/Widgets/entry_chooser.tmpl
Deleted: branches/commenting-form/cgi-bin/LJ/Widget/EntryChooser.pm
===================================================================
--- branches/commenting-form/cgi-bin/LJ/Widget/EntryChooser.pm	2011-11-18 08:51:32 UTC (rev 20571)
+++ branches/commenting-form/cgi-bin/LJ/Widget/EntryChooser.pm	2011-11-18 11:37:06 UTC (rev 20572)
@@ -1,106 +0,0 @@
-package LJ::Widget::EntryChooser;
-use strict;
-use warnings;
-
-use base qw( LJ::Widget::Template );
-
-sub template_filename {
-    return $ENV{'LJHOME'} . '/templates/Widgets/entry_chooser.tmpl';
-}
-
-sub prepare_template_params {
-    my ( $class, $template, $opts ) = @_;
-
-    my $entries = $opts->{'entries'};
-    my $remote = LJ::get_remote();
-
-    my @entries_display;
-
-    foreach my $entry (@$entries) {
-        my $entry_can_edit = 
-            $entry->poster->equals($remote) &&
-            ! $entry->journal->is_readonly &&
-            ! $entry->poster->is_readonly;
-
-        my $poster_ljuser = $opts->{'show_posters'}
-            ? $entry->poster->ljuser_display
-            : '';
-
-        my $entry_is_delayed = $entry->is_delayed;
-        my $entry_is_sticky  = $entry->is_sticky;
-
-        ### security indicator
-        my $entry_security = 'public';
-        if ( $entry->security eq 'private' ) {
-            $entry_security = 'private';
-        } elsif ( $entry->security eq 'usemask' ) {
-            if ( $entry->allowmask == 0 ) {
-                $entry_security = 'private';
-            } elsif ( $entry->allowmask > 1 ) {
-                $entry_security = 'groups';
-            } else {
-                $entry_security = 'friends';
-            }
-        }
-
-        my $edit_link_base = "$LJ::SITEROOT/editjournal.bml?";
-
-        $edit_link_base .= 'usejournal=' . $entry->journal->username . '&';
-
-        if ( $entry->is_delayed ) {
-            $edit_link_base .= 'delayedid=' . $entry->delayedid . '&';
-        } else {
-            $edit_link_base .= 'itemid=' . $entry->ditemid . '&';
-        }
-
-        my $edit_link   = $edit_link_base . 'mode=edit';
-        my $delete_link = $edit_link_base . 'mode=delete';
-
-        my $entry_url     = $entry->url;
-        my $entry_subject = $entry->subject_text;
-
-        my $alldateparts;
-        if ($entry->is_delayed) {
-            $alldateparts = $entry->alldatepart;
-        } else {
-            $alldateparts = LJ::TimeUtil->alldatepart_s2($entry->{'eventtime'});
-        }
-        my ($year, $mon, $mday, $hour, $min) = split(/\D/, $alldateparts);
-        my $monthlong = BML::ml(LJ::Lang::month_long_langcode($mon));
-
-        my $date_display = "$monthlong $mday, $year, $hour:$min";
-
-        my $entry_text_display =
-            LJ::ehtml( LJ::durl( $entry->event_raw ) );
-        $entry_text_display =~ s{\n}{<br />}g;
-
-        my $entry_taglist = '';
-        if ( my @taglist = $entry->tags ) {
-            $entry_taglist = join( ', ', @taglist );
-        }
-
-        push @entries_display, {
-            'entry_can_edit'     => $entry_can_edit,
-            'poster_ljuser'      => $poster_ljuser,
-            'entry_is_delayed'   => $entry_is_delayed,
-            'entry_is_sticky'    => $entry_is_sticky,
-            'entry_security'     => $entry_security,
-            'edit_link'          => $edit_link,
-            'delete_link'        => $delete_link,
-            'entry_url'          => $entry_url,
-            'entry_subject'      => $entry_subject,
-            'date_display'       => $date_display,
-            'entry_text_display' => $entry_text_display,
-            'entry_taglist'      => $entry_taglist,
-        };
-    }
-
-    $template->param(
-        'link_prev' => $opts->{'link_prev'},
-        'link_next' => $opts->{'link_next'},
-        'entries'   => \@entries_display,
-        'adhtml'    => $opts->{'adhtml'},
-    );
-}
-
-1;

Modified: branches/commenting-form/htdocs/editjournal.bml
===================================================================
--- branches/commenting-form/htdocs/editjournal.bml	2011-11-18 08:51:32 UTC (rev 20571)
+++ branches/commenting-form/htdocs/editjournal.bml	2011-11-18 11:37:06 UTC (rev 20572)
@@ -140,54 +140,149 @@
         my $ref = shift;
         my %opts = @_;
 
+        my $ret;
+
         my @res = @$ref;
         my $show_ad = $opts{show_ad} ? 1 : 0;
         my $delayed_prev = $opts{'delayed_prev'};
         my $delayed_next = $opts{'delayed_next'};
 
-        my ( $link_prev, $link_next );
+        if ($opts{'prev'} || $opts{'next'} || !$opts{'first_page'}) {
+        $ret .= "<p class='i-qotd-nav'>";
+        if ($opts{'prev'} || !$opts{'first_page'}) {
+            $ret .=  "<a class='i-qotd-nav-prev' href='$LJ::SITEROOT/editjournal.bml$getextra" .
+                    ($getextra ? "&" : "?") .
+                    "skip=$opts{prev}'>prev</a>";
+        } else {
+            $ret .=  "<span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>";
+        }
+        if ($opts{'next'}) {
+            $ret .= "<a class='i-qotd-nav-next' href='$LJ::SITEROOT/editjournal.bml$getextra" .
+                    ($getextra ? "&" : "?") .
+                    "skip=$opts{next}'>next</a>";
+        } else {
+            $ret .= "<span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>";
+        }
+        $ret .= "</p>"
+            if @res;
+        }
+        unless (@res) {
+            $ret .= "<p class='i-bubble b-bubble-warning b-bubble-noarrow'>" .  BML::ml('.no_entries_to_edit') . "</p>";
+        }
+        $ret .= "</div>";
 
-        if ($opts{'prev'} || $opts{'next'} || !$opts{'first_page'}) {
-            if ($opts{'prev'} || !$opts{'first_page'}) {
-                $link_prev = "$LJ::SITEROOT/editjournal.bml$getextra" .
-                             ($getextra ? "&" : "?") .
-                             "skip=$opts{prev}";
+        $ret .= "<ul class='b-editentries'>" if @res;
+        foreach my $e_raw (@res) {
+            my $entry;
+            if ( $e_raw->{'itemid'} ) {
+                $entry = LJ::Entry->new_from_item_hash (LJ::load_user($usejournal) || $remote, $e_raw);
+            } elsif ($e_raw->{'delayedid'}) {
+                $entry = LJ::DelayedEntry->get_entry_by_id(LJ::load_user($usejournal,) || $remote, 
+                                                            $e_raw->{'delayedid'}, {'dateformat' => 'S2'});
+            } else {
+                die "unknown entry type";
             }
 
-            if ($opts{'next'}) {
-                $link_next = "$LJ::SITEROOT/editjournal.bml$getextra" .
-                             ($getextra ? "&" : "?") .
-                             "skip=$opts{next}";
+            my $edit_disable = 0;
+            if (
+                ($e_raw->{'posterid'} != $remote->userid)
+                || ($remote->is_readonly || ($usejournal_u && $usejournal_u->is_readonly))
+            ) {
+                $edit_disable++;
             }
-        }
 
-        my @entries;
+            my $poster = $usejournal ? LJ::ljuser(LJ::load_userid($entry->posterid)) : "";
 
-        my $journal = LJ::load_user($usejournal) || $remote;
-        foreach my $e_raw (@res) {
-            if ( $e_raw->{'itemid'} ) {
-                push @entries,
-                    LJ::Entry->new_from_item_hash( $journal, $e_raw );
-            } elsif ( $e_raw->{'delayedid'} ) {
-                push @entries,
-                    LJ::DelayedEntry->get_entry_by_id( $journal,
-                        $e_raw->{'delayedid'}, { 'dateformat' => 'S2' } );
+            $ret .= "<li class='b-editentry'>";
+
+            if ( $entry->is_delayed() ) {
+                  $ret .= BML::fill_template("typedelayed");
             }
+ 
+            if ( $entry->is_sticky())  {
+                $ret .= BML::fill_template("typesticky");
+            }
+
+            ### security indicator
+            my $sec = ' ';
+            if ($entry->security eq "private") {
+                $sec .= BML::fill_template("securityprivate");
+            } elsif ($entry->security eq "usemask") {
+                if ($entry->allowmask == 0) { # custom security with no group -- essentially private
+                    $sec .= BML::fill_template("securityprivate");
+                } elsif ($entry->allowmask > 1) { # custom group
+                    $sec .= BML::fill_template("securitygroups");
+                } else { # friends only
+                    $sec .= BML::fill_template("securityprotected");
+                }
+            }
+            $ret .= $sec;
+
+            $ret .= "<p class='b-editentry-ctrls'>";
+            my $ditemid_get;
+            if ($entry->is_delayed) {
+                $ditemid_get = $getextra ? ("$getextra&amp;delayedid=" . $entry->delayedid) : ("?delayedid=" . $entry->delayedid);
+            } else {
+                $ditemid_get = $getextra ? ("$getextra&amp;itemid=" . $entry->ditemid) : ("?itemid=" . $entry->ditemid);
+            }
+            if (!$edit_disable) {
+                $ret .= "<a href='editjournal.bml" . $ditemid_get . "&amp;mode=edit' class='b-editentry-edit-btn b-editentry-ctrl-btn'></a>";
+            } else {
+                $ret .= "<a href='editjournal.bml" . $ditemid_get . "&amp;mode=delete' class='b-editentry-del-btn b-editentry-ctrl-btn'></a>";
+            }
+            $ret .= "</p>";
+
+            $ret .= "<h2><a href='".$entry->url."'>";
+            if (my $subj = $entry->subject_text) {
+                $ret .= LJ::ehtml($subj);
+            } else {
+                $ret .= BML::ml('.event.no_subject.title');
+            }
+            $ret .= "</a></h2>";
+            my $alldateparts;
+            if ($entry->is_delayed) {
+                $alldateparts = $entry->alldatepart;
+            } else {
+                $alldateparts = LJ::TimeUtil->alldatepart_s2($entry->{'eventtime'});
+            }
+            my ($year, $mon, $mday, $hour, $min) = split(/\D/, $alldateparts);
+            my $monthlong = BML::ml(LJ::Lang::month_long_langcode($mon));
+            $ret .= "<p class='date'>" . $poster . " $monthlong $mday, $year, $hour:$min" . "</p>";
+
+            my $event = LJ::ehtml(LJ::durl($entry->event_raw));
+            $event =~ s!\n!<br />!g;
+            $ret .= $event;
+            if (my @taglist = $entry->tags) {
+                $ret .= "<p><b>Tags:</b> " . LJ::ehtml(join ", ", @taglist) . "</p>";
+            }
+            $ret .= "</li>";
         }
-
-        my $adhtml = '';
         if ($show_ad) {
-            $adhtml = LJ::get_ads(
-                { 'location' => 'bml.editjournal', 'ljadwrapper' => 1 } );
+            my $ad = LJ::get_ads({ location => 'bml.editjournal', ljadwrapper => 1 });
+            $ret .= "<td valign='top'>$ad</td>" if $ad;
         }
+        $ret .= "</ul>" if @res;
 
-        return LJ::Widget::EntryChooser->render(
-            'link_prev'    => $link_prev,
-            'link_next'    => $link_next,
-            'show_posters' => $usejournal ? 1 : 0,
-            'entries'      => \@entries,
-            'adhtml'       => $adhtml,
-        );
+        if ($opts{'prev'} || $opts{'next'} || !$opts{'first_page'}) {
+        $ret .= "<p class='i-qotd-nav'>";
+        if ($opts{'prev'} || !$opts{'first_page'}) {
+            $ret .=  "<a class='i-qotd-nav-prev' href='$LJ::SITEROOT/editjournal.bml$getextra" .
+                     ($getextra ? "&" : "?") .
+                     "skip=$opts{prev}'>prev</a>";
+        } else {
+            $ret .=  "<span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>";
+        }
+        if ($opts{'next'}) {
+            $ret .= "<a class='i-qotd-nav-next' href='$LJ::SITEROOT/editjournal.bml$getextra" .
+                     ($getextra ? "&" : "?") .
+                      "skip=$opts{next}'>next</a>";
+        } else {
+            $ret .= "<span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>";
+        }
+        $ret .= "</p>";
+        }
+
+        return $ret;
     };
 
     if ($mode eq "edit") {
@@ -738,8 +833,6 @@
             </script>
 JS_INIT
 
-        $ret .= '</div>'; # b-editentries-header
-
         my $err = '';
         my $usejournal_u = LJ::load_user ($usejournal || $remote->{'user'});
         my @recent_entries = ();

Deleted: branches/commenting-form/templates/Widgets/entry_chooser.tmpl
===================================================================
--- branches/commenting-form/templates/Widgets/entry_chooser.tmpl	2011-11-18 08:51:32 UTC (rev 20571)
+++ branches/commenting-form/templates/Widgets/entry_chooser.tmpl	2011-11-18 11:37:06 UTC (rev 20572)
@@ -1,98 +0,0 @@
-<TMPL_IF expr="link_prev || link_next">
-    <p class='i-qotd-nav'>
-        <TMPL_IF link_prev>
-            <a class='i-qotd-nav-prev' href='<TMPL_VAR link_prev>'>prev</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>
-        </TMPL_IF>
-
-        <TMPL_IF link_next>
-            <a class='i-qotd-nav-next' href='<TMPL_VAR link_next>'>next</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>
-        </TMPL_IF>
-    </p>
-</TMPL_IF>
-
-<TMPL_UNLESS entries>
-    <p class='i-bubble b-bubble-warning b-bubble-noarrow'><TMPL_VAR expr="ml('/editjournal.bml.no_entries_to_edit')"></p>
-</TMPL_UNLESS>
-
-<TMPL_IF entries>
-    <ul class='b-editentries'>
-        <TMPL_LOOP entries>
-            <li class='b-editentry'>
-                <TMPL_IF entry_is_delayed>
-                    <img src="<TMPL_VAR lj_imgprefix>/icon_delayed.png" width=13 height=15 align=absmiddle class="i-posticon">
-                </TMPL_IF>
-
-                <TMPL_IF entry_is_sticky>
-                    <img src="<TMPL_VAR lj_imgprefix>/icon_sticky.png" width=13 height=15 align=absmiddle class="i-posticon">
-                </TMPL_IF>
-
-                <TMPL_IF expr="entry_security eq 'private'">
-                    <img src="<?imgprefix?>/icon_private.gif" width=16 height=16 align=absmiddle class="i-posticon">
-                <TMPL_ELSIF expr="entry_security eq 'groups'">
-                    <img src="<?imgprefix?>/icon_groups.gif" width=19 height=16 align=absmiddle class="i-posticon">
-                <TMPL_ELSIF expr="entry_security eq 'friends'">
-                    <img src="<?imgprefix?>/icon_protected.gif" width=14 height=15 align=absmiddle class="i-posticon">
-                </TMPL_IF>
-
-                <p class='b-editentry-ctrls'>
-                    <TMPL_IF entry_can_edit>
-                        <a href='<TMPL_VAR edit_link ESCAPE=HTML>' class='b-editentry-edit-btn b-editentry-ctrl-btn'></a>
-                    <TMPL_ELSE>
-                        <a href='<TMPL_VAR delete_link ESCAPE=HTML>' class='b-editentry-del-btn b-editentry-ctrl-btn'></a>
-                    </TMPL_IF>
-                </p>
-
-                <h2><a href='<TMPL_VAR entry_url>'>
-                    <TMPL_IF entry_subject>
-                        <TMPL_VAR entry_subject ESCAPE=HTML>
-                    <TMPL_ELSE>
-                        <TMPL_VAR expr="ml('/editjournal.bml.event.no_subject.title')">
-                    </TMPL_IF>
-                </a></h2>
-
-                <p class='date'>
-                    <TMPL_VAR poster_ljuser>
-                    <TMPL_VAR date_display>
-                </p>
-
-                <TMPL_VAR entry_text_display>
-
-                <TMPL_IF entry_taglist>
-                    <p>
-                        <b>Tags:</b>
-                        <TMPL_VAR entry_taglist ESCAPE=HTML>
-                    </p>
-                </TMPL_IF>
-            </li>
-        </TMPL_LOOP>
-    </ul>
-
-    <TMPL_IF adhtml>
-        <td valign='top'><TMPL_VAR adhtml></td>
-    </TMPL_IF>
-</TMPL_IF>
-
-<TMPL_UNLESS entries>
-    <td valign='top'><TMPL_VAR adhtml></td>
-</TMPL_UNLESS>
-
-<TMPL_IF expr="link_prev || link_next">
-    <p class='i-qotd-nav'>
-        <TMPL_IF link_prev>
-            <a class='i-qotd-nav-prev' href='<TMPL_VAR link_prev>'>prev</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>
-        </TMPL_IF>
-
-        <TMPL_IF link_next>
-            <a class='i-qotd-nav-next' href='<TMPL_VAR link_next>'>next</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>
-        </TMPL_IF>
-    </p>
-</TMPL_IF>
-

Tags: ailyin, andy, bml, livejournal, pm, tmpl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments