本文整理汇总了PHP中PKPString::regexp_replace方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPString::regexp_replace方法的具体用法?PHP PKPString::regexp_replace怎么用?PHP PKPString::regexp_replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PKPString
的用法示例。
在下文中一共展示了PKPString::regexp_replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display user login form.
* Redirect to user index page if user is already validated.
*/
function index($args, $request)
{
$this->setupTemplate($request);
if (Validation::isLoggedIn()) {
$this->sendHome($request);
}
if (Config::getVar('security', 'force_login_ssl') && $request->getProtocol() != 'https') {
// Force SSL connections for login
$request->redirectSSL();
}
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$templateMgr = TemplateManager::getManager($request);
// If the user wasn't expecting a login page, i.e. if they're new to the
// site and want to submit a paper, it helps to explain why they need to
// register.
if ($request->getUserVar('loginMessage')) {
$templateMgr->assign('loginMessage', $request->getUserVar('loginMessage'));
}
$templateMgr->assign('username', $session->getSessionVar('username'));
$templateMgr->assign('remember', $request->getUserVar('remember'));
$templateMgr->assign('source', $request->getUserVar('source'));
$templateMgr->assign('showRemember', Config::getVar('general', 'session_lifetime') > 0);
// For force_login_ssl with base_url[...]: make sure SSL used for login form
$loginUrl = $this->_getLoginUrl($request);
if (Config::getVar('security', 'force_login_ssl')) {
$loginUrl = PKPString::regexp_replace('/^http:/', 'https:', $loginUrl);
}
$templateMgr->assign('loginUrl', $loginUrl);
$templateMgr->display('frontend/pages/userLogin.tpl');
}
示例2: array
/**
* @copydoc Filter::process()
* @param $citationString string
* @return MetadataDescription
*/
function &process(&$input)
{
$nullVar = null;
$queryParams = array('demo' => '3', 'textlines' => $input);
// Parscit web form - the result is (mal-formed) HTML
if (is_null($result = $this->callWebService(PARSCIT_WEBSERVICE, $queryParams, XSL_TRANSFORMER_DOCTYPE_STRING, 'POST'))) {
return $nullVar;
}
$result = html_entity_decode($result);
// Detect errors.
if (!PKPString::regexp_match('/.*<algorithm[^>]+>.*<\\/algorithm>.*/s', $result)) {
$translationParams = array('filterName' => $this->getDisplayName());
$this->addError(__('submission.citations.filter.webserviceResultTransformationError', $translationParams));
return $nullVar;
}
// Screen-scrape the tagged portion and turn it into XML.
$xmlResult = PKPString::regexp_replace('/.*<algorithm[^>]+>(.*)<\\/algorithm>.*/s', '\\1', $result);
$xmlResult = PKPString::regexp_replace('/&/', '&', $xmlResult);
// Transform the result into an array of meta-data.
if (is_null($metadata = $this->transformWebServiceResults($xmlResult, dirname(__FILE__) . DIRECTORY_SEPARATOR . 'parscit.xsl'))) {
return $nullVar;
}
// Extract a publisher from the place string if possible.
$metadata =& $this->fixPublisherNameAndLocation($metadata);
return $this->getNlm30CitationDescriptionFromMetadataArray($metadata);
}
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:31,代码来源:ParscitRawCitationNlm30CitationSchemaFilter.inc.php
示例3: array
/**
* @copydoc Filter::process()
* @param $isbn string
* @return MetadataDescription a looked up citation description
* or null if the filter fails
*/
function &process($isbn)
{
$nullVar = null;
// Instantiate the web service request
$lookupParams = array('access_key' => $this->getApiKey(), 'index1' => 'isbn', 'results' => 'details,authors', 'value1' => $isbn);
// Call the web service
if (is_null($resultDOM =& $this->callWebService(ISBNDB_WEBSERVICE_URL, $lookupParams))) {
return $nullVar;
}
// Transform and pre-process the web service result
if (is_null($metadata =& $this->transformWebServiceResults($resultDOM, dirname(__FILE__) . DIRECTORY_SEPARATOR . 'isbndb.xsl'))) {
return $nullVar;
}
// Extract place and publisher from the combined entry.
$metadata['publisher-loc'] = PKPString::trimPunctuation(PKPString::regexp_replace('/^(.+):.*/', '\\1', $metadata['place-publisher']));
$metadata['publisher-name'] = PKPString::trimPunctuation(PKPString::regexp_replace('/.*:([^,]+),?.*/', '\\1', $metadata['place-publisher']));
unset($metadata['place-publisher']);
// Reformat the publication date
$metadata['date'] = PKPString::regexp_replace('/^[^\\d{4}]+(\\d{4}).*/', '\\1', $metadata['date']);
// Clean non-numerics from ISBN
$metadata['isbn'] = PKPString::regexp_replace('/[^\\dX]*/', '', $isbn);
// Set the publicationType
$metadata['[@publication-type]'] = NLM30_PUBLICATION_TYPE_BOOK;
return $this->getNlm30CitationDescriptionFromMetadataArray($metadata);
}
示例4: filterKeywords
/**
* Split a string into a clean array of keywords
* @param $text string
* @param $allowWildcards boolean
* @return array of keywords
*/
static function filterKeywords($text, $allowWildcards = false)
{
$minLength = Config::getVar('search', 'min_word_length');
$stopwords = self::_loadStopwords();
// Join multiple lines into a single string
if (is_array($text)) {
$text = join("\n", $text);
}
$cleanText = Core::cleanVar($text);
// Remove punctuation
$cleanText = PKPString::regexp_replace('/[!"\\#\\$%\'\\(\\)\\.\\?@\\[\\]\\^`\\{\\}~]/', '', $cleanText);
$cleanText = PKPString::regexp_replace('/[\\+,:;&\\/<=>\\|\\\\]/', ' ', $cleanText);
$cleanText = PKPString::regexp_replace('/[\\*]/', $allowWildcards ? '%' : ' ', $cleanText);
$cleanText = PKPString::strtolower($cleanText);
// Split into words
$words = PKPString::regexp_split('/\\s+/', $cleanText);
// FIXME Do not perform further filtering for some fields, e.g., author names?
// Remove stopwords
$keywords = array();
foreach ($words as $k) {
if (!isset($stopwords[$k]) && PKPString::strlen($k) >= $minLength && !is_numeric($k)) {
$keywords[] = PKPString::substr($k, 0, SEARCH_KEYWORD_MAX_LENGTH);
}
}
return $keywords;
}
示例5: formatElement
/**
* Format XML for single DC element.
* @param $propertyName string
* @param $value array
* @param $multilingual boolean optional
*/
function formatElement($propertyName, $values, $multilingual = false)
{
if (!is_array($values)) {
$values = array($values);
}
// Translate the property name to XML syntax.
$openingElement = str_replace(array('[@', ']'), array(' ', ''), $propertyName);
$closingElement = PKPString::regexp_replace('/\\[@.*/', '', $propertyName);
// Create the actual XML entry.
$response = '';
foreach ($values as $key => $value) {
if ($multilingual) {
$key = str_replace('_', '-', $key);
assert(is_array($value));
foreach ($value as $subValue) {
if ($key == METADATA_DESCRIPTION_UNKNOWN_LOCALE) {
$response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
} else {
$response .= "\t<{$openingElement} xml:lang=\"{$key}\">" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
}
}
} else {
assert(is_scalar($value));
$response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($value) . "</{$closingElement}>\n";
}
}
return $response;
}
示例6: trim
/**
* @see Filter::process()
* @param $input string
* @return mixed array
*/
function &process(&$input)
{
// The default implementation assumes that raw citations are
// separated with line endings.
// 1) Remove empty lines and normalize line endings.
$input = PKPString::regexp_replace('/[\\r\\n]+/s', "\n", $input);
// 2) Remove trailing/leading line breaks.
$input = trim($input, "\n");
// 3) Break up at line endings.
if (empty($input)) {
$citations = array();
} else {
$citations = explode("\n", $input);
}
// 4) Remove numbers from the beginning of each citation.
foreach ($citations as $index => $citation) {
$citations[$index] = PKPString::regexp_replace('/^\\s*[\\[#]?[0-9]+[.)\\]]?\\s*/', '', $citation);
}
return $citations;
}
示例7: index
/**
* Display user login form.
* Redirect to user index page if user is already validated.
*/
function index($args, $request)
{
$this->setupTemplate($request);
if (Validation::isLoggedIn()) {
$this->sendHome($request);
}
if (Config::getVar('security', 'force_login_ssl') && $request->getProtocol() != 'https') {
// Force SSL connections for login
$request->redirectSSL();
}
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array('loginMessage' => $request->getUserVar('loginMessage'), 'username' => $session->getSessionVar('username'), 'remember' => $request->getUserVar('remember'), 'source' => $request->getUserVar('source'), 'showRemember' => Config::getVar('general', 'session_lifetime') > 0));
// For force_login_ssl with base_url[...]: make sure SSL used for login form
$loginUrl = $this->_getLoginUrl($request);
if (Config::getVar('security', 'force_login_ssl')) {
$loginUrl = PKPString::regexp_replace('/^http:/', 'https:', $loginUrl);
}
$templateMgr->assign('loginUrl', $loginUrl);
$templateMgr->display('frontend/pages/userLogin.tpl');
}
示例8: fetch
/**
* @see Form::fetch()
*/
function fetch($request)
{
$templateMgr = TemplateManager::getManager($request);
// The form description depends on the current state
// of the selection process: do we select a filter template
// or configure the settings of a selected template?
$filter =& $this->getFilter();
if (is_a($filter, 'Filter')) {
$displayName = $filter->getDisplayName();
$templateMgr->assign('filterDisplayName', $displayName);
if (count($filter->getSettings())) {
// We need a filter specific translation key so that we
// can explain the filter's configuration options.
// We use the display name to generate such a key as this
// is probably easiest for translators to understand.
// This also has the advantage that we can explain
// composite filters individually.
// FIXME: When we start to translate display names then
// please make sure that you use the en-US key for this
// processing. Alternatively we might want to introduce
// an alphanumeric "filter key" to the filters table.
$filterKey = PKPString::regexp_replace('/[^a-zA-Z0-9]/', '', $displayName);
$filterKey = strtolower(substr($filterKey, 0, 1)) . substr($filterKey, 1);
$formDescriptionKey = $this->getDescription() . '.' . $filterKey;
} else {
$formDescriptionKey = $this->getDescription() . 'Confirm';
}
} else {
$templateMgr->assign('filterDisplayName', '');
$formDescriptionKey = $this->getDescription() . 'Template';
}
$templateMgr->assign('formTitle', $this->getTitle());
$templateMgr->assign('formDescription', $formDescriptionKey);
return parent::fetch($request);
}
示例9: array
/**
* Converts a string with a single person
* to an NLM name description.
*
* TODO: add initials from all given names to initials
* element
*
* @param $personString string
* @param $title boolean true to parse for title
* @param $degrees boolean true to parse for degrees
* @return MetadataDescription an NLM name description or null
* if the string could not be converted
*/
function &_parsePersonString($personString, $title, $degrees)
{
// Expressions to parse person strings, ported from CiteULike person
// plugin, see http://svn.citeulike.org/svn/plugins/person.tcl
static $personRegex = array('title' => '(?:His (?:Excellency|Honou?r)\\s+|Her (?:Excellency|Honou?r)\\s+|The Right Honou?rable\\s+|The Honou?rable\\s+|Right Honou?rable\\s+|The Rt\\.? Hon\\.?\\s+|The Hon\\.?\\s+|Rt\\.? Hon\\.?\\s+|Mr\\.?\\s+|Ms\\.?\\s+|M\\/s\\.?\\s+|Mrs\\.?\\s+|Miss\\.?\\s+|Dr\\.?\\s+|Sir\\s+|Dame\\s+|Prof\\.?\\s+|Professor\\s+|Doctor\\s+|Mister\\s+|Mme\\.?\\s+|Mast(?:\\.|er)?\\s+|Lord\\s+|Lady\\s+|Madam(?:e)?\\s+|Priv\\.-Doz\\.\\s+)+', 'degrees' => '(,\\s+(?:[A-Z\\.]+))+', 'initials' => '(?:(?:[A-Z]\\.){1,3}[A-Z]\\.?)|(?:(?:[A-Z]\\.\\s){1,3}[A-Z]\\.?)|(?:[A-Z]{1,4})|(?:(?:[A-Z]\\.-?){1,4})|(?:(?:[A-Z]\\.-?){1,3}[A-Z]\\.?)|(?:(?:[A-Z]-){1,3}[A-Z])|(?:(?:[A-Z]\\s){1,3}[A-Z]\\.?)|(?:(?:[A-Z]-){1,3}[A-Z]\\.?)', 'prefix' => 'Dell(?:[a|e])?(?:\\s|$)|Dalle(?:\\s|$)|D[a|e]ll\'(?:\\s|$)|Dela(?:\\s|$)|Del(?:\\s|$)|[Dd]e(?:\\s|$)(?:La(?:\\s|$)|Los(?:\\s|$))?|[Dd]e(?:\\s|$)|[Dd][a|i|u](?:\\s|$)|L[a|e|o](?:\\s|$)|[D|L|O]\'|St\\.?(?:\\s|$)|San(?:\\s|$)|[Dd]en(?:\\s|$)|[Vv]on(?:\\s|$)(?:[Dd]er(?:\\s|$))?|(?:[Ll][ea](?:\\s|$))?[Vv]an(?:\\s|$)(?:[Dd]e(?:n|r)?(?:\\s|$))?', 'givenName' => '(?:[^ \\t\\n\\r\\f\\v,.;()]{2,}|[^ \\t\\n\\r\\f\\v,.;()]{2,}\\-[^ \\t\\n\\r\\f\\v,.;()]{2,})');
// The expressions for given name, suffix and surname are the same
$personRegex['surname'] = $personRegex['suffix'] = $personRegex['givenName'];
$personRegex['double-surname'] = "(?:" . $personRegex['surname'] . "\\s)*" . $personRegex['surname'];
// Shortcut for prefixed surname
$personRegexPrefixedSurname = "(?P<prefix>(?:" . $personRegex['prefix'] . ")?)(?P<surname>" . $personRegex['surname'] . ")";
$personRegexPrefixedDoubleSurname = "(?P<prefix>(?:" . $personRegex['prefix'] . ")?)(?P<surname>" . $personRegex['double-surname'] . ")";
// Instantiate the target person description
$personDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema', $this->_assocType);
// Clean the person string
$personString = trim($personString);
// 1. Extract title and degree from the person string and use this as suffix
$suffixString = '';
$results = array();
if ($title && PKPString::regexp_match_get('/^(' . $personRegex['title'] . ')/i', $personString, $results)) {
$suffixString = trim($results[1], ',:; ');
$personString = PKPString::regexp_replace('/^(' . $personRegex['title'] . ')/i', '', $personString);
}
if ($degrees && PKPString::regexp_match_get('/(' . $personRegex['degrees'] . ')$/i', $personString, $results)) {
$degreesArray = explode(',', trim($results[1], ','));
foreach ($degreesArray as $key => $degree) {
$degreesArray[$key] = PKPString::trimPunctuation($degree);
}
$suffixString .= ' - ' . implode('; ', $degreesArray);
$personString = PKPString::regexp_replace('/(' . $personRegex['degrees'] . ')$/i', '', $personString);
}
if (!empty($suffixString)) {
$personDescription->addStatement('suffix', $suffixString);
}
// Space initials when followed by a given name or last name.
$personString = PKPString::regexp_replace('/([A-Z])\\.([A-Z][a-z])/', '\\1. \\2', $personString);
// 2. Extract names and initials from the person string
// The parser expressions are ordered by specificity. The most specific expressions
// come first. Only if these specific expressions don't work will we turn to less
// specific ones. This avoids parsing errors. It also explains why we don't use the
// ?-quantifier for optional elements like initials or middle name where they could
// be misinterpreted.
$personExpressions = array('/^' . $personRegexPrefixedSurname . '$/i', '/^(?P<initials>' . $personRegex['initials'] . ')\\s' . $personRegexPrefixedSurname . '$/', '/^' . $personRegexPrefixedSurname . ',?\\s(?P<initials>' . $personRegex['initials'] . ')$/', '/^' . $personRegexPrefixedDoubleSurname . ',\\s(?P<givenName>' . $personRegex['givenName'] . ')\\s(?P<initials>' . $personRegex['initials'] . ')$/', '/^(?P<givenName>' . $personRegex['givenName'] . ')\\s(?P<initials>' . $personRegex['initials'] . ')\\s' . $personRegexPrefixedSurname . '$/', '/^' . $personRegexPrefixedDoubleSurname . ',\\s(?P<givenName>(?:' . $personRegex['givenName'] . '\\s)+)(?P<initials>' . $personRegex['initials'] . ')$/', '/^(?P<givenName>(?:' . $personRegex['givenName'] . '\\s)+)(?P<initials>' . $personRegex['initials'] . ')\\s' . $personRegexPrefixedSurname . '$/', '/^' . $personRegexPrefixedDoubleSurname . ',(?P<givenName>(?:\\s' . $personRegex['givenName'] . ')+)$/', '/^(?P<givenName>(?:' . $personRegex['givenName'] . '\\s)+)' . $personRegexPrefixedSurname . '$/', '/^\\s*(?P<surname>' . $personRegex['surname'] . ')(?P<suffix>(?:\\s+' . $personRegex['suffix'] . ')?)\\s*,\\s*(?P<initials>(?:' . $personRegex['initials'] . ')?)\\s*\\((?P<givenName>(?:\\s*' . $personRegex['givenName'] . ')+)\\s*\\)\\s*(?P<prefix>(?:' . $personRegex['prefix'] . ')?)$/', '/^(?P<givenName>' . $personRegex['givenName'] . ')\\.(?P<surname>' . $personRegex['double-surname'] . ')$/', '/^(?P<surname>.*)$/');
$results = array();
foreach ($personExpressions as $expressionId => $personExpression) {
if ($nameFound = PKPString::regexp_match_get($personExpression, $personString, $results)) {
// Given names
if (!empty($results['givenName'])) {
// Split given names
$givenNames = explode(' ', trim($results['givenName']));
foreach ($givenNames as $givenName) {
$personDescription->addStatement('given-names', $givenName);
unset($givenName);
}
}
// Initials (will also be saved as given names)
if (!empty($results['initials'])) {
$results['initials'] = str_replace(array('.', '-', ' '), array('', '', ''), $results['initials']);
for ($initialNum = 0; $initialNum < PKPString::strlen($results['initials']); $initialNum++) {
$initial = $results['initials'][$initialNum];
$personDescription->addStatement('given-names', $initial);
unset($initial);
}
}
// Surname
if (!empty($results['surname'])) {
// Correct all-upper surname
if (strtoupper($results['surname']) == $results['surname']) {
$results['surname'] = ucwords(strtolower($results['surname']));
}
$personDescription->addStatement('surname', $results['surname']);
}
// Prefix/Suffix
foreach (array('prefix', 'suffix') as $propertyName) {
if (!empty($results[$propertyName])) {
$results[$propertyName] = trim($results[$propertyName]);
$personDescription->addStatement($propertyName, $results[$propertyName]);
}
}
break;
}
}
return $personDescription;
}
示例10: createIssueNode
/**
* Create and return an issue node, either as work or as manifestation.
* @param $doc DOMDocument
* @param $pubObject Issue
* @return DOMElement
*/
function createIssueNode($doc, $pubObject)
{
$deployment = $this->getDeployment();
$context = $deployment->getContext();
$cache = $deployment->getCache();
$plugin = $deployment->getPlugin();
$request = Application::getRequest();
$router = $request->getRouter();
$issueNodeName = $this->isWork($context, $plugin) ? 'DOISerialIssueWork' : 'DOISerialIssueVersion';
$issueNode = $doc->createElementNS($deployment->getNamespace(), $issueNodeName);
// Notification type (mandatory)
$doi = $pubObject->getStoredPubId('doi');
$registeredDoi = $pubObject->getData('medra::registeredDoi');
assert(empty($registeredDoi) || $registeredDoi == $doi);
$notificationType = empty($registeredDoi) ? O4DOI_NOTIFICATION_TYPE_NEW : O4DOI_NOTIFICATION_TYPE_UPDATE;
$issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'NotificationType', $notificationType));
// DOI (mandatory)
$issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'DOI', htmlspecialchars($doi, ENT_COMPAT, 'UTF-8')));
// DOI URL (mandatory)
$url = $router->url($request, $context->getPath(), 'article', 'view', $pubObject->getBestIssueId(), null, null, true);
if ($plugin->isTestMode($context)) {
// Change server domain for testing.
$url = PKPString::regexp_replace('#://[^\\s]+/index.php#', '://example.com/index.php', $url);
}
$issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'DOIWebsiteLink', $url));
// DOI strucural type
$structuralType = $this->isWork($context, $plugin) ? 'Abstraction' : 'DigitalFixation';
$issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'DOIStructuralType', $structuralType));
// Registrant (mandatory)
$issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'RegistrantName', htmlspecialchars($plugin->getSetting($context->getId(), 'registrantName'), ENT_COMPAT, 'UTF-8')));
// Registration authority (mandatory)
$issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'RegistrationAuthority', 'mEDRA'));
// Work/ProductIdentifier - proprietary ID
$pubObjectProprietaryId = $context->getId() . '-' . $pubObject->getId();
$workOrProduct = $this->isWork($context, $plugin) ? 'Work' : 'Product';
$issueNode->appendChild($this->createIdentifierNode($doc, $workOrProduct, O4DOI_ID_TYPE_PROPRIETARY, $pubObjectProprietaryId));
// Issue/journal and object locale precedence.
$journalLocalePrecedence = $objectLocalePrecedence = $this->getObjectLocalePrecedence($context, null, null);
// Serial Publication (mandatory)
$issueNode->appendChild($this->createSerialPublicationNode($doc, $journalLocalePrecedence, O4DOI_EPUB_FORMAT_HTML));
// Journal Issue (mandatory)
$issueId = $pubObject->getId();
if (!$cache->isCached('issues', $issueId)) {
$cache->add($pubObject, null);
}
$issueNode->appendChild($this->createJournalIssueNode($doc, $pubObject, $journalLocalePrecedence));
// Object Description 'OtherText'
$descriptions = $this->getTranslationsByPrecedence($pubObject->getDescription(null), $objectLocalePrecedence);
foreach ($descriptions as $locale => $description) {
$issueNode->appendChild($this->createOtherTextNode($doc, $locale, $description));
}
// 4) issue (as-work and as-manifestation):
// related works:
// - includes articles-as-work
$articleDao = DAORegistry::getDAO('PublishedArticleDAO');
/* @var $articleDao PublishedArticleDAO */
$articlesByIssue = $articleDao->getPublishedArticles($issueId);
$galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
/* @var $galleyDao ArticleGalleyDAO */
$galleysByIssue = array();
foreach ($articlesByIssue as $relatedArticle) {
$articleProprietaryId = $context->getId() . '-' . $pubObject->getId() . '-' . $relatedArticle->getId();
$relatedArticleIds = array(O4DOI_ID_TYPE_PROPRIETARY => $articleProprietaryId);
$doi = $relatedArticle->getStoredPubId('doi');
if (!empty($doi)) {
$relatedArticleIds[O4DOI_ID_TYPE_DOI] = $doi;
}
$issueNode->appendChild($this->createRelatedNode($doc, 'Work', O4DOI_RELATION_INCLUDES, $relatedArticleIds));
// Collect galleys by issue
$galleysByArticle = $galleyDao->getBySubmissionId($relatedArticle->getId())->toArray();
$galleysByIssue = array_merge($galleysByIssue, $galleysByArticle);
unset($relatedArticle, $relatedArticleIds);
}
// related products:
// - includes articles-as-manifestation
foreach ($galleysByIssue as $relatedGalley) {
$galleyProprietaryId = $context->getId() . '-' . $pubObject->getId() . '-' . $relatedGalley->getSubmissionId() . '-g' . $relatedGalley->getId();
$relatedGalleyIds = array(O4DOI_ID_TYPE_PROPRIETARY => $galleyProprietaryId);
$doi = $relatedGalley->getStoredPubId('doi');
if (!empty($doi)) {
$relatedGalleyIds[O4DOI_ID_TYPE_DOI] = $doi;
}
$issueNode->appendChild($this->createRelatedNode($doc, 'Product', O4DOI_RELATION_INCLUDES, $relatedGalleyIds));
unset($relatedGalley, $relatedGalleyIds);
}
return $issueNode;
}
示例11: markRegistered
/**
* Mark an object as "registered"
* by saving it's DOI to the object's
* "registeredDoi" setting.
* We prefix the setting with the plug-in's
* id so that we do not get name clashes
* when several DOI registration plug-ins
* are active at the same time.
* @parem $request Request
* @param $object Issue|PublishedArticle|ArticleGalley
* @parem $testPrefix string
*/
function markRegistered($request, $object, $testPrefix)
{
$registeredDoi = $object->getPubId('doi');
assert(!empty($registeredDoi));
if ($this->isTestMode($request)) {
$registeredDoi = PKPString::regexp_replace('#^[^/]+/#', $testPrefix . '/', $registeredDoi);
}
$this->saveRegisteredDoi($object, $registeredDoi);
}
示例12: _getDoi
/**
* Retrieve the DOI of an object. The DOI will be
* patched if we are in test mode.
* @param $object Issue|PublishedArticle|ArticleGalley
* @return string
*/
function _getDoi(&$object)
{
$doi = $object->getPubId('doi');
if (!empty($doi) && $this->getTestMode()) {
$doi = PKPString::regexp_replace('#^[^/]+/#', MEDRA_WS_TESTPREFIX . '/', $doi);
}
return $doi;
}
示例13: stripComments
/**
* Strip SQL comments from SQL string.
* @param $sql string
*/
function stripComments(&$sql)
{
$sql = trim(PKPString::regexp_replace(sprintf('/^\\s*%s(.*)$/m', $this->commentDelim), '', $sql));
}
示例14: _translateSearchPhrase
/**
* Translate query keywords.
* @param $searchPhrase string
* @return The translated search phrase.
*/
function _translateSearchPhrase($searchPhrase, $backwards = false)
{
static $queryKeywords;
if (is_null($queryKeywords)) {
// Query keywords.
$queryKeywords = array(PKPString::strtoupper(__('search.operator.not')) => 'NOT', PKPString::strtoupper(__('search.operator.and')) => 'AND', PKPString::strtoupper(__('search.operator.or')) => 'OR');
}
if ($backwards) {
$translationTable = array_flip($queryKeywords);
} else {
$translationTable = $queryKeywords;
}
// Translate the search phrase.
foreach ($translationTable as $translateFrom => $translateTo) {
$searchPhrase = PKPString::regexp_replace("/(^|\\s){$translateFrom}(\\s|\$)/i", "\\1{$translateTo}\\2", $searchPhrase);
}
return $searchPhrase;
}
示例15: suggestUsername
/**
* Suggest a username given the first and last names.
* @return string
*/
static function suggestUsername($firstName, $lastName)
{
$initial = PKPString::substr($firstName, 0, 1);
$suggestion = PKPString::regexp_replace('/[^a-zA-Z0-9_-]/', '', PKPString::strtolower($initial . $lastName));
$userDao = DAORegistry::getDAO('UserDAO');
for ($i = ''; $userDao->userExistsByUsername($suggestion . $i); $i++) {
}
return $suggestion . $i;
}