/** * Register JavaScript data used by the core JS library * * This function registers script data that is required by the core JS * library. This data is queued after jQuery but before the pkp-lib * framework, allowing dynamic data to be passed to the framework. It is * intended to be used for passing constants and locale strings, but plugins * may also take advantage of a hook to include data required by their own * scripts, when integrating with the pkp-lib framework. */ function registerJSLibraryData() { $application = PKPApplication::getApplication(); // Instantiate the namespace $output = '$.pkp = $.pkp || {};'; // Load data intended for general use by the app $app_data = array('baseUrl' => $this->_request->getBaseUrl()); $output .= '$.pkp.app = ' . json_encode($app_data) . ';'; // Load exposed constants $exposedConstants = $application->getExposedConstants(); if (!empty($exposedConstants)) { $output .= '$.pkp.cons = ' . json_encode($exposedConstants) . ';'; } // Load locale keys $localeKeys = $application->getJSLocaleKeys(); if (!empty($localeKeys)) { // Replace periods in the key name with underscores for better- // formatted JS keys $jsLocaleKeys = array(); foreach ($localeKeys as $key) { $jsLocaleKeys[str_replace('.', '_', $key)] = __($key); } $output .= '$.pkp.locale = ' . json_encode($jsLocaleKeys) . ';'; } // Allow plugins to load data within their own namespace $plugin_data = array(); HookRegistry::call('TemplateManager::registerJSLibraryData', array(&$plugin_data)); if (!empty($plugin_data) && is_array($plugin_data)) { $output .= '$.pkp.plugins = {};'; foreach ($plugin_data as $namespace => $data) { $output .= $namespace . ' = ' . json_encode($data) . ';'; } } $this->addJavaScript('pkpLibData', $output, array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend', 'inline' => true)); }
/** * Initialize the template manager. */ function initialize() { // Retrieve the router $router = $this->_request->getRouter(); assert(is_a($router, 'PKPRouter')); $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset')); $this->assign('basePath', $this->_request->getBasePath()); $this->assign('baseUrl', $this->_request->getBaseUrl()); $this->assign('requiresFormRequest', $this->_request->isPost()); if (is_a($router, 'PKPPageRouter')) { $this->assign('requestedPage', $router->getRequestedPage($this->_request)); } $this->assign('currentUrl', $this->_request->getCompleteUrl()); $this->assign('dateFormatTrunc', Config::getVar('general', 'date_format_trunc')); $this->assign('dateFormatShort', Config::getVar('general', 'date_format_short')); $this->assign('dateFormatLong', Config::getVar('general', 'date_format_long')); $this->assign('datetimeFormatShort', Config::getVar('general', 'datetime_format_short')); $this->assign('datetimeFormatLong', Config::getVar('general', 'datetime_format_long')); $this->assign('timeFormat', Config::getVar('general', 'time_format')); $this->assign('allowCDN', Config::getVar('general', 'enable_cdn')); $this->assign('useMinifiedJavaScript', Config::getVar('general', 'enable_minified')); $this->assign('toggleHelpOnText', __('help.toggleInlineHelpOn')); $this->assign('toggleHelpOffText', __('help.toggleInlineHelpOff')); $this->assign('currentContext', $this->_request->getContext()); $locale = AppLocale::getLocale(); $this->assign('currentLocale', $locale); // Add uncompilable styles $this->addStyleSheet($this->_request->getBaseUrl() . '/styles/lib.css', STYLE_SEQUENCE_CORE); $dispatcher = $this->_request->getDispatcher(); if ($dispatcher) { $this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE); } // If there's a locale-specific stylesheet, add it. if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) { $this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet); } $application = PKPApplication::getApplication(); $this->assign('pageTitle', $application->getNameKey()); $this->assign('applicationName', __($application->getNameKey())); $this->assign('exposedConstants', $application->getExposedConstants()); $this->assign('jsLocaleKeys', $application->getJSLocaleKeys()); // Register custom functions $this->register_modifier('translate', array('AppLocale', 'translate')); $this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml')); $this->register_modifier('String_substr', array('String', 'substr')); $this->register_modifier('to_array', array($this, 'smartyToArray')); $this->register_modifier('compare', array($this, 'smartyCompare')); $this->register_modifier('concat', array($this, 'smartyConcat')); $this->register_modifier('escape', array($this, 'smartyEscape')); $this->register_modifier('strtotime', array($this, 'smartyStrtotime')); $this->register_modifier('explode', array($this, 'smartyExplode')); $this->register_modifier('assign', array($this, 'smartyAssign')); $this->register_function('translate', array($this, 'smartyTranslate')); $this->register_function('null_link_action', array($this, 'smartyNullLinkAction')); $this->register_function('flush', array($this, 'smartyFlush')); $this->register_function('call_hook', array($this, 'smartyCallHook')); $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate')); $this->register_block('iterate', array($this, 'smartyIterate')); $this->register_function('page_links', array($this, 'smartyPageLinks')); $this->register_function('page_info', array($this, 'smartyPageInfo')); $this->register_function('icon', array($this, 'smartyIcon')); $this->register_modifier('truncate', array($this, 'smartyTruncate')); // Modified vocabulary for creating forms $fbv = $this->getFBV(); $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection')); $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea')); $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons')); $this->register_function('fbvElement', array($fbv, 'smartyFBVElement')); $this->assign('fbvStyles', $fbv->getStyles()); $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel')); // register the resource name "core" $this->register_resource('core', array(array($this, 'smartyResourceCoreGetTemplate'), array($this, 'smartyResourceCoreGetTimestamp'), array($this, 'smartyResourceCoreGetSecure'), array($this, 'smartyResourceCoreGetTrusted'))); $this->register_function('url', array($this, 'smartyUrl')); // ajax load into a div $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv')); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $this->assign('isUserLoggedIn', Validation::isLoggedIn()); $this->assign('isUserLoggedInAs', Validation::isLoggedInAs()); $application = PKPApplication::getApplication(); $currentVersion = $application->getCurrentVersion(); $this->assign('currentVersionString', $currentVersion->getVersionString(false)); $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page')); $this->assign('numPageLinks', Config::getVar('interface', 'page_links')); } // Load enabled block plugins. PluginRegistry::loadCategory('blocks', true); if (!defined('SESSION_DISABLE_INIT')) { $user = $this->_request->getUser(); $hasSystemNotifications = false; if ($user) { // Assign the user name to be used in the sitenav $this->assign('loggedInUsername', $user->getUserName()); $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL); if ($notifications->getCount() > 0) { $hasSystemNotifications = true; } $this->assign('initialHelpState', (int) $user->getInlineHelp()); } $this->assign('hasSystemNotifications', $hasSystemNotifications); } }
/** * @see OAIMetadataFormat#toXml */ function toXml(&$record, $format = null) { error_log("OAIMetadataFormat_MODS: toXml wird aufgerufen"); $article =& $record->getData('article'); $journal =& $record->getData('journal'); $section =& $record->getData('section'); $issue =& $record->getData('issue'); $galleys =& $record->getData('galleys'); $articleId = $article->getArticleId(); //date the article was published $datePublished = $article->getDatePublished(); if (!$datePublished) { $datePublished = $issue->getDatePublished(); } if ($datePublished) { $datePublished = strtotime($datePublished); } //date the article was last modified $dateLastModified = $article->getLastModified(); $dateLastModified = strtotime($dateLastModified); // PaperPackage Name for direct Link to the Package $daos =& DAORegistry::getDAOs(); $rpositoryDao =& $daos['RpositoryDAO']; $packageName = htmlspecialchars(Core::cleanVar(strip_tags($rpositoryDao->getPackageName($articleId)))); // All Versions of the Package $packages = $rpositoryDao->getAllPackagesByArticle($articleId); error_log('OJS - MODS: Die Pakete: ' . json_encode($packages)); //PID $pid = $rpositoryDao->getPID($articleId); //Name of the Package without tar.gz-Ending $filename = ereg_replace('(_)[0-9].[0-9](.tar.gz)', '', $packageName); //PackageType $packageType = $this->getPackageType($articleId); //check if $pid is set if ($pid == NULL) { $pidOutPut = 'NOT_ISSUED'; } else { $pidOutPut = $pid; } /* $response = "<?xml version=\"1.0\" enconding=\"UTF-8\"?>" . */ // $response = "<CMD_ComponentSpec isProfile=\"true\" xsi:schemaLocation=\"http://www.clarin.eu/cmd https://infra.clarin.eu/cmd/general-component-schema.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" . $response = "<CMD CMDVersion=\"1.1\" xmlns=\"http://www.clarin.eu/cmd/\" \n" . "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.clarin.eu/cmd/ http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1375880372976/xsd\">\n" . "\t<Header>\n" . "\t\t<MdCreator>Mind Research Repository CMDI Creator 1.0</MdCreator>\n" . "\t\t\t<MdCreationDate>" . date('Y-m-d', $dateLastModified) . "</MdCreationDate>\n" . "\t\t\t<MdSelfLink>" . $pidOutPut . "</MdSelfLink>\n" . "\t\t\t<MdProfile>clarin.eu:cr1:p_1375880372976</MdProfile>\n" . "\t\t\t<MdCollectionDisplayName>Mind Research Repository</MdCollectionDisplayName>\n" . "\t</Header>\n" . "\t<Resources>\n" . "\t\t<ResourceProxyList>\n"; foreach ($packages as $package) { if ($package['pidv1'] == NULL) { $pid = $package['pidv2']; } else { $pid = $package['pidv1']; } $current = NULL; if ($package['current'] == 1) { $current = '-current'; } $response .= "\t\t\t<ResourceProxy id=\"mrr-" . htmlspecialchars(Core::cleanVar($pid)) . "-resource" . $current . "\">\n" . "\t\t\t\t<ResourceType mimetype=\"application/x-gzip\">Resource</ResourceType>\n" . "\t\t\t\t<ResourceRef>" . htmlspecialchars(Core::cleanVar(PKPRequest::getBaseUrl() . "/Rpository/src/contrib/" . $package['filename'])) . "</ResourceRef>\n" . "\t\t\t</ResourceProxy>\n"; $n++; } $response .= "\t\t</ResourceProxyList>\n" . "\t\t<JournalFileProxyList/>\n" . "\t\t<ResourceRelationList/>\n" . "\t</Resources>\n" . "\t<CMD_ComponentSpec isProfile=\"true\">\n" . "\t\t<Header>\n" . "\t\t\t<ID>clarin.eu:cr1:p_1375880372976</ID>\n" . "\t\t\t<Name>singlePaperPackage</Name>\n" . "\t\t\t<Description>Profile for single PaperPackage</Description>\n" . "\t\t</Header>\n" . "\t\t<CMD_Component CardinalityMax=\"1\" CardinalityMin=\"1\" name=\"singlePaperPackage\">\n" . "\t\t\t<CMD_Component CardinalityMax=\"1\" CardinalityMin=\"1\" name=\"paperPackage\"/>\n" . "\t\t<paperPackage>\n" . "\t\t\t<type>{$packageType}</type>\n" . "<mods ID=\"{$filename}\">\n" . "\t<titleInfo>\n" . "\t\t<title>" . htmlspecialchars(Core::cleanVar(strip_tags($article->getArticleTitle()))) . "</title>\n" . "\t</titleInfo>\n"; // authors foreach ($article->getAuthors() as $author) { $response .= "\t<name type=\"personal\">\n" . "\t\t<namePart type=\"given\">" . htmlspecialchars(Core::cleanVar($author->getFirstName()) . (($s = $author->getMiddleName()) != '' ? " {$s}" : '')) . "</namePart>\n" . "\t\t<namePart type=\"family\">" . htmlspecialchars(Core::cleanVar($author->getLastName())) . "</namePart>\n" . "\t\t<role>\n" . "\t\t\t<roleTerm authority=\"marcrelator\" type=\"text\">author</roleTerm>\n" . "\t\t</role>\n" . "\t</name>\n"; } //date published $response .= "\t<originInfo>\n" . "\t\t<dateIssued>" . strftime('%Y', $datePublished) . "</dateIssued>\n" . "\t</originInfo>\n" . "\t<typeOfResource>text</typeOfResource>\n" . "\t<genre>journal article</genre>\n"; // Include abstract $abstract = htmlspecialchars(Core::cleanVar(strip_tags($article->getArticleAbstract()))); if (!empty($abstract)) { $response .= "\t<abstract>{$abstract}</abstract>\n"; } $response .= "\t<identifier type=\"hdl\">{$pidOutPut}</identifier>\n" . "\t<location>\n" . "\t\t<url displayLabel=\"Electronic full text\" access=\"raw object\">" . htmlspecialchars(Core::cleanVar(PKPRequest::getBaseUrl() . "/Rpository/src/contrib/{$packageName}")) . "\" />\n" . "\t\t</url>\n" . "\t</location>\n"; $response .= "</mods>\n" . "\t\t</paperPackage>\n" . "\t\t</CMD_Component>\n" . "\t</CMD_ComponentSpec>\n" . "</CMD>\n"; return $response; }
/** * Output OAI response. * @param $response string text of response message. * @param $printParams boolean display request parameters */ function response($response, $printParams = true) { header('Content-Type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<?xml-stylesheet type=\"text/xsl\" href=\"" . PKPRequest::getBaseUrl() . "/lib/pkp/xml/oai2.xsl\" ?>\n" . "<OAI-PMH xmlns=\"http://www.openarchives.org/OAI/2.0/\"\n" . "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" . "\txsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/\n" . "\t\thttp://www.openarchives.org/OAI/2.0/OAI-PMH.xsd\">\n" . "\t<responseDate>" . OAIUtils::UTCDate() . "</responseDate>\n" . "\t<request"; // print request params, if applicable if ($printParams) { foreach ($this->params as $k => $v) { echo " {$k}=\"" . OAIUtils::prepOutput($v) . "\""; } } echo ">" . OAIUtils::prepOutput($this->config->baseUrl) . "</request>\n" . $response . "</OAI-PMH>\n"; }
/** * Initialize the template manager. */ function initialize() { $locale = AppLocale::getLocale(); $application = PKPApplication::getApplication(); $router = $this->_request->getRouter(); assert(is_a($router, 'PKPRouter')); $this->assign(array('defaultCharset' => Config::getVar('i18n', 'client_charset'), 'basePath' => $this->_request->getBasePath(), 'baseUrl' => $this->_request->getBaseUrl(), 'requiresFormRequest' => $this->_request->isPost(), 'currentUrl' => $this->_request->getCompleteUrl(), 'dateFormatTrunc' => Config::getVar('general', 'date_format_trunc'), 'dateFormatShort' => Config::getVar('general', 'date_format_short'), 'dateFormatLong' => Config::getVar('general', 'date_format_long'), 'datetimeFormatShort' => Config::getVar('general', 'datetime_format_short'), 'datetimeFormatLong' => Config::getVar('general', 'datetime_format_long'), 'timeFormat' => Config::getVar('general', 'time_format'), 'allowCDN' => Config::getVar('general', 'enable_cdn'), 'useMinifiedJavaScript' => Config::getVar('general', 'enable_minified'), 'currentContext' => $this->_request->getContext(), 'currentLocale' => $locale, 'pageTitle' => $application->getNameKey(), 'applicationName' => __($application->getNameKey()), 'exposedConstants' => $application->getExposedConstants(), 'jsLocaleKeys' => $application->getJSLocaleKeys())); if (is_a($router, 'PKPPageRouter')) { $this->assign(array('requestedPage' => $router->getRequestedPage($this->_request), 'requestedOp' => $router->getRequestedOp($this->_request))); } if ($dispatcher = $this->_request->getDispatcher()) { $this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE, 'backend'); } // If there's a locale-specific stylesheet, add it. if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) { $this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet, 'backend'); } // Register custom functions $this->register_modifier('translate', array('AppLocale', 'translate')); $this->register_modifier('strip_unsafe_html', array('PKPString', 'stripUnsafeHtml')); $this->register_modifier('String_substr', array('PKPString', 'substr')); $this->register_modifier('to_array', array($this, 'smartyToArray')); $this->register_modifier('compare', array($this, 'smartyCompare')); $this->register_modifier('concat', array($this, 'smartyConcat')); $this->register_modifier('strtotime', array($this, 'smartyStrtotime')); $this->register_modifier('explode', array($this, 'smartyExplode')); $this->register_modifier('assign', array($this, 'smartyAssign')); $this->register_function('translate', array($this, 'smartyTranslate')); $this->register_function('null_link_action', array($this, 'smartyNullLinkAction')); $this->register_function('help', array($this, 'smartyHelp')); $this->register_function('flush', array($this, 'smartyFlush')); $this->register_function('call_hook', array($this, 'smartyCallHook')); $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate')); $this->register_block('iterate', array($this, 'smartyIterate')); $this->register_function('page_links', array($this, 'smartyPageLinks')); $this->register_function('page_info', array($this, 'smartyPageInfo')); $this->register_function('pluck_files', array($this, 'smartyPluckFiles')); // Modified vocabulary for creating forms $fbv = $this->getFBV(); $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection')); $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea')); $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons')); $this->register_function('fbvElement', array($fbv, 'smartyFBVElement')); $this->assign('fbvStyles', $fbv->getStyles()); $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel')); // register the resource name "core" $coreResource = new PKPTemplateResource($this->core_template_dir); $this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted'))); $appResource = new PKPTemplateResource($this->app_template_dir); $this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted'))); $this->register_function('url', array($this, 'smartyUrl')); // ajax load into a div or any element $this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl')); $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv')); // load stylesheets from a given context $this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet')); /** * Kludge to make sure no code that tries to connect to the * database is executed (e.g., when loading installer pages). */ if (!defined('SESSION_DISABLE_INIT')) { $application = PKPApplication::getApplication(); $currentVersion = $application->getCurrentVersion(); $this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'currentVersionString' => $currentVersion->getVersionString(false), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links'))); $user = $this->_request->getUser(); $hasSystemNotifications = false; if ($user) { $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL); if ($notifications->getCount() > 0) { $this->assign('hasSystemNotifications', true); } // Assign the user name to be used in the sitenav $this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp())); } } // Load enabled block plugins and setup active sidebar variables PluginRegistry::loadCategory('blocks', true); $leftSidebarHooks = HookRegistry::getHooks('Templates::Common::LeftSidebar'); $this->assign(array('hasLeftSidebar' => !empty($leftSidebarHooks))); }