package lang; use diagnostics; use strict; #-###################################################################################### #- misc imports #-###################################################################################### use common qw(:common :file :system); use commands; use log; #-###################################################################################### #- Globals #-###################################################################################### #- key (to be used in $LC_ALL), [0] = english name, [1] = charset encoding, #- [2] = value for $LANG, [3] = value for LANGUAGE (a list of possible #- languages, carefully choosen) my %languages = ( 'en_US' => [ 'English (US)', 'iso-8859-1', 'en', 'en_US:en' ], 'en_GB' => [ 'English (UK)', 'iso-8859-1', 'en', 'en_GB:en' ], 'af' => [ 'Afrikaans', 'iso-8859-1', 'af', 'af:en_ZA' ], 'ar' => [ 'Arabic', 'iso-8859-6', 'ar', 'ar' ], 'az' => [ 'Azeri (latin)', 'iso-8859-9e', 'az', 'az' ], 'a3' => [ 'Azeri (cyrillic)', 'koi8-c', 'a3', 'a3' ], 'be_BY.CP1251' => [ 'Belarussian', 'cp1251', 'be', 'be:be_BY.CP1251:ru_RU.CP1251' ], #- provide aliases for some not very standard names used in po files... 'bg_BG' => [ 'Bulgarian', 'cp1251', 'bg', 'bg:bg.CP1251:bg_BG.CP1251' ], 'br' => [ 'Brezhoneg', 'iso-8859-1', 'br', 'br:fr_FR:fr' ], 'ca' => [ 'Catalan', 'iso-8859-1', 'ca', 'ca:es_ES:es:fr_FR:fr' ], 'cs' => [ 'Czech', 'iso-8859-2', 'cs', 'cs' ], 'cy' => [ 'Cymraeg (Welsh)', 'iso-8859-14','cy', 'cy:en_GB:en' ], 'da' => [ 'Danish', 'iso-8859-1', 'da', 'da' ], 'de_AT' => [ 'German (Austria)', 'iso-8859-1', 'de', 'de_AT:de' ], 'de_DE' => [ 'German (Germany)', 'iso-8859-1', 'de', 'de_DE:de' ], 'el' => [ 'Greek', 'iso-8859-7', 'el', 'el' ], 'eo' => [ 'Esperanto', 'iso-8859-3', 'eo', 'eo' ], 'es_AR' => [ 'Spanish (Argentina)', 'iso-8859-1', 'es', 'es_AR:es_UY:es:es_ES' ], 'es_ES' => [ 'Spanish (Spain, modern sorting)', 'iso-8859-1', 'es', 'es_ES:es' ], 'es@tradicional' => [ 'Spanish (Spain, traditional sorting)', 'iso-8859-1', 'es', 'es' ], 'es_MX' => [ 'Spanish (Mexico)', 'iso-8859-1', 'es', 'es_MX:es:es_ES' ], 'et' => [ 'Estonian', 'iso-8859-15','et', 'et' ], 'eu' => [ 'Euskara (Basque)', 'iso-8859-1', 'eu', 'eu:es_ES:fr_FR:es:fr' ], 'fa' => [ 'Farsi (Iranian)', 'isiri-3342', 'fa', 'fa' ], 'fi' => [ 'Suomi (Finnish)', 'iso-8859-15', 'fi', 'fi' ], #-'fo' => [ 'Faroese', 'iso-8859-1', 'fo', 'fo:??:??' ], 'fr_CA' => [ 'French (Canada)', 'iso-8859-1', 'fr', 'fr_CA:fr' ], 'fr_FR' => [ 'French (France)', 'iso-8859-1', 'fr', 'fr_FR:fr' ], 'ga' => [ 'Gaeilge (Irish)', 'iso-8859-14','ga', 'ga:en_IE:en' ], #-'gd' => [ 'Scottish gaelic', 'iso-8859-14','gd', 'gd:en_GB:en' ], 'gl' => [ 'Galego (Galician)', 'iso-8859-1', 'gl', 'gl:es_ES:pt_PT:pt_BR:es:pt' ], #-'gv' => [ 'Manx gaelic', 'iso-8859-14','gv', 'gv:en_GB:en' ], #- 'iw' was the old code for hebrew language 'he' => [ 'Hebrew', 'iso-8859-8', 'he', 'he:iw_IL' ], 'hr' => [ 'Croatian', 'iso-8859-2', 'hr', 'hr' ], 'hu' => [ 'Hungarian', 'iso-8859-2', 'hu', 'hu' ], 'hy' => [ 'Armenian', 'armscii-8', 'hy', 'hy' ], #- 'in' was the old code for indonesian language; by putting LANGUAGE=id:in_ID #- we catch the few catalog files still using the wrong code 'id' => [ 'Indonesian', 'iso-8859-1', 'id', 'id:in_ID' ], 'is' => [ 'Icelandic', 'iso-8859-1', 'is', 'is' ], 'it' => [ 'Italian', 'iso-8859-1', 'it', 'it_IT:it' ], 'ja' => [ 'Japanese', 'jisx0208', 'ja', 'ja_JP.ujis:ja' ], 'ka' => [ 'Georgian', 'georgian-academy', 'ka', 'ka' ], 'kl' => [ 'Greenlandic (inuit)', 'iso-8859-1', 'kl', 'kl' ], 'ko' => [ 'Korean', 'ksc5601', 'ko', 'ko' ], #-'kw' => [ 'Cornish gaelic', 'iso-8859-14','kw', 'kw:en_GB:en' ], #-'lo' => [ 'Laotian', 'mulelao-1', 'lo', 'lo' ], 'lt' => [ 'Lithuanian', 'iso-8859-13','lt', 'lt' ], 'lv' => [ 'Latvian', 'iso-8859-13','lv', 'lv' ], 'mi' => [ 'Maori', 'iso-8859-13','mi', 'mi' ], 'mk' => [ 'Macedonian (Cyrillic)', 'iso-8859-5', 'mk', 'mk:sp:sr' ], #-'ms' => [ 'Malay', 'iso-8859-1', 'ms', 'ms' ], 'nl' => [ 'Dutch (Netherlands)', 'iso-8859-1', 'nl', 'nl_NL:nl' ], # 'nb' is the new locale name in glibc 2.2 'no' => [ 'Norwegian (Bokmaal)', 'iso-8859-1', 'no', 'no:nb:no@nynorsk:no_NY' ], # no_NY is used by KDE (but not standard); 'ny' is the new locale in glibc 2.2 'no@nynorsk' => [ 'Norwegian (Nynorsk)','iso-8859-1', 'no', 'no@nynorsk:ny:no_NY:no' ], #-'oc' => [ 'Occitan', 'iso-8859-1', 'oc', 'oc:fr_FR' ], #-'pd' => [ 'Plauttdietsch', 'iso-8859-1', 'pd', 'pd' ], #-'ph' => [ 'Pilipino', 'iso-8859-1', 'ph', 'ph:tl' ], 'pl' => [ 'Polish', 'iso-8859-2', 'pl', 'pl' ], #-'pp' => [ 'Papiamento', 'iso-8859-1', 'pp', 'pp' ], 'pt_BR' => [ 'Portuguese (Brazil)', 'iso-8859-1', 'pt_BR', 'pt_BR:pt_PT:pt' ], 'pt_PT' => [ 'Portuguese (Portugal)', 'iso-8859-1', 'pt', 'pt_PT:pt:pt_BR' ], 'ro' => [ 'Romanian', 'iso-8859-2', 'ro', 'ro' ], 'ru_RU.KOI8-R' => [ 'Russian', 'koi8-r', 'ru', 'ru_RU.KOI8-R:ru' ], 'sk' => [ 'Slovak', 'iso-8859-2', 'sk', 'sk' ], 'sl' => [ 'Slovenian', 'iso-8859-2', 'sl', 'sl' ], 'sp' => [ 'Serbian (Cyrillic)', 'iso-8859-5', 'sp', 'sp:sr' ], 'sr' => [ 'Serbian (Latin)', 'iso-8859-2', 'sr', 'sr' ], 'sv@traditionell' => [ 'Swedish (traditional sorting)','iso-8859-1', 'sv', 'sv' ], 'sv@ny' => [ 'Swedish (new sorting (v diff of w)','iso-8859-1', 'sv', 'sv' ], #-'ta' => [ 'Tamil', 'tscii-0', 'ta', 'ta' ], 'tg' => [ 'Tajik', 'koi8-c', 'tg', 'tg' ], 'th' => [ 'Thai', 'tis620', 'th', 'th' ], 'tr' => [ 'Turkish', 'iso-8859-9', 'tr', 'tr' ], 'tt' => [ 'Tatar', 'tatar-cyr', 'tg', 'tg' ], #-'ur' => [ 'Urdu', 'cp1256', 'ur', 'ur' ], 'uk_UA' => [ 'Ukrainian', 'koi8-u', 'uk', 'uk_UA:uk' ], 'vi' => [ 'Vietnamese (TCVN)', 'tcvn', 'vi', 'vi_VN.tcvn:vi_VN.tcvn-5712:vi' ], 'vi_VN.viscii' => [ 'Vietnamese (VISCII)','viscii', 'vi', 'vi_VN.viscii:vi_VN.tcvn-viscii1.1-1:vi' ], 'wa' => [ 'Walon', 'iso-8859-1', 'wa', 'wa:fr_BE:fr' ], #-'yi' => [ 'Yiddish', 'cp1255', 'yi', 'yi' ], 'zh_TW.Big5' => [ 'Chinese (Big5)', 'Big5', 'zh_TW.Big5', 'zh_TW.Big5:zh_TW.big5:zh' ], 'zh_CN' git-svn-id: file:///svn/phpbb/trunk@4451 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/message_parser.php')
-rw-r--r--phpBB/includes/message_parser.php61
1 files changed, 24 insertions, 37 deletions
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 665e9bb982..16b6208975 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -79,37 +79,7 @@ class parse_message
if (!strlen($this->message) || (intval($config['max_post_chars']) && strlen($this->message) > intval($config['max_post_chars'])))
{
$this->warn_msg[] = (!strlen($this->message)) ? $user->lang['TOO_FEW_CHARS'] : $user->lang['TOO_MANY_CHARS'];
- }
-
- // Smiley check
- if (intval($config['max_post_smilies']) && $smilies)
- {
- // NOTE: couldn't we move this to emoticons()? they both use the same rowset
- $sql = "SELECT code
- FROM " . SMILIES_TABLE;
- $result = $db->sql_query($sql);
-
- $match = 0;
- while ($row = $db->sql_fetchrow($result))
- {
- if (preg_match_all('#('. preg_quote($row['code'], '#') . ')#', $this->message, $matches))
- {
- $match++;
- }
-
- if ($match > intval($config['max_post_smilies']))
- {
- $this->warn_msg[] = $user->lang['TOO_MANY_SMILIES'];
- break;
- }
- }
- $db->sql_freeresult($result);
- unset($matches);
- }
-
- if ($this->warn_msg)
- {
- return implode('<br />', $this->warn_msg);
+ return $this->warn_msg;
}
$this->html($html);
@@ -636,12 +606,17 @@ class parse_message
}
}
- function emoticons($smile)
+ function emoticons($smilie)
{
- global $db, $user, $phpbb_root_path;
+ global $db, $user, $phpbb_root_path, $config;
+
+ if (!$smilie)
+ {
+ return;
+ }
- $sql = "SELECT *
- FROM " . SMILIES_TABLE;
+ $sql = 'SELECT *
+ FROM ' . SMILIES_TABLE;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
@@ -649,11 +624,23 @@ class parse_message
$match = $replace = array();
do
{
- $match[] = "#(?<=.\W|\W.|^\W)" . preg_quote($row['code'], '#') . "(?=.\W|\W.|\W$)#";
- $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $phpbb_root_path . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
+ $match[] = '#(' . preg_quote($row['code'], '#') . ')#';
+// $match[] = "#(?<=.\W|\W.|^\W)" . preg_quote($row['code'], '#') . "(?=.\W|\W.|\W$)#";
+ $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
}
while ($row = $db->sql_fetchrow($result));
+ if ($config['max_post_smilies'])
+ {
+ $num_matches = preg_match_all('#' . str_replace('#', '', implode('|', $match)) . '#', $this->message, $matches);
+
+ if ($num_matches !== FALSE && $num_matches > intval($config['max_post_smilies']))
+ {
+ $this->warn_msg[] = $user->lang['TOO_MANY_SMILIES'];
+ return;
+ }
+ }
+
$this->message = preg_replace($match, $replace, ' ' . $this->message . ' ');
}
$db->sql_freeresult($result);
; add2hash $h, { LC_NUMERIC => $lang }; add2hash $h, { LC_MONETARY => $lang }; add2hash $h, { LC_TIME => $lang }; if (my $l = $languages{$lang}) { add2hash $h, { LANG => $l->[2], LANGUAGE => $l->[3], KDE_LANG => $l->[3], RPM_INSTALL_LANG => $l->[3] }; my $c = $charsets{$l->[1] || ''}; if ($c) { my $p = "$prefix/usr/lib/kbd"; if ($c->[0]) { add2hash $h, { SYSFONT => $c->[0] }; eval { commands::cp("-f", "$p/consolefonts/$c->[0].psf.gz", "$prefix/etc/sysconfig/console"); }; $@ and log::l("missing console font $c->[0]"); } if ($c->[1]) { add2hash $h, { UNIMAP => $c->[1] }; eval { commands::cp("-f", glob_("$p/consoletrans/$c->[1]*"), "$prefix/etc/sysconfig/console"); }; $@ and log::l("missing console unimap file $c->[1]"); } if ($c->[2]) { add2hash $h, { SYSFONTACM => $c->[2] }; eval { commands::cp("-f", glob_("$p/consoletrans/$c->[2]*"), "$prefix/etc/sysconfig/console"); }; $@ and log::l("missing console acm file $c->[2]"); } } add2hash $h, $xim{$lang}; } setVarsInSh("$prefix/etc/sysconfig/i18n", $h); } sub load_po($) { my ($lang) = @_; my ($s, $from, $to, $state, $fuzzy); $s .= "package po::I18N;\n"; $s .= "no strict;\n"; $s .= "\%{'$lang'} = ("; my $f; -e ($f = "$_/po/$lang.po") and last foreach @INC; local *F; unless ($f && -e $f) { -e ($f = "$_/po/$lang.po.bz2") and last foreach @INC; if (-e $f) { open F, "bzip2 -dc $f 2>/dev/null |"; } else { -e ($f = "$_/po.cz2") and last foreach @INC; log::l("trying to load $lang.po from $f"); open F, "packdrake -x $f '' $lang.po 2>/dev/null |"; } } else { open F, $f; #- not returning here help avoiding reading the same multiple times. } foreach () { /^msgstr/ and $state = 1; /^msgid/ && !$fuzzy and $state = 2; if (/^(#|$)/ && $state != 3) { $state = 3; if (my @l = $to =~ /%(\d+)\$/g) { $to =~ s/%(\d+)\$/%/g; $to = qq([ "$to", ) . join(",", map { $_ - 1 } @l) . " ],"; } else { $to = qq("$to"); } $s .= qq("$from" => $to,\n) if $from; $from = $to = ''; } $to .= (/"(.*)"/)[0] if $state == 1; $from .= (/"(.*)"/)[0] if $state == 2; $fuzzy = /^#, fuzzy/; } $s .= ");"; no strict "vars"; eval $s; !$@; } sub console_font_files { map { -e $_ ? $_ : "$_.gz" } (map { "/usr/lib/kbd/consolefonts/$_.psf" } uniq grep {$_} map { $_->[0] } values %charsets), (map { -e $_ ? $_ : "$_.sfm" } map { "/usr/lib/kbd/consoletrans/$_" } uniq grep {$_} map { $_->[1] } values %charsets), (map { -e $_ ? $_ : "$_.acm" } map { "/usr/lib/kbd/consoletrans/$_" } uniq grep {$_} map { $_->[2] } values %charsets), } sub load_console_font { my ($lang) = @_; my ($charset) = $languages{$lang} && $languages{$lang}[1] ; my ($f, $u, $m) = @{$charsets{$charset} || []}; run_program::run('consolechars', '-v', ('-f', $f || 'lat0-sun16'), $u ? ('-u', $u) : (), $m ? ('-m', $m) : ()); } #-sub load_font { #- my ($charset) = @_; #- my $fontFile = "lat0-sun16"; #- #- if (my $c = $charsets{$charset}) { #- log::l("loading $charset font"); #- $fontFile = $c->[0]; #- } #- #- # text mode font #- log::l("loading font $ENV{SHARE_PATH}/consolefonts/$fontFile"); #- #c::loadFont("/tmp/$fontFile") or log::l("error in loadFont: one of PIO_FONT PIO_UNIMAPCLR PIO_UNIMAP PIO_UNISCRNMAP failed: $!"); #- #print STDERR "\033(K"; #- #-} sub get_x_fontset { my ($lang, $size) = @_; my $l = $languages{$lang} or return; my $c = $charsets{$l->[1]} or return; my ($big, $small) = @$c[3..4]; ($big, $small) = $big->($size) if ref $big; ($big, $small); } #-###################################################################################### #- Wonderful perl :( #-###################################################################################### 1;