Ejemplo n.º 1
0
 /**
  * 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);
     }
 }
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();
}
Ejemplo n.º 3
0
 public function testSetTitle()
 {
     $c = new ae_CategoryModel();
     $c->setTitle('my-category');
     $this->assertEquals($c->getTitle(), 'my-category');
     $c->setTitle(4);
     $this->assertTrue($c->getTitle() === '4');
     $this->setExpectedException('Exception');
     $c->setTitle('');
 }