<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/routing" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mime" />
- <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mailer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-foundation" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/graham-campbell/result-type" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dragonmantank/cron-expression" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/swiftmailer/swiftmailer" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/cubist/util" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/cubist/pdf" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/cubist/net" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/opis/closure" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-iconv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
<path value="$PROJECT_DIR$/vendor/symfony/process" />
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
- <path value="$PROJECT_DIR$/vendor/symfony/mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<path value="$PROJECT_DIR$/vendor/graham-campbell/result-type" />
<path value="$PROJECT_DIR$/vendor/dragonmantank/cron-expression" />
<path value="$PROJECT_DIR$/vendor/composer" />
+ <path value="$PROJECT_DIR$/vendor/swiftmailer/swiftmailer" />
+ <path value="$PROJECT_DIR$/vendor/cubist/util" />
+ <path value="$PROJECT_DIR$/vendor/cubist/pdf" />
+ <path value="$PROJECT_DIR$/vendor/cubist/net" />
+ <path value="$PROJECT_DIR$/vendor/opis/closure" />
+ <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
+ <path value="$PROJECT_DIR$/vendor/symfony/polyfill-iconv" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
"require": {
"php": ">=7.3.0",
"laravel/framework": "^v8.64.0",
- "ext-json": "*"
+ "ext-json": "*",
+ "cubist/pdf": "dev-master"
+ },
+ "suggest": {
+ "cubist/pdf": "Allows to support PDF indexation"
},
"repositories": [
{
}
/**
- * @return array
+ * @return array[]
*/
public function process()
{
- //TODO
- return [];
+ return [$this->getIndividualDocData()];
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getIndividualDocData()
+ {
+ return ['id' => $this->getId(), 'type' => $this->getType(), 'thumb' => $this->getTitle(), 'title' => $this->getTitle(), 'url' => $this->getUrl(), 'text' => $this->getText()];
}
}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Cubist\Minisearch\Document;
+
+use Cubist\Minisearch\Document;
+use Cubist\PDF\PDFTools;
+
+class PDF extends Document
+{
+ /**
+ * @var string
+ */
+ protected $file;
+
+ public function __construct($file)
+ {
+ if (!class_exists(\Cubist\PDF\PDFTools::class)) {
+ throw new \Exception('Package cubist/pdf is required in order to index PDF documents');
+ }
+ }
+
+ public function process()
+ {
+ $base = $this->getIndividualDocData();
+
+
+ $doc = new \Cubist\PDF\Document($this->file);
+ $doc->processFullTexts();
+
+ $pages = $doc->getPages();
+
+ $res = [];
+ for ($i = 1; $i <= $pages; $i++) {
+ $page = $base;
+ $page['id'] .= '#' . $i;
+ $page['url'] .= '#' . $i;
+ $page['text'] = file_get_contents($doc->getConvertPath() . '/texts/fp' . $i . '.txt');
+ $res[] = $page;
+ }
+ return $res;
+ }
+}
\ No newline at end of file
{
$res = [];
foreach ($this->documents as $document) {
- $res[] = $document->process();
+ $res = array_merge($res,$document->process());
}
return 'const documents = ' . json_encode($res) . ';';
}