function editLocaleFile($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);
     }
     $templateMgr =& TemplateManager::getManager();
     import('file.FileManager');
     import('file.EditableLocaleFile');
     $journal = Request::getJournal();
     $journalId = $journal->getJournalId();
     $publicFilesDir = Config::getVar('files', 'public_files_dir');
     $customLocaleDir = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR;
     $customLocalePath = $customLocaleDir . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $filename;
     if (FileManager::fileExists($customLocalePath)) {
         $localeContents = EditableLocaleFile::load($customLocalePath);
     } else {
         $localeContents = null;
     }
     $referenceLocaleContents = EditableLocaleFile::load($filename);
     $referenceLocaleContentsRangeInfo = Handler::getRangeInfo('referenceLocaleContents');
     // Handle a search, if one was executed.
     $searchKey = Request::getUserVar('searchKey');
     $found = false;
     $index = 0;
     $pageIndex = 0;
     if (!empty($searchKey)) {
         foreach ($referenceLocaleContents as $key => $value) {
             if ($index % $referenceLocaleContentsRangeInfo->getCount() == 0) {
                 $pageIndex++;
             }
             if ($key == $searchKey) {
                 $found = true;
                 break;
             }
             $index++;
         }
     }
     if ($found) {
         $referenceLocaleContentsRangeInfo->setPage($pageIndex);
         $templateMgr->assign('searchKey', $searchKey);
     }
     $templateMgr->assign('filename', $filename);
     $templateMgr->assign('locale', $locale);
     import('core.ArrayItemIterator');
     $templateMgr->assign_by_ref('referenceLocaleContents', new ArrayItemIterator($referenceLocaleContents, $referenceLocaleContentsRangeInfo->getPage(), $referenceLocaleContentsRangeInfo->getCount()));
     $templateMgr->assign('localeContents', $localeContents);
     $templateMgr->display($plugin->getTemplatePath() . 'localeFile.tpl');
 }
 /**
  * @copydoc GridHandler::loadData()
  */
 function loadData($request)
 {
     import('lib.pkp.classes.file.EditableLocaleFile');
     $referenceLocaleContents = EditableLocaleFile::load(str_replace($this->locale, MASTER_LOCALE, $this->filename));
     $localeContents = file_exists($this->filename) ? EditableLocaleFile::load($this->filename) : array();
     $returner = array();
     foreach ($referenceLocaleContents as $key => $value) {
         $returner[$key][MASTER_LOCALE] = $value;
     }
     foreach ($localeContents as $key => $value) {
         $returner[$key][$this->locale] = $value;
     }
     return $returner;
 }
Beispiel #3
0
 function editLocaleFile($args, $request)
 {
     $this->validate();
     $plugin =& $this->plugin;
     $this->setupTemplate($request);
     $locale = array_shift($args);
     if (!AppLocale::isLocaleValid($locale)) {
         $request->redirect(null, null, 'index');
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!TranslatorAction::isLocaleFile($locale, $filename)) {
         $request->redirect(null, null, 'edit', $locale);
     }
     $templateMgr = TemplateManager::getManager($request);
     if (!is_writeable(Core::getBaseDir() . DIRECTORY_SEPARATOR . $filename)) {
         $templateMgr->assign('error', true);
     }
     import('lib.pkp.classes.file.EditableLocaleFile');
     $localeContentsRangeInfo = $this->getRangeInfo($request, 'localeContents');
     $localeContents = EditableLocaleFile::load($filename);
     // Handle a search, if one was executed.
     $searchKey = $request->getUserVar('searchKey');
     $found = false;
     $index = 0;
     $pageIndex = 0;
     if (!empty($searchKey)) {
         foreach ($localeContents as $key => $value) {
             if ($index % $localeContentsRangeInfo->getCount() == 0) {
                 $pageIndex++;
             }
             if ($key == $searchKey) {
                 $found = true;
                 break;
             }
             $index++;
         }
     }
     if ($found) {
         $localeContentsRangeInfo->setPage($pageIndex);
         $templateMgr->assign('searchKey', $searchKey);
     }
     $templateMgr->assign('filename', $filename);
     $templateMgr->assign('locale', $locale);
     import('lib.pkp.classes.core.ArrayItemIterator');
     $templateMgr->assign('localeContents', new ArrayItemIterator($localeContents, $localeContentsRangeInfo->getPage(), $localeContentsRangeInfo->getCount()));
     $templateMgr->assign('referenceLocaleContents', EditableLocaleFile::load(TranslatorAction::determineReferenceFilename($locale, $filename)));
     $templateMgr->display($plugin->getTemplatePath() . 'localeFile.tpl');
 }
Beispiel #4
0
 function editLocaleFile($args)
 {
     list($plugin) = TranslatorHandler::validate();
     TranslatorHandler::setupTemplate();
     $locale = array_shift($args);
     if (!Locale::isLocaleValid($locale)) {
         Request::redirect(null, null, 'index');
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!TranslatorAction::isLocaleFile($locale, $filename)) {
         Request::redirect(null, null, 'edit', $locale);
     }
     $templateMgr =& TemplateManager::getManager();
     import('i18n.EditableLocaleFile');
     $localeContentsRangeInfo = Handler::getRangeInfo('localeContents');
     $localeContents = EditableLocaleFile::load($filename);
     // Handle a search, if one was executed.
     $searchKey = Request::getUserVar('searchKey');
     $found = false;
     $index = 0;
     $pageIndex = 0;
     if (!empty($searchKey)) {
         foreach ($localeContents as $key => $value) {
             if ($index % $localeContentsRangeInfo->getCount() == 0) {
                 $pageIndex++;
             }
             if ($key == $searchKey) {
                 $found = true;
                 break;
             }
             $index++;
         }
     }
     if ($found) {
         $localeContentsRangeInfo->setPage($pageIndex);
         $templateMgr->assign('searchKey', $searchKey);
     }
     $templateMgr->assign('filename', $filename);
     $templateMgr->assign('locale', $locale);
     $templateMgr->assign_by_ref('localeContents', new ArrayItemIterator($localeContents, $localeContentsRangeInfo->getPage(), $localeContentsRangeInfo->getCount()));
     $templateMgr->assign('referenceLocaleContents', EditableLocaleFile::load(TranslatorAction::determineReferenceFilename($locale, $filename)));
     $templateMgr->display($plugin->getTemplatePath() . 'localeFile.tpl');
 }