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


PHP String::strtolower方法代码示例

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


在下文中一共展示了String::strtolower方法的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;
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:32,代码来源:SubmissionSearchIndex.inc.php

示例2: getName

 /**
  * @see PKPPlugin::getName()
  */
 function getName()
 {
     // Lazy load enabled plug-ins always use the plugin's class name
     // as plug-in name. Legacy plug-ins will override this method so
     // this implementation is backwards compatible.
     // NB: strtolower is required for PHP4 compatibility.
     return String::strtolower(get_class($this));
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:11,代码来源:LazyLoadPlugin.inc.php

示例3: _parseQueryInternal

 /**
  * Query parsing helper routine.
  * Returned structure is based on that used by the Search::QueryParser Perl module.
  */
 function _parseQueryInternal($signTokens, $tokens, &$pos, $total)
 {
     $return = array('+' => array(), '' => array(), '-' => array());
     $postBool = $preBool = '';
     $submissionSearchIndex = new SubmissionSearchIndex();
     $notOperator = String::strtolower(__('search.operator.not'));
     $andOperator = String::strtolower(__('search.operator.and'));
     $orOperator = String::strtolower(__('search.operator.or'));
     while ($pos < $total) {
         if (!empty($signTokens[$pos])) {
             $sign = $signTokens[$pos];
         } else {
             if (empty($sign)) {
                 $sign = '+';
             }
         }
         $token = String::strtolower($tokens[$pos++]);
         switch ($token) {
             case $notOperator:
                 $sign = '-';
                 break;
             case ')':
                 return $return;
             case '(':
                 $token = $this->_parseQueryInternal($signTokens, $tokens, $pos, $total);
             default:
                 $postBool = '';
                 if ($pos < $total) {
                     $peek = String::strtolower($tokens[$pos]);
                     if ($peek == $orOperator) {
                         $postBool = 'or';
                         $pos++;
                     } else {
                         if ($peek == $andOperator) {
                             $postBool = 'and';
                             $pos++;
                         }
                     }
                 }
                 $bool = empty($postBool) ? $preBool : $postBool;
                 $preBool = $postBool;
                 if ($bool == 'or') {
                     $sign = '';
                 }
                 if (is_array($token)) {
                     $k = $token;
                 } else {
                     $k = $submissionSearchIndex->filterKeywords($token, true);
                 }
                 if (!empty($k)) {
                     $return[$sign][] = $k;
                 }
                 $sign = '';
                 break;
         }
     }
     return $return;
 }
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:62,代码来源:SubmissionSearch.inc.php

示例4: cite

 /**
  * Return an HTML-formatted citation. Default implementation displays
  * an HTML-based citation using the citation.tpl template in the plugin
  * path.
  * @param $paper object
  */
 function cite(&$paper)
 {
     $loweredTitle = String::strtolower($paper->getLocalizedTitle());
     $apaCapitalized = String::ucfirst($loweredTitle);
     HookRegistry::register('Template::RT::CaptureCite', array(&$this, 'displayCitation'));
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('citationPlugin', $this);
     $templateMgr->assign('apaCapitalized', $apaCapitalized);
     $templateMgr->display('rt/captureCite.tpl');
 }
开发者ID:sedici,项目名称:ocs,代码行数:16,代码来源:ApaCitationPlugin.inc.php

示例5: _handleOcsUrl

 function _handleOcsUrl($matchArray)
 {
     $url = $matchArray[2];
     $anchor = null;
     if (($i = strpos($url, '#')) !== false) {
         $anchor = substr($url, $i + 1);
         $url = substr($url, 0, $i);
     }
     $urlParts = explode('/', $url);
     if (isset($urlParts[0])) {
         switch (String::strtolower($urlParts[0])) {
             case 'conference':
                 $url = Request::url(isset($urlParts[1]) ? $urlParts[1] : Request::getRequestedConferencePath(), null, null, null, null, null, $anchor);
                 break;
             case 'paper':
                 if (isset($urlParts[1])) {
                     $url = Request::url(null, null, 'paper', 'view', $urlParts[1], null, $anchor);
                 }
                 break;
             case 'schedConf':
                 if (isset($urlParts[1])) {
                     $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
                     $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
                     $thisSchedConf =& $schedConfDao->getSchedConfByPath($urlParts[1]);
                     if (!$thisSchedConf) {
                         break;
                     }
                     $thisConference =& $conferenceDao->getConference($thisSchedConf->getConferenceId());
                     $url = Request::url($thisConference->getPath(), $thisSchedConf->getPath(), null, null, null, null, $anchor);
                 } else {
                     $url = Request::url(null, null, 'schedConfs', 'current', null, null, $anchor);
                 }
                 break;
             case 'suppfile':
                 if (isset($urlParts[1]) && isset($urlParts[2])) {
                     $url = Request::url(null, null, 'paper', 'downloadSuppFile', array($urlParts[1], $urlParts[2]), null, $anchor);
                 }
                 break;
             case 'sitepublic':
                 array_shift($urlParts);
                 import('file.PublicFileManager');
                 $publicFileManager = new PublicFileManager();
                 $url = Request::getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath() . '/' . implode('/', $urlParts) . ($anchor ? '#' . $anchor : '');
                 break;
             case 'public':
                 array_shift($urlParts);
                 $schedConf =& Request::getSchedConf();
                 import('file.PublicFileManager');
                 $publicFileManager = new PublicFileManager();
                 $url = Request::getBaseUrl() . '/' . $publicFileManager->getSchedConfFilesPath($schedConf->getId()) . '/' . implode('/', $urlParts) . ($anchor ? '#' . $anchor : '');
                 break;
         }
     }
     return $matchArray[1] . $url . $matchArray[3];
 }
开发者ID:sedici,项目名称:ocs,代码行数:55,代码来源:PaperHTMLGalley.inc.php

示例6: 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 == '' || String::strpos(String::strtolower(serialize($plugin)), String::strtolower($search)) !== false)) {
             $plugins[] = $plugin;
         }
     }
     return $plugins;
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:22,代码来源:PluginGalleryDAO.inc.php

