当前位置: 首页>>代码示例>>PHP>>正文


PHP AppLocale::getIso1FromLocale方法代码示例

本文整理汇总了PHP中AppLocale::getIso1FromLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP AppLocale::getIso1FromLocale方法的具体用法?PHP AppLocale::getIso1FromLocale怎么用?PHP AppLocale::getIso1FromLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppLocale的用法示例。


在下文中一共展示了AppLocale::getIso1FromLocale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display help.
  * @param $args array
  * @param $request PKPRequest
  */
 function index($args, $request)
 {
     require_once 'lib/pkp/lib/vendor/michelf/php-markdown/Michelf/Markdown.inc.php';
     $path = 'docs/manual/';
     $filename = join('/', $request->getRequestedArgs());
     // If a hash (anchor) was specified, discard it -- we don't need it here.
     if ($hashIndex = strpos($filename, '#')) {
         $hash = substr($filename, $hashIndex + 1);
         $filename = substr($filename, 0, $hashIndex);
     } else {
         $hash = null;
     }
     $language = AppLocale::getIso1FromLocale(AppLocale::getLocale());
     if (!file_exists($path . $language)) {
         $language = 'en';
     }
     // Default
     if (!$filename || !preg_match('#^([[a-zA-Z0-9_-]+/)+[a-zA-Z0-9_-]+\\.\\w+$#', $filename) || !file_exists($path . $filename)) {
         $request->redirect(null, null, null, array($language, 'SUMMARY.md'));
     }
     // Use the summary document to find next/previous links.
     // (Yes, we're grepping markdown outside the parser, but this is much faster.)
     $previousLink = $nextLink = null;
     if (preg_match_all('/\\(([^)]+\\.md)\\)/sm', file_get_contents($path . $language . '/SUMMARY.md'), $matches)) {
         $matches = $matches[1];
         if (($i = array_search(substr($filename, strpos($filename, '/') + 1), $matches)) !== false) {
             if ($i > 0) {
                 $previousLink = $matches[$i - 1];
             }
             if ($i < count($matches) - 1) {
                 $nextLink = $matches[$i + 1];
             }
         }
     }
     // Use a URL filter to prepend the current path to relative URLs.
     $parser = new \Michelf\Markdown();
     $parser->url_filter_func = function ($url) use($filename) {
         return dirname($filename) . '/' . $url;
     };
     return new JSONMessage(true, array('content' => $parser->transform(file_get_contents($path . $filename)), 'previous' => $previousLink, 'next' => $nextLink));
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:46,代码来源:HelpHandler.inc.php

示例2:

 /**
  * Identify published article, issue and language of the given galley.
  * @param $galley ArticleGalley
  * @param $journal Journal
  * @return array|null An array with article, issue and language of
  *  the given galley. Null will be returned if one of these objects
  *  cannot be identified for the galley (e.g. when the galley belongs
  *  to an unpublished article).
  */
 function &_prepareGalleyData(&$galley, &$journal)
 {
     // Retrieve article and issue for the galley.
     $galleyData =& $this->prepareArticleFileData($galley, $journal);
     if (!is_array($galleyData)) {
         $nullVar = null;
         return $nullVar;
     }
     // Add the galley language.
     $languageDao = DAORegistry::getDAO('LanguageDAO');
     /* @var $languageDao LanguageDAO */
     $galleyData['language'] = $languageDao->getLanguageByCode(AppLocale::getIso1FromLocale($galley->getLocale()));
     // Add the galley itself.
     $galleyData['galley'] =& $galley;
     return $galleyData;
 }
开发者ID:laelnasan,项目名称:UTFPR-ojs,代码行数:25,代码来源:DOIExportPlugin.inc.php

示例3: extract

 /**
  * @see DOIExportDom::generate()
  */
 function &generate(&$object)
 {
     $falseVar = false;
     // Declare variables that will contain publication objects.
     $journal =& $this->getJournal();
     $issue = null;
     /* @var $issue Issue */
     $article = null;
     /* @var $article PublishedArticle */
     $galley = null;
     /* @var $galley ArticleGalley */
     $suppFile = null;
     /* @var $suppFile SuppFile */
     $articlesByIssue = null;
     $galleysByArticle = null;
     $suppFilesByArticle = null;
     // Retrieve required publication objects (depends on the object to be exported).
     $pubObjects =& $this->retrievePublicationObjects($object);
     extract($pubObjects);
     // Identify an object implementing an ArticleFile (if any).
     $articleFile = empty($suppFile) ? $galley : $suppFile;
     // Identify the object locale.
     $objectLocalePrecedence = $this->getObjectLocalePrecedence($article, $galley, $suppFile);
     // The publisher is required.
     $publisher = is_a($object, 'SuppFile') ? $object->getSuppFilePublisher() : null;
     if (empty($publisher)) {
         $publisher = $this->getPublisher($objectLocalePrecedence);
     }
     // The publication date is required.
     $publicationDate = is_a($article, 'PublishedArticle') ? $article->getDatePublished() : null;
     if (empty($publicationDate)) {
         $publicationDate = $issue->getDatePublished();
     }
     assert(!empty($publicationDate));
     // Create the XML document and its root element.
     $doc =& $this->getDoc();
     $rootElement =& $this->rootElement();
     XMLCustomWriter::appendChild($doc, $rootElement);
     // DOI (mandatory)
     if (($identifierElement =& $this->_identifierElement($object)) === false) {
         return false;
     }
     XMLCustomWriter::appendChild($rootElement, $identifierElement);
     // Creators (mandatory)
     XMLCustomWriter::appendChild($rootElement, $this->_creatorsElement($object, $objectLocalePrecedence, $publisher));
     // Title (mandatory)
     XMLCustomWriter::appendChild($rootElement, $this->_titlesElement($object, $objectLocalePrecedence));
     // Publisher (mandatory)
     XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'publisher', $publisher);
     // Publication Year (mandatory)
     XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'publicationYear', date('Y', strtotime($publicationDate)));
     // Subjects
     if (!empty($suppFile)) {
         $this->_appendNonMandatoryChild($rootElement, $this->_subjectsElement($suppFile, $objectLocalePrecedence));
     } elseif (!empty($article)) {
         $this->_appendNonMandatoryChild($rootElement, $this->_subjectsElement($article, $objectLocalePrecedence));
     }
     // Dates
     XMLCustomWriter::appendChild($rootElement, $this->_datesElement($issue, $article, $articleFile, $suppFile, $publicationDate));
     // Language
     XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'language', AppLocale::getIso1FromLocale($objectLocalePrecedence[0]));
     // Resource Type
     if (!is_a($object, 'SuppFile')) {
         $resourceTypeElement =& $this->_resourceTypeElement($object);
         XMLCustomWriter::appendChild($rootElement, $resourceTypeElement);
     }
     // Alternate Identifiers
     $this->_appendNonMandatoryChild($rootElement, $this->_alternateIdentifiersElement($object, $issue, $article, $articleFile));
     // Related Identifiers
     $this->_appendNonMandatoryChild($rootElement, $this->_relatedIdentifiersElement($object, $articlesByIssue, $galleysByArticle, $suppFilesByArticle, $issue, $article));
     // Sizes
     $sizesElement =& $this->_sizesElement($object, $article);
     if ($sizesElement) {
         XMLCustomWriter::appendChild($rootElement, $sizesElement);
     }
     // Formats
     if (!empty($articleFile)) {
         XMLCustomWriter::appendChild($rootElement, $this->_formatsElement($articleFile));
     }
     // Rights
     $rightsURL = $article ? $article->getLicenseURL() : $journal->getSetting('licenseURL');
     $rightsListElement =& XMLCustomWriter::createElement($this->getDoc(), 'rightsList');
     $rightsElement = $this->createElementWithText('rights', strip_tags(Application::getCCLicenseBadge($rightsURL)), array('rightsURI' => $rightsURL));
     XMLCustomWriter::appendChild($rightsListElement, $rightsElement);
     XMLCustomWriter::appendChild($rootElement, $rightsListElement);
     // Descriptions
     $descriptionsElement =& $this->_descriptionsElement($issue, $article, $suppFile, $objectLocalePrecedence, $articlesByIssue);
     if ($descriptionsElement) {
         XMLCustomWriter::appendChild($rootElement, $descriptionsElement);
     }
     return $doc;
 }
