mOptions = $options; } function setText( &$text, $form_submitted = FALSE ) { if ( $this->isTranslateEnabled() && isset($this->mOptions['translatable']) && $this->mOptions['translatable']) { if (!$form_submitted) { // remove translate tags when displaying the form as it messes up with VE if(preg_match('#^([\S\s]*)<\/translate>$#m', $text, $matches)) { $text = $matches[1]; } } else { // fix : rearrange tags to avoid errors // 4 cases : // 1 : text => text\n\n // 2 : text => \ntext // 3 : \n* => \n\n // 4 : \n* => \n\n $text = preg_replace(['#([^\s])()#m', '#()([^\s])#m', '#()([\s]+)#m', '#([\s]+)()#m'], ["$1\n\n$2", "$1\n$2", "$1\n", "\n\n$2"], $text); // put translate tags back $text = '' . $text .''; } } $this->mText = $text; } function isTranslateEnabled() { return class_exists('SpecialTranslate'); } function getText() { return $this->mText; } function getOptions() { return $this->mOptions; } function setOptions( $options ) { $this->mOptions = $options; } }