/**
  * Saves an category into the database.
  *
  * @param \GamyGoody\Domain\category $category The category to save
  */
 public function save(category $category)
 {
     $categoryData = array('cat_title' => $category->getTitle());
     if ($category->getId()) {
         // The category has already been saved : update it
         $this->getDb()->update('category', $categoryData, array('cat_id' => $category->getId()));
     } else {
         // The category has never been saved : insert it
         $this->getDb()->insert('category', $categoryData);
         // Get the id of the newly created category and set it on the entity.
         $id = $this->getDb()->lastInsertId();
         $category->setId($id);
     }
 }
Esempio n. 2
0
			  <button type="reset" name="cancel" class="red"><?php 
        echo $language['cancel'];
        ?>
</button>
			</div>
		</form>
        
<?php 
    } else {
        if (isset($_POST['published'])) {
            $_POST['published'] = true;
        } else {
            $_POST['published'] = false;
        }
        $category = new category();
        $category->setId(intval($_GET['i']));
        $category->setContent($_POST['title_1'], $_POST['description_1'], $_POST['title_2'], $_POST['description_2'], $_POST['title_3'], $_POST['description_3'], $_POST['title_4'], $_POST['description_4'], $_POST['title_5'], $_POST['description_5'], $_POST['title_6'], $_POST['description_6'], $_POST['code']);
        $category->setUserId($account["name"]);
        $category->setDateUpdate();
        $category->setPublished($_POST['published']);
        $category->setCategoryType($_POST['category_type']);
        if ($category->update()) {
            print 'sucess';
        } else {
            print 'failure';
        }
    }
} else {
    print 'error';
}
?>
Esempio n. 3
0
print $language["template"]["del"];
?>
</button>
	</div>
	<table class="db-list">
	  <tr>
		<th>#</th>
		<th>Titulo</th>
		<th>Categoria</th>
		<th>Pub.</th>
		<th>Sel.</th>
	  </tr>
	  <?php 
foreach ($article_list as $article) {
    $object_category = new category();
    $object_category->setId($article['category_id']);
    $category = $object_category->returnOneCategory();
    if ($article['published']) {
        $published = '<img src="./site-assets/images/icon_on.png" alt="on" title="publicado"/>';
    } else {
        $published = '<img src="./site-assets/images/icon_off.png" alt="off"  title="não publicado"/>';
    }
    print '<tr>' . '<td>' . $article['id'] . '</td>' . '<td>' . $article['title_1'] . '</td>' . '<td>' . $category['name_1'] . '</td>' . '<td>' . $published . '</td>' . '<td><input type="radio" name="article" value="' . $article['id'] . '"/></td>' . '</tr>';
}
?>
	</table>
	<div class="button-area">
		<button onclick="goTo('./backoffice.php?pg=article-add');" class="green"><?php 
print $language["template"]["add"];
?>
</button>  
Esempio n. 4
0
<?php

if (isset($_REQUEST['i']) && !empty($_REQUEST['i'])) {
    $object_category = new category();
    $object_category->setId($_REQUEST['i']);
    if ($object_category->delete()) {
        print 'sucess';
    } else {
        print 'error';
    }
} else {
    print 'error';
}
Esempio n. 5
0
?>
</button>
	</div>
	<table class="db-list">
	  <tr>
		<th>#</th>
		<th>Produto</th>
		<th>Categoria</th>
		<th>Pub.</th>
		<th>Sel.</th>
	  </tr>
	  <?php 
$i_last = 0;
foreach ($product_list as $product) {
    $object_category = new category();
    $object_category->setId($product['category_id']);
    $category = $object_category->returnOneCategory();
    if ($product['published']) {
        $published = '<img src="./site-assets/images/icon_on.png" alt="on" />';
    } else {
        $published = '<img src="./site-assets/images/icon_off.png" alt="off" />';
    }
    print '<tr>' . '<td>' . $product['id'] . '</td>' . '<td>' . $product['title_1'] . '</td>' . '<td>' . $category['name_1'] . '</td>' . '<td>' . $published . '</td>' . '<td><input type="radio" name="product" value="' . $product['id'] . '"/></td>' . '</tr>';
    $i_last = $product['id'];
}
?>
	</table>
	<div class="button-area">
		<button onclick="goTo('./backoffice.php?pg=product-add');" class="green"><?php 
print $language["template"]["add"];
?>