/** * Constructor * @param $request PKPRequest */ function NlmCitationSchemaCitationOutputFormatFilter(&$request) { parent::Filter(); // Load additional translations $locale = AppLocale::getLocale(); $basePath = $this->getBasePath(); $localeFile = $basePath . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'locale.xml'; AppLocale::registerLocaleFile($locale, $localeFile); // Save the request for later use $this->_request =& $request; }
/** * @see PKPPlugin::register() * @return boolean true iff success */ function register($category, $path) { $success = parent::register($category, $path); $this->addLocaleData(); if ($success && $this->getEnabled()) { // Register DAOs. $this->registerDAOs(); // Delete all plug-in data for a journal when the journal is deleted HookRegistry::register('JournalDAO::deleteJournalById', array($this, 'deleteJournalById')); // Editor links to review object types and objects for review pages HookRegistry::register('Templates::Editor::Index::AdditionalItems', array($this, 'displayLink')); // Hook against the MyAccount link for Readers to have access. HookRegistry::register('Templates::User::Index::MyAccount', array($this, 'displayLink')); // Handler for editor, author and public objects for review pages HookRegistry::register('LoadHandler', array($this, 'callbackLoadHandler')); // Enable TinyMCE for the text areas HookRegistry::register('TinyMCEPlugin::getEnableFields', array($this, 'enableTinyMCE')); // Enable notifications HookRegistry::register('NotificationManager::getNotificationContents', array($this, 'callbackNotificationContents')); // Ensure object for review user assignments are transferred when merging users HookRegistry::register('UserAction::mergeUsers', array($this, 'mergeObjectsForReviewAuthors')); $journal =& Request::getJournal(); if ($journal) { // Register all supported/available locale/translation file $availableLocales = $journal->getSupportedLocaleNames(); foreach ($availableLocales as $locale => $localeName) { $localePath = $this->getPluginPath() . '/locale/' . $locale . '/locale.xml'; AppLocale::registerLocaleFile($locale, $localePath, true); } $mode = $this->getSetting($journal->getId(), 'mode'); // If the menagment of objects reviewers should be supported // then include additional links and pages if ($mode == OFR_MODE_FULL) { // Navigation bar link to the public objects for review page HookRegistry::register('Templates::Common::Header::Navbar::CurrentJournal', array($this, 'displayLink')); // Author link to objects for review pages HookRegistry::register('Templates::Author::Index::AdditionalItems', array($this, 'displayLink')); // Display author's objects for review during submission HookRegistry::register('Author::SubmitHandler::saveSubmit', array($this, 'saveSubmitHandler')); HookRegistry::register('Templates::Author::Submit::Step5::AdditionalItems', array($this, 'displayAuthorObjectsForReview')); } // Display object metadata on article abstract page if ($this->getSetting($journal->getId(), 'displayAbstract')) { HookRegistry::register('TemplateManager::display', array(&$this, 'handleTemplateDisplay')); HookRegistry::register('Templates::Article::MoreInfo', array(&$this, 'displayAbstract')); } // remove side bar editor links for enrolled publishers. HookRegistry::register('TemplateManager::display', array($this, 'removeLinks')); } } return $success; }
function addCustomLocale($hookName, $args) { $locale =& $args[0]; $localeFilename =& $args[1]; $conference = Request::getConference(); $conferenceId = $conference->getId(); $publicFilesDir = Config::getVar('files', 'public_files_dir'); $customLocalePath = $publicFilesDir . DIRECTORY_SEPARATOR . 'conferences' . DIRECTORY_SEPARATOR . $conferenceId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename; import('file.FileManager'); if (FileManager::fileExists($customLocalePath)) { AppLocale::registerLocaleFile($locale, $customLocalePath, true); } return true; }
function addCustomLocale($hookName, $args) { $locale =& $args[0]; $localeFilename =& $args[1]; $journal = Request::getJournal(); $journalId = $journal->getId(); $publicFilesDir = Config::getVar('files', 'public_files_dir'); $customLocalePath = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename; import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); if ($fileManager->fileExists($customLocalePath)) { AppLocale::registerLocaleFile($locale, $customLocalePath, false); } return true; }
function requireComponents($components, $locale = null) { $loadedComponents =& Registry::get('loadedLocaleComponents', true, array()); if ($locale === null) { $locale = AppLocale::getLocale(); } $filenameComponentMap = AppLocale::getFilenameComponentMap($locale); foreach ($components as $component) { // Don't load components twice if (isset($loadedComponents[$locale][$component])) { continue; } if (!isset($filenameComponentMap[$component])) { fatalError('Unknown locale component ' . $component); } $filename = $filenameComponentMap[$component]; AppLocale::registerLocaleFile($locale, $filename); $loadedComponents[$locale][$component] = true; } }
/** * Load locale data for this plugin. * @param $locale string * @return boolean */ function addLocaleData($locale = null) { if ($locale == '') { $locale = AppLocale::getLocale(); } $localeFilename = $this->getLocaleFilename($locale); if ($localeFilename) { AppLocale::registerLocaleFile($locale, $this->getLocaleFilename($locale)); return true; } return false; }
/** * Load locale data for this plugin. * * @param $locale string * @return boolean */ function addLocaleData($locale = null) { if ($locale == '') { $locale = AppLocale::getLocale(); } $localeFilenames = $this->getLocaleFilename($locale); if ($localeFilenames) { if (is_scalar($localeFilenames)) { $localeFilenames = array($localeFilenames); } foreach ($localeFilenames as $localeFilename) { AppLocale::registerLocaleFile($locale, $localeFilename); } return true; } return false; }
/** * Load a set of locale components. Parameters of mixed length may * be supplied, each a LOCALE_COMPONENT_... constant. An optional final * parameter may be supplied to specify the locale (e.g. 'en_US'). */ static function requireComponents() { $params = func_get_args(); $paramCount = count($params); if ($paramCount === 0) { return; } // Get the locale $lastParam = $params[$paramCount - 1]; if (is_string($lastParam)) { $locale = $lastParam; $paramCount--; } else { $locale = AppLocale::getLocale(); } // Backwards compatibility: the list used to be supplied // as an array in the first parameter. if (is_array($params[0])) { $params = $params[0]; $paramCount = count($params); } // Go through and make sure each component is loaded if valid. $loadedComponents =& Registry::get('loadedLocaleComponents', true, array()); $filenameComponentMap = AppLocale::getFilenameComponentMap($locale); for ($i = 0; $i < $paramCount; $i++) { $component = $params[$i]; // Don't load components twice if (isset($loadedComponents[$locale][$component])) { continue; } // Validate component if (!isset($filenameComponentMap[$component])) { fatalError('Unknown locale component ' . $component); } $filename = $filenameComponentMap[$component]; AppLocale::registerLocaleFile($locale, $filename); $loadedComponents[$locale][$component] = true; } }
/** * Update or install review objects * @param $journal Journal * @param $reviewObjects array of review object types keys or ids * @param $locales array of locales * @param $action string (install or update) */ function _updateOrInstallReviewObjectTypes($journal, $reviewObjects, $locales, $action) { $plugin =& $this->_getObjectsForReviewPlugin(); if (!isset($journal) || !isset($reviewObjects) || !isset($locales) || !isset($action)) { return false; } $journalId = $journal->getId(); $plugin->import('classes.ReviewObjectType'); $plugin->import('classes.ReviewObjectMetadata'); $reviewObjectTypeDao =& DAORegistry::getDAO('ReviewObjectTypeDAO'); $reviewObjectMetadataDao =& DAORegistry::getDAO('ReviewObjectMetadataDAO'); $onlyCommonMetadata = false; foreach ($reviewObjects as $keyOrId) { if ($action == 'install') { // Create a new review object type $reviewObjectType = $reviewObjectTypeDao->newDataObject(); $reviewObjectType->setContextId($journalId); $reviewObjectType->setActive(0); $reviewObjectType->setKey($keyOrId); } elseif ($action == 'update') { // Get the review object type $reviewObjectType =& $reviewObjectTypeDao->getById($keyOrId, $journalId); if (!isset($reviewObjectType)) { return false; } // If the type was created by the user, update only the common metadata if ($reviewObjectType->getKey() == NULL) { $onlyCommonMetadata = true; } } // Callect the metadata in the array $reviewObjectMetadataArray = array(); // For all languages foreach ($locales as $locale) { // Register the locale/translation file $localePath = $plugin->getPluginPath() . '/locale/' . $locale . '/locale.xml'; AppLocale::registerLocaleFile($locale, $localePath, true); $xmlDao = new XMLDAO(); // Get common metadata $commonDataPath = $plugin->getPluginPath() . '/xml/commonMetadata.xml'; $commonData = $xmlDao->parse($commonDataPath); $commonMetadata = $commonData->getChildByName('objectMetadata'); $allMetadataChildren = $commonMetadata->getChildren(); // Get the object metadata if (!$onlyCommonMetadata) { // Parse the review object XML file $itemPath = $plugin->getPluginPath() . '/xml/reviewObjects/' . $reviewObjectType->getKey() . '.xml'; $data = $xmlDao->parse($itemPath); if (!$data) { return false; } // Set the review object name $itemTypeName = __($data->getChildValue('objectType'), array(), $locale); $reviewObjectType->setName($itemTypeName, $locale); // $reviewObjectType->setDescription($itemTypeNameDescription, $locale); // Get the review object role selection options $roleSelectionOptions = $data->getChildByName('roleSelectionOptions'); // Handle Metadata // Get multiple options metadata types $multipleOptionsTypes = ReviewObjectMetadata::getMultipleOptionsTypes(); // Get metadata types defined in DTD $dtdTypes = ReviewObjectMetadata::getMetadataDTDTypes(); // Get the review object metadata $itemMetadata = $data->getChildByName('objectMetadata'); // Merge all (common + review objec) metadata $allMetadataChildren = array_merge($commonMetadata->getChildren(), $itemMetadata->getChildren()); } // Go through the metadata foreach ($allMetadataChildren as $metadataNode) { $key = $metadataNode->getAttribute('key'); // If we have already went througt, collected/considered the metadata if (array_key_exists($key, $reviewObjectMetadataArray)) { $reviewObjectMetadata = $reviewObjectMetadataArray[$key]; } else { if ($action == 'update') { // Get the metadata $reviewObjectMetadata = $reviewObjectMetadataDao->getByKey($key, $reviewObjectType->getId()); } if ($action == 'install' || !isset($reviewObjectMetadata)) { // Create a new metadata $reviewObjectMetadata = $reviewObjectMetadataDao->newDataObject(); $reviewObjectMetadata->setSequence(REALLY_BIG_NUMBER); $metadataType = $dtdTypes[$metadataNode->getAttribute('type')]; $reviewObjectMetadata->setMetadataType($metadataType); $required = $metadataNode->getAttribute('required'); $reviewObjectMetadata->setRequired($required == 'true' ? 1 : 0); $display = $metadataNode->getAttribute('display'); $reviewObjectMetadata->setDisplay($display == 'true' ? 1 : 0); } } // Set metadata name $name = __($metadataNode->getChildValue('name'), array(), $locale); $reviewObjectMetadata->setName($name, $locale); // Set roles options if ($key == REVIEW_OBJECT_METADATA_KEY_ROLE) { if (!$onlyCommonMetadata) { $possibleOptions = array(); $index = 1; foreach ($roleSelectionOptions->getChildren() as $selectionOptionNode) { $possibleOptions[] = array('order' => $index, 'content' => __($selectionOptionNode->getValue(), array(), $locale)); $index++; } $reviewObjectMetadata->setPossibleOptions($possibleOptions, $locale); } } else { // Set possible options for multiple options metadata type if (in_array($reviewObjectMetadata->getMetadataType(), $multipleOptionsTypes)) { $selectionOptions = $metadataNode->getChildByName('selectionOptions'); $possibleOptions = array(); $index = 1; foreach ($selectionOptions->getChildren() as $selectionOptionNode) { $possibleOptions[] = array('order' => $index, 'content' => __($selectionOptionNode->getValue(), array(), $locale)); $index++; } $reviewObjectMetadata->setPossibleOptions($possibleOptions, $locale); } else { $reviewObjectMetadata->setPossibleOptions(null, null); } } // Collect/consider the metadata $reviewObjectMetadataArray[$key] = $reviewObjectMetadata; unset($reviewObjectMetadata); } // End foreach metadata } // End foreach locales // Insert resp. update the review object type if ($action == 'install') { $reviewObjectTypeId = $reviewObjectTypeDao->insertObject($reviewObjectType); } elseif ($action == 'update') { $reviewObjectTypeDao->updateObject($reviewObjectType); } // Insert resp. update review object metadata foreach ($reviewObjectMetadataArray as $key => $reviewObjectMetadata) { // if this is a new metadata insert it if ($reviewObjectMetadata->getKey() == '') { $reviewObjectMetadata->setKey($key); $reviewObjectMetadata->setReviewObjectTypeId($reviewObjectType->getId()); $reviewObjectMetadataDao->insertObject($reviewObjectMetadata); $reviewObjectMetadataDao->resequence($reviewObjectType->getId()); } else { $reviewObjectMetadataDao->updateObject($reviewObjectMetadata); } } unset($reviewObjectType); } // End foreach review objects }