本文整理汇总了PHP中PKPString::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPString::strpos方法的具体用法?PHP PKPString::strpos怎么用?PHP PKPString::strpos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PKPString
的用法示例。
在下文中一共展示了PKPString::strpos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFileName
/**
* Generate a filename for a library file.
* @param $type int LIBRARY_FILE_TYPE_...
* @param $originalFileName string
* @return string
*/
function generateFileName($type, $originalFileName)
{
$libraryFileDao = DAORegistry::getDAO('LibraryFileDAO');
$suffix = $this->getFileSuffixFromType($type);
$ext = $this->getExtension($originalFileName);
$truncated = $this->truncateFileName($originalFileName, 127 - PKPString::strlen($suffix) - 1);
$baseName = PKPString::substr($truncated, 0, PKPString::strpos($originalFileName, $ext) - 1);
// Try a simple syntax first
$fileName = $baseName . '-' . $suffix . '.' . $ext;
if (!$libraryFileDao->filenameExists($this->contextId, $fileName)) {
return $fileName;
}
for ($i = 1;; $i++) {
$fullSuffix = $suffix . '-' . $i;
//truncate more if necessary
$truncated = $this->truncateFileName($originalFileName, 127 - PKPString::strlen($fullSuffix) - 1);
// get the base name and append the suffix
$baseName = PKPString::substr($truncated, 0, PKPString::strpos($originalFileName, $ext) - 1);
//try the following
$fileName = $baseName . '-' . $fullSuffix . '.' . $ext;
if (!$libraryFileDao->filenameExists($this->contextId, $fileName)) {
return $fileName;
}
}
}
示例2: getNewestCompatible
/**
* Get a set of GalleryPlugin objects describing the available
* compatible plugins in their newest versions.
* @param $application PKPApplication
* @param $category string Optional category name to use as filter
* @param $search string Optional text to use as filter
* @return array GalleryPlugin objects
*/
function getNewestCompatible($application, $category = null, $search = null)
{
$doc = $this->_getDocument();
$plugins = array();
foreach ($doc->getElementsByTagName('plugin') as $element) {
$plugin = $this->_compatibleFromElement($element, $application);
// May be null if no compatible version exists; also
// apply search filters if any supplied.
if ($plugin && ($category == '' || $plugin->getCategory() == $category) && ($search == '' || PKPString::strpos(PKPString::strtolower(serialize($plugin)), PKPString::strtolower($search)) !== false)) {
$plugins[] = $plugin;
}
}
return $plugins;
}
示例3: array
//.........这里部分代码省略.........
}*/
$metadata['person-group[@person-group-type="author"]'][] =& $authorDescription;
unset($authorDescription);
}
// Extract pagination
$medlinePgnNodes = $resultDOM->getElementsByTagName('MedlinePgn');
$medlinePgnFirstNode = $medlinePgnNodes->item(0);
if (PKPString::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) (PKPString::substr($pages['fpage'], 0, -PKPString::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);
}
}
// Retrieve the data parts and assemble date.
if (!is_null($dateNode)) {
$publicationDate = '';
$requiresNormalization = false;
foreach (array('Year' => 4, 'Month' => 2, 'Day' => 2) as $dateElement => $padding) {
$dateElementNodes = $dateNode->getElementsByTagName($dateElement);
if ($dateElementNodes->length > 0) {
if (!empty($publicationDate)) {
$publicationDate .= '-';
}
$dateElementFirstNode = $dateElementNodes->item(0);
$datePart = str_pad($dateElementFirstNode->textContent, $padding, '0', STR_PAD_LEFT);
if (!is_numeric($datePart)) {
$requiresNormalization = true;
}
$publicationDate .= $datePart;
} else {
break;
}
}
// Normalize the date to NLM standard if necessary.
if ($requiresNormalization) {
$dateFilter = new DateStringNormalizerFilter();
$publicationDate = $dateFilter->execute($publicationDate);
}
if (!empty($publicationDate)) {
$metadata['date'] = $publicationDate;
}
}
// Get publication type
$publicationTypeNodes = $resultDOM->getElementsByTagName('PublicationType');
if ($publicationTypeNodes->length > 0) {
foreach ($publicationTypeNodes as $publicationType) {
// The vast majority of items on PubMed are articles so catch these...
if (PKPString::strpos(PKPString::strtolower($publicationType->textContent), 'article') !== false) {
$metadata['[@publication-type]'] = NLM30_PUBLICATION_TYPE_JOURNAL;
break;
}
}
}
// Get DOI if it exists
$articleIdNodes = $resultDOM->getElementsByTagName('ArticleId');
foreach ($articleIdNodes as $idNode) {
if ($idNode->getAttribute('IdType') == 'doi') {
$metadata['pub-id[@pub-id-type="doi"]'] = $idNode->textContent;
}
}
// Use eLink utility to find fulltext links
$lookupParams = array('dbfrom' => 'pubmed', 'cmd' => 'llinks', 'tool' => 'pkp-wal', 'id' => $pmid);
if (!is_null($resultDOM = $this->callWebService(PUBMED_WEBSERVICE_ELINK, $lookupParams))) {
// Get a list of possible links
foreach ($resultDOM->getElementsByTagName("ObjUrl") as $linkOut) {
$attributes = '';
foreach ($linkOut->getElementsByTagName("Attribute") as $attribute) {
$attributes .= PKPString::strtolower($attribute->textContent) . ' / ';
}
// Only add links to open access resources
if (PKPString::strpos($attributes, "subscription") === false && PKPString::strpos($attributes, "membership") === false && PKPString::strpos($attributes, "fee") === false && $attributes != "") {
$urlNodes = $linkOut->getElementsByTagName('Url');
$urlFirstNode = $urlNodes->item(0);
$links[] = $urlFirstNode->textContent;
}
}
// Take the first link if we have any left (presumably pubmed returns them in preferential order)
if (isset($links[0])) {
$metadata['uri'] = $links[0];
}
}
return $this->getNlm30CitationDescriptionFromMetadataArray($metadata);
}
示例4: getResolvingURL
/**
* @see PubIdPlugin::getResolvingURL()
*/
function getResolvingURL($journalId, $pubId)
{
// See ANSI/NISO Z39.84-2005, Appendix E. (Bug #8190)
$separatorIndex = PKPString::strpos($pubId, '/');
assert($separatorIndex !== false);
// Should contain a slash
$prefix = PKPString::substr($pubId, 0, $separatorIndex);
$suffix = PKPString::substr($pubId, $separatorIndex + 1);
return 'http://dx.doi.org/' . $prefix . '/' . urlencode($suffix);
}