Inheritance: extends Handler
 function manage($verb, $args)
 {
     if (!parent::manage($verb, $args, $message)) {
         return false;
     }
     $this->import('CustomLocaleHandler');
     $customLocaleHandler = new CustomLocaleHandler();
     switch ($verb) {
         case 'edit':
             $customLocaleHandler->edit($args);
             return true;
         case 'saveLocaleChanges':
             $customLocaleHandler->saveLocaleChanges($args);
             return true;
         case 'editLocaleFile':
             $customLocaleHandler->editLocaleFile($args);
             return true;
         case 'saveLocaleFile':
             $customLocaleHandler->saveLocaleFile($args);
             return true;
         default:
             $customLocaleHandler->index();
             return true;
     }
 }
 function manage($verb, $args, &$message)
 {
     $this->import('CustomLocaleHandler');
     $returner = true;
     switch ($verb) {
         case 'enable':
             $this->setEnabled(true);
             $message = Locale::translate('plugins.generic.customLocale.enabled');
             $returner = false;
             break;
         case 'disable':
             $this->setEnabled(false);
             $message = Locale::translate('plugins.generic.customLocale.disabled');
             $returner = false;
             break;
         case 'index':
             if ($this->getEnabled()) {
                 $customLocaleHandler = new CustomLocaleHandler();
                 $customLocaleHandler->index();
             }
             break;
         case 'edit':
             if ($this->getEnabled()) {
                 $customLocaleHandler = new CustomLocaleHandler();
                 $customLocaleHandler->edit($args);
             }
             break;
         case 'saveLocaleChanges':
             if ($this->getEnabled()) {
                 $customLocaleHandler = new CustomLocaleHandler();
                 $customLocaleHandler->saveLocaleChanges($args);
             }
             break;
         case 'editLocaleFile':
             if ($this->getEnabled()) {
                 $customLocaleHandler = new CustomLocaleHandler();
                 $customLocaleHandler->editLocaleFile($args);
             }
             break;
         case 'saveLocaleFile':
             if ($this->getEnabled()) {
                 $customLocaleHandler = new CustomLocaleHandler();
                 $customLocaleHandler->saveLocaleFile($args);
             }
             break;
         default:
             if ($this->getEnabled()) {
                 $customLocaleHandler = new CustomLocaleHandler();
                 $customLocaleHandler->index();
             }
     }
     return $returner;
 }
Beispiel #3
0
 /**
  * @copydoc Plugin::manage()
  */
 function manage($args, $request)
 {
     if (!parent::manage($args, $request)) {
         return false;
     }
     $this->import('CustomLocaleHandler');
     $customLocaleHandler = new CustomLocaleHandler($this->getName());
     switch ($array_shift($args)) {
         case 'edit':
             $customLocaleHandler->edit($args, $request);
             return true;
         case 'saveLocaleChanges':
             $customLocaleHandler->saveLocaleChanges($args, $request);
             return true;
         case 'editLocaleFile':
             $customLocaleHandler->editLocaleFile($args, $request);
             return true;
         case 'saveLocaleFile':
             $customLocaleHandler->saveLocaleFile($args, $request);
             return true;
         default:
             $customLocaleHandler->index($args, $request);
             return true;
     }
 }
 function saveLocaleFile($args)
 {
     list($plugin) = CustomLocaleHandler::validate();
     CustomLocaleHandler::setupTemplate($plugin, true);
     $locale = array_shift($args);
     if (!Locale::isLocaleValid($locale)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'index');
         Request::redirect(null, null, null, $path);
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!CustomLocaleAction::isLocaleFile($locale, $filename)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'edit', $locale);
         Request::redirect(null, null, null, $path);
     }
     $journal =& Request::getJournal();
     $journalId = $journal->getJournalId();
     $changes = Request::getUserVar('changes');
     $customFilesDir = Config::getVar('files', 'public_files_dir') . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale;
     $customFilePath = $customFilesDir . DIRECTORY_SEPARATOR . $filename;
     // Create empty custom locale file if it doesn't exist
     import('file.FileManager');
     import('file.EditableLocaleFile');
     if (!FileManager::fileExists($customFilePath)) {
         $numParentDirs = substr_count($customFilePath, DIRECTORY_SEPARATOR);
         $parentDirs = '';
         for ($i = 0; $i < $numParentDirs; $i++) {
             $parentDirs .= '..' . DIRECTORY_SEPARATOR;
         }
         $newFileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $newFileContents .= '<!DOCTYPE locale SYSTEM "' . $parentDirs . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'dtd' . DIRECTORY_SEPARATOR . 'locale.dtd' . '">' . "\n";
         $newFileContents .= '<locale name="' . $locale . '">' . "\n";
         $newFileContents .= '</locale>';
         FileManager::writeFile($customFilePath, $newFileContents);
     }
     $file =& new EditableLocaleFile($locale, $customFilePath);
     while (!empty($changes)) {
         $key = array_shift($changes);
         $value = CustomLocaleHandler::correctCr(array_shift($changes));
         if (!empty($value)) {
             if (!$file->update($key, $value)) {
                 $file->insert($key, $value);
             }
         } else {
             $file->delete($key);
         }
     }
     $file->write();
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
 function manage($verb, $args)
 {
     $this->import('CustomLocaleHandler');
     $returner = true;
     switch ($verb) {
         case 'enable':
             $this->setEnabled(true);
             $returner = false;
             break;
         case 'disable':
             $this->setEnabled(false);
             $returner = false;
             break;
         case 'index':
             if ($this->getEnabled()) {
                 CustomLocaleHandler::index();
             }
             break;
         case 'edit':
             if ($this->getEnabled()) {
                 CustomLocaleHandler::edit($args);
             }
             break;
         case 'saveLocaleChanges':
             if ($this->getEnabled()) {
                 CustomLocaleHandler::saveLocaleChanges($args);
             }
             break;
         case 'editLocaleFile':
             if ($this->getEnabled()) {
                 CustomLocaleHandler::editLocaleFile($args);
             }
             break;
         case 'saveLocaleFile':
             if ($this->getEnabled()) {
                 CustomLocaleHandler::saveLocaleFile($args);
             }
             break;
         default:
             if ($this->getEnabled()) {
                 CustomLocaleHandler::index();
             }
     }
     return $returner;
 }
Beispiel #6
0
 /**
  * @see Plugin::manage()
  */
 function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
 {
     if (!parent::manage($verb, $args, $message, $messageParams)) {
         return false;
     }
     $request = $this->getRequest();
     $this->import('CustomLocaleHandler');
     $customLocaleHandler = new CustomLocaleHandler($this->getName());
     switch ($verb) {
         case 'edit':
             $customLocaleHandler->edit($args, $request);
             return true;
         case 'saveLocaleChanges':
             $customLocaleHandler->saveLocaleChanges($args, $request);
             return true;
         case 'editLocaleFile':
             $customLocaleHandler->editLocaleFile($args, $request);
             return true;
         case 'saveLocaleFile':
             $customLocaleHandler->saveLocaleFile($args, $request);
             return true;
         default:
             $customLocaleHandler->index($args, $request);
             return true;
     }
 }