2004-02-18 02:15:00 +00:00
|
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
|
2008-11-30 03:15:22 +00:00
|
|
|
|
require_once( dirname(__FILE__).'/../LanguageConverter.php' );
|
|
|
|
|
|
require_once( dirname(__FILE__).'/LanguageSr_ec.php' );
|
|
|
|
|
|
require_once( dirname(__FILE__).'/LanguageSr_el.php' );
|
2006-03-02 22:22:18 +00:00
|
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* There are two levels of conversion for Serbian: the script level
|
|
|
|
|
|
* (Cyrillics <-> Latin), and the variant level (ekavian
|
|
|
|
|
|
* <->iyekavian). The two are orthogonal. So we really only need two
|
|
|
|
|
|
* dictionaries: one for Cyrillics and Latin, and one for ekavian and
|
|
|
|
|
|
* iyekavian.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2006-03-02 22:22:18 +00:00
|
|
|
|
class SrConverter extends LanguageConverter {
|
|
|
|
|
|
var $mToLatin = array(
|
|
|
|
|
|
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd',
|
|
|
|
|
|
'ђ' => 'đ', 'е' => 'e', 'ж' => 'ž', 'з' => 'z', 'и' => 'i',
|
|
|
|
|
|
'ј' => 'j', 'к' => 'k', 'л' => 'l', 'љ' => 'lj', 'м' => 'm',
|
|
|
|
|
|
'н' => 'n', 'њ' => 'nj', 'о' => 'o', 'п' => 'p', 'р' => 'r',
|
|
|
|
|
|
'с' => 's', 'т' => 't', 'ћ' => 'ć', 'у' => 'u', 'ф' => 'f',
|
|
|
|
|
|
'х' => 'h', 'ц' => 'c', 'ч' => 'č', 'џ' => 'dž', 'ш' => 'š',
|
|
|
|
|
|
|
|
|
|
|
|
'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D',
|
|
|
|
|
|
'Ђ' => 'Đ', 'Е' => 'E', 'Ж' => 'Ž', 'З' => 'Z', 'И' => 'I',
|
|
|
|
|
|
'Ј' => 'J', 'К' => 'K', 'Л' => 'L', 'Љ' => 'Lj', 'М' => 'M',
|
|
|
|
|
|
'Н' => 'N', 'Њ' => 'Nj', 'О' => 'O', 'П' => 'P', 'Р' => 'R',
|
|
|
|
|
|
'С' => 'S', 'Т' => 'T', 'Ћ' => 'Ć', 'У' => 'U', 'Ф' => 'F',
|
|
|
|
|
|
'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Č', 'Џ' => 'Dž', 'Ш' => 'Š',
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
var $mToCyrillics = array(
|
|
|
|
|
|
'a' => 'а', 'b' => 'б', 'c' => 'ц', 'č' => 'ч', 'ć' => 'ћ',
|
|
|
|
|
|
'd' => 'д', 'dž' => 'џ', 'đ' => 'ђ', 'e' => 'е', 'f' => 'ф',
|
|
|
|
|
|
'g' => 'г', 'h' => 'х', 'i' => 'и', 'j' => 'ј', 'k' => 'к',
|
|
|
|
|
|
'l' => 'л', 'lj' => 'љ', 'm' => 'м', 'n' => 'н', 'nj' => 'њ',
|
|
|
|
|
|
'o' => 'о', 'p' => 'п', 'r' => 'р', 's' => 'с', 'š' => 'ш',
|
|
|
|
|
|
't' => 'т', 'u' => 'у', 'v' => 'в', 'z' => 'з', 'ž' => 'ж',
|
|
|
|
|
|
|
|
|
|
|
|
'A' => 'А', 'B' => 'Б', 'C' => 'Ц', 'Č' => 'Ч', 'Ć' => 'Ћ',
|
|
|
|
|
|
'D' => 'Д', 'Dž' => 'Џ', 'Đ' => 'Ђ', 'E' => 'Е', 'F' => 'Ф',
|
|
|
|
|
|
'G' => 'Г', 'H' => 'Х', 'I' => 'И', 'J' => 'Ј', 'K' => 'К',
|
|
|
|
|
|
'L' => 'Л', 'LJ' => 'Љ', 'M' => 'М', 'N' => 'Н', 'NJ' => 'Њ',
|
|
|
|
|
|
'O' => 'О', 'P' => 'П', 'R' => 'Р', 'S' => 'С', 'Š' => 'Ш',
|
|
|
|
|
|
'T' => 'Т', 'U' => 'У', 'V' => 'В', 'Z' => 'З', 'Ž' => 'Ж',
|
|
|
|
|
|
|
|
|
|
|
|
'DŽ' => 'Џ', 'd!ž' => 'дж', 'D!ž'=> 'Дж', 'D!Ž'=> 'ДЖ',
|
|
|
|
|
|
'Lj' => 'Љ', 'l!j' => 'лј', 'L!j'=> 'Лј', 'L!J'=> 'ЛЈ',
|
|
|
|
|
|
'Nj' => 'Њ', 'n!j' => 'нј', 'N!j'=> 'Нј', 'N!J'=> 'НЈ'
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
function loadDefaultTables() {
|
2006-11-21 09:53:45 +00:00
|
|
|
|
$this->mTables = array(
|
|
|
|
|
|
'sr-ec' => new ReplacementArray( $this->mToCyrillics ),
|
|
|
|
|
|
'sr-el' => new ReplacementArray( $this->mToLatin),
|
|
|
|
|
|
'sr' => new ReplacementArray()
|
|
|
|
|
|
);
|
2005-08-15 19:27:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2006-03-02 22:22:18 +00:00
|
|
|
|
/* rules should be defined as -{ekavian | iyekavian-} -or-
|
|
|
|
|
|
-{code:text | code:text | ...}-
|
2006-09-20 10:22:12 +00:00
|
|
|
|
update: delete all rule parsing because it's not used
|
|
|
|
|
|
currently, and just produces a couple of bugs
|
2005-12-27 00:04:57 +00:00
|
|
|
|
*/
|
2006-07-10 20:22:49 +00:00
|
|
|
|
function parseManualRule($rule, $flags=array()) {
|
2007-01-01 17:20:19 +00:00
|
|
|
|
if(in_array('T',$flags)){
|
|
|
|
|
|
return parent::parseManualRule($rule, $flags);
|
|
|
|
|
|
}
|
2005-08-19 00:05:06 +00:00
|
|
|
|
|
2007-01-01 17:20:19 +00:00
|
|
|
|
// otherwise ignore all formatting
|
|
|
|
|
|
foreach($this->mVariants as $v) {
|
|
|
|
|
|
$carray[$v] = $rule;
|
|
|
|
|
|
}
|
2008-05-17 17:10:18 +00:00
|
|
|
|
|
2006-03-02 22:22:18 +00:00
|
|
|
|
return $carray;
|
2005-10-12 07:40:34 +00:00
|
|
|
|
}
|
2005-08-19 00:05:06 +00:00
|
|
|
|
|
2007-01-01 17:20:19 +00:00
|
|
|
|
// Do not convert content on talk pages
|
2006-12-11 23:33:27 +00:00
|
|
|
|
function parserConvert( $text, &$parser ){
|
2007-01-17 22:57:06 +00:00
|
|
|
|
if(is_object($parser->getTitle() ) && $parser->getTitle()->isTalkPage())
|
2007-01-01 17:20:19 +00:00
|
|
|
|
$this->mDoContentConvert=false;
|
2008-05-17 17:10:18 +00:00
|
|
|
|
else
|
2007-01-01 17:20:19 +00:00
|
|
|
|
$this->mDoContentConvert=true;
|
2006-12-11 23:33:27 +00:00
|
|
|
|
|
2007-01-01 17:20:19 +00:00
|
|
|
|
return parent::parserConvert($text, $parser );
|
2006-06-16 22:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-12-26 12:19:45 +00:00
|
|
|
|
* A function wrapper:
|
2008-05-17 17:10:18 +00:00
|
|
|
|
* - if there is no selected variant, leave the link
|
2006-12-26 12:19:45 +00:00
|
|
|
|
* names as they were
|
|
|
|
|
|
* - do not try to find variants for usernames
|
2006-06-16 22:30:39 +00:00
|
|
|
|
*/
|
2009-02-02 07:54:43 +00:00
|
|
|
|
function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
|
2006-12-26 12:19:45 +00:00
|
|
|
|
// check for user namespace
|
|
|
|
|
|
if(is_object($nt)){
|
|
|
|
|
|
$ns = $nt->getNamespace();
|
|
|
|
|
|
if($ns==NS_USER || $ns==NS_USER_TALK)
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-06-16 22:30:39 +00:00
|
|
|
|
$oldlink=$link;
|
2009-02-02 07:54:43 +00:00
|
|
|
|
parent::findVariantLink( $link, $nt, $ignoreOtherCond );
|
2006-06-16 22:30:39 +00:00
|
|
|
|
if($this->getPreferredVariant()==$this->mMainLanguageCode)
|
|
|
|
|
|
$link=$oldlink;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* We want our external link captions to be converted in variants,
|
|
|
|
|
|
* so we return the original text instead -{$text}-, except for URLs
|
|
|
|
|
|
*/
|
2006-09-20 10:22:12 +00:00
|
|
|
|
function markNoConversion($text, $noParse=false) {
|
|
|
|
|
|
if($noParse || preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text))
|
2006-06-16 22:30:39 +00:00
|
|
|
|
return parent::markNoConversion($text);
|
|
|
|
|
|
return $text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* An ugly function wrapper for parsing Image titles
|
|
|
|
|
|
* (to prevent image name conversion)
|
|
|
|
|
|
*/
|
|
|
|
|
|
function autoConvert($text, $toVariant=false) {
|
|
|
|
|
|
global $wgTitle;
|
2008-12-01 17:14:30 +00:00
|
|
|
|
if(is_object($wgTitle) && $wgTitle->getNameSpace()==NS_FILE){
|
2006-06-16 22:30:39 +00:00
|
|
|
|
$imagename = $wgTitle->getNsText();
|
|
|
|
|
|
if(preg_match("/^$imagename:/",$text)) return $text;
|
|
|
|
|
|
}
|
|
|
|
|
|
return parent::autoConvert($text,$toVariant);
|
2008-05-17 17:10:18 +00:00
|
|
|
|
}
|
2006-06-16 22:30:39 +00:00
|
|
|
|
|
2006-09-20 10:22:12 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* It translates text into variant, specials:
|
|
|
|
|
|
* - ommiting roman numbers
|
|
|
|
|
|
*/
|
|
|
|
|
|
function translate($text, $toVariant){
|
|
|
|
|
|
$breaks = '[^\w\x80-\xff]';
|
|
|
|
|
|
|
|
|
|
|
|
// regexp for roman numbers
|
|
|
|
|
|
$roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
|
|
|
|
|
|
|
|
|
|
|
|
$reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
|
|
|
|
|
|
|
|
|
|
|
|
$matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
2008-05-17 17:10:18 +00:00
|
|
|
|
|
2006-09-20 10:22:12 +00:00
|
|
|
|
$m = array_shift($matches);
|
2006-12-27 01:49:09 +00:00
|
|
|
|
if( !isset( $this->mTables[$toVariant] ) ) {
|
|
|
|
|
|
throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
|
|
|
|
|
|
}
|
2006-11-21 09:53:45 +00:00
|
|
|
|
$ret = $this->mTables[$toVariant]->replace( $m[0] );
|
2006-09-20 10:22:12 +00:00
|
|
|
|
$mstart = $m[1]+strlen($m[0]);
|
|
|
|
|
|
foreach($matches as $m) {
|
|
|
|
|
|
$ret .= substr($text, $mstart, $m[1]-$mstart);
|
|
|
|
|
|
$ret .= parent::translate($m[0], $toVariant);
|
|
|
|
|
|
$mstart = $m[1] + strlen($m[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
|
|
}
|
2003-11-09 11:24:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2006-03-02 22:22:18 +00:00
|
|
|
|
class LanguageSr extends LanguageSr_ec {
|
2006-06-24 18:48:58 +00:00
|
|
|
|
function __construct() {
|
2006-03-02 22:22:18 +00:00
|
|
|
|
global $wgHooks;
|
2006-09-20 10:22:12 +00:00
|
|
|
|
|
2006-07-26 07:15:39 +00:00
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
2006-09-20 10:22:12 +00:00
|
|
|
|
$variants = array('sr', 'sr-ec', 'sr-el');
|
2006-03-02 22:22:18 +00:00
|
|
|
|
$variantfallbacks = array(
|
|
|
|
|
|
'sr' => 'sr-ec',
|
2007-01-01 17:20:19 +00:00
|
|
|
|
'sr-ec' => 'sr',
|
|
|
|
|
|
'sr-el' => 'sr',
|
2008-05-17 17:10:18 +00:00
|
|
|
|
);
|
2006-09-20 10:22:12 +00:00
|
|
|
|
|
2006-03-02 22:22:18 +00:00
|
|
|
|
$marker = array();//don't mess with these, leave them as they are
|
|
|
|
|
|
$flags = array(
|
|
|
|
|
|
'S' => 'S', 'писмо' => 'S', 'pismo' => 'S',
|
|
|
|
|
|
'W' => 'W', 'реч' => 'W', 'reč' => 'W', 'ријеч' => 'W', 'riječ' => 'W'
|
|
|
|
|
|
);
|
|
|
|
|
|
$this->mConverter = new SrConverter($this, 'sr', $variants, $variantfallbacks, $marker, $flags);
|
|
|
|
|
|
$wgHooks['ArticleSaveComplete'][] = $this->mConverter;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|