/** * Compares the language of the site with the language of the edit * Returns true if different, and false if the same or null if error * * @param $text string * @return bool|null */ public static function differentLanguage($text) { global $wgLanguageCode; $language = AthenaHelper::getTextLanguage($text); // Remove any region specialities from wiki's language code (e.g. en-gb becomes en) $arr = preg_split("/-/", $wgLanguageCode); // echo( "\n\n language code is " . $arr[0] ); // echo( "\n\n language is " . $language ); if ($language !== null) { if ($arr[0] === $language) { return false; } return true; } return null; }
/** * Prepare an array with the details we want to insert into the athena_page_details table * * @param $namespace int * @param $title string * @param $content string * @param $comment string * @param $user int * @return array */ static function preparePageDetailsArray($namespace, $title, $content, $comment, $user) { $dbw = wfGetDB(DB_MASTER); $title = $dbw->strencode($title); $content = $dbw->strencode($content); $insertArray = array('apd_namespace' => $namespace, 'apd_title' => $title, 'apd_content' => $content, 'apd_user' => $user, 'page_id' => 'NULL', 'rev_id' => 'NULL'); if ($comment != '') { $comment = $dbw->strencode($comment); $insertArray['apd_comment'] = $comment; } $language = AthenaHelper::getTextLanguage($content); $insertArray['apd_language'] = $dbw->strencode(Language::fetchLanguageName($language)); return $insertArray; }