Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_official / tests [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
05 Aug 2002 01:49:58postnuke_official/testsimport8.php,1.11,1.12Mike
 importing FAQs

Update of /home/cvsroot/postnuke_official/tests
In directory ns7.hostnuke.net:/tmp/cvs-serv25349

Modified Files:
	import8.php 
Log Message:
importing FAQs


Index: import8.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/tests/import8.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** import8.php	2 Aug 2002 13:14:12 -0000	1.11
--- import8.php	5 Aug 2002 01:49:56 -0000	1.12
***************
*** 201,205 ****
  
      $query = 'SELECT pn_topicid, pn_topicname, pn_topictext, pn_topicimage
!               FROM ' . $oldprefix . '_topics';
      $result = $dbconn->Execute($query);
      if ($dbconn->ErrorNo() != 0) {
--- 201,206 ----
  
      $query = 'SELECT pn_topicid, pn_topicname, pn_topictext, pn_topicimage
!               FROM ' . $oldprefix . '_topics
!               ORDER BY pn_topicid ASC';
      $result = $dbconn->Execute($query);
      if ($dbconn->ErrorNo() != 0) {
***************
*** 219,223 ****
  
      $query = 'SELECT pn_catid, pn_title
!               FROM ' . $oldprefix . '_stories_cat';
      $result = $dbconn->Execute($query);
      if ($dbconn->ErrorNo() != 0) {
--- 220,225 ----
  
      $query = 'SELECT pn_catid, pn_title
!               FROM ' . $oldprefix . '_stories_cat
!               ORDER BY pn_catid ASC';
      $result = $dbconn->Execute($query);
      if ($dbconn->ErrorNo() != 0) {
***************
*** 258,263 ****
      $regid = pnModGetIDFromName('articles');
      $query = 'SELECT pn_sid, pn_title, pn_hometext, pn_bodytext, pn_aid,
!                      UNIX_TIMESTAMP(pn_time), pn_language, pn_catid, pn_topic
!               FROM ' . $oldprefix . '_stories';
      $numitems = 1000;
      if (!isset($startnum)) {
--- 260,267 ----
      $regid = pnModGetIDFromName('articles');
      $query = 'SELECT pn_sid, pn_title, pn_hometext, pn_bodytext, pn_aid,
!                      UNIX_TIMESTAMP(pn_time), pn_language, pn_catid, pn_topic,
!                      pn_notes, pn_ihome
!               FROM ' . $oldprefix . '_stories
!               ORDER BY pn_sid ASC';
      $numitems = 1000;
      if (!isset($startnum)) {
***************
*** 278,285 ****
      while (!$result->EOF) {
          list($aid, $title, $summary, $body, $authorid, $pubdate, $language,
!             $cat, $topic) = $result->fields;
          $insert = 'INSERT INTO ' . $pntable['articles'] . ' 
                       (pn_aid, pn_title, pn_summary, pn_body, pn_authorid,
!                      pn_pubdate, pn_pubtypeid, pn_pages, pn_language)
                     VALUES (' .
                       pnVarPrepForStore($aid) . ",'" .
--- 282,295 ----
      while (!$result->EOF) {
          list($aid, $title, $summary, $body, $authorid, $pubdate, $language,
!             $cat, $topic, $notes, $ihome) = $result->fields;
!         if (empty($ihome)) {
!             $status = 3;
!         } else {
!             $status = 2;
!         }
          $insert = 'INSERT INTO ' . $pntable['articles'] . ' 
                       (pn_aid, pn_title, pn_summary, pn_body, pn_authorid,
!                      pn_pubdate, pn_pubtypeid, pn_pages, pn_notes,
!                      pn_status, pn_language)
                     VALUES (' .
                       pnVarPrepForStore($aid) . ",'" .
***************
*** 291,294 ****
--- 301,306 ----
                       '1' . "','" .
                       '0' . "','" .
+                      pnVarPrepForStore($notes) . "','" .
+                      pnVarPrepForStore($status) .  "','" .
                       pnVarPrepForStore($language) . "')";
          $dbconn->Execute($insert);
***************
*** 316,320 ****
      }
      $result->Close();
!     echo "<strong>TODO : add notes, comments etc.</strong><br><br>\n";
      echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;';
      if ($count > $numitems && $startnum + $numitems < $count) {
--- 328,332 ----
      }
      $result->Close();
!     echo "<strong>TODO : add comments etc.</strong><br><br>\n";
      echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;';
      if ($count > $numitems && $startnum + $numitems < $count) {
***************
*** 322,327 ****
          echo '<a href="import8.php?step=' . $step . '&startnum=' . $startnum . '">Go to step ' . $step . ' - articles ' . $startnum . '+ of ' . $count . '</a><br>';
      } else {
!         // OK, we still have something to do here :-)
!         echo '<a href="import8.php?step=' . ($step+2) . '">Go to step ' . ($step+2) . '</a><br>';
      }
      }
--- 334,429 ----
          echo '<a href="import8.php?step=' . $step . '&startnum=' . $startnum . '">Go to step ' . $step . ' - articles ' . $startnum . '+ of ' . $count . '</a><br>';
      } else {
!         echo '<a href="import8.php?step=' . ($step+1) . '">Go to step ' . ($step+1) . '</a><br>';
!     }
!     }
! 
!     if ($step == 4) {
!     $topics = pnModGetVar('import','topics');
!     $topicid = unserialize(pnModGetVar('import','topicid'));
!     $categories = pnModGetVar('import','categories');
!     $catid = unserialize(pnModGetVar('import','catid'));
!     echo "<strong>4. Importing queued articles</strong><br>\n";
!     $query = 'SELECT COUNT(*) FROM ' . $oldprefix . '_queue';
!     $result = $dbconn->Execute($query);
!     if ($dbconn->ErrorNo() != 0) {
!         die("Oops, count queue failed : " . $dbconn->ErrorMsg());
!     }
!     $count = $result->fields[0];
!     $result->Close();
!     $regid = pnModGetIDFromName('articles');
!     $query = 'SELECT pn_qid, pn_subject, pn_story, pn_bodytext, pn_uid,
!                      UNIX_TIMESTAMP(pn_timestamp), pn_language, pn_topic,
!                      pn_arcd
!               FROM ' . $oldprefix . '_queue
!               ORDER BY pn_qid ASC';
!     $numitems = 1000;
!     if (!isset($startnum)) {
!         $startnum = 0;
!     }
!     if ($count > $numitems) {
!         $result = $dbconn->SelectLimit($query, $numitems, $startnum);
!     } else {
!         $result = $dbconn->Execute($query);
!     }
!     if ($dbconn->ErrorNo() != 0) {
!         die("Oops, select queue failed : " . $dbconn->ErrorMsg());
!     }
!     $num = 1;
!     while (!$result->EOF) {
!         list($qid, $title, $summary, $body, $authorid, $pubdate, $language,
!             $topic, $arcd) = $result->fields;
!         if (empty($arcd)) {
!             $status = 0;
!         } else {
!             $status = 1;
!         }
!         $nextId = $dbconn->GenId($pntable['articles']);
!         $notes = '';
!         $insert = 'INSERT INTO ' . $pntable['articles'] . ' 
!                      (pn_aid, pn_title, pn_summary, pn_body, pn_authorid,
!                      pn_pubdate, pn_pubtypeid, pn_pages, pn_notes,
!                      pn_status, pn_language)
!                    VALUES (' .
!                      pnVarPrepForStore($nextId) . ",'" .
!                      pnVarPrepForStore($title) . "','" .
!                      pnVarPrepForStore($summary) . "','" .
!                      pnVarPrepForStore($body) . "','" .
!                      pnVarPrepForStore($authorid) . "','" .
!                      pnVarPrepForStore($pubdate) . "','" .
!                      '1' . "','" .
!                      '0' . "','" .
!                      pnVarPrepForStore($notes) . "','" .
!                      pnVarPrepForStore($status) .  "','" .
!                      pnVarPrepForStore($language) . "')";
!         $dbconn->Execute($insert);
!         if ($dbconn->ErrorNo() != 0) {
!             echo "Insert queued article ($qid) $title failed : " . $dbconn->ErrorMsg() ."<br>\n";
!         } elseif ($count < 200) {
!             echo "Inserted queued article ($qid) $title<br>\n";
!         } elseif ($num % 100 == 0) {
!             echo "Inserted queued article " . ($num + $startnum) . "<br>\n";
!             flush();
!         }
!         $num++;
!         $cids = array();
!         if (isset($topicid[$topic])) {
!             $cids[] = $topicid[$topic];
!         }
!         // Get aid to return
!         $aid = $dbconn->PO_Insert_ID($pntable['articles'], 'pn_aid');
!         pnModAPIFunc('categories', 'admin', 'linkcat', array(
!                      'cids' => $cids,
!                      'iids' => array($aid),
!                      'modid' => $regid ));
!         $result->MoveNext();
!     }
!     $result->Close();
!     echo "<strong>TODO : add comments etc.</strong><br><br>\n";
!     echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;';
!     if ($count > $numitems && $startnum + $numitems < $count) {
!         $startnum += $numitems;
!         echo '<a href="import8.php?step=' . $step . '&startnum=' . $startnum . '">Go to step ' . $step . ' - articles ' . $startnum . '+ of ' . $count . '</a><br>';
!     } else {
!         echo '<a href="import8.php?step=' . ($step+1) . '">Go to step ' . ($step+1) . '</a><br>';
      }
      }
***************
*** 340,344 ****
      if ($sections > 0) {
          $query = 'SELECT pn_secid, pn_secname, pn_image
!                   FROM ' . $oldprefix . '_sections';
          $result = $dbconn->Execute($query);
          if ($dbconn->ErrorNo() != 0) {
--- 442,447 ----
      if ($sections > 0) {
          $query = 'SELECT pn_secid, pn_secname, pn_image
!                   FROM ' . $oldprefix . '_sections
!                   ORDER BY pn_secid ASC';
          $result = $dbconn->Execute($query);
          if ($dbconn->ErrorNo() != 0) {
***************
*** 370,374 ****
      echo "<strong>6. Importing section content</strong><br>\n";
      $query = 'SELECT pn_artid, pn_secid, pn_title, pn_content, pn_language
!               FROM ' . $oldprefix . '_seccont';
      $result = $dbconn->Execute($query);
      if ($dbconn->ErrorNo() != 0) {
--- 473,478 ----
      echo "<strong>6. Importing section content</strong><br>\n";
      $query = 'SELECT pn_artid, pn_secid, pn_title, pn_content, pn_language
!               FROM ' . $oldprefix . '_seccont
!               ORDER BY pn_artid ASC';
      $result = $dbconn->Execute($query);
      if ($dbconn->ErrorNo() != 0) {
***************
*** 380,384 ****
          $insert = 'INSERT INTO ' . $pntable['articles'] . ' 
                       (pn_aid, pn_title, pn_summary, pn_body, pn_authorid,
!                      pn_pubdate, pn_pubtypeid, pn_pages, pn_language)
                     VALUES (' . 
                       pnVarPrepForStore($nextId) . ",'" .
--- 484,489 ----
          $insert = 'INSERT INTO ' . $pntable['articles'] . ' 
                       (pn_aid, pn_title, pn_summary, pn_body, pn_authorid,
!                      pn_pubdate, pn_pubtypeid, pn_pages, pn_status,
!                      pn_language)
                     VALUES (' . 
                       pnVarPrepForStore($nextId) . ",'" .
***************
*** 390,393 ****
--- 495,499 ----
                       '2' . "','" .
                       '0' . "','" .
+                      '2' . "','" .
                       pnVarPrepForStore($language) . "')";
          $dbconn->Execute($insert);
***************
*** 415,418 ****
--- 521,636 ----
      }
      $result->Close();
+     echo "<strong>TODO : support page breaks in articles :-)</strong><br><br>\n";
+     echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;
+           <a href="import8.php?step=' . ($step+1) . '">Go to step ' . ($step+1) . '</a><br>';
+     }
+ 
+     if ($step == 7) {
+     echo "<strong>7. Importing old FAQs into categories</strong><br>\n";
+     echo "Creating root for old FAQs<br>\n";
+     $faqs = pnModAPIFunc('categories', 'admin', 'create', array(
+                              'name' => 'FAQs',
+                              'description' => 'Root for old FAQs',
+                              'parent_id' => 0));
+     if ($reset) {
+         pnModSetVar('articles', 'number_of_categories.4', 1);
+         pnModSetVar('articles', 'cids.4', $faqs);
+     }
+     if ($faqs > 0) {
+         $query = 'SELECT pn_id_cat, pn_categories, pn_parent_id
+                   FROM ' . $oldprefix . '_faqcategories 
+                   ORDER BY pn_parent_id ASC, pn_id_cat ASC';
+         $result = $dbconn->Execute($query);
+         if ($dbconn->ErrorNo() != 0) {
+             die("Oops, select faqcategories failed : " . $dbconn->ErrorMsg());
+         }
+         // set parent 0 to root FAQ category
+         $faqid[0] = $faqs;
+         while (!$result->EOF) {
+             list($id, $name, $parent) = $result->fields;
+             if (!isset($parent) || $parent < 0) {
+                 $parent = 0;
+             }
+             if (!isset($faqid[$parent])) {
+                 echo "Oops, missing parent $parent for FAQ ($id) $name<br>\n";
+             } else {
+                 $faqid[$id] = pnModAPIFunc('categories', 'admin', 'create',
+                                            array('name' => $name,
+                                            'description' => "$name FAQ",
+                                            'parent_id' => $faqid[$parent]));
+                 echo "Creating FAQ ($id) $name [parent $parent]<br>\n";
+             }
+             $result->MoveNext();
+         }
+         $result->Close();
+     }
+     pnModSetVar('import','faqs',$faqs);
+     pnModSetVar('import','faqid',serialize($faqid));
+     echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;
+           <a href="import8.php?step=' . ($step+1) . '">Go to step ' . ($step+1) . '</a><br>';
+     }
+ 
+     if ($step == 8) {
+     $regid = pnModGetIDFromName('articles');
+     $faqs = pnModGetVar('import','faqs');
+     $faqid = unserialize(pnModGetVar('import','faqid'));
+     echo "<strong>8. Importing FAQ questions & answers</strong><br>\n";
+     $query = 'SELECT pn_id, pn_id_cat, pn_question, pn_answer, pn_submittedby
+               FROM ' . $oldprefix . '_faqanswer
+               ORDER BY pn_id ASC';
+     $result = $dbconn->Execute($query);
+     if ($dbconn->ErrorNo() != 0) {
+         die("Oops, select faq answer failed : " . $dbconn->ErrorMsg());
+     }
+     while (!$result->EOF) {
+         list($id, $catid, $title, $content, $notes) = $result->fields;
+         $language = '';
+         $nextId = $dbconn->GenId($pntable['articles']);
+         $insert = 'INSERT INTO ' . $pntable['articles'] . ' 
+                      (pn_aid, pn_title, pn_summary, pn_body, pn_authorid,
+                      pn_pubdate, pn_pubtypeid, pn_pages, pn_notes,
+                      pn_status, pn_language)
+                    VALUES (' . 
+                      pnVarPrepForStore($nextId) . ",'" .
+                      pnVarPrepForStore($title) . "','" .
+                      '' . "','" .
+                      pnVarPrepForStore($content) . "','" .
+                      '1' . "','" .
+                      '0' . "','" .
+                      '4' . "','" .
+                      '0' . "','" .
+                      pnVarPrepForStore($notes) . "','" .
+                      '2' . "','" .
+                      pnVarPrepForStore($language) .  "')";
+         $dbconn->Execute($insert);
+         if ($dbconn->ErrorNo() != 0) {
+             echo "Insert FAQ ($id) $title failed : " . $dbconn->ErrorMsg() ."<br>\n";
+         } else {
+             echo "Inserted FAQ ($id) $title<br>\n";
+         }
+         $cids = array();
+     // TODO: check if we want to add articles to the Sections root too or not
+         //$cids[] = $sections;
+         if (isset($faqid[$catid])) {
+             $cids[] = $faqid[$catid];
+         }
+         if (count($cids) == 0) {
+             $cids[] = $faqs;
+         }
+         // Get aid to return
+         $aid = $dbconn->PO_Insert_ID($pntable['articles'], 'pn_aid');
+         pnModAPIFunc('categories', 'admin', 'linkcat', array(
+                      'cids' => $cids,
+                      'iids' => array($aid),
+                      'modid' => $regid ));
+         $result->MoveNext();
+     }
+     $result->Close();
+     echo "<strong>TODO : do something with FAQ display</strong><br><br>\n";
+ // the end - for now...
+ //    echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;
+ //          <a href="import8.php?step=' . ($step+1) . '">Go to step ' . ($step+1) . '</a><br>';
+ //    }
+ 
      echo "<strong>TODO : import the rest...</strong><br><br>\n";
      pnModDelVar('import','oldprefix');
***************
*** 426,429 ****
--- 644,649 ----
      pnModDelVar('import','sections');
      pnModDelVar('import','sectionid');
+     pnModDelVar('import','faqs');
+     pnModDelVar('import','faqid');
      echo '<a href="import8.php">Return to start</a>&nbsp;&nbsp;&nbsp;
            <a href="index.php">Go to your imported site</a><br>';


Directory filter : [ all ] / postnuke_official / tests [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3