kunzite (kunzite1) wrote in component_help,
kunzite
kunzite1
component_help

[theme] - [component] - [tags page]

fixes "unknown view" problem.
fixes fucked up tag urls for tags with spaces.
"group" counts are messed up in the backend so do some math to figure it out.
"group" counts are not accurate for users other than owner, so, only show to owner of journal.
function TagsPage::view_title() : string  {
  return "Tags Page";
}

function TagsPage::print_body() {
  var string welcome_title = "Visible Tags";

  print_entry_header("<b>$welcome_title<b>");
  """
  <table cellspacing="0" cellpadding="0" border="0" width="100%">
    <tr>
      <td width="1" class="dkLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" border="0" /></td>
      <td class="entryHolderBg" width="100%">
  """;
  print_content_top();

  var string   content         = "";
  var string[] security_order  = ["public"];
  var int security_index = 1;
  if(viewer_is_owner()) {
    $security_order[$security_index++] = "private";
    $security_order[$security_index++] = "group";
  }
  if(viewer_logged_in()) {
    $security_order[$security_index++] = "friends";
  }
  var int colspan = viewer_is_owner() ? 3 : 2;
  var string{} security_labels = {
                                  "public"  => """<img src="http://pics.livejournal.com/kunzite1/pic/000f5p4c" />""",
                                  "private" => """<img src="$*IMGDIR/icon_private.gif" />""",
                                  "friends" => """<img src="$*IMGDIR/icon_protected.gif" />""",
                                  "group"   => """<img src="http://pics.livejournal.com/kunzite1/pic/00074yeb" />"""
                                 };
  var string{} security_headers = {
                                   "public"  => "Public",
                                   "private" => "Private",
                                   "friends" => "Protected",
                                   "group"   => "Group"
                                  };

  $content = $content + """<table>\n<tr>\n  <th align="center" colspan="2" nowrap="nowrap">&nbsp;Tag&nbsp;</th>\n""" + (viewer_is_owner() ? """<th align="center" nowrap="nowrap">&nbsp;Total&nbsp;</th>\n""" : "");
  foreach var string security($security_order) {
    $content = $content + """  <th align="center" nowrap="nowrap">&nbsp;$security_headers{$security}&nbsp;</th>\n""";
  }
  $content = $content + "</tr>\n";
  foreach var TagDetail td ($.tags) {
    var int security_count = 0;
    var int group_count    = $td.use_count;
    var string uses = (viewer_is_owner() ? ("""<td style="font-family: courier; text-align: right;">$td.use_count</td>""") : "");
    foreach var string security($security_order) {
      $security_count = $security != "group" ? $td.security_counts{$security} : $group_count;
      $uses           = $uses + """<td style="font-family: courier; text-align: right;">$security_count</td>""";
      $group_count    = $group_count - $security_count;
    }
    $content = $content + """<tr><td>$security_labels{$td.visibility}</td><td><a href="$td.url">$td.name</a></td>$uses</tr>\n""";
  }
  $content = $content + "</table>";
  print $content;

  print_content_bottom();
  print_system_box_bottom();
}
Tags: !tutorial, *account level: paid/perm, class: tagspage, function: print_body, function: view_title, user: kunzite1
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 72 comments