Ejemplo n.º 1
0
 public function testSetId()
 {
     $c = new ae_CategoryModel();
     $c->setId(4);
     $this->assertTrue($c->getId() === 4);
     $this->setExpectedException('Exception');
     $c->setId(-1);
 }
Ejemplo n.º 2
0
/**
 * 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();
}