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(); }
public function add(tpost $post) { return tposttransform::add($post); }
public function setassoc(array $items) { if (count($items) == 0) { return array(); } $result = array(); $t = new tposttransform(); $fileitems = array(); foreach ($items as $a) { $t->post = tpost::newpost($a['class']); $t->setassoc($a); $result[] = $t->post->id; $f = $t->post->files; if (count($f)) { $fileitems = array_merge($fileitems, array_diff($f, $fileitems)); } } unset($t); if ($this->syncmeta) { tmetapost::loaditems($result); } if (count($fileitems)) { tfiles::i()->preload($fileitems); } $this->onselect($result); return $result; }