开发者ID:jasonzou,项目名称:OJS-2.4.6,代码行数:95,代码来源:DataciteExportDom.inc.php

示例4: DOMDocument


//.........这里部分代码省略.........
     if (!$issue) {
         $issueId = $article->getIssueId();
         if ($cache->isCached('issues', $issueId)) {
             $issue = $cache->get('issues', $issueId);
         } else {
             $issueDao = DAORegistry::getDAO('IssueDAO');
             /* @var $issueDao IssueDAO */
             $issue = $issueDao->getById($issueId, $context->getId());
             if ($issue) {
                 $cache->add($issue, null);
             }
         }
     }
     // The publisher is required.
     // Use the journal title as DataCite recommends for now.
     $publisher = $this->getPrimaryTranslation($context->getName(null), $objectLocalePrecedence);
     assert(!empty($publisher));
     // The publication date is required.
     $publicationDate = isset($article) ? $article->getDatePublished() : null;
     if (empty($publicationDate)) {
         $publicationDate = $issue->getDatePublished();
     }
     assert(!empty($publicationDate));
     // Create the root node
     $rootNode = $this->createRootNode($doc);
     $doc->appendChild($rootNode);
     // Identify the object locale.
     $objectLocalePrecedence = $this->getObjectLocalePrecedence($context, $article, $galley);
     // DOI (mandatory)
     $doi = $pubObject->getStoredPubId('doi');
     if ($plugin->isTestMode($context)) {
         $doi = PKPString::regexp_replace('#^[^/]+/#', DATACITE_API_TESTPREFIX . '/', $doi);
     }
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'identifier', htmlspecialchars($doi, ENT_COMPAT, 'UTF-8')));
     $node->setAttribute('identifierType', DATACITE_IDTYPE_DOI);
     // Creators (mandatory)
     $rootNode->appendChild($this->createCreatorsNode($doc, $issue, $article, $galley, $galleyFile, $publisher, $objectLocalePrecedence));
     // Title (mandatory)
     $rootNode->appendChild($this->createTitlesNode($doc, $issue, $article, $galley, $galleyFile, $objectLocalePrecedence));
     // Publisher (mandatory)
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'publisher', htmlspecialchars($publisher, ENT_COMPAT, 'UTF-8')));
     // Publication Year (mandatory)
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'publicationYear', date('Y', strtotime($publicationDate))));
     // Subjects
     $subject = null;
     if (!empty($galleyFile) && is_a($galleyFile, 'SupplementaryFile')) {
         $subject = $this->getPrimaryTranslation($galleyFile->getSubject(null), $objectLocalePrecedence);
     } elseif (!empty($article)) {
         $subject = $this->getPrimaryTranslation($article->getSubject(null), $objectLocalePrecedence);
     }
     if (!empty($subject)) {
         $subjectsNode = $doc->createElementNS($deployment->getNamespace(), 'subjects');
         $subjectsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'subject', htmlspecialchars($subject, ENT_COMPAT, 'UTF-8')));
         $rootNode->appendChild($subjectsNode);
     }
     // Dates
     $rootNode->appendChild($this->createDatesNode($doc, $issue, $article, $galley, $galleyFile, $publicationDate));
     // Language
     $rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'language', AppLocale::getIso1FromLocale($objectLocalePrecedence[0])));
     // Resource Type
     $resourceTypeNode = $this->createResourceTypeNode($doc, $issue, $article, $galley, $galleyFile);
     if ($resourceTypeNode) {
         $rootNode->appendChild($resourceTypeNode);
     }
     // Alternate Identifiers
     $rootNode->appendChild($this->createAlternateIdentifiersNode($doc, $issue, $article, $galley));
     // Related Identifiers
     $relatedIdentifiersNode = $this->createRelatedIdentifiersNode($doc, $issue, $article, $galley);
     if ($relatedIdentifiersNode) {
         $rootNode->appendChild($relatedIdentifiersNode);
     }
     // Sizes
     $sizesNode = $this->createSizesNode($doc, $issue, $article, $galley, $galleyFile);
     if ($sizesNode) {
         $rootNode->appendChild($sizesNode);
     }
     // Formats
     if (!empty($galleyFile)) {
         $format = $galleyFile->getFileType();
         if (!empty($format)) {
             $formatsNode = $doc->createElementNS($deployment->getNamespace(), 'formats');
             $formatsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'format', htmlspecialchars($format, ENT_COMPAT, 'UTF-8')));
             $rootNode->appendChild($formatsNode);
         }
     }
     // Rights
     $rightsURL = $article ? $article->getLicenseURL() : $context->getSetting('licenseURL');
     if (!empty($rightsURL)) {
         $rightsNode = $doc->createElementNS($deployment->getNamespace(), 'rightsList');
         $rightsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'rights', htmlspecialchars(strip_tags(Application::getCCLicenseBadge($rightsURL)), ENT_COMPAT, 'UTF-8')));
         $node->setAttribute('rightsURI', $rightsURL);
         $rootNode->appendChild($rightsNode);
     }
     // Descriptions
     $descriptionsNode = $this->createDescriptionsNode($doc, $issue, $article, $galley, $galleyFile, $objectLocalePrecedence);
     if ($descriptionsNode) {
         $rootNode->appendChild($descriptionsNode);
     }
     return $doc;
 }
开发者ID:pkp,项目名称:ojs,代码行数:101,代码来源:DataciteXmlFilter.inc.php


注:本文中的AppLocale::getIso1FromLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。