本文整理汇总了PHP中PKPString::titleCase方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPString::titleCase方法的具体用法?PHP PKPString::titleCase怎么用?PHP PKPString::titleCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PKPString
的用法示例。
在下文中一共展示了PKPString::titleCase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
/**
* @copydoc Filter::process()
* @param $input string
* @return MetadataDescription
*/
function &process(&$input)
{
$citationString =& $input;
$nullVar = null;
// Check the availability of perl
$perlCommand = Config::getVar('cli', 'perl');
if (empty($perlCommand) || !file_exists($perlCommand)) {
return $nullVar;
}
// Convert to ASCII - Paracite doesn't handle UTF-8 well
$citationString = PKPString::utf8_to_ascii($citationString);
// Call the paracite parser
$wrapperScript = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'paracite.pl';
$paraciteCommand = $perlCommand . ' ' . escapeshellarg($wrapperScript) . ' ' . $this->getCitationModule() . ' ' . escapeshellarg($citationString);
$xmlResult = shell_exec($paraciteCommand);
if (empty($xmlResult)) {
return $nullVar;
}
if (Config::getVar('i18n', 'charset_normalization') == 'On' && !PKPString::utf8_compliant($xmlResult)) {
$xmlResult = PKPString::utf8_normalize($xmlResult);
}
// Create a temporary DOM document
$resultDOM = new DOMDocument();
$resultDOM->recover = true;
$resultDOM->loadXML($xmlResult);
// Extract the parser results as an array
$xmlHelper = new XMLHelper();
$metadata = $xmlHelper->xmlToArray($resultDOM->documentElement);
// We have to merge subtitle and title as neither OpenURL
// nor NLM can handle subtitles.
if (isset($metadata['subtitle'])) {
$metadata['title'] .= '. ' . $metadata['subtitle'];
unset($metadata['subtitle']);
}
// Break up the authors field
if (isset($metadata['authors'])) {
$metadata['authors'] = PKPString::trimPunctuation($metadata['authors']);
$metadata['authors'] = PKPString::iterativeExplode(array(':', ';'), $metadata['authors']);
}
// Convert pages to integers
foreach (array('spage', 'epage') as $pageProperty) {
if (isset($metadata[$pageProperty])) {
$metadata[$pageProperty] = (int) $metadata[$pageProperty];
}
}
// Convert titles to title case
foreach (array('title', 'chapter', 'publication') as $titleProperty) {
if (isset($metadata[$titleProperty])) {
$metadata[$titleProperty] = PKPString::titleCase($metadata[$titleProperty]);
}
}
// Map ParaCite results to OpenURL - null means
// throw the value away.
$metadataMapping = array('genre' => 'genre', '_class' => null, 'any' => null, 'authors' => 'au', 'aufirst' => 'aufirst', 'aufull' => null, 'auinit' => 'auinit', 'aulast' => 'aulast', 'atitle' => 'atitle', 'cappublication' => null, 'captitle' => null, 'date' => 'date', 'epage' => 'epage', 'featureID' => null, 'id' => null, 'issue' => 'issue', 'jnl_epos' => null, 'jnl_spos' => null, 'match' => null, 'marked' => null, 'num_of_fig' => null, 'pages' => 'pages', 'publisher' => 'pub', 'publoc' => 'place', 'ref' => null, 'rest_text' => null, 'spage' => 'spage', 'targetURL' => 'url', 'text' => null, 'ucpublication' => null, 'uctitle' => null, 'volume' => 'volume', 'year' => 'date');
// Ignore 'year' if 'date' is set
if (isset($metadata['date'])) {
$metadataMapping['year'] = null;
}
// Set default genre
if (empty($metadata['genre'])) {
$metadata['genre'] = OPENURL10_GENRE_ARTICLE;
}
// Handle title, chapter and publication depending on
// the (inferred) genre. Also instantiate the target schema.
switch ($metadata['genre']) {
case OPENURL10_GENRE_BOOK:
case OPENURL10_GENRE_BOOKITEM:
case OPENURL10_GENRE_REPORT:
case OPENURL10_GENRE_DOCUMENT:
$metadataMapping += array('publication' => 'btitle', 'chapter' => 'atitle');
if (isset($metadata['title'])) {
if (!isset($metadata['publication'])) {
$metadata['publication'] = $metadata['title'];
} elseif (!isset($metadata['chapter'])) {
$metadata['chapter'] = $metadata['title'];
}
unset($metadata['title']);
}
$openurl10SchemaName = 'lib.pkp.plugins.metadata.openurl10.schema.Openurl10BookSchema';
$openurl10SchemaClass = 'Openurl10BookSchema';
break;
case OPENURL10_GENRE_ARTICLE:
case OPENURL10_GENRE_JOURNAL:
case OPENURL10_GENRE_ISSUE:
case OPENURL10_GENRE_CONFERENCE:
case OPENURL10_GENRE_PROCEEDING:
case OPENURL10_GENRE_PREPRINT:
default:
$metadataMapping += array('publication' => 'jtitle');
if (isset($metadata['title'])) {
if (!isset($metadata['publication'])) {
$metadata['publication'] = $metadata['title'];
} elseif (!isset($metadata['atitle'])) {
$metadata['atitle'] = $metadata['title'];
}
//.........这里部分代码省略.........
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:101,代码来源:ParaciteRawCitationNlm30CitationSchemaFilter.inc.php
示例2: testTitleCase
/**
* @covers PKPString::titleCase
*/
public function testTitleCase()
{
AppLocale::setTranslations(array('common.titleSmallWords' => 'is a'));
$originalTitle = 'AND This IS A TEST title';
self::assertEquals('And This is a Test Title', PKPString::titleCase($originalTitle));
}