Пример #1
0
 /**
  * Return an array of search results matching the supplied
  * keyword IDs in decreasing order of match quality.
  * Keywords are supplied in an array of the following format:
  * $keywords[PAPER_SEARCH_AUTHOR] = array('John', 'Doe');
  * $keywords[PAPER_SEARCH_...] = array(...);
  * $keywords[null] = array('Matches', 'All', 'Fields');
  * @param $conference object The conference to search
  * @param $keywords array List of keywords
  * @param $publishedFrom object Search-from date
  * @param $publishedTo object Search-to date
  * @param $rangeInfo Information on the range of results to return
  */
 function &retrieveResults(&$conference, &$keywords, $publishedFrom = null, $publishedTo = null, $rangeInfo = null)
 {
     // Fetch all the results from all the keywords into one array
     // (mergedResults), where mergedResults[paper_id]
     // = sum of all the occurences for all keywords associated with
     // that paper ID.
     // resultCount contains the sum of result counts for all keywords.
     $mergedResults =& PaperSearch::_getMergedArray($conference, $keywords, $publishedFrom, $publishedTo, $resultCount);
     // Convert mergedResults into an array (frequencyIndicator =>
     // $paperId).
     // The frequencyIndicator is a synthetically-generated number,
     // where higher is better, indicating the quality of the match.
     // It is generated here in such a manner that matches with
     // identical frequency do not collide.
     $results =& PaperSearch::_getSparseArray($mergedResults, $resultCount);
     $totalResults = count($results);
     // Use only the results for the specified page, if specified.
     if ($rangeInfo && $rangeInfo->isValid()) {
         $results = array_slice($results, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
         $page = $rangeInfo->getPage();
         $itemsPerPage = $rangeInfo->getCount();
     } else {
         $page = 1;
         $itemsPerPage = max($totalResults, 1);
     }
     // Take the range of results and retrieve the Paper, Conference,
     // and associated objects.
     $results =& PaperSearch::formatResults($results);
     // Return the appropriate iterator.
     import('core.VirtualArrayIterator');
     $returner = new VirtualArrayIterator($results, $totalResults, $page, $itemsPerPage);
     return $returner;
 }
Пример #2
0
 /**
  * Show index of published papers by title.
  * @param $args array
  * @param $request PKPRequest
  */
 function titles($args, &$request)
 {
     parent::validate();
     $this->setupTemplate($request, true);
     $conference =& $request->getConference();
     $schedConf =& $request->getSchedConf();
     import('classes.schedConf.SchedConfAction');
     $publishedPaperDao = DAORegistry::getDAO('PublishedPaperDAO');
     $schedConfDao = DAORegistry::getDAO('SchedConfDAO');
     $rangeInfo = $this->getRangeInfo($request, 'search');
     $allPaperIds =& $publishedPaperDao->getPublishedPaperIdsAlphabetizedByTitle($conference ? $conference->getId() : null, $schedConf ? $schedConf->getId() : null, $rangeInfo);
     // FIXME: this is horribly inefficient.
     $paperIds = array();
     $schedConfAbstractPermissions = array();
     $schedConfPaperPermissions = array();
     foreach ($allPaperIds as $paperId) {
         $publishedPaper =& $publishedPaperDao->getPublishedPaperByPaperId($paperId);
         if (!$publishedPaper) {
             continue;
         }
         // Bonehead check (e.g. cached IDs)
         $schedConfId = $publishedPaper->getSchedConfId();
         if (!isset($schedConfAbstractPermissions[$schedConfId])) {
             unset($schedConf);
             $schedConf = $schedConfDao->getById($schedConfId);
             $schedConfAbstractPermissions[$schedConfId] = SchedConfAction::mayViewProceedings($schedConf);
             $schedConfPaperPermissions[$schedConfId] = SchedConfAction::mayViewPapers($schedConf, $conference);
         }
         if ($schedConfAbstractPermissions[$schedConfId]) {
             $paperIds[] = $paperId;
         }
     }
     $totalResults = count($paperIds);
     $paperIds = array_slice($paperIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
     import('lib.pkp.classes.core.VirtualArrayIterator');
     $results = new VirtualArrayIterator(PaperSearch::formatResults($paperIds), $totalResults, $rangeInfo->getPage(), $rangeInfo->getCount());
     $templateMgr =& TemplateManager::getManager($request);
     $templateMgr->assign_by_ref('results', $results);
     $templateMgr->display('search/titleIndex.tpl');
 }
Пример #3
0
 /**
  * Execute import/export tasks using the command-line interface.
  * @param $args Parameters to the plugin
  */
 function executeCLI($scriptName, &$args)
 {
     $command = array_shift($args);
     $xmlFile = array_shift($args);
     $conferencePath = array_shift($args);
     $schedConfPath = array_shift($args);
     $conferenceDao = DAORegistry::getDAO('ConferenceDAO');
     $schedConfDao = DAORegistry::getDAO('SchedConfDAO');
     $trackDao = DAORegistry::getDAO('TrackDAO');
     $userDao = DAORegistry::getDAO('UserDAO');
     $publishedPaperDao = DAORegistry::getDAO('PublishedPaperDAO');
     $conference =& $conferenceDao->getByPath($conferencePath);
     if ($conference) {
         $schedConf =& $schedConfDao->getByPath($schedConfPath, $conference->getId());
     }
     if (!$conference || !$schedConfPath) {
         if ($conferencePath != '') {
             echo __('plugins.importexport.native.cliError') . "\n";
             echo __('plugins.importexport.native.error.unknownConference', array('conferencePath' => $conferencePath, 'schedConfPath' => $schedConfPath)) . "\n\n";
         }
         $this->usage($scriptName);
         return;
     }
     $this->import('NativeImportDom');
     if ($xmlFile && NativeImportDom::isRelativePath($xmlFile)) {
         $xmlFile = PWD . '/' . $xmlFile;
     }
     switch ($command) {
         case 'import':
             $userName = array_shift($args);
             $user =& $userDao->getByUsername($userName);
             if (!$user) {
                 if ($userName != '') {
                     echo __('plugins.importexport.native.cliError') . "\n";
                     echo __('plugins.importexport.native.error.unknownUser', array('userName' => $userName)) . "\n\n";
                 }
                 $this->usage($scriptName);
                 return;
             }
             $doc =& $this->getDocument($xmlFile);
             $context = array('user' => $user, 'conference' => $conference, 'schedConf' => $schedConf);
             switch ($this->getRootNodeName($doc)) {
                 case 'paper':
                 case 'papers':
                     // Determine the extra context information required
                     // for importing papers.
                     switch (array_shift($args)) {
                         case 'track_id':
                             $track =& $trackDao->getTrack($trackIdentifier = array_shift($args));
                             break;
                         case 'track_name':
                             $track =& $trackDao->getTrackByTitle($trackIdentifier = array_shift($args), $schedConf->getId());
                             break;
                         case 'track_abbrev':
                             $track =& $trackDao->getTrackByAbbrev($trackIdentifier = array_shift($args), $schedConf->getId());
                             break;
                         default:
                             return $this->usage($scriptName);
                     }
                     if (!$track) {
                         echo __('plugins.importexport.native.cliError') . "\n";
                         echo __('plugins.importexport.native.export.error.trackNotFound', array('trackIdentifier' => $trackIdentifier)) . "\n\n";
                         return;
                     }
                     $context['track'] =& $track;
             }
             $result = $this->handleImport($context, $doc, $errors, $papers, true);
             if ($result) {
                 echo __('plugins.importexport.native.import.success.description') . "\n\n";
                 AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON);
                 if (!empty($papers)) {
                     echo __('paper.papers') . ":\n";
                 }
                 foreach ($papers as $paper) {
                     echo "\t" . $paper->getLocalizedTitle() . "\n";
                 }
             } else {
                 echo __('plugins.importexport.native.cliError') . "\n";
                 foreach ($errors as $error) {
                     echo "\t" . __($error[0], $error[1]) . "\n";
                 }
             }
             return;
             break;
         case 'export':
             if ($xmlFile != '') {
                 switch (array_shift($args)) {
                     case 'paper':
                         $paperId = array_shift($args);
                         $publishedPaper =& $publishedPaperDao->getPublishedPaperByBestPaperId($schedConf->getId(), $paperId);
                         if ($publishedPaper == null) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.paperNotFound', array('paperId' => $paperId)) . "\n\n";
                             return;
                         }
                         $trackDao = DAORegistry::getDAO('TrackDAO');
                         $track =& $trackDao->getTrack($publishedPaper->getTrackId());
                         if (!$this->exportPaper($schedConf, $track, $publishedPaper, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                     case 'papers':
                         $results =& PaperSearch::formatResults($args);
                         if (!$this->exportPapers($results, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                 }
             }
             break;
     }
     $this->usage($scriptName);
 }
Пример #4
0
 /**
  * Execute import/export tasks using the command-line interface.
  * @param $args Parameters to the plugin
  */
 function executeCLI($scriptName, &$args)
 {
     //		$command = array_shift($args);
     $xmlFile = array_shift($args);
     $conferencePath = array_shift($args);
     $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
     $conference =& $conferenceDao->getConferenceByPath($conferencePath);
     if (!$conference) {
         if ($conferencePath != '') {
             echo Locale::translate('plugins.importexport.nlm.cliError') . "\n";
             echo Locale::translate('plugins.importexport.nlm.export.error.unknownConference', array('conferencePath' => $conferencePath)) . "\n\n";
         }
         $this->usage($scriptName);
         return;
     }
     if ($xmlFile != '') {
         switch (array_shift($args)) {
             case 'papers':
                 $results =& PaperSearch::formatResults($args);
                 if (!$this->exportPapers($results, $xmlFile)) {
                     echo Locale::translate('plugins.importexport.nlm.cliError') . "\n";
                     echo Locale::translate('plugins.importexport.nlm.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                 }
                 return;
         }
     }
     $this->usage($scriptName);
 }