Thread Treemenu Admin Script: funzt nich...
(13 answers)
Opened by FlorianL at 2007-06-08 10:13
Was hältst Du davon? Ich habe nicht alles verbessert - ein wenig Arbeit soll ja auch noch für Dich übrig bleiben. Kann sein, dass Du bei Dir noch HTML::Template installieren musst. Bei Unklarheiten einfach fragen.
Skript: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 #!/usr/bin/perl # # Treeview-Script by F.Luettgens ### use strict; use CGI; use HTML::Template; my $nodefile = 'nodes.js';   ; # Use absolute Path! my $goto = $ENV{PATH_INFO}; my $cgi = "/cgi-bin/tree.cgi"; my $confquery = CGI->new; my @configs = $confquery->param; my %params = $confquery->Vars; $goto =~ s!^/!!; print $confquery->header; my %map = ( show => \&showconfig, newlink => \&newlink, config => \&config, saveconfig => \&saveconfig, safelink => \&safelink, new => \&new, ); if( exists $map{$goto} ){ $map{$goto}->(); } else{ my $tmpl = HTML::Template->new( filename => 'default.tmpl' ); $tmpl->param( SCRIPT => $cgi ); print $tmpl->output; } sub showconfig { open(NODES,$nodefile); my @scriptfile = <NODES>; close(NODES); my $tmpl = HTML::Template->new( filename => 'showconfig.tmpl' ); $tmpl->param( PRE => join(" ",@scriptfile) ); print $tmpl->output; } sub new { my $tmpl = HTML::Template->new( filename => 'new.tmpl' ); $tmpl->param( SCRIPT => $cgi ); print $tmpl->output; } sub newlink { my $tmpl = HTML::Template->new( filename => 'newlink.tmpl' ); $tmpl->param( SCRIPT => $cgi ); print $tmpl->output; } sub savelink { my $newlink_name = $params{'newlink_name'}; my $newlink_link = $params{'newlink_link'}; my $newlink_posi = $params{'newlink_posi'}; my ($kategorie, $sub_kategorie) = split(/\,/, $newlink_posi); my $newlink_frame = $params{'newlink_frame'}; open(NEWNODE,">>.nodes.dat") or die $!; print NEWNODE qq~aux$kategorie = gLnk("Rh", "$newlink_frame", "$newlink_link"))~; close (NEWNODE); rebuild(); } sub config { my $tmpl = HTML::Template->new( filename => 'config.tmpl' ); $tmpl->param( SCRIPT => $cgi ); print $tmpl->output; } sub saveconfig { my $use_buildall = $confquery->param('buildall'); my $use_highlight = $confquery->param('highlight'); my $highlightcolor = $confquery->param('highlight_color'); my $highlight_bg = $confquery->param('highlight_bg'); my $iconpath = $confquery->param('iconpath'); my $use_preserved = $confquery->param('preservedstate'); my $use_startallopen = $confquery->param('startallopen'); my $use_frames = $confquery->param('useframes'); my $use_icons = $confquery->param('useicons'); my $use_textlinks = $confquery->param('usetextlinks'); my $use_wraptext = $confquery->param('wraptext'); my $comment = $confquery->param('comment'); open(CONFIG_HEAD,">.config.dat"); if ($use_buildall eq '0') { print CONFIG_HEAD ("BUILDALL = 0\n") } elsif ($use_buildall eq '1') { print CONFIG_HEAD ("BUILDALL = 1\n") } if ($use_highlight eq '0') { print CONFIG_HEAD ("HIGHLIGHT = 0\n") } elsif ($use_highlight eq '1') { print CONFIG_HEAD ("HIGHLIGHT = 1\n") } if ($use_preserved eq '0') { print CONFIG_HEAD ("PRESERVESTATE = 0\n") } elsif ($use_preserved eq '1') { print CONFIG_HEAD ("PRESERVESTATE = 1\n") } if ($use_startallopen eq '0') { print CONFIG_HEAD ("STARTALLOPEN = 0\n") } elsif ($use_startallopen eq '1') { print CONFIG_HEAD ("STARTALLOPEN = 1\n") } if ($use_frames eq '0') { print CONFIG_HEAD ("USEFRAMES = 0\n") } elsif ($use_frames eq '1') { print CONFIG_HEAD ("USEFRAMES = 1\n") } if ($use_icons eq '0') { print CONFIG_HEAD ("USEICONS = 0\n") } elsif ($use_icons eq '1') { print CONFIG_HEAD ("USEICONS = 1\n") } if ($use_textlinks eq '0') { print CONFIG_HEAD ("USETEXTLINKS = 0\n") } elsif ($use_textlinks eq '1') { print CONFIG_HEAD ("USETEXTLINKS = 1\n") } if ($use_wraptext eq '0') { print CONFIG_HEAD ("WRAPTEXT = 0\n") } elsif ($use_wraptext eq '1') { print CONFIG_HEAD ("WRAPTEXT = 1\n") } print CONFIG_HEAD ("HIGHLIGHT_COLOR = $highlightcolor\n"); print CONFIG_HEAD ("HIGHLIGHT_BG = $highlight_bg\n"); print CONFIG_HEAD ("ICONPATH = $iconpath\n"); print CONFIG_HEAD ("\# $comment\n"); close(CONFIG_HEAD); rebuild(); } sub rebuild { open(CONFIG_HEAD,".config.dat"); my @header = <CONFIG_HEAD>; close(CONFIG_HEAD); open(NEWNODES,".nodes.dat"); my @entries = <NEWNODES>; close(NEWNODES); open(FINAL_CONFIG,">$nodefile"); print FINAL_CONFIG @header; print FINAL_CONFIG @entries; close (FINAL_CONFIG); } newlink.tmpl[html]<html> <body> <form id="newlink" name="newlink" action="<TMPL_VAR NAME=SCRIPT>/savelink" method="post"> Bezeichner: <input name="newlink_name" value="z.B Software" maxlength="36"/><br/> Link: <input name="newlink_link" value="z.B software.html" maxlength="36"/><br/> Position: <input name="newlink_posi" value="1,5" maxlength="3"/> (z.B 1,5 fuer Kategorie 1, Position 5)<br/> Target-Frame: <input name="newlink_frame" value="_right" maxlength="36"/><br/> <input type="submit" value="Speichern" name="save"/><br/> </form><br><br> <a href="javascript:history.go(-1)">Back</a> </body> </html>[/html] showconfig.tmpl[html]<html> <body> <h2>Treeview Konfiguration</h2> <br> <hr/> <br> <pre><TMPL_VAR NAME=PRE></pre> <a href="javascript:history.go(-1)">Back</a> </body> </body>[/html] new.tmpl[html]<html> <body> <a href="<TMPL_VAR NAME=SCRIPT>/newkat">Neue Kategorie hinzufuegen</a> (Nicht fertig)<br> <a href="<TMPL_VAR NAME=SCRIPT>/newlink">Neuen Link hinzufuegen</a><br><br> <a href="javascript:history.go(-1)">Back</a> </body> </html>[/html] config.tmpl[html]<html> <body> <form id="config" name="config" action="<TMPL_VAR NAME=SCRIPT>/saveconfig" method="post"> <input type="radio" value="1" name="buildall"/> <input type="radio" value="0" name="buildall" checked/> Tree komplett bauen oder erst auf Abruf? (Standart: 0)<br/> <input type="radio" value="1" name="highlight"/> <input type="radio" value="0" name="highlight" checked/> Text hervorheben?<br/> <input name="highlight_color" value="blue" maxlength="8"/> Highlight Schrift-Farbe (z.B white oder #FFFFFF)<br/> <input name="highlight_bg" value="white" maxlength="8"/> Highlight Hintergrund-Farbe (z.B white oder #FFFFFF)<br/> <input name="iconpath" value="icons/" maxlength="36"/> Pfad zum Icons Verzeichniss<br/> <input type="radio" value="1" name="preservestate" checked/> <input type="radio" value="0" name="preservestate"/> Speichern des Trees per Cookie?<br/> <input type="radio" value="1" name="startallopen"/> <input type="radio" value="0" name="startallopen" checked/> Alle Nodes ausgeklappt starten?<br/> <input type="radio" value="1" name="useframes"/> <input type="radio" value="0" name="useframes" checked/> Frames nutzen?<br/> <input type="radio" value="1" name="useicons" checked/> <input type="radio" value="0" name="useicons"/> Icons nutzen?<br/> <input type="radio" value="1" name="usetextlinks" checked/> <input type="radio" value="0" name="usetextlinks"/> Text links nutzen? <br/> <input type="radio" value="1" name="wraptext"/> <input type="radio" value="0" name="wraptext" checked/> Zeilenumbruch?<br/> <input name="comment" value="Kommentar" maxlength="32"/> Kommentar<br/> <input type="submit" value="Speichern" name="save"/><br/> </form><br><br> <a href="javascript:history.go(-1)">Back</a> </body> </html>[/html] default.tmpl[html]<html> <body> <a href="<TMPL_VAR NAME=SCRIPT>/show">Config anzeigen</a> <BR> <a href="<TMPL_VAR NAME=SCRIPT>/config">Treeview anpassen</a> <BR> <a href="<TMPL_VAR NAME=SCRIPT>/new">Einen neuen Eintrag hinzufuegen</a> <BR> </body> </html>[/html] OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |