set detected type in pingback content
[stapibas.git] / src / stapibas / Content / Extractor.php
index c54344be9f7705bb79a2d020e02a39b91ed7de6d..7de4cd56de5a79ebe2e814c60bef1e4633529517 100644 (file)
@@ -48,7 +48,7 @@ class Content_Extractor
 
         //delete old content
         $this->db->exec(
-            'DELETE FROM rboomarks WHERE'
+            'DELETE FROM rbookmarks WHERE'
             . ' rb_pc_id = ' . $this->db->quote($contentRow->pc_id)
         );
         $this->db->exec(
@@ -67,7 +67,8 @@ class Content_Extractor
             var_dump($data);
             $this->db->exec(
                 'INSERT INTO rcomments SET'
-                . '  rc_pc_id = ' . $this->db->quote($contentRow->pc_id)
+                . '  rc_p_id = ' . $this->db->quote($contentRow->p_id)
+                . ', rc_pc_id = ' . $this->db->quote($contentRow->pc_id)
                 . ', rc_source = ' . $this->db->quote($contentRow->p_source)
                 . ', rc_target = ' . $this->db->quote($contentRow->p_target)
                 . ', rc_title = ' . $this->db->quote($data['title'])
@@ -77,6 +78,7 @@ class Content_Extractor
                 . ', rc_content = ' . $this->db->quote($data['content'])
                 . ', rc_updated = NOW()'
             );
+            $this->setDetectedType($contentRow, 'comment');
             return;
         }
 
@@ -86,24 +88,35 @@ class Content_Extractor
         $data = $ce->extract($doc, $contentRow->p_source, $contentRow->p_target);
         if ($data !== null) {
             $this->log->info('Link found');
-            var_dump($data);
             $this->db->exec(
                 'INSERT INTO rlinks SET'
-                . '  rl_pc_id = ' . $this->db->quote($contentRow->pc_id)
+                . '  rl_p_id = ' . $this->db->quote($contentRow->p_id)
+                . ', rl_pc_id = ' . $this->db->quote($contentRow->pc_id)
                 . ', rl_source = ' . $this->db->quote($contentRow->p_source)
                 . ', rl_target = ' . $this->db->quote($contentRow->p_target)
                 . ', rl_title = ' . $this->db->quote($data['title'])
                 . ', rl_author_name = ' . $this->db->quote($data['author_name'])
                 . ', rl_author_url = ' . $this->db->quote($data['author_url'])
                 . ', rl_author_image = ' . $this->db->quote($data['author_image'])
-                . ', rc_updated = NOW()'
+                . ', rl_updated = NOW()'
             );
+            $this->setDetectedType($contentRow, 'link');
             return;
         }
 
+        $this->setDetectedType($contentRow, 'nothing');
         $this->log->info('Nothing found');
     }
 
+    protected function setDetectedType($contentRow, $type)
+    {
+        $this->db->exec(
+            'UPDATE pingbackcontent'
+            . ' SET pc_detected_type = ' . $this->db->quote($type)
+            . ' WHERE pc_id = ' . $this->db->quote($contentRow->pc_id)
+        );
+    }
+
 
     protected function sqlNeedsUpdate()
     {