/**
  * @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
  */
 function getTemplateVarsFromRowColumn($row, $column)
 {
     $data = $row->getData();
     switch ($column->getId()) {
         case 'key':
             return array('key' => $row->getId(), 'strong' => !isset($data[MASTER_LOCALE]) || $data[MASTER_LOCALE] === '' || !isset($data[$this->locale]) || $data[$this->locale] === '' || 0 != count(array_diff(PKPLocale::getParameterNames($data[MASTER_LOCALE]), PKPLocale::getParameterNames($data[$this->locale]))));
         case 'value':
             $allLocales = PKPLocale::getAllLocales();
             return array('referenceLocale' => MASTER_LOCALE, 'referenceLocaleName' => $allLocales[MASTER_LOCALE], 'reference' => isset($data[MASTER_LOCALE]) ? $data[MASTER_LOCALE] : '', 'translationLocale' => $this->locale, 'translationLocaleName' => $allLocales[$this->locale], 'translation' => isset($data[$this->locale]) ? $data[$this->locale] : '');
     }
     assert(false);
 }
/**
 * Wrapper around PKPLocale::translate().
 *
 * Enables us to work with translated strings everywhere without
 * introducing a lot of duplicate code and without getting
 * blisters on our fingers.
 *
 * This is similar to WordPress' solution for translation, see
 * <http://codex.wordpress.org/Translating_WordPress>.
 *
 * @see PKPLocale::translate()
 *
 * @param $key string
 * @param $params array named substitution parameters
 * @param $locale string the locale to use
 * @return string
 */
function __($key, $params = array(), $locale = null)
{
    return PKPLocale::translate($key, $params, $locale);
}
Esempio n. 3
0
 /**
  * Make a map of components to their respective files.
  * @param $locale string
  * @return array
  */
 function makeComponentMap($locale)
 {
     $componentMap = parent::makeComponentMap($locale);
     $baseDir = "locale/{$locale}/";
     $componentMap[LOCALE_COMPONENT_APPLICATION_COMMON] = $baseDir . 'locale.xml';
     $componentMap[LOCALE_COMPONENT_OJS_AUTHOR] = $baseDir . 'author.xml';
     $componentMap[LOCALE_COMPONENT_OJS_EDITOR] = $baseDir . 'editor.xml';
     $componentMap[LOCALE_COMPONENT_OJS_MANAGER] = $baseDir . 'manager.xml';
     $componentMap[LOCALE_COMPONENT_OJS_ADMIN] = $baseDir . 'admin.xml';
     $componentMap[LOCALE_COMPONENT_OJS_DEFAULT] = $baseDir . 'default.xml';
     return $componentMap;
 }
Esempio n. 4
0
 function getMainEmailTemplateDataFilename($locale = null)
 {
     if ($locale !== null && !PKPLocale::isLocaleValid($locale)) {
         return null;
     }
     if ($locale === null) {
         $locale = '{$installedLocale}';
     }
     return "locale/{$locale}/emailTemplates.xml";
 }
Esempio n. 5
0
 /**
  * Make a map of components to their respective files.
  * @param $locale string
  * @return array
  */
 function makeComponentMap($locale)
 {
     $componentMap = parent::makeComponentMap($locale);
     $baseDir = "locale/{$locale}/";
     $componentMap[LOCALE_COMPONENT_APPLICATION_COMMON] = $baseDir . 'locale.xml';
     $componentMap[LOCALE_COMPONENT_OMP_MANAGER] = $baseDir . 'manager.xml';
     $componentMap[LOCALE_COMPONENT_OMP_SUBMISSION] = $baseDir . 'submission.xml';
     $componentMap[LOCALE_COMPONENT_OMP_EDITOR] = $baseDir . 'editor.xml';
     $componentMap[LOCALE_COMPONENT_OMP_ADMIN] = $baseDir . 'admin.xml';
     $componentMap[LOCALE_COMPONENT_OMP_DEFAULT_SETTINGS] = $baseDir . 'defaultSettings.xml';
     return $componentMap;
 }
 /**
  * Get the count of "correctly" translated locale keys for a translation.
  * @param $referenceLocaleData array Array of locale keys to locale data for reference locale
  * @param $localeData array Array of locale keys to locale data for the work translation
  * @return int Number of "correctly" translated locale keys
  */
 protected function _getTranslatedCount($referenceLocaleData, $localeData)
 {
     $completeCount = 0;
     foreach ($referenceLocaleData as $key => $value) {
         if (!isset($localeData[$key])) {
             continue;
         }
         // Not translated
         if (0 != count(array_diff(PKPLocale::getParameterNames($value), PKPLocale::getParameterNames($localeData[$key])))) {
             continue;
             // Parameters differ
         }
         $completeCount++;
     }
     return $completeCount;
 }
