}
$title = Title::newFromText( $part1, $ns );
+ $checkVariantLink = sizeof($wgContLang->getVariants())>1;
+ # Check for language variants if the template is not found
+ if($checkVariantLink && $title->getArticleID() == 0){
+ $wgContLang->findVariantLink($part1, $title);
+ }
+
if ( !is_null( $title ) ) {
if ( !$title->isExternal() ) {
# Check for excessive inclusion
$marker = '|' . $wgParser->UniqPrefix() . '[\-a-zA-Z0-9]+';
else
$marker = "";
- $reg = '/<[^>]+>|&[a-z#][a-z0-9]+;' . $marker . '/';
+
+ // this one is needed when the text is inside an html markup
+ $htmlfix = '|<[^>]+=\"[^(>=)]*$|^[^(<>=\")]*\"[^>]*>';
+
+ $reg = '/<[^>]+>|&[a-z#][a-z0-9]+;' . $marker . $htmlfix . '/';
+
$matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
if(isset($cache[$v]))
continue;
$cache[$v] = 1;
- $varnt = Title::newFromText( $v );
+ $varnt = Title::newFromText( $v, $ns );
if( $varnt && $varnt->getArticleID() > 0 ) {
$nt = $varnt;
if( !$wgDisableLangConversion )
*/
function parseManualRule($rule, $flags) {
- $choices = explode($this->mMarkup['varsep'], $rule);
+ $echoices = preg_split("/(<[^>]+>)/",$rule,-1,PREG_SPLIT_DELIM_CAPTURE);
+ $choices = array();
+
+ // check if we did a split across an HTML tag
+ // if so, glue them back together
+
+ $ctold = '';
+ foreach($echoices as $ct){
+ if($ct=='');
+ else if(preg_match('/<[^>]+>/',$ct)){
+ $ctold.=$ct;
+ }
+ else{
+ $c = explode($this->mMarkup['varsep'],$ct);
+ if(count($c)>1){
+ $choices[]=$ctold.array_shift($c);
+ $ctold=array_pop($c);
+ $choices=array_merge($choices,$c);
+ }
+ else $ctold.=array_pop($c);
+ }
+ }
+ if($ctold!='') $choices[]=$ctold;
+
$carray = array();
if(sizeof($choices) == 1) {
if(in_array('W', $flags)) {
return $carray;
}
+ /*
+ * Override function from LanguageConvertor
+ * Additional checks:
+ * - There should be no conversion for Talk pages
+ */
+ function getPreferredVariant(){
+ global $wgTitle;
+ if($wgTitle!=NULL && $wgTitle->isTalkPage()){
+ return $this->mMainLanguageCode;
+ }
+ return parent::getPreferredVariant();
+ }
+
+
+ /*
+ * A function wrapper, if there is no selected variant,
+ * leave the link names as they were
+ */
+ function findVariantLink( &$link, &$nt ) {
+ $oldlink=$link;
+ parent::findVariantLink($link,$nt);
+ 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
+ */
+ function markNoConversion($text) {
+ if(preg_match("/^https?:\/\/|ftp:\/\/|irc:\/\//",$text))
+ 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;
+ if($wgTitle->getNameSpace()==NS_IMAGE){
+ $imagename = $wgTitle->getNsText();
+ if(preg_match("/^$imagename:/",$text)) return $text;
+ }
+ return parent::autoConvert($text,$toVariant);
+ }
+
+
}
class LanguageSr extends LanguageSr_ec {