示例7: _handleOjsUrl

 function _handleOjsUrl($matchArray)
 {
     $url = $matchArray[2];
     $anchor = null;
     if (($i = strpos($url, '#')) !== false) {
         $anchor = substr($url, $i + 1);
         $url = substr($url, 0, $i);
     }
     $urlParts = explode('/', $url);
     if (isset($urlParts[0])) {
         switch (String::strtolower($urlParts[0])) {
             case 'journal':
                 $url = Request::url(isset($urlParts[1]) ? $urlParts[1] : Request::getRequestedJournalPath(), null, null, null, null, $anchor);
                 break;
             case 'article':
                 if (isset($urlParts[1])) {
                     $url = Request::url(null, 'article', 'view', $urlParts[1], null, $anchor);
                 }
                 break;
             case 'issue':
                 if (isset($urlParts[1])) {
                     $url = Request::url(null, 'issue', 'view', $urlParts[1], null, $anchor);
                 } else {
                     $url = Request::url(null, 'issue', 'current', null, null, $anchor);
                 }
                 break;
             case 'suppfile':
                 if (isset($urlParts[1]) && isset($urlParts[2])) {
                     $url = Request::url(null, 'article', 'downloadSuppFile', array($urlParts[1], $urlParts[2]), null, $anchor);
                 }
                 break;
             case 'sitepublic':
                 array_shift($urlParts);
                 import('file.PublicFileManager');
                 $publicFileManager =& new PublicFileManager();
                 $url = Request::getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath() . '/' . implode('/', $urlParts) . ($anchor ? '#' . $anchor : '');
                 break;
             case 'public':
                 array_shift($urlParts);
                 $journal =& Request::getJournal();
                 import('file.PublicFileManager');
                 $publicFileManager =& new PublicFileManager();
                 $url = Request::getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getJournalId()) . '/' . implode('/', $urlParts) . ($anchor ? '#' . $anchor : '');
                 break;
         }
     }
     return $matchArray[1] . $url . $matchArray[3];
 }
