[r1081]: / branches / 2.5.4 / cgi-bin / yabb2 / Sources / AdvancedTabs.pm  Maximize  Restore  History

Download this file

414 lines (380 with data), 15.9 kB

  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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
###############################################################################
# AdvancedTabs.pm #
# $Date: 2013-06-25 15:33:13 +0000 (Tue, 25 Jun 2013) $
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.5.4 #
# Packaged: July 1, 2013 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2013 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
# use strict;
# use warnings;
no warnings qw(uninitialized once redefine);
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.5.4';
$advancedtabspmver = 'YaBB 2.5.4 $Revision: 1081 $';
if ( $action eq 'detailedversion' ) { return 1; }
sub AddNewTab {
GetTexttab();
$edittabs = qq~<option value="thefront">$tabmenu_txt{'tabfront'}</option>~;
foreach (@AdvancedTabs) {
$_ =~ /^([^\|]+)/xsm;
if ( $texttab{$1} ) {
$edittabs .= qq~<option value="$1">$texttab{$1}</option>~;
}
}
$yyaddtab = qq~
<br />
<script type="text/javascript">
<!--
function submittab() {
if (window.submitted) return false;
window.submitted = true;
return true;
}
function checkTab(theForm) {
var isError = 0;
var tabError = "$tabmenu_txt{'taberr'}\\n";
if (theForm.tabtext.value == "") { tabError += "\\n- $tabmenu_txt{'texterr'}"; if(isError == 0) isError = 1; }
if (theForm.taburl.value == "") { tabError += "\\n- $tabmenu_txt{'urlerr'}"; if(isError == 0) isError = 2; }
if(isError >= 1) {
alert(tabError);
if(isError == 1) theForm.tabtext.focus();
else if(isError == 2) theForm.taburl.focus();
else if(isError == 3) theForm.tabtext.focus();
return false;
}
return true
}
//-->
</script>~
. $brd_advanced_tabs;
$yyaddtab =~ s/{yabb tabtext}/$tabmenu_txt{'tabtext'}/sm;
$yyaddtab =~ s/{yabb taburl}/$tabmenu_txt{'taburl'}/sm;
$yyaddtab =~ s/{yabb tabwin}/$tabmenu_txt{'tabwin'}/sm;
$yyaddtab =~ s/{yabb tabview}/$tabmenu_txt{'tabview'}/sm;
$yyaddtab =~ s/{yabb viewall}/$tabmenu_txt{'viewall'}/sm;
$yyaddtab =~ s/{yabb viewmem}/$tabmenu_txt{'viewmem'}/sm;
$yyaddtab =~ s/{yabb viewgm}/$tabmenu_txt{'viewgm'}/sm;
$yyaddtab =~ s/{yabb viewadm}/$tabmenu_txt{'viewadm'}/sm;
$yyaddtab =~ s/{yabb tabinsert}/$tabmenu_txt{'tabinsert'}/sm;
$yyaddtab =~ s/{yabb addtab}/$tabmenu_txt{'addtab'}/sm;
$yyaddtab =~ s/{yabb edittabs}/$edittabs/sm;
return $yyaddtab;
}
sub AddNewTab2 {
if ($iamadmin) {
my $tabtext = $FORM{'tabtext'};
my $taburl = $FORM{'taburl'};
$taburl =~ s/"/\%22/gxsm; #";
my $tabwin = $FORM{'tabwin'} ? 1 : 0;
my $tabview = $FORM{'showto'};
my $tabafter = $FORM{'addafter'};
my $tmpusernamereq = 0;
#Carsten's fix - nice and neat/';#
if ( $taburl !~ /[ht|f]tp[s]{0,1}:\/\//xsm ) {
$taburl = qq~http://$taburl~;
}
if ( $taburl =~ /$boardurl\/$yyexec\.$yyaext/ixsm
&& $taburl =~ /action\=(.*?)(\;|\Z)/ixsm )
{
$taburl = 1;
$tabaction = $1;
$tmpisaction = 1;
}
elsif ($taburl =~ /$boardurl\/AdminIndex\.$yyaext/ixsm
&& $taburl =~ /action\=(.*?)(\;|\Z)/ixsm )
{
$taburl = 2;
$tabaction = $1;
$tmpisaction = 1;
}
else {
$tabaction = lc $tabtext;
$tabaction =~ s/ /\_/gsm;
$tmpisaction = 0;
}
$tabaction =~ s/\W/_/gxsm;
map {
if ( $_ =~ /^$tabaction\|?/xsm )
{
fatal_error( 'tabext', $tabaction );
}
} @AdvancedTabs;
if ( $taburl == 1 || $taburl == 2 ) {
if ( $FORM{'taburl'} =~ m/username\=/ixsm ) { $tmpusernamereq = 1; }
$exttaburl = $FORM{'taburl'};
$exttaburl =~ s/(.*?)\?(.*?)/$2/gxsm;
$exttaburl =~ s/action\=(.*?)(\;|\Z)//ixsm;
$exttaburl =~ s/username\=(.*?)(\;|\Z)//ixsm;
}
else {
$exttaburl = q{};
}
ToHTML($tabtext);
opendir DIR, $langdir;
my @languages = readdir DIR;
closedir DIR;
foreach my $lngdir (@languages) {
next
if $lngdir eq q{.} || $lngdir eq q{..} || !-d "$langdir/$lngdir";
undef %tabtxt;
if ( fopen( TABTXT, "$langdir/$lngdir/tabtext.txt" ) ) {
%tabtxt = map { /(.*)\t(.*)/xsm } <TABTXT>;
fclose(TABTXT);
}
$tabtxt{$tabaction} = $tabtext;
fopen( TABTXT, ">$langdir/$lngdir/tabtext.txt" )
|| fatal_error( 'file_not_open', "$langdir/$lngdir/tabtext.txt",
1 );
print {TABTXT} map { "$_\t$tabtxt{$_}\n" } keys %tabtxt
or croak 'cannot print TABTXT';
fclose(TABTXT);
}
my @new_tabs_order;
if ( $tabafter eq 'thefront' ) {
push @new_tabs_order,
qq~$tabaction|$taburl|$tmpisaction|$tmpusernamereq|$tabview|$tabwin|$exttaburl~;
}
foreach (@AdvancedTabs) {
push @new_tabs_order, $_;
if (/^$tabafter\|?/xsm) {
push @new_tabs_order,
qq~$tabaction|$taburl|$tmpisaction|$tmpusernamereq|$tabview|$tabwin|$exttaburl~;
}
}
@AdvancedTabs = @new_tabs_order;
require Admin::NewSettings;
SaveSettingsTo('Settings.pm');
}
$yySetLocation = $scripturl;
redirectexit();
return;
}
sub EditTab {
get_micon();
$tabsave = $micon{'tabsave'};
$tabdel = $micon{'tabdel'};
$tabstyle = q~ class="tabstyle"~;
$edittab{'home'} =
qq~<span $tabstyle>$tabfill$img_txt{'103'}$tabfill</span>~;
$edittab{'help'} =
qq~<span $tabstyle>$tabfill$img_txt{'119'}$tabfill</span>~;
$edittab{'search'} =
qq~<span $tabstyle>$tabfill$img_txt{'182'}$tabfill</span>~;
$edittab{'ml'} = qq~<span $tabstyle>$tabfill$img_txt{'331'}$tabfill</span>~;
$edittab{'eventcal'} =
qq~<span $tabstyle>$tabfill$img_txt{'eventcal'}$tabfill</span>~;
$edittab{'birthdaylist'} =
qq~<span $tabstyle>$tabfill$img_txt{'birthdaylist'}$tabfill</span>~;
$edittab{'admin'} =
qq~<span $tabstyle>$tabfill$img_txt{'2'}$tabfill</span>~;
$edittab{'revalidatesession'} =
qq~<span $tabstyle>$tabfill$img_txt{'34a'}$tabfill</span>~;
$edittab{'login'} =
qq~<span $tabstyle>$tabfill$img_txt{'34'}$tabfill</span>~;
$edittab{'register'} =
qq~<span $tabstyle>$tabfill$img_txt{'97'}$tabfill</span>~;
$edittab{'guestpm'} =
qq~<span $tabstyle>$tabfill$img_txt{'pmadmin'}$tabfill</span>~;
$edittab{'mycenter'} =
qq~<span $tabstyle>$tabfill$img_txt{'mycenter'}$tabfill</span>~;
$edittab{'logout'} =
qq~<span $tabstyle>$tabfill$img_txt{'108'}$tabfill</span>~;
GetTexttab();
my $selsize = 0;
my $isexttabs = 0;
for my $i ( 0 .. ( @AdvancedTabs - 1 ) ) {
if ( $AdvancedTabs[$i] =~ /\|/xsm ) {
my ( $tab_key, $tmptab_url, $isaction, $username_req, $tab_access,
$dummy )
= split /\|/xsm, $AdvancedTabs[$i], 6;
my $enc_key = $tab_key;
$enc_key =~ s/\&/%26/gxsm;
$isexttabs++;
if ( !$tab_access
|| ( $tab_access < 2 && !$iamguest )
|| ( $tab_access < 3 && $iamgmod )
|| $iamadmin )
{
if ( $tmptab_url == 1 ) { $tab_url = qq~$scripturl~; }
elsif ( $tmptab_url == 2 ) {
$tab_url = qq~$boardurl/AdminIndex.$yyaext~;
}
else { $tab_url = qq~$tmptab_url~; }
if ($isaction) { $tab_url .= qq~?action=$tab_key~; }
if ($username_req) {
$tab_url .= qq~;username=$useraccount{$username}~;
}
$inputlength = length $tabtxt{$tab_key};
$edittab{$tab_key} =
qq~<form action="$scripturl?action=edittab2;savetab=$enc_key" method="post" name="$tab_key$isexttabs" style="display: inline; white-space: nowrap;" accept-charset="$yycharset">~;
$edittab{$tab_key} .=
qq~<input type="text" name="$tab_key" id="$tab_key" value="$tabtxt{$tab_key}" size="$inputlength" class="edittab" />~;
$edittab{$tab_key} .=
qq~<input type="image" src="$micon_bg{'tabsave'}" alt="$tabmenu_txt{'savetab'}" title="$tabmenu_txt{'savetab'}" class="editttab_img" />~;
$edittab{$tab_key} .=
qq~ <a href="$scripturl?action=deletetab;deltab=$enc_key" style="padding:0; margin:0">$tabdel</a>~;
$edittab{$tab_key} .= q~</form>~;
$edittabs .=
qq~<option value="$tab_key"~
. (
$tab_key eq $INFO{'thetab'} ? ' selected="selected"' : q{} )
. qq~>$texttab{$tab_key}</option>~;
$edittabmenu .= qq~<li>$edittab{$tab_key}</li>~;
$selsize++;
}
}
elsif ( $edittab{ $AdvancedTabs[$i] } ) {
$edittabs .= qq~<option value="$AdvancedTabs[$i]"~
. (
$AdvancedTabs[$i] eq $INFO{'thetab'}
? ' selected="selected"'
: q{}
) . qq~>$texttab{$AdvancedTabs[$i]}</option>~;
$edittabmenu .= qq~<li>$edittab{ $AdvancedTabs[$i] }</li>~;
$selsize++;
}
}
if ( $selsize > 11 ) { $selsize = 11; }
$yyaddtab = $brd_advanced_tabs_edit;
$yyaddtab =~ s/{yabb edittabmenu}/$edittabmenu/sm;
$yyaddtab =~ s/{yabb reordertab}/$tabmenu_txt{'reordertab'}/sm;
$yyaddtab =~ s/{yabb selsize}/$selsize/sm;
$yyaddtab =~ s/{yabb edittabs}/$edittabs/sm;
$yyaddtab =~ s/{yabb edittabs}/$edittabs/sm;
$yyaddtab =~ s/{yabb tableft}/$tabmenu_txt{'tableft'}/sm;
$yyaddtab =~ s/{yabb tabright}/$tabmenu_txt{'tabright'}/sm;
$yyaddtab =~ s/{yabb edittext1}/$tabmenu_txt{'edittext1'}/sm;
$yyaddtab =~ s/{yabb tabsave}/$tabsave/sm;
$yyaddtab =~ s/{yabb edittext2}/$tabmenu_txt{'edittext2'}/sm;
$yyaddtab =~ s/{yabb tabdel}/$tabdel/sm;
$yyaddtab =~ s/{yabb edittext3}/$tabmenu_txt{'edittext3'}/sm;
$yyaddtab =~ s/{yabb reordertext}/$tabmenu_txt{'reordertext'}/sm;
undef %edittab;
return;
}
sub EditTab2 {
if ($iamadmin) {
$tosave = $INFO{'savetab'};
$tosave =~ s/%26/&/gxsm;
$tosavetxt = $FORM{$tosave};
ToHTML($tosavetxt);
$tab_lang = $language ? $language : $lang;
fopen( TABTXT, "$langdir/$tab_lang/tabtext.txt" )
|| fatal_error( 'file_not_open', "$langdir/$tab_lang/tabtext.txt" );
%tabtxt = map { /(.*)\t(.*)/xsm } <TABTXT>;
fclose(TABTXT);
$tabtxt{$tosave} = $tosavetxt;
fopen( TABTXT, ">$langdir/$tab_lang/tabtext.txt" )
|| fatal_error( 'file_not_open', "$langdir/$tab_lang/tabtext.txt" );
print {TABTXT} map { "$_\t$tabtxt{$_}\n" } keys %tabtxt
or croak 'cannot print TABTXT';
fclose(TABTXT);
}
$yySetLocation = $scripturl;
redirectexit();
return;
}
sub ReorderTab {
my $moveitem = $FORM{'ordertabs'};
if ($iamadmin) {
if ($moveitem) {
if ( $FORM{'moveleft'} ) {
for my $i ( 0 .. ( @AdvancedTabs - 1 ) ) {
if ( $AdvancedTabs[$i] =~ /^$moveitem\|?/xsm && $i > 0 ) {
my $j = $i - 1;
my $x = $AdvancedTabs[$i];
$AdvancedTabs[$i] = $AdvancedTabs[$j];
$AdvancedTabs[$j] = $x;
last;
}
}
}
elsif ( $FORM{'moveright'} ) {
for my $i ( 0 .. ( @AdvancedTabs - 1 ) ) {
if ( $AdvancedTabs[$i] =~ /^$moveitem\|?/xsm
&& $i < $#AdvancedTabs )
{
my $j = $i + 1;
my $x = $AdvancedTabs[$i];
$AdvancedTabs[$i] = $AdvancedTabs[$j];
$AdvancedTabs[$j] = $x;
last;
}
}
}
}
require Admin::NewSettings;
SaveSettingsTo('Settings.pm');
}
$yySetLocation = qq~$scripturl?action=edittab;thetab=$moveitem~;
redirectexit();
return;
}
sub DeleteTab {
if ($iamadmin) {
my $todelete = $INFO{'deltab'};
$todelete =~ s/%26/&/gxsm;
opendir DIR, $langdir;
@languages = readdir DIR;
closedir DIR;
foreach my $lngdir (@languages) {
if ( $lngdir eq q{.}
|| $lngdir eq q{..}
|| !-d "$langdir/$lngdir"
|| !-e "$langdir/$lngdir/tabtext.txt" )
{
next;
}
fopen( TABTXT, "$langdir/$lngdir/tabtext.txt" )
|| fatal_error( 'file_not_open', "$langdir/$lngdir/tabtext.txt" );
%tabtxt = map { /(.*)\t(.*)/xsm } <TABTXT>;
fclose(TABTXT);
delete $tabtxt{$todelete};
if ( !%tabtxt ) {
unlink "$langdir/$lngdir/tabtext.txt";
}
else {
fopen( TABTXT, ">$langdir/$lngdir/tabtext.txt" );
print {TABTXT} map { "$_\t$tabtxt{$_}\n" } keys %tabtxt
or croak 'cannot print TABTXT';
fclose(TABTXT);
}
}
my @new_tabs_order;
foreach (@AdvancedTabs) {
if ( $_ !~ /^$todelete\|?/xsm ) { push @new_tabs_order, $_; }
}
@AdvancedTabs = @new_tabs_order;
require Admin::NewSettings;
SaveSettingsTo('Settings.pm');
}
$yySetLocation = $scripturl;
redirectexit();
return;
}
sub GetTexttab {
$texttab{'home'} = $img_txt{'103'};
$texttab{'help'} = $img_txt{'119'};
$texttab{'search'} = $img_txt{'182'};
$texttab{'ml'} = $img_txt{'331'};
$texttab{'eventcal'} = $img_txt{'eventcal'};
$texttab{'birthdaylist'} = $img_txt{'birthdaylist'};
$texttab{'admin'} = $img_txt{'2'};
$texttab{'revalidatesession'} = $img_txt{'34a'};
$texttab{'login'} = $img_txt{'34'};
$texttab{'register'} = $img_txt{'97'};
$texttab{'guestpm'} = $img_txt{'pmadmin'};
$texttab{'mycenter'} = $img_txt{'mycenter'};
$texttab{'logout'} = $img_txt{'108'};
if ( !$tab_lang ) { GetTabtxt(); }
foreach ( keys %tabtxt ) { $texttab{$_} = $tabtxt{$_}; }
return;
}
1;