/** * Translate query keywords. * @param $searchPhrase string * @return The translated search phrase. */ function _translateSearchPhrase($searchPhrase, $backwards = false) { static $queryKeywords; if (is_null($queryKeywords)) { // Query keywords. $queryKeywords = array(PKPString::strtoupper(__('search.operator.not')) => 'NOT', PKPString::strtoupper(__('search.operator.and')) => 'AND', PKPString::strtoupper(__('search.operator.or')) => 'OR'); } if ($backwards) { $translationTable = array_flip($queryKeywords); } else { $translationTable = $queryKeywords; } // Translate the search phrase. foreach ($translationTable as $translateFrom => $translateTo) { $searchPhrase = PKPString::regexp_replace("/(^|\\s){$translateFrom}(\\s|\$)/i", "\\1{$translateTo}\\2", $searchPhrase); } return $searchPhrase; }
/** * Returns a JSON list for the autocomplete field. Fetches a list of possible spotlight options * based on the spotlight type chosen. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function itemAutocomplete($args, $request) { $name = $request->getUserVar('name'); $press = $this->getPress(); $itemList = array(); // get the items that match. $matches = array(); $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO'); $publishedMonographs = $publishedMonographDao->getByPressId($press->getId()); while ($monograph = $publishedMonographs->next()) { if ($name == '' || preg_match('/' . preg_quote($name, '/') . '/i', $monograph->getLocalizedTitle())) { $matches[] = array('label' => $monograph->getLocalizedTitle(), 'value' => $monograph->getId() . ':' . SPOTLIGHT_TYPE_BOOK); } } if (!empty($matches)) { $itemList[] = array('label' => PKPString::strtoupper(__('submission.monograph')), 'value' => ''); $itemList = array_merge($itemList, $matches); } $matches = array(); $seriesDao = DAORegistry::getDAO('SeriesDAO'); $allSeries = $seriesDao->getByPressId($press->getId()); while ($series = $allSeries->next()) { if ($name == '' || preg_match('/' . preg_quote($name, '/') . '/i', $series->getLocalizedTitle())) { $matches[] = array('label' => $series->getLocalizedTitle(), 'value' => $series->getId() . ':' . SPOTLIGHT_TYPE_SERIES); } } if (!empty($matches)) { $itemList[] = array('label' => PKPString::strtoupper(__('manager.series.book')), 'value' => ''); $itemList = array_merge($itemList, $matches); } if (count($itemList) == 0) { return $this->noAutocompleteResults(); } return new JSONMessage(true, $itemList); }
/** * Display a list of users from which to choose a subscriber/subscription contact. */ function selectSubscriber($args, $request, $institutional = false) { $templateMgr = TemplateManager::getManager($request); if ($institutional) { $pageTitle = 'manager.subscriptions.selectContact'; $redirect = 'institutional'; } else { $pageTitle = 'manager.subscriptions.selectUser'; $redirect = 'individual'; } $userDao = DAORegistry::getDAO('UserDAO'); $searchType = null; $searchMatch = null; $search = $searchQuery = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = PKPString::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = Handler::getRangeInfo($request, 'users'); $users = $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); import('classes.security.Validation'); $templateMgr->assign('isJournalManager', Validation::isJournalManager()); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('users', $users); $templateMgr->assign('subscriptionId', $request->getUserVar('subscriptionId')); $templateMgr->assign('pageTitle', $pageTitle); $templateMgr->assign('redirect', $redirect); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->display('subscription/users.tpl'); }