开发者ID:Jouper,项目名称:jouper,代码行数:48,代码来源:ArticleHTMLGalley.inc.php

示例8: getAuthorsAlphabetizedByPress

    /**
     * Retrieve all published authors for a press in an associative array by
     * the first letter of the last name, for example:
     * $returnedArray['S'] gives array($misterSmithObject, $misterSmytheObject, ...)
     * Keys will appear in sorted order. Note that if pressId is null,
     * alphabetized authors for all presses are returned.
     * @param $pressId int
     * @param $initial An initial the last names must begin with
     * @return array Authors ordered by sequence
     */
    function getAuthorsAlphabetizedByPress($pressId = null, $initial = null, $rangeInfo = null)
    {
        $params = array('affiliation', AppLocale::getPrimaryLocale(), 'affiliation', AppLocale::getLocale());
        if (isset($pressId)) {
            $params[] = $pressId;
        }
        if (isset($initial)) {
            $params[] = String::strtolower($initial) . '%';
            $initialSql = ' AND LOWER(a.last_name) LIKE LOWER(?)';
        } else {
            $initialSql = '';
        }
        $result = $this->retrieveRange('SELECT DISTINCT
				CAST(\'\' AS CHAR) AS url,
				a.author_id AS author_id,
				a.submission_id AS submission_id,
				CAST(\'\' AS CHAR) AS email,
				0 AS primary_contact,
				0 AS seq,
				a.first_name AS first_name,
				a.middle_name AS middle_name,
				a.last_name AS last_name,
				asl.setting_value AS affiliation_l,
				asl.locale,
				aspl.setting_value AS affiliation_pl,
				aspl.locale AS primary_locale,
				a.suffix AS suffix,
				a.user_group_id AS user_group_id,
				a.include_in_browse AS include_in_browse,
				0 AS show_title,
				a.country
			FROM	authors a
				LEFT JOIN author_settings aspl ON (a.author_id = aspl.author_id AND aspl.setting_name = ? AND aspl.locale = ?)
				LEFT JOIN author_settings asl ON (a.author_id = asl.author_id AND asl.setting_name = ? AND asl.locale = ?)
				JOIN submissions s ON (a.submission_id = s.submission_id)
			WHERE	s.status = ' . STATUS_PUBLISHED . ' ' . (isset($pressId) ? 'AND s.context_id = ? ' : '') . '
				AND (a.last_name IS NOT NULL AND a.last_name <> \'\')' . $initialSql . '
			ORDER BY a.last_name, a.first_name', $params, $rangeInfo);
        return new DAOResultFactory($result, $this, '_fromRow');
    }
开发者ID:josekarvalho,项目名称:omp,代码行数:50,代码来源:AuthorDAO.inc.php

示例9: getAuthorsAlphabetizedByJournal

    /**
     * Retrieve all published authors for a journal in an associative array by
     * the first letter of the last name, for example:
     * $returnedArray['S'] gives array($misterSmithObject, $misterSmytheObject, ...)
     * Keys will appear in sorted order. Note that if journalId is null,
     * alphabetized authors for all journals are returned.
     * @param $journalId int
     * @param $initial An initial the last names must begin with
     * @param $rangeInfo Range information
     * @param $includeEmail Whether or not to include the email in the select distinct
     * @return array Authors ordered by sequence
     */
    function getAuthorsAlphabetizedByJournal($journalId = null, $initial = null, $rangeInfo = null, $includeEmail = false)
    {
        $params = array('affiliation', AppLocale::getPrimaryLocale(), 'affiliation', AppLocale::getLocale());
        if (isset($journalId)) {
            $params[] = $journalId;
        }
        if (isset($initial)) {
            $params[] = String::strtolower($initial) . '%';
            $initialSql = ' AND LOWER(aa.last_name) LIKE LOWER(?)';
        } else {
            $initialSql = '';
        }
        $result = $this->retrieveRange('SELECT DISTINCT
				CAST(\'\' AS CHAR) AS url,
				0 AS author_id,
				0 AS submission_id,
				' . ($includeEmail ? 'aa.email AS email,' : 'CAST(\'\' AS CHAR) AS email,') . '
				0 AS primary_contact,
				0 AS seq,
				aa.first_name,
				aa.middle_name,
				aa.last_name,
				SUBSTRING(asl.setting_value FROM 1 FOR 255) AS affiliation_l,
				asl.locale,
				SUBSTRING(aspl.setting_value FROM 1 FOR 255) AS affiliation_pl,
				aspl.locale AS primary_locale,
				aa.country
			FROM	authors aa
				LEFT JOIN author_settings aspl ON (aa.author_id = aspl.author_id AND aspl.setting_name = ? AND aspl.locale = ?)
				LEFT JOIN author_settings asl ON (aa.author_id = asl.author_id AND asl.setting_name = ? AND asl.locale = ?)
				JOIN submissions a ON (a.submission_id = aa.submission_id AND a.status = ' . STATUS_PUBLISHED . ')
				JOIN published_submissions pa ON (pa.submission_id = a.submission_id)
				JOIN issues i ON (pa.issue_id = i.issue_id AND i.published = 1)
			WHERE ' . (isset($journalId) ? 'a.context_id = ? AND ' : '') . '
				(aa.last_name IS NOT NULL AND aa.last_name <> \'\')' . $initialSql . '
			ORDER BY aa.last_name, aa.first_name', $params, $rangeInfo);
        return new DAOResultFactory($result, $this, '_returnSimpleAuthorFromRow');
    }
开发者ID:jalperin,项目名称:ojs,代码行数:50,代码来源:AuthorDAO.inc.php

示例10: array

    /**
     * Retrieve all published authors for a press in an associative array by
     * the first letter of the last name, for example:
     * $returnedArray['S'] gives array($misterSmithObject, $misterSmytheObject, ...)
     * Keys will appear in sorted order. Note that if pressId is null,
     * alphabetized authors for all presses are returned.
     * @param $pressId int
     * @param $initial An initial the last names must begin with
     * @return array Authors ordered by sequence
     */
    function &getAuthorsAlphabetizedByPress($pressId = null, $initial = null, $rangeInfo = null)
    {
        $authors = array();
        $params = array('affiliation', Locale::getPrimaryLocale(), 'affiliation', Locale::getLocale());
        if (isset($pressId)) {
            $params[] = $pressId;
        }
        if (isset($initial)) {
            $params[] = String::strtolower($initial) . '%';
            $initialSql = ' AND LOWER(ma.last_name) LIKE LOWER(?)';
        } else {
            $initialSql = '';
        }
        $result =& $this->retrieveRange('SELECT DISTINCT
				CAST(\'\' AS CHAR) AS url,
				0 AS author_id,
				0 AS submission_id,
				CAST(\'\' AS CHAR) AS email,
				0 AS primary_contact,
				0 AS seq,
				ma.first_name AS first_name,
				ma.middle_name AS middle_name,
				ma.last_name AS last_name,
				asl.setting_value AS affiliation_l,
				asl.locale,
				aspl.setting_value AS affiliation_pl,
				aspl.locale AS primary_locale,
				ma.country
			FROM	authors ma
				LEFT JOIN author_settings aspl ON (aa.author_id = aspl.author_id AND aspl.setting_name = ? AND aspl.locale = ?)
				LEFT JOIN author_settings asl ON (aa.author_id = asl.author_id AND asl.setting_name = ? AND asl.locale = ?)
				LEFT JOIN monographs a ON (ma.submission_id = a.monograph_id)
			WHERE	a.status = ' . STATUS_PUBLISHED . ' ' . (isset($pressId) ? 'AND a.press_id = ? ' : '') . '
				AND (ma.last_name IS NOT NULL AND ma.last_name <> \'\')' . $initialSql . '
			ORDER BY ma.last_name, ma.first_name', $params, $rangeInfo);
        $returner = new DAOResultFactory($result, $this, '_returnAuthorFromRow');
        return $returner;
    }
开发者ID:jerico-dev,项目名称:omp,代码行数:48,代码来源:AuthorDAO.inc.php

示例11: getPubId

 /**
  * @see PubIdPlugin::getPubId()
  */
 function getPubId($monograph, $preview = false)
 {
     // Determine the type of the publishing object.
     $pubObjectType = $this->getPubObjectType($monograph);
     // Get the press id of the object.
     if (in_array($pubObjectType, array('Monograph', 'PublishedMonograph'))) {
         $pressId = $monograph->getContextId();
     } else {
         return null;
     }
     $press = $this->_getPress($pressId);
     if (!$press) {
         return null;
     }
     $pressId = $press->getId();
     // If we already have an assigned URN, use it.
     $storedURNDNB = $monograph->getStoredPubId('urn');
     if ($storedURNDNB) {
         return $storedURNDNB;
     }
     // Retrieve the URN prefix.
     $urnPrefix = $this->getSetting($pressId, 'urnDNBPrefix');
     if (empty($urnPrefix)) {
         return null;
     }
     // Generate the URN suffix.
     $urnSuffixGenerationStrategy = $this->getSetting($pressId, 'urnDNBSuffix');
     switch ($urnSuffixGenerationStrategy) {
         case 'pattern':
             $urnSuffix = $this->getSetting($pressId, "urnDNBSuffixPattern");
             // %p - press initials
             $urnSuffix = String::regexp_replace('/%p/', String::strtolower($press->getPath()), $urnSuffix);
             if ($monograph) {
                 // %m - monograph id
                 $urnSuffix = String::regexp_replace('/%m/', $monograph->getId(), $urnSuffix);
             }
             break;
         default:
             $urnSuffix = '-' . String::strtolower($press->getPath());
             if ($monograph) {
                 $urnSuffix .= '.' . $monograph->getId();
             }
     }
     if (empty($urnSuffix)) {
         return null;
     }
     // Join prefix and suffix.
     $urn = $urnPrefix . $urnSuffix;
     if (!$preview) {
         // Save the generated URN.
         $this->setStoredPubId($monograph, $pubObjectType, $urn);
     }
     return $urn . $this->_calculateUrnCheckNo($urn);
 }
开发者ID:kadowa,项目名称:omp-dnb-urn-plugin,代码行数:57,代码来源:URNDNBPubIdPlugin.inc.php

示例12: mapLanguage

 /**
  * If $value is found in the mapping, return the mapped value; otherwise
  * return $value untouched. The comparison ignores case and white-
  * space.
  * @param $value string
  * @return string
  */
 function mapLanguage($value)
 {
     $cache =& $this->_getMapCache();
     if ($newValue = $cache->get(String::strtolower(trim($value)))) {
         return $newValue;
     }
     return $value;
 }
开发者ID:ramonsodoma,项目名称:harvester,代码行数:15,代码来源:LanguageMapPreprocessorPlugin.inc.php

示例13: getDOI

 /**
  * Get a DOI for this article.
  */
 function getDOI()
 {
     // If we already have an assigned DOI, use it.
     $storedDOI = $this->getStoredDOI();
     if ($storedDOI) {
         return $storedDOI;
     }
     // Otherwise, create a new one.
     $journalId = $this->getJournalId();
     // Get the Journal object (optimized)
     $journal =& Request::getJournal();
     if (!$journal || $journal->getId() != $journalId) {
         unset($journal);
         $journalDao =& DAORegistry::getDAO('JournalDAO');
         $journal =& $journalDao->getJournal($journalId);
     }
     if (($doiPrefix = $journal->getSetting('doiPrefix')) == '') {
         return null;
     }
     $doiSuffixSetting = $journal->getSetting('doiSuffix');
     // Get the issue
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getIssueById($this->getIssueId(), $this->getJournalId(), true);
     if (!$issue || !$journal || $journal->getId() != $issue->getJournalId()) {
         return null;
     }
     switch ($doiSuffixSetting) {
         case 'customIdentifier':
             $doi = $doiPrefix . '/' . $this->getBestArticleId();
             break;
         case 'pattern':
             $suffixPattern = $journal->getSetting('doiSuffixPattern');
             // %j - journal initials
             $suffixPattern = String::regexp_replace('/%j/', String::strtolower($journal->getLocalizedSetting('initials')), $suffixPattern);
             // %v - volume number
             $suffixPattern = String::regexp_replace('/%v/', $issue->getVolume(), $suffixPattern);
             // %i - issue number
             $suffixPattern = String::regexp_replace('/%i/', $issue->getNumber(), $suffixPattern);
             // %Y - year
             $suffixPattern = String::regexp_replace('/%Y/', $issue->getYear(), $suffixPattern);
             // %a - article id
             $suffixPattern = String::regexp_replace('/%a/', $this->getArticleId(), $suffixPattern);
             // %p - page number
             $suffixPattern = String::regexp_replace('/%p/', $this->getPages(), $suffixPattern);
             $doi = $doiPrefix . '/' . $suffixPattern;
             break;
         default:
             $doi = $doiPrefix . '/' . String::strtolower($journal->getLocalizedSetting('initials')) . '.v' . $issue->getVolume() . 'i' . $issue->getNumber() . '.' . $this->getArticleId();
     }
     // Save the generated DOI
     $this->setStoredDOI($doi);
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $articleDao->changeDOI($this->getId(), $doi);
     return $doi;
 }
开发者ID:ramonsodoma,项目名称:ojs,代码行数:58,代码来源:PublishedArticle.inc.php

示例14: _getFacetingAutosuggestions

 /**
  * Retrieve auto-suggestions from the faceting service.
  * @param $url string
  * @param $searchRequest SolrSearchRequest
  * @param $userInput string
  * @param $fieldName string
  * @return array The generated suggestions.
  */
 function _getFacetingAutosuggestions($url, $searchRequest, $userInput, $fieldName)
 {
     // Remove special characters from the user input.
     $searchTerms = strtr($userInput, '"()+-|&!', '        ');
     // Cut off the last search term.
     $searchTerms = explode(' ', $searchTerms);
     $facetPrefix = array_pop($searchTerms);
     if (empty($facetPrefix)) {
         return array();
     }
     // Use the remaining search query to pre-filter
     // facet results. This may be an invalid query
     // but edismax will deal gracefully with syntax
     // errors.
     $userInput = String::substr($userInput, 0, -String::strlen($facetPrefix));
     switch ($fieldName) {
         case 'query':
             // The 'query' filter goes agains all fields.
             $articleSearch = new ArticleSearch();
             $solrFields = array_values($articleSearch->getIndexFieldMap());
             break;
         case 'indexTerms':
             // The 'index terms' filter goes against keyword index fields.
             $solrFields = array('discipline', 'subject', 'type', 'coverage');
             break;
         default:
             // All other filters can be used directly.
             $solrFields = array($fieldName);
     }
     $solrFieldString = implode('|', $solrFields);
     $searchRequest->addQueryFieldPhrase($solrFieldString, $userInput);
     // Construct the main query.
     $params = $this->_getSearchQueryParameters($searchRequest);
     if (!isset($params['q'])) {
         // Use a catch-all query in case we have no limiting
         // search.
         $params['q'] = '*:*';
     }
     if ($fieldName == 'query') {
         $params['facet.field'] = 'default_spell';
     } else {
         $params['facet.field'] = $fieldName . '_spell';
     }
     $facetPrefixLc = String::strtolower($facetPrefix);
     $params['facet.prefix'] = $facetPrefixLc;
     // Make the request.
     $response = $this->_makeRequest($url, $params);
     if (!is_a($response, 'DOMXPath')) {
         return array();
     }
     // Extract term suggestions.
     $nodeList = $response->query('//lst[@name="facet_fields"]/lst/int/@name');
     if ($nodeList->length == 0) {
         return array();
     }
     $termSuggestions = array();
     foreach ($nodeList as $childNode) {
         $termSuggestions[] = $childNode->value;
     }
     // Add the term suggestion to the remaining user input.
     $suggestions = array();
     foreach ($termSuggestions as $termSuggestion) {
         // Restore case if possible.
         if (strpos($termSuggestion, $facetPrefixLc) === 0) {
             $termSuggestion = $facetPrefix . String::substr($termSuggestion, String::strlen($facetPrefix));
         }
         $suggestions[] = $userInput . $termSuggestion;
     }
     return $suggestions;
 }
开发者ID:mosvits,项目名称:ojs,代码行数:78,代码来源:SolrWebService.inc.php

示例15: array

    /**
     * Retrieve all published authors for a journal in an associative array by
     * the first letter of the last name, for example:
     * $returnedArray['S'] gives array($misterSmithObject, $misterSmytheObject, ...)
     * Keys will appear in sorted order. Note that if journalId is null,
     * alphabetized authors for all journals are returned.
     * @param $journalId int
     * @param $initial An initial the last names must begin with
     * @return array Authors ordered by sequence
     */
    function &getAuthorsAlphabetizedByJournal($journalId = null, $initial = null, $rangeInfo = null)
    {
        $authors = array();
        $params = array();
        $locale = Locale::getLocale();
        $params[] = 'firstName';
        $params[] = $locale;
        $params[] = 'lastName';
        $params[] = $locale;
        $params[] = 'middleName';
        $params[] = $locale;
        $params[] = 'affiliation';
        $params[] = $locale;
        if (isset($journalId)) {
            $params[] = $journalId;
        }
        if (isset($initial)) {
            $params[] = String::strtolower($initial) . '%';
            $initialSql = ' AND LOWER(aal.setting_value) LIKE LOWER(?)';
        } else {
            $initialSql = '';
        }
        // Opatan Inc. : joined with article_author_settings to provide setting_value of author firstName
        $result =& $this->retrieveRange('SELECT DISTINCT
				CAST(\'\' AS CHAR(1)) AS url,
				0 AS author_id,
				0 AS article_id,
				CAST(\'\' AS CHAR(1)) AS email,
				0 AS primary_contact,
				0 AS seq,
				aaf.setting_value AS first_name,
				aam.setting_value AS middle_name,
				aal.setting_value AS last_name,
				aaaf.setting_value AS affiliation,
				aa.country
			FROM	article_authors aa
				LEFT JOIN article_author_settings aaf ON (aa.author_id = aaf.author_id AND aaf.setting_name = ? AND aaf.locale = ?)
				LEFT JOIN article_author_settings aal ON (aa.author_id = aal.author_id AND aal.setting_name = ? AND aal.locale = ?)
				LEFT JOIN article_author_settings aam ON (aa.author_id = aam.author_id AND aam.setting_name = ? AND aam.locale = ?)
				LEFT JOIN article_author_settings aaaf ON (aa.author_id = aaaf.author_id AND aaaf.setting_name = ? AND aaaf.locale = ?),
				articles a,
				published_articles pa,
				issues i
			WHERE	i.issue_id = pa.issue_id
				AND i.published = 1
				AND aa.article_id = a.article_id ' . (isset($journalId) ? 'AND a.journal_id = ? ' : '') . '
				AND pa.article_id = a.article_id
				AND a.status = ' . STATUS_PUBLISHED . '
				AND (aal.setting_value IS NOT NULL AND aal.setting_value <> \'\')' . $initialSql . '
			ORDER BY last_name, first_name', empty($params) ? false : $params, $rangeInfo);
        $returner =& new DAOResultFactory($result, $this, '_returnAuthorFromRow');
        return $returner;
    }
开发者ID:alenoosh,项目名称:ojs,代码行数:63,代码来源:AuthorDAO.inc.php


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