Esempio n. 7
0
 /**
  * Initialize the locale system.
  * @param $request PKPRequest
  */
 static function initialize($request)
 {
     self::$request = $request;
     // Use defaults if locale info unspecified.
     $locale = AppLocale::getLocale();
     $sysLocale = $locale . '.' . LOCALE_ENCODING;
     if (!@setlocale(LC_ALL, $sysLocale, $locale)) {
         // For PHP < 4.3.0
         if (setlocale(LC_ALL, $sysLocale) != $sysLocale) {
             setlocale(LC_ALL, $locale);
         }
     }
     AppLocale::registerLocaleFile($locale, "lib/pkp/locale/{$locale}/common.xml");
     // Set site time zone
     // Starting from PHP 5.3.0 PHP will throw an E_WARNING if the default
     // time zone is not set and date/time functions are used
     // http://pl.php.net/manual/en/function.date-default-timezone-set.php
     $timeZone = self::getTimeZone();
     date_default_timezone_set($timeZone);
     if (Config::getVar('general', 'installed')) {
         // Set the time zone for DB
         // Get the offset from UTC
         $now = new DateTime();
         $mins = $now->getOffset() / 60;
         $sgn = $mins < 0 ? -1 : 1;
         $mins = abs($mins);
         $hrs = floor($mins / 60);
         $mins -= $hrs * 60;
         $offset = sprintf('%+d:%02d', $hrs * $sgn, $mins);
         $conn = DBConnection::getInstance();
         $dbconn =& $conn->getDBConn();
         switch ($conn->getDriver()) {
             case 'mysql':
             case 'mysqli':
                 $dbconn->execute('SET time_zone = \'' . $offset . '\'');
                 break;
             case 'postgres':
                 $dbconn->execute('SET TIME ZONE INTERVAL \'' . $offset . '\' HOUR TO MINUTE');
                 break;
             default:
                 assert(false);
         }
     }
 }
Esempio n. 8
0
 /**
  * Make a map of components to their respective files.
  * @param $locale string
  * @return array
  */
 static function makeComponentMap($locale)
 {
     $componentMap = parent::makeComponentMap($locale);
     $baseDir = "locale/{$locale}/";
     $componentMap[LOCALE_COMPONENT_APP_COMMON] = $baseDir . 'locale.xml';
     $componentMap[LOCALE_COMPONENT_APP_AUTHOR] = $baseDir . 'author.xml';
     $componentMap[LOCALE_COMPONENT_APP_SUBMISSION] = $baseDir . 'submission.xml';
     $componentMap[LOCALE_COMPONENT_APP_EDITOR] = $baseDir . 'editor.xml';
     $componentMap[LOCALE_COMPONENT_APP_MANAGER] = $baseDir . 'manager.xml';
     $componentMap[LOCALE_COMPONENT_APP_ADMIN] = $baseDir . 'admin.xml';
     $componentMap[LOCALE_COMPONENT_APP_DEFAULT] = $baseDir . 'default.xml';
     return $componentMap;
 }
Esempio n. 9
0
 /**
  * Make a map of components to their respective files.
  * @param $locale string
  * @return array
  */
 function makeComponentMap($locale)
 {
     $componentMap = parent::makeComponentMap($locale);
     $baseDir = "locale/{$locale}/";
     $componentMap[LOCALE_COMPONENT_APPLICATION_COMMON] = $baseDir . 'locale.xml';
     return $componentMap;
 }
Esempio n. 10
0
 /**
  * Initialize the locale system.
  * @param $request PKPRequest
  */
 static function initialize($request)
 {
     self::$request = $request;
     // Use defaults if locale info unspecified.
     $locale = AppLocale::getLocale();
     $sysLocale = $locale . '.' . LOCALE_ENCODING;
     if (!@setlocale(LC_ALL, $sysLocale, $locale)) {
         // For PHP < 4.3.0
         if (setlocale(LC_ALL, $sysLocale) != $sysLocale) {
             setlocale(LC_ALL, $locale);
         }
     }
     AppLocale::registerLocaleFile($locale, "lib/pkp/locale/{$locale}/common.xml");
 }
Esempio n. 11
0
 /**
  * Initialize the locale system.
  * @param $request PKPRequest
  */
 static function initialize($request)
 {
     self::$request = $request;
     // Use defaults if locale info unspecified.
     $locale = AppLocale::getLocale();
     $sysLocale = $locale . '.' . LOCALE_ENCODING;
     if (!@setlocale(LC_ALL, $sysLocale, $locale)) {
         // For PHP < 4.3.0
         if (setlocale(LC_ALL, $sysLocale) != $sysLocale) {
             setlocale(LC_ALL, $locale);
         }
     }
     AppLocale::registerLocaleFile($locale, "lib/pkp/locale/{$locale}/common.xml");
     // Set site time zone
     // Starting from PHP 5.3.0 PHP will throw an E_WARNING if the default
     // time zone is not set and date/time functions are used
     // http://pl.php.net/manual/en/function.date-default-timezone-set.php
     $timeZone = self::getTimeZone();
     date_default_timezone_set($timeZone);
 }
Esempio n. 12
0
 /**
  * Execute gzip to compress or extract files.
  * @param $filePath string file to be compressed or uncompressed.
  * @param $decompress boolean optional Set true if the passed file
  * needs to be decompressed.
  * @param $errorMsg string
  * @return false|string The file path that was created with the operation
  * or false in case of fail.
  */
 private function _executeGzip($filePath, $decompress = false, &$errorMsg)
 {
     PKPLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN);
     $gzipPath = Config::getVar('cli', 'gzip');
     if (!is_executable($gzipPath)) {
         $errorMsg = __('admin.error.executingUtil', array('utilPath' => $gzipPath, 'utilVar' => 'gzip'));
         return false;
     }
     $gzipCmd = escapeshellarg($gzipPath);
     if ($decompress) {
         $gzipCmd .= ' -d';
     }
     // Make sure any output message will mention the file path.
     $output = array($filePath);
     $returnValue = 0;
     $gzipCmd .= ' ' . $filePath;
     if (!Core::isWindows()) {
         // Get the output, redirecting stderr to stdout.
         $gzipCmd .= ' 2>&1';
     }
     exec($gzipCmd, $output, $returnValue);
     if ($returnValue > 0) {
         $errorMsg = __('admin.error.utilExecutionProblem', array('utilPath' => $gzipPath, 'output' => implode(PHP_EOL, $output)));
         return false;
     }
     if ($decompress) {
         return substr($filePath, 0, -3);
     } else {
         return $filePath . '.gz';
     }
 }