/** * Display the grid's containing page. * @param $args array * @param $request PKPRequest */ function save($args, $request) { $filename = $this->_getFilename($request); $notificationManager = new NotificationManager(); $user = $request->getUser(); if (!file_exists($filename)) { $dir = dirname($filename); if (!file_exists($dir)) { mkdir($dir); } $localeList = PKPLocale::getAllLocales(); file_put_contents($filename, strtr(file_get_contents(self::$plugin->getRegistryPath() . '/locale.xml'), array('{$locale}' => $this->locale, '{$localeName}' => $localeList[$this->locale]))); } // Use the EditableLocaleFile class to handle changes. import('lib.pkp.classes.file.EditableLocaleFile'); $this->file = new EditableLocaleFile($this->locale, $filename); // Delegate processing to the listbuilder handler. This will invoke the callbacks below. self::$plugin->import('controllers.listbuilder.LocaleFileListbuilderHandler'); if (LocaleFileListbuilderHandler::unpack($request, $request->getUserVar('localeKeys'))) { if ($this->file->write()) { $notificationManager->createTrivialNotification($user->getId()); } else { // Could not write the file $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.couldNotWriteFile', array('filename' => $filename)))); } } else { // Some kind of error occurred (probably garbled formatting) $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.errorEditingFile', array('filename' => $filename)))); } $message = new JSONMessage(true); return $message->getString(); }
/** * @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); }