public function execute() { $dbw = wfGetDB(DB_SLAVE); // Get all Athena logs $res = $dbw->select(array('athena_page_details'), array('al_id', 'apd_language', 'apd_content'), array(), __METHOD__, array(), array()); foreach ($res as $row) { echo "\n----------------------------------------------\n"; echo "al_id is {$row->al_id} \n"; echo "apd_language is {$row->apd_language} \n"; $content = $row->apd_content; if (strlen($content) == 0) { $code = null; } else { file_put_contents("temp", $content); $code = system("franc < temp"); } $code = AthenaHelper::convertISOCode($code); echo "Language code is {$code}\n"; $str = $dbw->strencode(Language::fetchLanguageName($code)); echo "Language name is {$str} \n"; $dbw->update('athena_page_details', array('apd_language' => $str), array('al_id' => $row->al_id), __METHOD__, null); echo "\n----------------------------------------------\n"; } }
/** * Gets the language of a given text * * @param $text string * @return string */ static function getTextLanguage($text) { //wfErrorLog( "getTextLanguage called", '/var/www/html/a/extensions/Athena/data/debug.log' ); if (strlen($text) == 0) { $code = null; } else { //wfErrorLog( "BEFORE TEMP", '/var/www/html/a/extensions/Athena/data/debug.log' ); file_put_contents("/var/www/html/a/extensions/Athena/data/temp", $text); //wfErrorLog( "AFTER TEMP", '/var/www/html/a/extensions/Athena/data/debug.log' ); $code = system("franc < /var/www/html/a/extensions/Athena/data/temp"); //wfErrorLog( "Language code is $code", '/var/www/html/a/extensions/Athena/data/debug.log' ); } return AthenaHelper::convertISOCode($code); }