home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / discus_admin_1357211388 / source / treeview.pl < prev    next >
Text File  |  2009-11-06  |  3KB  |  76 lines

  1. # FILE: treeview.pl
  2. # DESCRIPTION: User Interface "Tree View"
  3. #-------------------------------------------------------------------------------
  4. # DISCUS COPYRIGHT NOTICE
  5. #
  6. # Discus is copyright (c) 2002 by DiscusWare, LLC, all rights reserved.
  7. # The use of Discus is governed by the Discus License Agreement which is
  8. # available from the Discus WWW site at:
  9. #    http://www.discusware.com/discus/license
  10. #
  11. # Pursuant to the Discus License Agreement, this copyright notice may not be
  12. # removed or altered in any way.
  13. #-------------------------------------------------------------------------------
  14.  
  15. use strict;
  16. use vars qw($GLOBAL_OPTIONS $DCONF $PARAMS);
  17.  
  18. ###
  19. ### tree_control
  20. ###
  21. ### Generates a tree view for the user interface tree view script
  22. ###
  23.  
  24. sub tree_control {
  25.     my $FORMref = defined $_[0] ? $_[0] : parse_form($ENV{'QUERY_STRING'}, $ENV{'CONTENT_LENGTH'});
  26.     my $cookie_string = $_[1];
  27.     dreq("template");
  28.     my $subst = {};
  29.     my $tr = read_tree(undef, { no_lock => 1, no_unlock => 1, zero_ok => 1 });
  30.     if ($DCONF->{pro}) {
  31.         dreq("authwrap-PRO");
  32.         user_utility_login_check($FORMref);        
  33.         ($tr, $cookie_string) = tree_list_simple_prune($tr, $FORMref);
  34.     }
  35.     $subst->{topic_tree} = $tr;
  36.     if ($FORMref->{st} =~ m|^(\d+)$| && $FORMref->{x} eq "e") {
  37.         my $s = read_tree($1);
  38.         my @s = ();
  39.         foreach my $ss (@{ $s }) {
  40.             push @s, $ss if ($GLOBAL_OPTIONS->{skip_archives_tree} == 0 || $ss->{param} !~ m|Archive|);
  41.         }
  42.         $subst->{subtopic_tree} = \@s;
  43.     } else {
  44.         $FORMref->{st} = "";
  45.     }
  46.     undef my $par;
  47.     foreach my $y (@{ $subst->{subtopic_tree} }) {
  48.         $par->{ $y->{parent} } = $y->{page};
  49.     }
  50.     foreach my $yy (@{ $subst->{subtopic_tree} }) {
  51.         $yy->{last_of_parent} = 1 if $par->{ $yy->{parent} } == $yy->{page};
  52.     }
  53.     foreach my $z (@{ $subst->{topic_tree} }) {
  54.         $z->{expanded} = 1 if $FORMref->{st} == $z->{page};
  55.     }
  56.     $subst->{general}->{expand_url} = "$DCONF->{script_url}/board-viewtree.$DCONF->{cgi_extension}";
  57.     $subst->{general}->{link_to_page} = 1;
  58.     foreach my $o (@{ $subst->{topic_tree} }) {
  59.         $subst->{secure}->{$o->{topic}} = -e "$DCONF->{secdir}/$o->{topic}";
  60.     }
  61.     $DCONF->{html_url} =~ m%^(https?://.*?)(/|$)%; my $html_server = $1; my $html_after = join("", $2, $');
  62.     $DCONF->{message_url} =~ m%^(https?://.*?)(/|$)%; my $message_server = $1; my $message_after = join("", $2, $');
  63.     $DCONF->{script_url} =~ m%^(https?://.*?)(/|$)%; my $script_server = $1; my $script_after = join("", $2, $');
  64.     if ($script_server eq $html_server) {        
  65.         $subst->{general}->{icon_url} = join("/", $html_after, $DCONF->{icon_dir});
  66.         $subst->{general}->{script_url} = $script_after;
  67.     } else {
  68.         $subst->{general}->{icon_url} = join("/", $DCONF->{html_url}, $DCONF->{icon_dir});
  69.         $subst->{general}->{script_url} = $DCONF->{script_url};
  70.     }
  71.     $subst->{general}->{message_url} = $message_server eq $script_server ? $message_after : $DCONF->{message_url};
  72.     screen_out("treeview", $subst, $cookie_string);
  73. }
  74.  
  75. 1;
  76.