public function ImportFile($strTemplateFile, $strTranslatedFile = null) { $intTime = time(); if ($strTranslatedFile) { $arrTransKey = $this->FileAsArray($strTranslatedFile); } $arrSourceKey = $this->FileAsArray($strTemplateFile); QFirebug::error($arrSourceKey); QFirebug::error($arrTransKey); $intElapsedTime = time() - $intTime; if ($intElapsedTime > 0) { // NarroLogger::LogDebug(sprintf('Preprocessing %s took %d seconds.', $this->objFile->FileName, $intElapsedTime)); } // NarroLogger::LogDebug(sprintf('Found %d contexts in file %s.', count($arrSourceKey), $this->objFile->FileName)); if (is_array($arrSourceKey)) { foreach ($arrSourceKey as $strContext => $objEntity) { /* @var $objEntity NarroFileEntity */ $this->AddTranslation($objEntity->Value, null, isset($arrTransKey[$strContext]) ? $arrTransKey[$strContext]->Value : null, null, $objEntity->Key, $objEntity->Comment); } } else { NarroLogger::LogWarn(sprintf('Found a empty template (%s), copying the original', $strTemplateFile)); copy($strTemplateFile, $strTranslatedFile); chmod($strTranslatedFile, 0666); } }
private static function Log($strMessage, $intPriority, $intProjectId = null, $intLanguageId = null, $intUserId = null) { if (SERVER_INSTANCE != 'dev' && $intPriority == NarroLog::PRIORITY_DEBUG) { return true; } $objLogEntry = new NarroLog(); $objLogEntry->Date = QDateTime::Now(); $objLogEntry->Priority = $intPriority; $objLogEntry->Message = $strMessage; $objLogEntry->ProjectId = is_null($intProjectId) ? is_null(self::$intProjectId) ? null : self::$intProjectId : $intProjectId; $objLogEntry->LanguageId = is_null($intLanguageId) ? is_null(self::$intLanguageId) ? null : self::$intLanguageId : $intLanguageId; $objLogEntry->UserId = is_null($intUserId) ? is_null(self::$intUserId) ? null : self::$intUserId : $intUserId; try { $objLogEntry->Save(); } catch (Exception $objEx) { error_log($objEx->getMessage() . $objEx->getTraceAsString()); } if (QFirebug::getEnabled()) { switch ($intPriority) { case NarroLog::PRIORITY_INFO: QFirebug::info($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); break; case NarroLog::PRIORITY_WARN: QFirebug::warn($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); break; case NarroLog::PRIORITY_ERROR: QFirebug::error($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); break; default: QFirebug::log($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); } } }
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once dirname(__FILE__) . '/../configuration/prepend.inc.php'; if (!isset($argv)) { exit; } QFirebug::setEnabled(false); if (array_search('--help', $argv) !== false) { echo sprintf("php %s [options]\n" . "--project project id instead of exporting all projects\n" . "--language language code instead of importing all languages\n" . "--disable-plugins disable plugins during import/export\n" . " suggestions, optional, defaults to anonymous\n" . "--exported-suggestion 1 for approved,\n" . " 2 - approved, then most voted,\n" . " 3 - approved, then most recent,\n" . " 4 - approved, most voted, most recent,\n" . " 5 - approved, my suggestion\n" . "--skip-untranslated skip lines that don't have translated texts\n", basename(__FILE__), NarroLanguage::SOURCE_LANGUAGE_CODE); exit; } foreach (NarroProject::LoadArrayByActive(1) as $objProject) { if (in_array('--project', $argv) && $objProject->ProjectId != $argv[array_search('--project', $argv) + 1]) { continue; } foreach (NarroLanguage::LoadAllActive() as $objLanguage) { if (in_array('--language', $argv) && $objLanguage->LanguageCode != $argv[array_search('--language', $argv) + 1]) { continue; } QApplication::$TargetLanguage = $objLanguage; $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($objProject->ProjectId, $objLanguage->LanguageId); if (!$objProjectProgress || $objProjectProgress->Active) {
* * You should have received a copy of the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ?> </div> <?php if (class_exists('QApplication')) { if (QApplication::$Database[1]->EnableProfiling) { QApplication::$Database[1]->OutputProfiling(); } if (SERVER_INSTANCE == 'dev') { QFirebug::table('Queries', @$GLOBALS['arrQueries']); QFirebug::info(sprintf('%d queries in total', count(@$GLOBALS['arrQueries']))); QFirebug::table('Cache', @$GLOBALS['arrCacheQueries']); QFirebug::info(sprintf('%d cache queries in total, %s seconds spent on them', count(@$GLOBALS['arrCacheQueries']), intval(@$GLOBALS['arrCacheQueriesSpent']))); } } /** * Yes, you are free to remove this footer */ ?> <p align="center" style="font-size:small"> <a target="_blank" href="http://code.google.com/p/narro/wiki/About"> <?php echo sprintf(function_exists('t') ? t('%s, version %s') : '%s, version %s', 'Narro', NARRO_VERSION); ?> </a> </p> </body> </html>