3 * this is to convert akbkhome old stuff into db.
6 require_once 'Pman.php';
8 class Pman_Cms_Import_old extends Pman
16 function get($base = '', $opts = array())
18 //$this->convertblog();
19 DB_DataObject::debugLevel(1);
23 var $bdir = '/home/svn/svn_wikidata';
24 function convertDir($din='')
26 $d = empty($din) ? $this->bdir : $this->bdir.'/'.$din;
28 foreach(scandir($d) as $f) {
29 if (!strlen($f) || $f[0] =='.') {
35 $this->convertDir(substr($ff,strlen($this->bdir)+1));
38 if (!preg_match('/\.html$/', $f)) {
39 // skip images at present.
42 $p = DB_DataObject::factory('Page');
43 $p->published = strtotime('Y-m-d H:i:s', filemtime($ff));
44 $p->title = preg_replace('/\.html$/', '', $f);
45 if (!$p->find(true)) {
48 $p->contents = file_get_contents($ff);
53 // how the old site was structured.
54 //a) directories with .img == images...
55 // only bother with HTML files..
62 function convertblog()
65 $d = DB_DataObject::factory('Category');
67 SELECT * FROM serendipity.category
70 while( $d->fetch() ) {
73 // categoryid | category_name | category_description | authorid |
77 DB_DataObject::debugLevel(1);
80 $c = DB_DataObject::factory('Category');
81 if ($c->get('short_name', $b->category_name)) {
82 $cmap[$b->categoryid] = $c->id;
84 $c = DB_DataObject::factory('Category');
86 'short_name' => $b->category_name,
87 'title' => $b->category_description,
90 $cmap[$b->categoryid] = $c->id;
91 $d = DB_DataObject::factory('Page');
101 // import blog data..
102 //DB_DataObject::debugLevel(1);
103 $d = DB_DataObject::factory('Page');
105 SELECT * FROM serendipity.entries
108 while( $d->fetch() ) {
112 $a = DB_DataObject::factory('core_person');
113 $a->get('email', 'alan@akbkhome.com');
116 //echo '<PRE>'. htmlspecialchars(print_R($ar,true));
120 $d = DB_DataObject::factory('Page');
121 $d->published = strtotime('Y-m-d H:i:s', $b->timestamp);
122 $d->title = $b->title;
123 if (!$d->find(true)) {
126 $d->setFrom($b->toArray());
129 'contents' => $b->body,
130 'comments_no' => $b->comments,
131 'trackbacks_no' => $b->trackbacks,
132 'has_extended' => $b->exflag,
133 'contents' => $b->body,
134 'author_id' => $a->id,
135 'author_name' => $a->name,
136 'category_id' => $cmap[$b->categoryid],
137 'published' => strtotime('Y-m-d H:i:s', $b->timestamp),
138 'created' => strtotime('Y-m-d H:i:s', $b->timestamp),
139 'updated' => strtotime('Y-m-d H:i:s', $b->timestamp),
140 'replaces_id' => $b->isdraft ? -1 : 0,