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

Download this file

Menu.pm    180 lines (169 with data), 8.3 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
###############################################################################
# Menu.pm #
# $Date: 2013-07-12 15:49:28 +0000 (Fri, 12 Jul 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. #
#-----------------------------------------------------------------------------#
# CSS Buttons 4 YaBB 2.5 #
# Copyright (c) 2010 'Carsten Dalgaard' - All Rights Reserved #
# Released: December 12, 2010 #
# e-mail: post@carsten-dalgaard.dk #
# Added to YaBB core with the writer's permission, January 28, 2013 #
###############################################################################
# use strict;
# use warnings;
no warnings qw(uninitialized once redefine);
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.5.4';
$menupmver = 'YaBB 2.5.4 $Revision: 1088 $';
if ( $action eq 'detailedversion' ) { return 1; }
sub SetMenu {
if ( -e ("Templates/$usestyle/Menu.def") ) {
$Menu_def = qq~Templates/$usestyle/Menu.def~;
}
else { $Menu_def = q~Templates/default/Menu.def~; }
fopen( MENUFILE, "$Menu_def" );
%img = map { /(.*),(.*)/xsm } <MENUFILE>;
fclose(MENUFILE);
while ( ( $key, $value ) = each %img ) {
chomp $value;
(
$button_icon, $button_text, $text_num, $alt_text,
$alt_num, $span_class, $imgext, $mod_or_not
) = split /\|/xsm, $value;
if ( !$alt_text ) {
$alt_text = $button_text;
$alt_num = $text_num;
}
if ( $mod_or_not eq 'mod' ) {
$button_imgurl = qq~$yyhtml_root/ModImages~;
}
else {
$button_imgurl = qq~$yyhtml_root/Templates/Forum/$usestyle~;
if ( !-e ("$htmldir/Templates/Forum/$usestyle/$button_icon.$imgext")
)
{
$button_imgurl = qq~$yyhtml_root/Templates/Forum/default~;
}
}
if ( $key eq 'help' ) { $helpstyle = q~ cursor: help;~; }
else { $helpstyle = q~ cursor: pointer;~; }
if ( $key ne 'lastpost'
&& $key ne 'pollicon'
&& $key ne 'polliconnew'
&& $key ne 'polliconclosed' )
{
if ( $UseMenuType == 0 ) {
$menusep = q{ };
$img{$key} =
qq~<img src="$button_imgurl/$button_icon.$imgext" alt="${$alt_text}{$alt_num}" /> <span style="white-space: nowrap;" class="$span_class" title="${$alt_text}{$alt_num}">${$button_text}{$text_num}</span> ~;
}
elsif ( $UseMenuType == 1 ) {
$menusep = q{ };
$img{$key} =
qq~<span style="white-space: nowrap;" class="$span_class" title="${$alt_text}{$alt_num}">${$button_text}{$text_num}</span> ~;
}
else {
$menusep =
qq~<img src='$yyhtml_root/Templates/Forum/default/buttonsep.png' class='cssbutton1' alt='' title='' />~;
$img{$key} =
qq~<span class="buttonleft cssbutton2" title="${$alt_text}{$alt_num}" style="$helpstyle">~;
$img{$key} .= q~<span class="buttonright cssbutton3">~;
$img{$key} .=
qq~<span class="buttonimage cssbutton4" style="background-image: url($button_imgurl/$button_icon.$imgext);">~;
$img{$key} .=
qq~<span class="buttontext cssbutton5">${$button_text}{$text_num}</span></span></span></span>~;
}
}
else {
$img{$key} =
qq~<img src="$button_imgurl/$button_icon.$imgext" alt="${$button_text}{$text_num}" />~;
}
}
return;
}
sub SetImage {
my ( $img_name, $UseMenuT ) = @_;
if ( -e ("Templates/$usestyle/Menu.def") ) {
$Menu_def = qq~Templates/$usestyle/Menu.def~;
}
else { $Menu_def = q~Templates/default/Menu.def~; }
fopen( MENUFILE, "$Menu_def" );
%img_set = map { /(.*),(.*)/xsm } <MENUFILE>;
fclose(MENUFILE);
my $imgname = $img_set{$img_name};
(
$button_icon, $button_text, $text_num, $alt_text,
$alt_num, $span_class, $imgext, $mod_or_not
) = split /\|/xsm, $imgname;
chomp $mod_or_not;
if ( !$alt_text ) {
$alt_text = $button_text;
$alt_num = $text_num;
}
$button_imgurl = qq~$yyhtml_root/Templates/Forum/$usestyle~;
if ( !-e ("$htmldir/Templates/Forum/$usestyle/$img_name.$imgext") ) {
$button_imgurl = qq~$yyhtml_root/Templates/Forum/default~;
}
if ( $key eq 'help' ) { $helpstyle = q~ cursor: help;~; }
else { $helpstyle = q~~; }
if ( $UseMenuT == 0 ) {
$menusep = q{ };
if ( $img_name eq 'gtalk' ) {
$img_out =
qq~<img src="$button_imgurl/$button_icon.$imgext" class="cursor" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$thegtalkuser','','height=80,width=340,menubar=0,toolbar=0,scrollbars=0,resizable=1'); return false" alt="$thegtalkname" title="$thegtalkname" />~;
}
else {
$img_out =
qq~<img src="$button_imgurl/$button_icon.$imgext" alt="${$alt_text}{$alt_num}" /> <span style="white-space: nowrap;" class="$span_class" title="${$alt_text}{$alt_num}">${$button_text}{$text_num}</span>~;
}
}
elsif ( $UseMenuT == 1 ) {
$menusep = q{ };
if ( $img_name eq 'gtalk' ) {
$img_out =
qq~<span style="white-space: nowrap;" class="$span_class cursor" title="${$alt_text}{$alt_num}" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$thegtalkuser','','height=80,width=340,menubar=0,toolbar=0,scrollbars=0,resizable=1'); return false">${$button_text}{$text_num}</span>~;
}
else {
$img_out =
qq~<span style="white-space: nowrap;" class="$span_class" title="${$alt_text}{$alt_num}">${$button_text}{$text_num}</span>~;
}
}
elsif ( $UseMenuT == 3 ) {
$menusep = q{};
$img_out =
qq~$button_imgurl/$button_icon.$imgext|${$button_text}{$text_num}~;
}
else {
$menusep =
qq~<img src='$yyhtml_root/Templates/Forum/default/buttonsep.png' class='cssbutton1' alt='' title='' />~;
if ( $img_name eq 'gtalk' ) {
$img_out =
qq~<span class="buttonleft cssbutton2" style="$helpstyle">~;
$img_out .= q~<span class="buttonright cssbutton3">~;
$img_out .=
qq~<span class="buttonimage cssbutton4 cursor" style="background-image: url($button_imgurl/$button_icon.$imgext);" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$thegtalkuser','','height=80,width=340,menubar=0,toolbar=0,scrollbars=0,resizable=1'); return false" title="${$button_text}{$alt_num}">~;
$img_out .=
qq~<span class="buttontext cssbutton5">${$button_text}{$text_num}</span></span></span></span>~;
}
else {
$img_out =
qq~<span class="buttonleft cssbutton2" title="${$alt_text}{$alt_num}" style="$helpstyle">~;
$img_out .= q~<span class="buttonright cssbutton3">~;
$img_out .=
qq~<span class="buttonimage cssbutton4" style="background-image: url($button_imgurl/$button_icon.$imgext);">~;
$img_out .=
qq~<span class="buttontext cssbutton5">${$button_text}{$text_num}</span></span></span></span>~;
}
}
return $img_out;
}
1;