wip
[phinde.git] / src / phinde / Indexer.php
index 98b52c3a22304da42e9858e7d0588e5b7e5c2eab..4efef4284f3c0e1eca1d009298b7d100af592941 100644 (file)
@@ -16,15 +16,13 @@ class Indexer
 
         $mimetype = explode(';', $res->getHeader('content-type'))[0];
         if (!in_array($mimetype, static::$supportedTypes)) {
-            echo "MIME type not supported for indexing: $mimetype\n";
+            Log::info("MIME type not supported for indexing: $mimetype");
             return false;
         }
 
         if ($esDoc === null) {
-            $esDoc = new \stdClass();
-        }
-        if (!isset($esDoc->status)) {
-            $esDoc->status = new \stdClass();
+            $esDoc = Helper::baseDoc($url);
+            $retrieved->esDoc = $esDoc;
         }
 
         //FIXME: update index only if changed since last index time
@@ -52,8 +50,8 @@ class Indexer
             $robots = $meta->attributes->getNamedItem('content')->textContent;
             foreach (explode(',', $robots) as $value) {
                 if (trim($value) == 'noindex') {
-                    echo "URL does not want to be indexed: $url\n";
-                    exit(0);
+                    $esDoc->status->findable = false;
+                    return true;
                 }
             }
         }
@@ -79,12 +77,9 @@ class Indexer
             $xpContext = $doc->getElementById('content');
         }
 
-        $esDoc->url = $url;
-        $esDoc->schemalessUrl = Helper::noSchema($url);
         $esDoc->type = 'html';
         $esDoc->subtype = '';
         $esDoc->mimetype = $mimetype;
-        $esDoc->domain   = parse_url($url, PHP_URL_HOST);
 
         //$esDoc->source = 'FIXME';
         //$esDoc->sourcetitle = 'FIXME';
@@ -188,7 +183,6 @@ class Indexer
 
         //var_dump($esDoc);die();
 
-        $retrieved->esDoc = $esDoc;
         return true;
     }