public function testSetPermalink() { $c = new ae_CategoryModel(); $c->setPermalink('category-permalink-test'); $this->assertEquals($c->getPermalink(), 'category-permalink-test'); $input = 'Post "title" with Umlauten: <em>üöäß</em> und Zahlen! 4 9! '; $expected = 'post-title-with-umlauten-ueoeaess-und-zahlen-4-9-'; $c->setPermalink($input); $this->assertEquals($c->getPermalink(), $expected); }
/** * Assign the loaded category models to their post models. * @param {array} $categories Category models. */ protected function assignCategoriesToPosts($categories) { $id2Post = array(); foreach ($this->items as $item) { $id2Post[$item->getId()] = $item; } foreach ($categories as $row) { $ca = new ae_CategoryModel(); $ca->setId($row['ca_id']); $ca->setTitle($row['ca_title']); $ca->setPermalink($row['ca_permalink']); $ca->setParent($row['ca_parent']); $ca->setStatus(ae_CategoryModel::STATUS_AVAILABLE); $id2Post[$row['pc_post']]->addCategory($ca); } }
/** * Create the category. * @return {int} ID of the new category. */ function createCategory() { if (!isset($_POST['category-title'], $_POST['category-parent'], $_POST['category-permalink'])) { header('Location: ../admin.php?error=missing_data_for_category'); exit; } $permalink = trim($_POST['category-permalink']); $category = new ae_CategoryModel(); if (isset($_POST['edit-id'])) { $category->setId($_POST['edit-id']); } $category->setTitle($_POST['category-title']); $category->setParent($_POST['category-parent']); if ($permalink != '') { $category->setPermalink($permalink); } $category->save(); return $category->getId(); }