本文整理汇总了PHP中String::regexp_match_get方法的典型用法代码示例。如果您正苦于以下问题:PHP String::regexp_match_get方法的具体用法?PHP String::regexp_match_get怎么用?PHP String::regexp_match_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::regexp_match_get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: people
/**
* Display list of people in the selected role.
* @param $args array first parameter is the role ID to display
*/
function people($args, &$request)
{
$this->validate();
$this->setupTemplate($request, true);
$roleDao = DAORegistry::getDAO('RoleDAO');
if ($request->getUserVar('roleSymbolic') != null) {
$roleSymbolic = $request->getUserVar('roleSymbolic');
} else {
$roleSymbolic = isset($args[0]) ? $args[0] : 'all';
}
if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
$roleId = $roleDao->getRoleIdFromPath($matches[1]);
if ($roleId == null) {
$request->redirect(null, null, 'all');
}
$roleName = $roleDao->getRoleName($roleId, true);
} else {
$roleId = 0;
$roleName = 'admin.people.allUsers';
}
$sort = $request->getUserVar('sort');
$sort = isset($sort) ? $sort : 'name';
$sortDirection = $request->getUserVar('sortDirection');
$templateMgr =& TemplateManager::getManager($request);
$searchType = null;
$searchMatch = null;
$search = $request->getUserVar('search');
$searchInitial = $request->getUserVar('searchInitial');
if (isset($search)) {
$searchType = $request->getUserVar('searchField');
$searchMatch = $request->getUserVar('searchMatch');
} else {
if (isset($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
}
$rangeInfo = $this->getRangeInfo($request, 'users');
$users = $roleDao->getUsersByRoleId($roleId, $searchType, $search, $searchMatch, $rangeInfo, $sort, $sortDirection);
$templateMgr->assign('roleId', $roleId);
$templateMgr->assign('currentUrl', $request->url(null, 'people', 'all'));
$templateMgr->assign('roleName', $roleName);
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', $request->getUser());
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', $request->getUserVar('searchInitial'));
$fieldOptions = array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_INTERESTS => 'user.interests', USER_FIELD_EMAIL => 'user.email');
$templateMgr->assign('fieldOptions', $fieldOptions);
$role =& $roleDao->newDataObject();
$role->setId($roleId);
$templateMgr->assign('rolePath', $role->getPath());
$templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
$templateMgr->assign('roleSymbolic', $roleSymbolic);
$templateMgr->assign('sort', $sort);
$templateMgr->assign('sortDirection', $sortDirection);
$templateMgr->display('admin/people/enrollment.tpl');
}
示例2: submitSubmission
/**
* Submit a submission.
*/
protected function submitSubmission()
{
$this->logAuthorIn();
$submissionPage = self::$baseUrl . '/index.php/publicknowledge/submission/wizard/';
//
// First submission page.
//
$this->verifyAndOpen($submissionPage . '1');
$this->waitForElementPresent('css=button.submitFormButton');
$this->doActionsOnStep1();
// Accept submission conditions.
$checkboxId = 0;
while ($this->isElementPresent("checklist-{$checkboxId}")) {
$this->check("checklist-{$checkboxId}");
$checkboxId++;
}
$this->clickAndWait('css=button.submitFormButton');
//
// Second submission page.
//
$this->waitForLocation($submissionPage . '2*');
$this->waitForElementPresent('css=div.plupload_buttons');
// We should now have the submission ID in the URL.
$url = $this->getLocation();
$matches = null;
String::regexp_match_get('/submissionId=([0-9]+)#/', $url, $matches);
self::assertTrue(count($matches) == 2);
$submissionId = $matches[1];
self::assertTrue(is_numeric($submissionId));
$submissionId = (int) $submissionId;
// Close the upload file modal.
$this->click('id=cancelButton');
// Save the second step without uploading a file.
$this->waitForElementNotPresent('css=div.plupload_buttons');
$this->waitForElementPresent($selector = '//button[contains(., \'Save and continue\')]');
$this->click($selector);
//
// Third submission page.
//
$this->waitForElementPresent('css=button.submitFormButton');
$title = 'test book';
$this->waitForElementPresent("css=[id^=title]");
$this->type("css=[id^=title]", $title);
$this->verifyElementPresent('css=iframe[id^=abstract]');
if ($this->verified()) {
// TinyMCE hack.
$jsScript = "selenium.browserbot.getCurrentWindow().document" . ".querySelector('iframe[id^=abstract]').contentDocument.body.innerHTML = " . "'{$title} abstract'";
$this->getEval($jsScript);
} else {
$this->type('css=[id^=abstract]', $title . ' abstract');
}
$this->click("css=#submitStep3Form .submitFormButton");
$this->waitForElementPresent($selector = 'link=OK');
$this->click($selector);
$authorDashboardLink = self::$baseUrl . '/index.php/publicknowledge/authorDashboard/submission/' . $submissionId;
$this->waitForElementPresent("css=a[href='" . $authorDashboardLink . "']");
$this->assertTrue(is_int($submissionId));
return $submissionId;
}
示例3: getXmlOnExport
/**
* Retrieve the export as an XML string.
* @param $pluginUrl string the url to be requested for export.
* @param $postParams array additional post parameters
* @return string
*/
protected function getXmlOnExport($pluginUrl, $postParams = array())
{
// Prepare HTTP session.
$curlCh = curl_init();
curl_setopt($curlCh, CURLOPT_POST, true);
// Create a cookie file (required for log-in).
$cookies = tempnam(sys_get_temp_dir(), 'curlcookies');
// Log in.
$loginUrl = $this->baseUrl . '/index.php/test/login/signIn';
// Bug #8518 safety work-around
if ($this->password[0] == '@') {
die('CURL parameters may not begin with @.');
}
$loginParams = array('username' => 'admin', 'password' => $this->password);
curl_setopt($curlCh, CURLOPT_URL, $loginUrl);
curl_setopt($curlCh, CURLOPT_POSTFIELDS, $loginParams);
curl_setopt($curlCh, CURLOPT_COOKIEJAR, $cookies);
self::assertTrue(curl_exec($curlCh));
// Request export document.
$exportUrl = $this->baseUrl . '/index.php/test/manager/importexport/plugin/' . $pluginUrl;
curl_setopt($curlCh, CURLOPT_URL, $exportUrl);
// Bug #8518 safety work-around
foreach ($postParams as $paramValue) {
if ($paramValue[0] == '@') {
die('CURL parameters may not begin with @.');
}
}
curl_setopt($curlCh, CURLOPT_POSTFIELDS, $postParams);
curl_setopt($curlCh, CURLOPT_HTTPHEADER, array('Accept: application/xml, application/x-gtar, */*'));
curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlCh, CURLOPT_HEADER, true);
$response = curl_exec($curlCh);
do {
list($header, $response) = explode("\r\n\r\n", $response, 2);
} while (String::regexp_match('#HTTP/.*100#', $header));
// Check whether we got a tar file.
if (String::regexp_match('#Content-Type: application/x-gtar#', $header)) {
// Save the data to a temporary file.
$tempfile = tempnam(sys_get_temp_dir(), 'tst');
file_put_contents($tempfile, $response);
// Recursively extract tar file.
$result = $this->extractTarFile($tempfile);
unlink($tempfile);
} else {
$matches = null;
String::regexp_match_get('#filename="([^"]+)"#', $header, $matches);
self::assertTrue(isset($matches[1]));
$result = array($matches[1] => $response);
}
// Destroy HTTP session.
curl_close($curlCh);
unlink($cookies);
return $result;
}
示例4: extractPlugin
/**
* Extract and validate a plugin (prior to installation)
* @param $filePath string Full path to plugin archive
* @param $originalFileName string Original filename of plugin archive
* @return string|null Extracted plugin path on success; null on error
*/
function extractPlugin($filePath, $originalFileName, &$errorMsg)
{
// tar archive basename (less potential version number) must
// equal plugin directory name and plugin files must be in a
// directory named after the plug-in (potentially with version)
$matches = array();
String::regexp_match_get('/^[a-zA-Z0-9]+/', basename($originalFileName, '.tar.gz'), $matches);
$pluginShortName = array_pop($matches);
if (!$pluginShortName) {
$errorMsg = __('manager.plugins.invalidPluginArchive');
return null;
}
// Create random dirname to avoid symlink attacks.
$pluginExtractDir = dirname($filePath) . DIRECTORY_SEPARATOR . $pluginShortName . substr(md5(mt_rand()), 0, 10);
mkdir($pluginExtractDir);
// Test whether the tar binary is available for the export to work
$tarBinary = Config::getVar('cli', 'tar');
if (!empty($tarBinary) && file_exists($tarBinary)) {
exec($tarBinary . ' -xzf ' . escapeshellarg($filePath) . ' -C ' . escapeshellarg($pluginExtractDir));
} else {
$errorMsg = __('manager.plugins.tarCommandNotFound');
}
if (empty($errorMsg)) {
// Look for a directory named after the plug-in's short
// (alphanumeric) name within the extracted archive.
if (is_dir($tryDir = $pluginExtractDir . '/' . $pluginShortName)) {
return $tryDir;
// Success
}
// Failing that, look for a directory named after the
// archive. (Typically also contains the version number
// e.g. with github generated release archives.)
String::regexp_match_get('/^[a-zA-Z0-9.-]+/', basename($originalFileName, '.tar.gz'), $matches);
if (is_dir($tryDir = $pluginExtractDir . '/' . array_pop($matches))) {
// We found a directory named after the archive
// within the extracted archive. (Typically also
// contains the version number, e.g. github
// generated release archives.)
return $tryDir;
}
$errorMsg = __('manager.plugins.invalidPluginArchive');
}
return null;
}
示例5: array
/**
* Normalize incoming date string.
* @see Filter::process()
* @param $input string
* @return string
*/
function &process(&$input)
{
// FIXME: We have to i18nize this when expanding citation parsing to other languages
static $monthNames = array('Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12');
$dateExpressions = array('/(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})/', '/(?P<year>\\d{4})\\s*(?P<monthName>[a-z]\\w+)?\\s*(?P<day>\\d+)?/i');
$normalizedDate = null;
foreach ($dateExpressions as $dateExpression) {
if (String::regexp_match_get($dateExpression, $input, $parsedDate)) {
if (isset($parsedDate['year'])) {
$normalizedDate = $parsedDate['year'];
$month = '';
if (isset($parsedDate['monthName'])) {
$monthName = substr($parsedDate['monthName'], 0, 3);
if (isset($monthNames[$monthName])) {
// Convert the month name to a two digit numeric month representation
// before adding it to the normalized date string.
$month = $monthNames[$monthName];
}
}
if (isset($parsedDate['month'])) {
$monthInt = (int) $parsedDate['month'];
if ($monthInt >= 1 && $monthInt <= 12) {
$month = str_pad((string) $monthInt, 2, '0', STR_PAD_LEFT);
}
}
if (!empty($month)) {
$normalizedDate .= '-' . $month;
if (isset($parsedDate['day'])) {
$normalizedDate .= '-' . str_pad($parsedDate['day'], 2, '0', STR_PAD_LEFT);
}
}
}
if (!empty($normalizedDate)) {
break;
}
}
}
return $normalizedDate;
}
示例6: submitArticle
/**
* Submit a new test article.
* @param $title string
* @return integer the id of the new article
*/
protected function submitArticle($title = 'Editing test article')
{
// We need to be logged in to submit an article.
$this->logIn();
$submissionPage = $this->baseUrl . '/index.php/lucene-test/author/submit/';
//
// First submission page.
//
$this->verifyAndOpen($submissionPage . '1');
$this->waitForElementPresent('css=input.defaultButton');
// Set Section.
$this->select('sectionId', 'value=3');
// Accept submission conditions.
$checkboxId = 1;
while ($this->isElementPresent("checklist-{$checkboxId}")) {
$this->check("checklist-{$checkboxId}");
$checkboxId++;
}
// Submit first submission page.
$this->clickAndWait('css=input.defaultButton');
//
// Second submission page.
//
$this->waitForLocation($submissionPage . '2*');
$this->waitForElementPresent('css=input.defaultButton');
// We should now have the article ID in the URL.
$url = $this->getLocation();
$matches = null;
String::regexp_match_get('/articleId=([0-9]+)/', $url, $matches);
self::assertTrue(count($matches) == 2);
$articleId = $matches[1];
self::assertTrue(is_numeric($articleId));
$articleId = (int) $articleId;
// Submit the second submission page.
$this->clickAndWait('css=input.defaultButton');
$this->waitForConfirmation('*Are you sure you wish to continue*');
//
// Third submission page.
//
$this->waitForLocation($submissionPage . '3*');
$this->waitForElementPresent('css=input.defaultButton');
// Fill in article metadata.
$this->type('authors-0-firstName', 'Arthur');
$this->type('authors-0-lastName', 'McAutomatic');
$this->type('title', $title);
$this->verifyElementPresent('id=abstract_ifr');
if ($this->verified()) {
// TinyMCE hack.
$jsScript = "selenium.browserbot.getCurrentWindow().document" . ".getElementById('abstract_ifr').contentDocument.body.innerHTML = " . "'{$title} abstract'";
$this->getEval($jsScript);
} else {
$this->type('abstract', $title . ' abstract');
}
// Submit metadata.
$this->clickAndWait('css=input.defaultButton');
//
// Fourth and fifth submission page.
//
$this->waitForLocation($submissionPage . '4*');
$this->waitForElementPresent('css=input.defaultButton');
// Do not upload any supplementary file and continue.
$this->clickAndWait('css=input.defaultButton');
$this->waitForLocation($submissionPage . '5*');
$this->waitForElementPresent('css=input.defaultButton');
// Confirm the submission.
$this->clickAndWait('css=input.defaultButton');
return $articleId;
}
示例7: mergeUsers
//.........这里部分代码省略.........
$articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
foreach ($articleCommentDao->getArticleCommentsByUserId($oldUserId) as $articleComment) {
$articleComment->setAuthorId($newUserId);
$articleCommentDao->updateArticleComment($articleComment);
unset($articleComment);
}
$accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
$accessKeyDao->transferAccessKeys($oldUserId, $newUserId);
// Delete the old user and associated info.
$sessionDao =& DAORegistry::getDAO('SessionDAO');
$sessionDao->deleteSessionsByUserId($oldUserId);
$subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO');
$subscriptionDao->deleteSubscriptionsByUserId($oldUserId);
$temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
$temporaryFileDao->deleteTemporaryFilesByUserId($oldUserId);
$notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
$notificationStatusDao->deleteNotificationStatusByUserId($oldUserId);
$userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
$userSettingsDao->deleteSettings($oldUserId);
$groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
$groupMembershipDao->deleteMembershipByUserId($oldUserId);
$sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
$sectionEditorsDao->deleteEditorsByUserId($oldUserId);
// Transfer old user's roles
$roles =& $roleDao->getRolesByUserId($oldUserId);
foreach ($roles as $role) {
if (!$roleDao->roleExists($role->getJournalId(), $newUserId, $role->getRoleId())) {
$role->setUserId($newUserId);
$roleDao->insertRole($role);
}
}
$roleDao->deleteRoleByUserId($oldUserId);
$userDao->deleteUserById($oldUserId);
Request::redirect(null, 'manager');
}
if (!empty($oldUserId)) {
// Get the old username for the confirm prompt.
$oldUser =& $userDao->getUser($oldUserId);
$templateMgr->assign('oldUsername', $oldUser->getUsername());
unset($oldUser);
}
// The manager must select one or both IDs.
if (Request::getUserVar('roleSymbolic') != null) {
$roleSymbolic = Request::getUserVar('roleSymbolic');
} else {
$roleSymbolic = isset($args[0]) ? $args[0] : 'all';
}
if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
$roleId = $roleDao->getRoleIdFromPath($matches[1]);
if ($roleId == null) {
Request::redirect(null, null, null, 'all');
}
$roleName = $roleDao->getRoleName($roleId, true);
} else {
$roleId = 0;
$roleName = 'manager.people.allUsers';
}
$searchType = null;
$searchMatch = null;
$search = Request::getUserVar('search');
$searchInitial = Request::getUserVar('searchInitial');
if (isset($search)) {
$searchType = Request::getUserVar('searchField');
$searchMatch = Request::getUserVar('searchMatch');
} else {
if (isset($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
}
$rangeInfo = Handler::getRangeInfo('users');
if ($roleId) {
$users =& $roleDao->getUsersByRoleId($roleId, $journalId, $searchType, $search, $searchMatch, $rangeInfo);
$templateMgr->assign('roleId', $roleId);
} else {
$users =& $roleDao->getUsersByJournalId($journalId, $searchType, $search, $searchMatch, $rangeInfo);
}
$templateMgr->assign('currentUrl', Request::url(null, null, 'people', 'all'));
$templateMgr->assign('helpTopicId', 'journal.managementPages.mergeUsers');
$templateMgr->assign('roleName', $roleName);
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', Request::getUser());
$templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
if ($roleId == ROLE_ID_REVIEWER) {
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$templateMgr->assign('rateReviewerOnQuality', $journal->getSetting('rateReviewerOnQuality'));
$templateMgr->assign('qualityRatings', $journal->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($journalId) : null);
}
$templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests'));
$templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
$templateMgr->assign('oldUserId', $oldUserId);
$templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
$templateMgr->assign('roleSymbolic', $roleSymbolic);
$templateMgr->display('manager/people/selectMergeUser.tpl');
}
示例8: isValid
/**
* @see Validator::isValid()
* @param $value mixed
* @return boolean
*/
function isValid($value)
{
return (bool) String::regexp_match_get($this->_regExp, $value, $this->_matches);
}
示例9: mergeUsers
//.........这里部分代码省略.........
unset($layoutEditorSubmission);
}
$monographEmailLogDao =& DAORegistry::getDAO('MonographEmailLogDAO');
$monographEmailLogDao->changeUser($oldUserId, $newUserId);
$monographEventLogDao =& DAORegistry::getDAO('MonographEventLogDAO');
$monographEventLogDao->changeUser($oldUserId, $newUserId);
$monographCommentDao =& DAORegistry::getDAO('MonographCommentDAO');
foreach ($monographCommentDao->getMonographCommentsByUserId($oldUserId) as $monographComment) {
$monographComment->setAuthorId($newUserId);
$monographCommentDao->updateMonographComment($monographComment);
unset($monographComment);
}
$accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
$accessKeyDao->transferAccessKeys($oldUserId, $newUserId);
// Delete the old user and associated info.
$sessionDao =& DAORegistry::getDAO('SessionDAO');
$sessionDao->deleteSessionsByUserId($oldUserId);
$temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
$temporaryFileDao->deleteTemporaryFilesByUserId($oldUserId);
$notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
$notificationStatusDao->deleteNotificationStatusByUserId($oldUserId);
$userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
$userSettingsDao->deleteSettings($oldUserId);
$groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
$groupMembershipDao->deleteMembershipByUserId($oldUserId);
$seriesEditorsDao =& DAORegistry::getDAO('SeriesEditorsDAO');
$seriesEditorsDao->deleteEditorsByUserId($oldUserId);
// Transfer old user's roles
$userGroups =& $userGroupDao->getByUserId($oldUserId);
while (!$userGroups->eof()) {
$userGroup =& $userGroups->next();
if (!$userGroupDao->userInGroup($userGroup->getContextId(), $newUserId, $userGroup->getId())) {
$userGroupDao->assignUserToGroup($newUserId, $userGroup->getId());
}
unset($userGroup);
}
$userGroupDao->deleteAssignmentsByUserId($oldUserId);
$userDao->deleteUserById($oldUserId);
Request::redirect(null, 'admin', 'mergeUsers');
}
if (!empty($oldUserId)) {
// Get the old username for the confirm prompt.
$oldUser =& $userDao->getUser($oldUserId);
$templateMgr->assign('oldUsername', $oldUser->getUsername());
unset($oldUser);
}
// The administrator must select one or both IDs.
if (Request::getUserVar('roleSymbolic') != null) {
$roleSymbolic = Request::getUserVar('roleSymbolic');
} else {
$roleSymbolic = isset($args[0]) ? $args[0] : 'all';
}
if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
$roleId = $roleDao->getRoleIdFromPath($matches[1]);
if ($roleId == null) {
Request::redirect(null, null, null, 'all');
}
$roleName = $roleDao->getRoleName($roleId, true);
} else {
$roleId = 0;
$roleName = 'admin.mergeUsers.allUsers';
}
$searchType = null;
$searchMatch = null;
$search = Request::getUserVar('search');
$searchInitial = Request::getUserVar('searchInitial');
if (!empty($search)) {
$searchType = Request::getUserVar('searchField');
$searchMatch = Request::getUserVar('searchMatch');
} else {
if (!empty($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
}
$rangeInfo = Handler::getRangeInfo('users');
if ($roleId) {
$users =& $roleDao->getUsersByRoleId($roleId, null, $searchType, $search, $searchMatch, $rangeInfo);
$templateMgr->assign('roleId', $roleId);
} else {
$users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo);
}
$templateMgr->assign('currentUrl', Request::url(null, null, 'mergeUsers'));
$templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
$templateMgr->assign('roleName', $roleName);
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', Request::getUser());
$templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
$templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests'));
$templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
$templateMgr->assign('oldUserId', $oldUserId);
$templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
$templateMgr->assign('roleSymbolic', $roleSymbolic);
$templateMgr->display('admin/selectMergeUser.tpl');
}
示例10: toXml
/**
* @see OAIMetadataFormat#toXml
* TODO:
* <copyright-holder>
* In Isabelle's mapping document:
* Article order in the issue's Table of Contents
*/
function toXml(&$record, $format = null)
{
$article =& $record->getData('article');
$journal =& $record->getData('journal');
$section =& $record->getData('section');
$issue =& $record->getData('issue');
$galleys =& $record->getData('galleys');
$articleId = $article->getId();
// Cache issue ordering information.
static $issueId;
static $sectionSeq;
if (!isset($issueId) || $issueId != $issue->getId()) {
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$issueId = $issue->getId();
$sections =& $sectionDao->getSectionsForIssue($issueId);
$sectionSeq = array();
$i = 0;
foreach ($sections as $thisSection) {
$sectionSeq[$thisSection->getSectionId()] = $i++;
}
unset($sections);
}
$abbreviation = $journal->getLocalizedSetting('abbreviation');
$printIssn = $journal->getSetting('printIssn');
$onlineIssn = $journal->getSetting('onlineIssn');
$primaryLocale = $journal->getPrimaryLocale();
$publisherInstitution = $journal->getSetting('publisherInstitution');
$datePublished = strtotime($article->getDatePublished());
$response = "<article\n" . "\txmlns=\"http://dtd.nlm.nih.gov/publishing/2.3\"\n" . "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" . "\txmlns:mml=\"http://www.w3.org/1998/Math/MathML\"\n" . "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" . "\txsi:schemaLocation=\"http://dtd.nlm.nih.gov/publishing/2.3\n" . "\thttp://dtd.nlm.nih.gov/publishing/2.3/xsd/journalpublishing.xsd\"\n" . (($s = $section->getSectionIdentifyType()) != '' ? "\tarticle-type=\"" . htmlspecialchars(Core::cleanVar($s)) . "\"" : '') . "\txml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">\n" . "\t<front>\n" . "\t\t<journal-meta>\n" . "\t\t\t<journal-id journal-id-type=\"other\">" . htmlspecialchars(Core::cleanVar(($s = Config::getVar('oai', 'nlm_journal_id')) != '' ? $s : $journal->getPath())) . "</journal-id>\n" . "\t\t\t<journal-title>" . htmlspecialchars(Core::cleanVar($journal->getJournalTitle())) . "</journal-title>\n";
// Include translated journal titles
foreach ($journal->getTitle(null) as $locale => $title) {
if ($locale == $primaryLocale) {
continue;
}
$response .= "\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar($title)) . "</trans-title>\n";
}
$response .= (!empty($onlineIssn) ? "\t\t\t<issn pub-type=\"epub\">" . htmlspecialchars(Core::cleanVar($onlineIssn)) . "</issn>" : '') . (!empty($printIssn) ? "\t\t\t<issn pub-type=\"ppub\">" . htmlspecialchars(Core::cleanVar($printIssn)) . "</issn>" : '') . ($publisherInstitution != '' ? "\t\t\t<publisher><publisher-name>" . htmlspecialchars(Core::cleanVar($publisherInstitution)) . "</publisher-name></publisher>\n" : '') . "\t\t</journal-meta>\n" . "\t\t<article-meta>\n" . "\t\t\t<article-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($article->getBestArticleId())) . "</article-id>\n" . (($s = $article->getDOI()) != '' ? "\t\t\t<article-id pub-id-type=\"doi\">" . htmlspecialchars(Core::cleanVar($s)) . "</article-id>\n" : '') . "\t\t\t<article-categories><subj-group subj-group-type=\"heading\"><subject>" . htmlspecialchars(Core::cleanVar($section->getSectionTitle())) . "</subject></subj-group></article-categories>\n" . "\t\t\t<title-group>\n" . "\t\t\t\t<article-title>" . htmlspecialchars(Core::cleanVar(strip_tags($article->getArticleTitle()))) . "</article-title>\n";
// Include translated journal titles
foreach ($article->getTitle(null) as $locale => $title) {
if ($locale == $primaryLocale) {
continue;
}
$response .= "\t\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar(strip_tags($title))) . "</trans-title>\n";
}
$response .= "\t\t\t</title-group>\n" . "\t\t\t<contrib-group>\n";
// Include authors
foreach ($article->getAuthors() as $author) {
$response .= "\t\t\t\t<contrib " . ($author->getPrimaryContact() ? 'corresp="yes" ' : '') . "contrib-type=\"author\">\n" . "\t\t\t\t\t<name name-style=\"western\">\n" . "\t\t\t\t\t\t<surname>" . htmlspecialchars(Core::cleanVar($author->getLastName())) . "</surname>\n" . "\t\t\t\t\t\t<given-names>" . htmlspecialchars(Core::cleanVar($author->getFirstName()) . (($s = $author->getMiddleName()) != '' ? " {$s}" : '')) . "</given-names>\n" . "\t\t\t\t\t</name>\n" . (($s = $author->getAffiliation()) != '' ? "\t\t\t\t\t<aff>" . htmlspecialchars(Core::cleanVar($s)) . "</aff>\n" : '') . "\t\t\t\t\t<email>" . htmlspecialchars(Core::cleanVar($author->getEmail())) . "</email>\n" . (($s = $author->getUrl()) != '' ? "\t\t\t\t\t<uri>" . htmlspecialchars(Core::cleanVar($s)) . "</uri>\n" : '') . "\t\t\t\t</contrib>\n";
}
// Include editorships (optimized)
$response .= $this->getEditorialInfo($journal->getId());
$response .= "\t\t\t</contrib-group>\n" . "\t\t\t<pub-date pub-type=\"epub\">\n" . "\t\t\t\t<day>" . strftime('%d', $datePublished) . "</day>\n" . "\t\t\t\t<month>" . strftime('%m', $datePublished) . "</month>\n" . "\t\t\t\t<year>" . strftime('%Y', $datePublished) . "</year>\n" . "\t\t\t</pub-date>\n" . ($issue->getShowYear() ? "\t\t\t<pub-date pub-type=\"collection\"><year>" . htmlspecialchars(Core::cleanVar($issue->getYear())) . "</year></pub-date>\n" : '') . ($issue->getShowVolume() ? "\t\t\t<volume>" . htmlspecialchars(Core::cleanVar($issue->getVolume())) . "</volume>\n" : '') . ($issue->getShowNumber() ? "\t\t\t<issue seq=\"" . htmlspecialchars(Core::cleanVar($sectionSeq[$section->getId()] * 100 + $article->getSeq())) . "\">" . htmlspecialchars(Core::cleanVar($issue->getNumber())) . "</issue>\n" : '') . "\t\t\t<issue-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($issue->getBestIssueId())) . "</issue-id>\n" . ($issue->getShowTitle() ? "\t\t\t<issue-title>" . htmlspecialchars(Core::cleanVar($issue->getIssueTitle())) . "</issue-title>\n" : '');
// Include page info, if available and parseable.
$matches = null;
if (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)$/', $article->getPages(), $matches)) {
$matchedPage = htmlspecialchars(Core::cleanVar($matches[1]));
$response .= "\t\t\t\t<fpage>{$matchedPage}</fpage><lpage>{$matchedPage}</lpage>\n";
$pageCount = 1;
} elseif (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\\d+)$/', $article->getPages(), $matches)) {
$matchedPageFrom = htmlspecialchars(Core::cleanVar($matches[1]));
$matchedPageTo = htmlspecialchars(Core::cleanVar($matches[3]));
$response .= "\t\t\t\t<fpage>{$matchedPageFrom}</fpage>\n" . "\t\t\t\t<lpage>{$matchedPageTo}</lpage>\n";
$pageCount = $matchedPageTo - $matchedPageFrom + 1;
}
$response .= "\t\t\t<permissions>\n" . (($s = $journal->getLocalizedSetting('copyrightNotice')) != '' ? "\t\t\t\t<copyright-statement>" . htmlspecialchars(Core::cleanVar($s)) . "</copyright-statement>\n" : '') . "\t\t\t\t<copyright-year>" . strftime('%Y', $datePublished) . "</copyright-year>\n" . "\t\t\t</permissions>\n" . "\t\t\t<self-uri xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', $article->getBestArticleId()))) . "\" />\n";
// Include galley links
foreach ($article->getGalleys() as $galley) {
$response .= "\t\t\t<self-uri content-type=\"" . htmlspecialchars(Core::cleanVar($galley->getFileType())) . "\" xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId(), $galley->getId())))) . "\" />\n";
}
// Include abstract(s)
$abstract = htmlspecialchars(Core::cleanVar(strip_tags($article->getArticleAbstract())));
if (!empty($abstract)) {
$abstract = "<p>{$abstract}</p>";
// $abstract = '<p>' . String::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
$response .= "\t\t\t<abstract xml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">{$abstract}</abstract>\n";
}
if (is_array($article->getAbstract(null))) {
foreach ($article->getAbstract(null) as $locale => $abstract) {
if ($locale == $primaryLocale || empty($abstract)) {
continue;
}
$abstract = htmlspecialchars(Core::cleanVar(strip_tags($abstract)));
if (empty($abstract)) {
continue;
}
$abstract = "<p>{$abstract}</p>";
//$abstract = '<p>' . String::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
$response .= "\t\t\t<abstract-trans xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">{$abstract}</abstract-trans>\n";
}
}
$subjects = array();
if (is_array($article->getSubject(null))) {
foreach ($article->getSubject(null) as $locale => $subject) {
//.........这里部分代码省略.........
示例11: mergeUsers
/**
* Allow the Site Administrator to merge user accounts.
*/
function mergeUsers($args)
{
$this->validate();
$this->setupTemplate(true);
$roleDao =& DAORegistry::getDAO('RoleDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$templateMgr =& TemplateManager::getManager();
$oldUserIds = (array) Request::getUserVar('oldUserIds');
$newUserId = Request::getUserVar('newUserId');
if (!empty($oldUserIds) && !empty($newUserId)) {
import('user.UserAction');
foreach ($oldUserIds as $oldUserId) {
UserAction::mergeUsers($oldUserId, $newUserId);
}
Request::redirect(null, null, 'admin', 'mergeUsers');
}
// The administrator must select one or both IDs.
if (Request::getUserVar('roleSymbolic') != null) {
$roleSymbolic = Request::getUserVar('roleSymbolic');
} else {
$roleSymbolic = isset($args[0]) ? $args[0] : 'all';
}
if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
$roleId = $roleDao->getRoleIdFromPath($matches[1]);
if ($roleId == null) {
Request::redirect(null, null, null, null, 'all');
}
$roleName = $roleDao->getRoleName($roleId, true);
} else {
$roleId = 0;
$roleName = 'admin.mergeUsers.allUsers';
}
$searchType = null;
$searchMatch = null;
$search = Request::getUserVar('search');
$searchInitial = Request::getUserVar('searchInitial');
if (!empty($search)) {
$searchType = Request::getUserVar('searchField');
$searchMatch = Request::getUserVar('searchMatch');
} elseif (!empty($searchInitial)) {
$searchInitial = String::strtoupper($searchInitial);
$searchType = USER_FIELD_INITIAL;
$search = $searchInitial;
}
$rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType));
if ($roleId) {
while (true) {
$users =& $roleDao->getUsersByRoleId($roleId, null, null, $searchType, $search, $searchMatch, $rangeInfo);
if ($users->isInBounds()) {
break;
}
unset($rangeInfo);
$rangeInfo =& $users->getLastPageRangeInfo();
unset($users);
}
$templateMgr->assign('roleId', $roleId);
} else {
while (true) {
$users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo);
if ($users->isInBounds()) {
break;
}
unset($rangeInfo);
$rangeInfo =& $users->getLastPageRangeInfo();
unset($users);
}
}
$templateMgr->assign('currentUrl', Request::url(null, null, 'admin', 'mergeUsers'));
$templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
$templateMgr->assign('roleName', $roleName);
$templateMgr->assign_by_ref('users', $users);
$templateMgr->assign_by_ref('thisUser', Request::getUser());
$templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
$templateMgr->assign('searchField', $searchType);
$templateMgr->assign('searchMatch', $searchMatch);
$templateMgr->assign('search', $search);
$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
if ($roleId == ROLE_ID_REVIEWER) {
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality'));
$templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null);
}
$templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests'));
$templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
$templateMgr->assign('oldUserIds', $oldUserIds);
$templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
$templateMgr->assign('roleSymbolic', $roleSymbolic);
$templateMgr->display('admin/selectMergeUser.tpl');
}
示例12: _doAuthenticate
/**
* Authenticate against the AnthroNET portal.
* @return String the auth token if successful
*/
function _doAuthenticate()
{
// Build the multipart SOAP message from scratch.
$journal =& Request::getJournal();
$ofrPlugin =& $this->_getObjectsForReviewPlugin();
$soapMessage = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.avectra.com/2005/">
<soapenv:Header />
<soapenv:Body>
<ns:Authenticate>
<ns:userName>' . $ofrPlugin->getSetting($journal->getId(), 'anthroNetUsername') . '</ns:userName>
<ns:password><![CDATA[' . $ofrPlugin->getSetting($journal->getId(), 'anthroNetPassword') . ']]></ns:password>
</ns:Authenticate>
</soapenv:Body>
</soapenv:Envelope>';
// Prepare HTTP session.
$curlCh = curl_init();
curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlCh, CURLOPT_POST, true);
// Set up SSL.
curl_setopt($curlCh, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curlCh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
// Make SOAP request.
curl_setopt($curlCh, CURLOPT_URL, $ofrPlugin->getSetting($journal->getId(), 'anthroNetSoapURL'));
$extraHeaders = array('Host: avectra.aaanet.org', 'SOAPAction: "http://www.avectra.com/2005/Authenticate"', 'Content-Type: text/xml;charset=UTF-8');
curl_setopt($curlCh, CURLOPT_HTTPHEADER, $extraHeaders);
curl_setopt($curlCh, CURLOPT_POSTFIELDS, $soapMessage);
$result = true;
$response = curl_exec($curlCh);
// We do not localize our error messages as they are all
// fatal errors anyway and must be analyzed by technical staff.
if ($response === false) {
$result = 'OJS-OFR: Expected string response.';
}
if ($result === true && ($status = curl_getinfo($curlCh, CURLINFO_HTTP_CODE)) != OFR_WS_RESPONSE_OK) {
$result = 'OJS-OFR: Expected ' . OFR_WS_RESPONSE_OK . ' response code, got ' . $status . ' instead.';
}
curl_close($curlCh);
// Check SOAP response by simple string manipulation rather
// than instantiating a DOM.
if (is_string($response)) {
$matches = array();
String::regexp_match_get('#<Token>([^<]*)</Token>#', $response, $matches);
if (!empty($matches)) {
$result = $matches[1];
} else {
$result = 'OFR: ' . $status . ' - ' . $matches[1];
}
} else {
$result = 'OJS-OFR: Expected string response.';
}
return $result;
}
示例13: foreach
/**
* Processes form-submitted addresses for inclusion in
* the recipient list
* @param $currentList array Current recipient/cc/bcc list
* @param $newAddresses array "Raw" form parameter for additional addresses
*/
function &processAddresses($currentList, &$newAddresses)
{
foreach ($newAddresses as $newAddress) {
$regs = array();
// Match the form "My Name <my_email@my.domain.com>"
if (String::regexp_match_get('/^([^<>' . "\n" . ']*[^<> ' . "\n" . '])[ ]*<(?P<email>' . PCRE_EMAIL_ADDRESS . ')>$/i', $newAddress, $regs)) {
$currentList[] = array('name' => $regs[1], 'email' => $regs['email']);
} elseif (String::regexp_match_get('/^<?(?P<email>' . PCRE_EMAIL_ADDRESS . ')>?$/i', $newAddress, $regs)) {
$currentList[] = array('name' => '', 'email' => $regs['email']);
} elseif ($newAddress != '') {
$this->errorMessages[] = array('type' => MAIL_ERROR_INVALID_EMAIL, 'address' => $newAddress);
}
}
return $currentList;
}
示例14: fetch
/**
* Handle fetch requests for this plugin.
*/
function fetch($args, $request)
{
if (!$this->getEnabled()) {
return false;
}
$scheme = array_shift($args);
switch ($scheme) {
case 'doi':
$doi = implode('/', $args);
$journal =& $request->getJournal();
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$articles =& $publishedArticleDao->getPublishedArticlesByDOI($doi, $journal ? $journal->getId() : null);
while ($article =& $articles->next()) {
$request->redirect(null, 'article', 'view', $article->getBestArticleId());
}
break;
case 'vnp':
// Volume, number, page
// Volume, number, page
case 'ynp':
// Volume, number, year, page
// This can only be used from within a journal context
$journal =& Request::getJournal();
if (!$journal) {
break;
}
if ($scheme == 'vnp') {
$volume = (int) array_shift($args);
$year = null;
} elseif ($scheme == 'ynp') {
$year = (int) array_shift($args);
$volume = null;
}
$number = array_shift($args);
$page = (int) array_shift($args);
$issueDao =& DAORegistry::getDAO('IssueDAO');
$issues =& $issueDao->getPublishedIssuesByNumber($journal->getId(), $volume, $number, $year);
// Ensure only one issue matched, and fetch it.
$issue =& $issues->next();
if (!$issue || $issues->next()) {
break;
}
unset($issues);
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$articles =& $publishedArticleDao->getPublishedArticles($issue->getId());
foreach ($articles as $article) {
// Look for the correct page in the list of articles.
$matches = null;
if (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)$/', $article->getPages(), $matches)) {
$matchedPage = $matches[1];
if ($page == $matchedPage) {
Request::redirect(null, 'article', 'view', $article->getBestArticleId());
}
}
if (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\\d+)$/', $article->getPages(), $matches)) {
$matchedPageFrom = $matches[1];
$matchedPageTo = $matches[3];
if ($page >= $matchedPageFrom && ($page < $matchedPageTo || $page == $matchedPageTo && ($matchedPageFrom = $matchedPageTo))) {
Request::redirect(null, 'article', 'view', $article->getBestArticleId());
}
}
unset($article);
}
}
// Failure.
header("HTTP/1.0 500 Internal Server Error");
$templateMgr =& TemplateManager::getManager();
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
$templateMgr->assign('message', 'plugins.gateways.resolver.errors.errorMessage');
$templateMgr->display('common/message.tpl');
exit;
}
示例15: array
/**
* Fills the given citation object with
* meta-data retrieved from PubMed.
* @param $pmid string
* @return MetadataDescription
*/
function &_lookup($pmid)
{
$nullVar = null;
// Use eFetch to get XML metadata for the given PMID
$lookupParams = array('db' => 'pubmed', 'mode' => 'xml', 'tool' => 'pkp-wal', 'id' => $pmid);
if (!is_null($this->getEmail())) {
$lookupParams['email'] = $this->getEmail();
}
// Call the eFetch URL and get an XML result
if (is_null($resultDOM = $this->callWebService(PUBMED_WEBSERVICE_EFETCH, $lookupParams))) {
return $nullVar;
}
$articleTitleNodes =& $resultDOM->getElementsByTagName("ArticleTitle");
$articleTitleFirstNode =& $articleTitleNodes->item(0);
$medlineTaNodes =& $resultDOM->getElementsByTagName("MedlineTA");
$medlineTaFirstNode =& $medlineTaNodes->item(0);
$metadata = array('pub-id[@pub-id-type="pmid"]' => $pmid, 'article-title' => $articleTitleFirstNode->textContent, 'source' => $medlineTaFirstNode->textContent);
$volumeNodes =& $resultDOM->getElementsByTagName("Volume");
$issueNodes =& $resultDOM->getElementsByTagName("Issue");
if ($volumeNodes->length > 0) {
$volumeFirstNode =& $volumeNodes->item(0);
}
$metadata['volume'] = $volumeFirstNode->textContent;
if ($issueNodes->length > 0) {
$issueFirstNode =& $issueNodes->item(0);
}
$metadata['issue'] = $issueFirstNode->textContent;
// Get list of author full names
foreach ($resultDOM->getElementsByTagName("Author") as $authorNode) {
if (!isset($metadata['person-group[@person-group-type="author"]'])) {
$metadata['person-group[@person-group-type="author"]'] = array();
}
// Instantiate an NLM name description
$authorDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema', ASSOC_TYPE_AUTHOR);
// Surname
$lastNameNodes =& $authorNode->getElementsByTagName("LastName");
$lastNameFirstNode =& $lastNameNodes->item(0);
$authorDescription->addStatement('surname', $lastNameFirstNode->textContent);
// Given names
$givenNamesString = '';
$firstNameNodes =& $authorNode->getElementsByTagName("FirstName");
if ($firstNameNodes->length > 0) {
$firstNameFirstNode =& $firstNameNodes->item(0);
$givenNamesString = $firstNameFirstNode->textContent;
} else {
$foreNameNodes =& $authorNode->getElementsByTagName("ForeName");
if ($foreNameNodes->length > 0) {
$foreNameFirstNode =& $foreNameNodes->item(0);
$givenNamesString = $foreNameFirstNode->textContent;
}
}
if (!empty($givenNamesString)) {
foreach (explode(' ', $givenNamesString) as $givenName) {
$authorDescription->addStatement('given-names', String::trimPunctuation($givenName));
}
}
// Suffix
$suffixNodes =& $authorNode->getElementsByTagName("Suffix");
if ($suffixNodes->length > 0) {
$suffixFirstNode =& $suffixNodes->item(0);
$authorDescription->addStatement('suffix', $suffixFirstNode->textContent);
}
// Include collective names
// FIXME: This corresponds to an NLM-citation <collab> tag and should be part of the Metadata implementation
/*if ($resultDOM->getElementsByTagName("CollectiveName")->length > 0 && $authorNode->getElementsByTagName("CollectiveName")->item(0)->textContent != '') {
}*/
$metadata['person-group[@person-group-type="author"]'][] =& $authorDescription;
unset($authorDescription);
}
// Extract pagination
$medlinePgnNodes =& $resultDOM->getElementsByTagName("MedlinePgn");
$medlinePgnFirstNode =& $medlinePgnNodes->item(0);
if (String::regexp_match_get("/^[:p\\.\\s]*(?P<fpage>[Ee]?\\d+)(-(?P<lpage>\\d+))?/", $medlinePgnFirstNode->textContent, $pages)) {
$fPage = (int) $pages['fpage'];
$metadata['fpage'] = $fPage;
if (!empty($pages['lpage'])) {
$lPage = (int) $pages['lpage'];
// Deal with shortcuts like '382-7'
if ($lPage < $fPage) {
$lPage = (int) (String::substr($pages['fpage'], 0, -String::strlen($pages['lpage'])) . $pages['lpage']);
}
$metadata['lpage'] = $lPage;
}
}
// Get publication date (can be in several places in PubMed).
$dateNode = null;
$articleDateNodes =& $resultDOM->getElementsByTagName("ArticleDate");
if ($articleDateNodes->length > 0) {
$dateNode =& $articleDateNodes->item(0);
} else {
$pubDateNodes =& $resultDOM->getElementsByTagName("PubDate");
if ($pubDateNodes->length > 0) {
$dateNode =& $pubDateNodes->item(0);
}
//.........这里部分代码省略.........