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); } } }