本文整理汇总了PHP中String::regexp_replace方法的典型用法代码示例。如果您正苦于以下问题:PHP String::regexp_replace方法的具体用法?PHP String::regexp_replace怎么用?PHP String::regexp_replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::regexp_replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 = String::regexp_replace('/[!"\\#\\$%\'\\(\\)\\.\\?@\\[\\]\\^`\\{\\}~]/', '', $cleanText);
$cleanText = String::regexp_replace('/[\\+,:;&\\/<=>\\|\\\\]/', ' ', $cleanText);
$cleanText = String::regexp_replace('/[\\*]/', $allowWildcards ? '%' : ' ', $cleanText);
$cleanText = String::strtolower($cleanText);
// Split into words
$words = String::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]) && String::strlen($k) >= $minLength && !is_numeric($k)) {
$keywords[] = String::substr($k, 0, SEARCH_KEYWORD_MAX_LENGTH);
}
}
return $keywords;
}
示例2: index
/**
* Display user login form.
* Redirect to user index page if user is already validated.
*/
function index($args, &$request)
{
$this->validate();
$this->setupTemplate($request);
if (Validation::isLoggedIn()) {
$request->redirect(null, 'user');
}
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();
// 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 = String::regexp_replace('/^http:/', 'https:', $loginUrl);
}
$templateMgr->assign('loginUrl', $loginUrl);
$templateMgr->display('user/login.tpl');
}
示例3: array
/**
* @see Filter::process()
* @param $citationString string
* @return MetadataDescription
*/
function &process($citationString)
{
$nullVar = null;
$queryParams = array('demo' => '3', 'textlines' => $citationString);
// 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 (!String::regexp_match('/.*<algorithm[^>]+>.*<\\/algorithm>.*/s', $result)) {
$translationParams = array('filterName' => $this->getDisplayName());
$this->addError(Locale::translate('submission.citations.filter.webserviceResultTransformationError', $translationParams));
return $nullVar;
}
// Screen-scrape the tagged portion and turn it into XML.
$xmlResult = String::regexp_replace('/.*<algorithm[^>]+>(.*)<\\/algorithm>.*/s', '\\1', $result);
$xmlResult = String::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);
}
示例4: array
/**
* @see 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'] = String::trimPunctuation(String::regexp_replace('/^(.+):.*/', '\\1', $metadata['place-publisher']));
$metadata['publisher-name'] = String::trimPunctuation(String::regexp_replace('/.*:([^,]+),?.*/', '\\1', $metadata['place-publisher']));
unset($metadata['place-publisher']);
// Reformat the publication date
$metadata['date'] = String::regexp_replace('/^[^\\d{4}]+(\\d{4}).*/', '\\1', $metadata['date']);
// Clean non-numerics from ISBN
$metadata['isbn'] = String::regexp_replace('/[^\\dX]*/', '', $isbn);
// Set the publicationType
$metadata['[@publication-type]'] = NLM_PUBLICATION_TYPE_BOOK;
return $this->getNlmCitationDescriptionFromMetadataArray($metadata);
}
示例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 = String::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: array
/**
* @see Filter::process()
* @param $citationDescription MetadataDescription
* @return MetadataDescription
*/
function &process(&$citationDescription)
{
$nullVar = null;
$searchParams = array('pid' => $this->getEmail(), 'noredirect' => 'true', 'format' => 'unixref');
$doi = $citationDescription->getStatement('pub-id[@pub-id-type="doi"]');
if (!empty($doi)) {
// Directly look up the DOI with OpenURL 0.1
$searchParams['id'] = 'doi:' . $doi;
} else {
// Use OpenURL meta-data to search for the entry
if (is_null($openUrlMetadata = $this->_prepareOpenUrlSearch($citationDescription))) {
return $nullVar;
}
$searchParams += $openUrlMetadata;
}
// Call the CrossRef web service
if (is_null($resultXml =& $this->callWebService(CROSSREF_WEBSERVICE_URL, $searchParams, XSL_TRANSFORMER_DOCTYPE_STRING))) {
return $nullVar;
}
// Remove default name spaces from XML as CrossRef doesn't
// set them reliably and element names are unique anyway.
$resultXml = String::regexp_replace('/ xmlns="[^"]+"/', '', $resultXml);
// Transform and process the web service result
if (is_null($metadata =& $this->transformWebServiceResults($resultXml, dirname(__FILE__) . DIRECTORY_SEPARATOR . 'crossref.xsl'))) {
return $nullVar;
}
return $this->addMetadataArrayToNlmCitationDescription($metadata, $citationDescription);
}
示例7: explode
/**
* @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
$input = String::regexp_replace('/[\\r\\n]+/s', "\n", $input);
// 2) Break up at line endings
$output = explode("\n", $input);
// TODO: Implement more complex treatment, e.g. filtering of
// number strings at the beginning of each string, etc.
return $output;
}
示例8: getContents
/**
* Get the HTML contents for this block.
* @param $templateMgr object
* @param $request PKPRequest
* @return $string
*/
function getContents(&$templateMgr, $request = null)
{
if (!defined('SESSION_DISABLE_INIT')) {
$session =& $request->getSession();
$templateMgr->assign_by_ref('userSession', $session);
$templateMgr->assign('loggedInUsername', $session->getSessionVar('username'));
$loginUrl = $request->url(null, null, 'login', 'signIn');
if (Config::getVar('security', 'force_login_ssl')) {
$loginUrl = String::regexp_replace('/^http:/', 'https:', $loginUrl);
}
$templateMgr->assign('userBlockLoginUrl', $loginUrl);
}
return parent::getContents($templateMgr, $request);
}
示例9: getContents
function getContents(&$templateMgr)
{
if (!defined('SESSION_DISABLE_INIT')) {
$session =& Request::getSession();
$templateMgr->assign_by_ref('userSession', $session);
$templateMgr->assign('loggedInUsername', $session->getSessionVar('username'));
$loginUrl = Request::url(null, 'login', 'signIn');
$templateMgr->assign('paperPackageUpPlugin', "/index.php/mr2/PaperPackageUpPlugin/view/");
if (Config::getVar('security', 'force_login_ssl')) {
$loginUrl = String::regexp_replace('/^http:/', 'https:', $loginUrl);
}
$templateMgr->assign('userBlockLoginUrl', $loginUrl);
}
return parent::getContents($templateMgr);
}
示例10: array
/**
* @see Filter::process()
* @param $citationString string
* @return MetadataDescription
*/
function &process($citationString)
{
$nullVar = null;
$queryParams = array('textlines' => $citationString);
// Parscit web form - the result is (mal-formed) HTML
if (is_null($result = $this->callWebService(PARSCIT_WEBSERVICE, $queryParams, XSL_TRANSFORMER_DOCTYPE_STRING))) {
return $nullVar;
}
// Screen-scrape the tagged portion and turn it into XML
$xmlResult = String::regexp_replace('/.*<algorithm[^>]+>(.*)<\\/algorithm>.*/s', '\\1', html_entity_decode($result));
$xmlResult = String::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->addMetadataArrayToNlmCitationDescription($metadata);
}
示例11: 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 = String::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] = String::regexp_replace('/^\\s*[\\[#]?[0-9]+[.)\\]]?\\s*/', '', $citation);
}
return $citations;
}
示例12: getContents
function getContents(&$templateMgr)
{
if (!defined('SESSION_DISABLE_INIT')) {
$session =& Request::getSession();
$templateMgr->assign_by_ref('userSession', $session);
$templateMgr->assign('loggedInUsername', $session->getSessionVar('username'));
$loginUrl = Request::url(null, 'login', 'signIn');
// if the page is not ssl enabled, and force_login_ssl is set, this flag will present a link instead of the form
$forceSSL = false;
if (Config::getVar('security', 'force_login_ssl')) {
if (Request::getProtocol() != 'https') {
$loginUrl = Request::url(null, 'login');
$forceSSL = true;
}
$loginUrl = String::regexp_replace('/^http:/', 'https:', $loginUrl);
}
$templateMgr->assign('userBlockLoginSSL', $forceSSL);
$templateMgr->assign('userBlockLoginUrl', $loginUrl);
}
return parent::getContents($templateMgr);
}
示例13: getPubId
/**
* @see PubIdPlugin::getPubId()
*/
function getPubId($pubObject, $preview = false)
{
// Determine the type of the publishing object.
$pubObjectType = $this->getPubObjectType($pubObject);
// Initialize variables for publication objects.
$publicationFormat = $pubObjectType == 'PublicationFormat' ? $pubObject : null;
$monograph = $pubObjectType == 'Monograph' ? $pubObject : null;
// Get the press id of the object.
if (in_array($pubObjectType, array('PublicationFormat', 'Monograph'))) {
$pressId = $pubObject->getContextId();
} else {
return null;
}
$press = $this->_getPress($pressId);
if (!$press) {
return null;
}
$pressId = $press->getId();
// If we already have an assigned DOI, use it.
$storedDOI = $pubObject->getStoredPubId('doi');
if ($storedDOI) {
return $storedDOI;
}
// Retrieve the DOI prefix.
$doiPrefix = $this->getSetting($pressId, 'doiPrefix');
if (empty($doiPrefix)) {
return null;
}
// Generate the DOI suffix.
$doiSuffixGenerationStrategy = $this->getSetting($pressId, 'doiSuffix');
switch ($doiSuffixGenerationStrategy) {
case 'customId':
$doiSuffix = $pubObject->getData('doiSuffix');
break;
case 'pattern':
$doiSuffix = $this->getSetting($pressId, "doi{$pubObjectType}SuffixPattern");
// %p - press initials
$doiSuffix = String::regexp_replace('/%p/', String::strtolower($press->getPath()), $doiSuffix);
if ($publicationFormat) {
// %m - monograph id, %f - publication format id
$doiSuffix = String::regexp_replace('/%m/', $publicationFormat->getMonographId(), $doiSuffix);
$doiSuffix = String::regexp_replace('/%f/', $publicationFormat->getId(), $doiSuffix);
}
if ($monograph) {
// %m - monograph id
$doiSuffix = String::regexp_replace('/%m/', $monograph->getId(), $doiSuffix);
}
break;
default:
$doiSuffix = String::strtolower($press->getPath());
if ($publicationFormat) {
$doiSuffix .= '.' . $publicationFormat->getMonographId();
$doiSuffix .= '.' . $publicationFormat->getId();
}
if ($monograph) {
$doiSuffix .= '.' . $monograph->getId();
}
}
if (empty($doiSuffix)) {
return null;
}
// Join prefix and suffix.
$doi = $doiPrefix . '/' . $doiSuffix;
if (!$preview) {
// Save the generated DOI.
$this->setStoredPubId($pubObject, $pubObjectType, $doi);
}
return $doi;
}
示例14: 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 && String::regexp_match_get('/^(' . $personRegex['title'] . ')/i', $personString, $results)) {
$suffixString = trim($results[1], ',:; ');
$personString = String::regexp_replace('/^(' . $personRegex['title'] . ')/i', '', $personString);
}
if ($degrees && String::regexp_match_get('/(' . $personRegex['degrees'] . ')$/i', $personString, $results)) {
$degreesArray = explode(',', trim($results[1], ','));
foreach ($degreesArray as $key => $degree) {
$degreesArray[$key] = String::trimPunctuation($degree);
}
$suffixString .= ' - ' . implode('; ', $degreesArray);
$personString = String::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 = String::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 = String::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 < String::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;
}
示例15: 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 = String::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);
}