function savepost(tpost $post) { if ($post->posted == 0) { $post->posted = time(); } $post->modified = time(); $posts = tposts::instance(); if (dbversion) { //tfiler::log($post->id); $self = tposttransform::instance($post); $values = array('id' => $post->id); foreach (tposttransform::$props as $name) { $values[$name] = $self->__get($name); } $db = litepublisher::$db; $db->table = 'posts'; $db->insert_a($values); $post->rawdb->insert_a(array('id' => $post->id, 'created' => sqldate(), 'modified' => sqldate(), 'rawcontent' => $post->data['rawcontent'])); $db->table = 'pages'; foreach ($post->data['pages'] as $i => $content) { $db->insert_a(array('post' => $POST->id, 'page' => $i, 'content' => $content)); } } else { $posts->autoid = max($posts->autoid, $post->id); $dir = litepublisher::$paths->data . 'posts' . DIRECTORY_SEPARATOR . $post->id; if (!is_dir($dir)) { mkdir($dir, 0777); } chmod($dir, 0777); $post->save(); $posts->items[$post->id] = array('posted' => $post->posted); if ($post->status != 'published') { $posts->items[$post->id]['status'] = $post->status; } if ($post->author > 1) { $posts->items[$post->id]['author'] = $post->author; } } echo "{$post->id}\n"; flush(); }
public function CreateFirstPost() { $html = THtmlResource::instance(); $html->section = 'installation'; $lang = tlocal::instance(); $theme = ttheme::instance(); $post = tpost::instance(0); $post->title = $lang->posttitle; $post->catnames = $lang->postcategories; $post->tagnames = $lang->posttags; $post->content = $theme->parse($lang->postcontent); $posts = tposts::instance(); $posts->add($post); $icons = ticons::instance(); $cats = tcategories::instance(); $cats->setvalue($post->categories[0], 'icon', $icons->getid('news')); $comusers = tcomusers::instance($post->id); $userid = $comusers->add($lang->author, $lang->email, $lang->homeurl); echo "new comuser id = "; var_dump($userid); echo "<br>"; litepublisher::$classes->commentmanager->addcomment($post->id, $userid, $lang->postcomment); $plugins = tplugins::instance(); $plugins->lock(); //$plugins->add('oldestposts'); //$plugins->add('adminlinks'); //$plugins->add('nicedit'); $plugins->unlock(); }