public function testSetPermalink() { $p = new ae_PostModel(); $p->setPermalink('page-permalink-test'); $this->assertEquals($p->getPermalink(), 'page-permalink-test'); $input = 'Post "title" with Umlauten: <em>üöäß</em> und Zahlen! 4 9! '; $expected = 'post-title-with-umlauten-ueoeaess-und-zahlen-4-9-'; $p->setPermalink($input); $this->assertEquals($p->getPermalink(), $expected); }
/** * Create the post. * @return {int} ID of the new post. */ function createPost() { if (!isset($_POST['post-title'], $_POST['post-permalink'], $_POST['post-content'], $_POST['post-tags'], $_POST['post-publish-month'], $_POST['post-publish-day'], $_POST['post-publish-year'], $_POST['post-publish-hour'], $_POST['post-publish-minute'], $_POST['submit'])) { header('Location: ../admin.php?error=missing_data_for_post'); exit; } $datetime = sprintf('%04d-%02d-%02d %02d:%02d:00', $_POST['post-publish-year'], $_POST['post-publish-month'], $_POST['post-publish-day'], $_POST['post-publish-hour'], $_POST['post-publish-minute']); $permalink = trim($_POST['post-permalink']); $status = $_POST['submit'] == 'draft' ? ae_PostModel::STATUS_DRAFT : ae_PostModel::STATUS_PUBLISHED; $post = new ae_PostModel(); if (isset($_POST['edit-id'])) { $post->setId($_POST['edit-id']); } $post->setTitle($_POST['post-title']); if ($permalink != '') { $post->setPermalink($permalink); } $post->setContent($_POST['post-content']); $post->setDatetime(isset($_POST['post-schedule']) ? $datetime : date('Y-m-d H:i:s')); $post->setCommentsStatus($_POST['post-comments-status']); $post->setStatus($status); $post->setTags($_POST['post-tags']); $post->setUserId(ae_Security::getCurrentUserId()); $post->save(); return $post->getId(); }