public function actionLatest($cid = 0, $tid = 0) { $cid = (int) $cid; $tid = (int) $tid; $criteria = new CDbCriteria(); $title = t('post_list_table', 'admin'); if ($cid > 0) { $category = AdminCategory::model()->findByPk($cid); if ($category === null) { throw new CException(t('category_is_not_exist', 'admin')); } $title = $title . ' - ' . $category->postsLink; $criteria->addColumnCondition(array('category_id' => $cid)); } if ($tid > 0) { $topic = AdminTopic::model()->findByPk($tid); if ($topic === null) { throw new CException(t('topic_is_not_exist', 'admin')); } $title = $title . ' - ' . $topic->postsLink; $criteria->addColumnCondition(array('topic_id' => $tid)); } $criteria->addCondition('t.state != ' . POST_STATE_TRASH); $data = AdminPost::fetchList($criteria); $this->adminTitle = $title; $this->render('list', $data); }
public function actionList() { $criteria = new CDbCriteria(); $criteria->limit = param('adminCategoryCountOfPage'); $sort = new CSort('Category'); $sort->defaultOrder = 'orderid desc, id asc'; $sort->applyOrder($criteria); $pages = new CPagination(AdminCategory::model()->count($criteria)); $pages->pageSize = $criteria->limit; $pages->applyLimit($criteria); $models = AdminCategory::model()->findAll($criteria); $data = array('models' => $models, 'sort' => $sort, 'pages' => $pages); $this->render('list', $data); }
<div class="content form_create"> <article> <header> <h1>Atualizar Categoria:</h1> </header> <?php require '_models/AdminCategory.class.php'; $data = filter_input_array(INPUT_POST, FILTER_DEFAULT); $catid = filter_input(INPUT_GET, 'catid', FILTER_VALIDATE_INT); if (!empty($data['SendPostForm'])) { unset($data['SendPostForm']); $cadastra = new AdminCategory(); $cadastra->ExeUpdate($catid, $data); WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } else { $Read = new Wscategories(); $Read->setCategory_id($catid); $Read->Execute()->Query("#category_id#"); if (!$Read->Execute()->getResult()) { header("Location: painel.php?exe=categories/index&empty=true"); } else { $data = (array) $Read->Execute()->getResult()[0]; } } $checkCreate = filter_input(INPUT_GET, 'create', FILTER_VALIDATE_BOOLEAN); if ($checkCreate && empty($cadastra)) { $tipo = empty($data['category_parent']) ? 'seção' : 'categoria';
?> <div class="content form_create"> <article> <header> <h1>Criar Categoria:</h1> </header> <?php require '_models/AdminCategory.class.php'; $data = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (!empty($data['SendPostForm'])) { unset($data['SendPostForm']); $cadastra = new AdminCategory(); $cadastra->ExeCreate($data); if ($cadastra->getResult() == null) { WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } else { header('Location: painel.php?exe=categories/update&create=true&catid=' . $cadastra->getResult()); } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label"> <span class="field">Titulo:</span> <input type="text" name="category_title" value="<?php if (isset($data)) { echo $data['category_title'];
<div class="content form_create"> <article> <header> <h1>Atualizar Categoria:</h1> </header> <?php $data = filter_input_array(INPUT_POST, FILTER_DEFAULT); $catid = filter_input(INPUT_GET, 'catid', FILTER_VALIDATE_INT); if (isset($data['SendPostForm'])) { $delUlt = array_pop($data); require '_models/AdminCategory.class.php'; $cadastra = new AdminCategory(); // $cadastra->ExeCreate($data); WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } else { $read = new Read(); $read->ExeRead('ws_categories', "WHERE category_id = :id", "id={$catid}"); if (!$read->getResult()) { header('Location: painel.php?exe=categories/index&update=false'); } else { $data = $read->getResult()[0]; } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data">
<div class="content cat_list"> <section> <h1>Categorias:</h1> <?php $empty = filter_input(INPUT_GET, 'empty', FILTER_VALIDATE_BOOLEAN); if ($empty) { WSErro("Você tentou editar uma categoria que não existe no sistema!", WS_INFOR); } $delCat = filter_input(INPUT_GET, 'delete', FILTER_VALIDATE_INT); if ($delCat) { require '_models/AdminCategory.class.php'; $deletar = new AdminCategory(); $deletar->ExeDelete($delCat); WSErro($deletar->getError()[0], $deletar->getError()[1]); } $ReadSes = new WsCategories(); $ReadSes->Execute()->Query("category_parent IS NULL ORDER BY category_title ASC"); if (!$ReadSes->Execute()->getResult()) { WSErro("Desculpa, ainda não temos categorias cadastrados", WS_INFOR); } else { foreach ($ReadSes->Execute()->getResult() as $ses) { extract((array) $ses); $ReadPosts = new WsPosts(); $ReadPosts->setPost_cat_parent($category_id); $ReadPosts->Execute()->Query("#post_cat_parent#"); $ContSesPosts = $ReadPosts->Execute()->getRowCount(); $ReadSes->setCategory_parent($category_id); $ReadSes->Execute()->Query("#category_parent#");