public function set($args) { if (!$this->set_file($args['id'])) { return false; } $new_obj = new NBXML(PATH_POSTS . $this->files[0], 0, TRUE, '', FALSE); $new_obj->setChild('title', $args['title']); $new_obj->setChild('content', $args['content']); $new_obj->setChild('description', $args['description']); $new_obj->setChild('allow_comments', $args['allow_comments']); $new_obj->setChild('mod_date', Date::unixstamp()); // Quote if (isset($args['quote'])) { $new_obj->setChild('quote', $args['quote']); } // --------------------------------------------------------- // Filename // --------------------------------------------------------- $file = explode('.', $this->files[0]); // Category if (isset($args['id_cat'])) { $file[2] = $args['id_cat']; } // Draft, publish $file[4] = 'NULL'; if (isset($args['mode'])) { if ($args['mode'] == 'draft') { $file[4] = 'draft'; } } // Publish date if (isset($args['unixstamp'])) { $file[0] = $args['unixstamp']; $new_obj->setChild('pub_date', $args['unixstamp']); $file[5] = Date::format_gmt($args['unixstamp'], 'Y'); $file[6] = Date::format_gmt($args['unixstamp'], 'm'); $file[7] = Date::format_gmt($args['unixstamp'], 'd'); $file[8] = Date::format_gmt($args['unixstamp'], 'H'); $file[9] = Date::format_gmt($args['unixstamp'], 'i'); $file[10] = Date::format_gmt($args['unixstamp'], 's'); } // Implode the filename $filename = implode('.', $file); // Delete the old post if ($this->delete(array('id' => $args['id']))) { // Slug $this->slug($args['id'], $args['slug']); // Save config $this->savetofile(); // Save the new post return $new_obj->asXml(PATH_POSTS . $filename); } return false; }
public function set($args) { if (!$this->set_file($args['id'])) { return false; } $new_obj = new NBXML(PATH_PAGES . $this->files[0], 0, TRUE, '', FALSE); $new_obj->setChild('title', $args['title']); $new_obj->setChild('content', $args['content']); $new_obj->setChild('description', $args['description']); $new_obj->setChild('keywords', $args['keywords']); $new_obj->setChild('position', (int) $args['position']); $new_obj->setChild('mod_date', Date::unixstamp()); // --------------------------------------------------------- // Filename // --------------------------------------------------------- $file = explode('.', $this->files[0]); // Draft, publish $file[3] = 'NULL'; if (isset($args['mode'])) { if ($args['mode'] == 'draft') { $file[3] = 'draft'; } } // Publish date if (isset($args['unixstamp'])) { $new_obj->setChild('pub_date', $args['unixstamp']); $file[4] = Date::format_gmt($args['unixstamp'], 'Y'); $file[5] = Date::format_gmt($args['unixstamp'], 'm'); $file[6] = Date::format_gmt($args['unixstamp'], 'd'); $file[7] = Date::format_gmt($args['unixstamp'], 'H'); $file[8] = Date::format_gmt($args['unixstamp'], 'i'); $file[9] = Date::format_gmt($args['unixstamp'], 's'); } // Implode the filename $filename = implode('.', $file); // Delete the old page if ($this->delete(array('id' => $args['id']))) { // Slug $slug = $this->slug_generator($args['slug']); $this->slug_add($args['id'], $slug); // Save config $this->savetofile(); // Save the new page return $new_obj->asXml(PATH_PAGES . $filename); } return false; }