16 import(
'lib.pkp.classes.search.SubmissionSearchIndex');
26 'ArticleSearchIndex::articleMetadataChanged',
30 if (!empty($hookResult)) {
34 $publication = $submission->getCurrentPublication();
38 foreach ($publication->getData(
'authors') as $author) {
39 $authorText = array_merge(
41 array_values((array) $author->getData(
'givenName')),
42 array_values((array) $author->getData(
'familyName')),
43 array_values(array_map(
'strip_tags', (array) $author->getData(
'affiliation'))),
44 array_values(array_map(
'strip_tags', (array) $author->getData(
'biography')))
49 import(
'classes.search.ArticleSearch');
50 $submissionId = $submission->getId();
51 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_AUTHOR, $authorText);
52 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_TITLE, $publication->getFullTitles());
53 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_ABSTRACT, $publication->getData(
'abstract'));
55 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_SUBJECT, (array) $publication->getData(
'subjects'));
56 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_DISCIPLINE, (array) $publication->getData(
'disciplines'));
57 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_TYPE, (array) $publication->getData(
'type'));
58 $this->
_updateTextIndex($submissionId, SUBMISSION_SEARCH_COVERAGE, (array) $publication->getData(
'coverage'));
66 if (
Config::getVar(
'debug',
'deprecation_warnings')) trigger_error(
'Deprecated call to articleMetadataChanged. Use submissionMetadataChanged instead.');
78 return $searchDao->deleteSubmissionKeywords($articleId, $type, $assocId);
94 'ArticleSearchIndex::submissionFileChanged',
95 array($articleId, $type, $fileId)
100 if ($hookResult ===
false || is_null($hookResult)) {
102 $file = $submissionFileDao->getLatestRevision($fileId);
107 if (isset($parser) && $parser->open()) {
109 $objectId = $searchDao->insertObject($articleId, $type, $fileId);
112 while(($text = $parser->read()) !==
false) {
126 $searchDao->deleteSubmissionKeywords($submission->getId(), SUBMISSION_SEARCH_GALLEY_FILE);
141 'ArticleSearchIndex::submissionFilesChanged',
147 if ($hookResult ===
false || is_null($hookResult)) {
149 import(
'lib.pkp.classes.submission.SubmissionFile');
151 $files = $fileDao->getLatestRevisions(
152 $article->getId(), SUBMISSION_FILE_PROOF
154 foreach ($files as $file) {
155 if ($file->getFileId()) {
158 $dependentFiles = $fileDao->getLatestRevisionsByAssocId(ASSOC_TYPE_SUBMISSION_FILE, $file->getFileId(), $article->getId(), SUBMISSION_FILE_DEPENDENT);
159 foreach ($dependentFiles as $depFile) {
160 if ($depFile->getFileId()) {
161 $this->
submissionFileChanged($article->getId(), SUBMISSION_SEARCH_SUPPLEMENTARY_FILE, $depFile->getFileId());
182 'ArticleSearchIndex::submissionFileDeleted',
183 array($articleId, $type, $assocId)
188 if ($hookResult ===
false || is_null($hookResult)) {
190 return $searchDao->deleteSubmissionKeywords($articleId, $type, $assocId);
207 'ArticleSearchIndex::articleDeleted',
222 'ArticleSearchIndex::articleChangesFinished'
233 if (
Config::getVar(
'debug',
'deprecation_warnings')) trigger_error(
'Deprecated call to articleChangesFinished. Use submissionChangesFinished instead.');
248 public function rebuildIndex($log =
false, $journal =
null, $switches = array()) {
251 'ArticleSearchIndex::rebuildIndex',
252 array($log, $journal, $switches)
257 if ($hookResult ===
false || is_null($hookResult)) {
263 if (is_a($journal,
'Journal')) die(__(
'search.cli.rebuildIndex.indexingByJournalNotSupported') .
"\n");
266 if ($log) echo __(
'search.cli.rebuildIndex.clearingIndex') .
' ... ';
268 $searchDao->clearIndex();
269 if ($log) echo __(
'search.cli.rebuildIndex.done') .
"\n";
274 $journals = $journalDao->getAll();
275 while ($journal = $journals->next()) {
278 if ($log) echo __(
'search.cli.rebuildIndex.indexing', array(
'journalName' => $journal->getLocalizedName())) .
' ... ';
280 $submissionsIterator =
Services::get(
'submission')->getMany([
'contextId' => $journal->getId()]);
281 foreach ($submissionsIterator as $submission) {
282 if ($submission->getSubmissionProgress() == 0) {
290 if ($log) echo __(
'search.cli.rebuildIndex.result', array(
'numIndexed' => $numIndexed)) .
"\n";
308 for ($i = 0, $count = count($keywords); $i < $count; $i++) {
309 if ($searchDao->insertObjectKeyword($objectId, $keywords[$i], $position) !==
null) {
324 $objectId = $searchDao->insertObject($articleId, $type, $assocId);