public function gettransform(tpost $post) { return tposttransform::i($post); }
function savepost($post) { if ($post->posted == 0) { $post->posted = time(); } $post->modified = time(); $posts = tposts::i(); if (dbversion) { $self = tposttransform::i($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; } } flush(); }