/**
  * Allows a user to add a workshop category
  *
  */
 public function addAction()
 {
     $messages = array();
     $category = new Category();
     $form = $category->form();
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('name' => $form->getValue('name'), 'description' => $form->getValue('description'));
             $categoryId = $category->insert($data);
             $trigger = new Ot_Trigger();
             $data['accountId'] = Zend_Auth::getInstance()->getIdentity()->accountId;
             $trigger->setVariables($data);
             $trigger->dispatch('Category_Add');
             $this->_helper->flashMessenger->addMessage('msg-info-categoryAdded');
             $this->_helper->redirector->gotoUrl('/workshop/category/details/?categoryId=' . $categoryId);
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->form = $form;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.wysiwyg.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.wysiwyg.css');
     $this->_helper->pageTitle('workshop-category-add:title');
 }
 /**
  * 添加、修改分类结果
  */
 public function actionModified()
 {
     $Category = new Category();
     $data = WaveCommon::getFilter($_POST);
     $cid = (int) $data['cid'];
     unset($data['cid']);
     if ($cid == 0) {
         $Category->insert($data);
     } else {
         $Category->update($data, array('cid' => $cid));
     }
     $this->jumpBox('成功!', Wave::app()->homeUrl . 'categories', 1);
 }
 /**
  * Create new Category
  */
 public function create()
 {
     if ($this->slim->request->isGet()) {
         $this->slim->render('category/create.html.twig', ['sessionUser' => $this->getSessionUser()]);
     } elseif ($this->slim->request->isPost()) {
         $name = $_POST['name'];
         $newCategory = new Category($this->slim->db);
         $newCategory->setName($name);
         $newCategory->insert();
         $this->slim->flash('success', 'Category created');
         $this->slim->redirect('/categories');
     }
 }
Example #4
0
 function action()
 {
     // 子类
     $category = new Category();
     $kdgs = new Kdgs();
     $story_url = new StoryUrl();
     $current_time = date('Y-m-d H:i:s');
     $parent_category_list = $kdgs->get_parent_category($this->home_url);
     foreach ($parent_category_list as $k => $v) {
         $exists = $category->check_exists("`res_name`='kdgs' and `s_id`='{$v['s_id']}'");
         if ($exists) {
             continue;
         } else {
             $category_id = $category->insert(array('res_name' => 'kdgs', 'parent_id' => 0, 'title' => $v['title'], 's_id' => $v['s_id'], 's_p_id' => 0, 'from_url' => $this->home_url, 'link_url' => $v['link_url'], 's_cover' => $v['cover'], 'add_time' => date('Y-m-d H:i:s')));
             $story_url->insert(array('res_name' => 'category', 'res_id' => $category_id, 'field_name' => 'cover', 'source_url' => $v['cover'], 'source_file_name' => ltrim(strrchr($v['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
             echo $category_id;
             echo "<br />";
         }
     }
     // 子类
     $category_list = $category->get_list("`res_name`='kdgs' and `s_p_id`=0");
     foreach ($category_list as $k => $v) {
         $children_category_list = $kdgs->get_children_category_list($v['link_url']);
         foreach ($children_category_list as $k2 => $v2) {
             $exists = $category->check_exists("`res_name`='kdgs' and `s_id`='0' and `s_p_id`='{$v2['s_p_id']}'");
             if ($exists) {
                 continue;
             } else {
                 $category_id = $category->insert(array('res_name' => 'kdgs', 'parent_id' => $v['id'], 'title' => $v2['title'], 's_id' => 0, 's_p_id' => $v2['s_p_id'], 'from_url' => $v['link_url'], 'link_url' => $v2['link_url'], 's_cover' => $v2['cover'], 'add_time' => date('Y-m-d H:i:s')));
                 $story_url->insert(array('res_name' => 'category', 'res_id' => $category_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
                 echo "children:" . $category_id;
                 echo "<br />";
             }
         }
     }
 }
 public function run()
 {
     $date = new DateTime();
     $category[] = array('name' => 'Laptops', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Desktops', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Tablets', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Phones', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     $date = new DateTime();
     $category[] = array('name' => 'Monitors', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'use_default_eula' => 0, 'require_acceptance' => 0, 'deleted_at' => NULL, 'eula_text' => NULL);
     // Delete all the blog posts
     DB::table('categories')->truncate();
     // Insert the blog posts
     Category::insert($category);
 }
Example #6
0
<?php

///////////////////////////////////
require 'tables.php';
if (isset($_GET['categoryName'])) {
    $category_new = $_GET['categoryName'];
    $Categorys = new Category();
    $Categorys->categoryName = $category_new;
    $Categorys->insert();
}
$Categorys = new Category();
$data = $Categorys->select();
$response = json_encode($data);
echo $response;
Example #7
0
session_start();
include 'cat.php';
$cat = new Category();
if (isset($_GET['method'])) {
    $method = $_GET['method'];
} else {
    $method = $_POST['method'];
}
if (isset($_GET['id'])) {
    $id = $_GET['id'];
}
switch ($method) {
    case 'insert':
        if (isset($_POST['add_cat']) && !empty($_POST['add_cat'])) {
            $cat->name = $_POST['add_cat'];
            $cat->insert();
            header("location:../controle.php");
        } else {
            $_SESSTION['error'] = "please enter a valid name";
            header("location:../controle.php");
        }
        # code...
        break;
    case 'edit':
        # code...
        break;
    case 'delete':
        $cat->delete($id);
        header("location:../controle.php");
        # code...
        break;
Example #8
0
	private $id;
	private $name;
	private $content;
	private $cid;
	
	public function __set($name, $value) {
		$this->name = $value;
	}
	
	public function __get($name) {
		return $this->$name;
	}
	
	public function insert($row) {
		$sql = "insert into think_category values(null, '$this->name'.'$this->content'.'$this->cid')";
		mysql_query ( $sql );
	}
	
	public function delete() {
		$sql = "delete from think_category where id='$this->id'";
		mysql_query ( $sql );
	}
}

$cate=new Category();
$cate->name='电话';
$cate->content = '很好';
$cate->cid = '1';
$cate->insert();

Example #9
0
<?php

require_once "config.php";
if (isset($_POST['btn_submit'])) {
    $new_cat = new Category();
    $new_cat->name = $_POST['tb_new_cat'];
    $new_cat->insert();
    header("Location: " . SITE_ROOT . "personal");
}
Example #10
0
if ($action == "save") {
    $insert = TRUE;
    $errMsg = NULL;
    if ($name == "") {
        $errMsg = Text::getText("MissingName");
        $insert = FALSE;
    }
    if ($insert) {
        $existing = Category::getByName($name);
        if ($existing != NULL) {
            $errMsg = Text::getText("AlreadyExists");
            $insert = FALSE;
        }
    }
    if ($insert) {
        $c->insert();
        header("Location: categoryList.php");
        exit;
    } else {
        $buttonCaption = Text::getText("Add");
        include("header.php");
        print "<h2>".Text::getText("AddCategory")."</h2>";
        include("categoryForm.php");
        include("footer.php");
    }
} else {
    $title = Text::getText("AddCategory");
    $buttonCaption = Text::getText("Add");
    include("header.php");
    print "<h2>".Text::getText("AddCategory")."</h2>";
    include("categoryForm.php");
function newCategory()
{
    $results = array();
    $results['pageTitle'] = "New Article Category";
    $results['formAction'] = "newCategory";
    if (isset($_POST['saveChanges'])) {
        $category = new Category();
        $category->storeFormValues($_POST);
        $category->insert();
        header("Location: admin.php?action=listCategories&status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        header("Location: admin.php?action=listCategories");
    } else {
        $results['category'] = new Category();
        require TEMPLATE_PATH . "/admin/editCategory.php";
    }
}
Example #12
0
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.user.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.category.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "categories");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    @($prj_id = $HTTP_POST_VARS["prj_id"] ? $HTTP_POST_VARS["prj_id"] : $HTTP_GET_VARS["prj_id"]);
    $tpl->assign("project", Project::getDetails($prj_id));
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", Category::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", Category::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        Category::remove();
    }
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $tpl->assign("info", Category::getDetails($HTTP_GET_VARS["id"]));
    }
    $tpl->assign("list", Category::getList($prj_id));
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Example #13
0
                    unlink($dir . "/" . $object);
                }
            }
        }
        reset($objects);
        rmdir($dir);
    } else {
        unlink($dir);
    }
}
//------------------------------------------------------ insert new category ----------------------------------------------
if (isset($_GET['categoryName'])) {
    if (!empty($_GET['categoryName'])) {
        $category = new Category();
        $category->cName = $_GET['categoryName'];
        $responce = $category->insert();
        if ($responce == 0) {
            $responce = 'this category name already exist';
        } else {
            mkdir('../../images/products/' . $responce, 0777);
            chmod('../../images/products/' . $responce, 0777);
        }
    } else {
        $responce = 'please enter a value';
    }
}
//------------------------------------------------------ delete category ----------------------------------------------
if (isset($_GET['cID'])) {
    if (!empty($_GET['cID'])) {
        $category = new Category();
        $category->delete($_GET['cID']);
Example #14
0
require 'City.php';
require 'Category.php';
require 'Slim/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(array('debug' => true));
$app->response()->header('Content-Type', 'application/json;charset=utf-8');
$app->get('/category', function () {
    $categoryDAO = new Category();
    $result = $categoryDAO->get();
    echo json_encode($result);
});
$app->post('/category/insert', function () {
    $request = \Slim\Slim::getInstance()->request();
    $category = json_decode($request->getBody());
    $categoryDAO = new Category();
    $categoryDAO->insert($category);
    echo '{"result":"ok"}';
});
$app->post('/category/update', function () {
    $request = \Slim\Slim::getInstance()->request();
    $category = json_decode($request->getBody());
    $categoryDAO = new Category();
    $categoryDAO->update($category);
    echo '{"result":"ok"}';
});
$app->post('/category/delete', function () {
    $request = \Slim\Slim::getInstance()->request();
    $category = json_decode($request->getBody());
    $categoryDAO = new Category();
    $categoryDAO->delete($category);
    echo '{"result":"ok"}';
Example #15
0
    $idCategory = POST('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
    //
    $nameSubCategory = POST('nameSubCategory');
    ossim_valid($nameSubCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Subcategory::insert($conn, $idCategory, $nameSubCategory)) {
        // insert ok
        $msg = 'Ok! Add Subcategory';
    } else {
        // fail insert
        $msg = 'Error no add Subcategory';
    }
} elseif ($action == 'addCategory') {
    $nameCategory = POST('nameCategory');
    ossim_valid($nameCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Category::insert($conn, $nameCategory)) {
        // insert ok
        $msg = 'Ok! Add Category';
    } else {
        // fail insert
        $msg = 'Error no add Category';
    }
} elseif ($action == 'deleteCategory') {
    $idCategory = GET('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
    if (Category::delete($conn, $idCategory)) {
        // insert ok
        $msg = 'Ok! Delete Category';
    } else {
        // fail insert
        $msg = 'Error no delete Category';
Example #16
0
                 $data['data'] = _('Subcategory added successfully');
             }
         } else {
             $data['data'] = _('Error! This subcategory already exists');
         }
     } else {
         $data['data'] = ossim_get_error_clean();
     }
 } elseif ($action == 'add_category') {
     $c_name = POST('c_name') != '' ? str_replace(' ', '_', POST('c_name')) : POST('c_name');
     ossim_valid($c_name, OSS_SCORE, OSS_ALPHA, 'illegal:' . _('Category Name'));
     $data['status'] = 'error';
     $data['data'] = _('Error! Category not added');
     if (!ossim_error()) {
         if (!Category::exist($conn, $c_name)) {
             if (Category::insert($conn, $c_name)) {
                 $data['status'] = 'OK';
                 $data['data'] = _('Category added successfully');
             }
         } else {
             $data['data'] = _('Error! This category already exists');
         }
     } else {
         $data['data'] = ossim_get_error_clean();
     }
 } elseif ($action == 'delete_category') {
     $cat_id = GET('cat_id');
     ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category'));
     $data['status'] = 'error';
     $data['data'] = _('Error! Category not deleted');
     if (!ossim_error()) {
function newCategory()
{
    $results = array();
    $results['pageTitle'] = "New Article Category";
    $results['formAction'] = "newCategory";
    if (isset($_POST['saveChanges'])) {
        // User has posted the category edit form: save the new category
        $category = new Category();
        $category->storeFormValues($_POST);
        $category->insert();
        header("Location: admin.php?action=listCategories&status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        // User has cancelled their edits: return to the category list
        header("Location: admin.php?action=listCategories");
    } else {
        // User has not posted the category edit form yet: display the form
        $results['category'] = new Category();
        require TEMPLATE_PATH . "/admin/editCategory.php";
    }
}
 /**
  *保存增加的三级目录数据
  * @access public
  */
 function add_saveCategory3()
 {
     $category_3_cn = get_post_value('category_3_cn');
     $category_3_th = get_post_value('category_3_th');
     $category_3_url = get_post_value('category_3_url');
     $category_2_id = get_post_value('category_2_id');
     $category_1_id = get_post_value('category_1_id');
     $orders = get_post_value('order');
     if (!$this->verifyCategory3()) {
         echo '<br> ' . $category_3_cn . ' 已存在,请核对后重新输入。<a href="javascript:history.go(-1)">返回</a><br>';
         return;
     }
     $field = array('category_1_cn', 'category_1_th');
     $m = new Category();
     $m->clear();
     $m->setTable('vcb_product_category_1');
     $m->setField($field);
     $m->setWhere('category_1_id', '=', $category_1_id);
     $dataCategory1 = $m->select();
     print_r($dataCategory1);
     $field = array('category_2_cn', 'category_2_th');
     $m->clear();
     $m->setTable('vcb_product_category_2');
     $m->setField($field);
     $m->setWhere('category_2_id', '=', $category_2_id);
     $dataCategory2 = $m->select();
     print_r($dataCategory2);
     $category_1_cn = $dataCategory1[0]['category_1_cn'];
     $category_1_th = $dataCategory1[0]['category_1_th'];
     $category_2_cn = $dataCategory2[0]['category_2_cn'];
     $category_2_th = $dataCategory2[0]['category_2_th'];
     $field = array('category_1_id' => $category_1_id, 'category_1_cn' => trim($category_1_cn), 'category_1_th' => trim($category_1_th), 'category_2_id' => $category_2_id, 'category_2_cn' => trim($category_2_cn), 'category_2_th' => trim($category_2_th), 'category_3_cn' => trim($category_3_cn), 'category_3_th' => trim($category_3_th), 'category_3_url' => trim($category_3_url), 'orders' => $orders, 'status' => '10000');
     $m->clear();
     $m->setTable('vcb_product_category_3');
     $m->setField($field);
     $data = $m->insert();
     if (!$data) {
         echo '<br>保存失败<br>';
     } else {
         echo '<br>保存成功,<a href="addCategory3">继续添加</a>,<a href="category3">返回</a><br>';
     }
 }
Example #19
0
?>
    <!-- Main Container -->
    <div class="main-panel">
        <div class="row">
            <div class="column column-12">
                <i class="fa fa-columns"></i> Category
            </div>
            <div class="row">
                <div class="column column-5">
                    <h3>Category Edit</h3>
                    <form action="" method="post">
                        <?php 
if (isset($_POST['submit'])) {
    $cat_name = $_POST['category'];
    $category = new Category($db);
    $stmt = $category->insert($cat_name);
}
?>
                            <input type="text" name="category" placeholder="Enter name of category">
                            <br>
                            <button name="submit" type="submit">Add</button>
                            <br>
                    </form>
                    <?php 
if (isset($_GET['edit'])) {
    include "includes/update_category.php";
}
?>
                </div>
                <div class="column column-7">
                    <h3>List</h3>
Example #20
0
     if (isset($_POST["txtCatProID"])) {
         $Category->setCatID($_POST["txtCatProID"]);
     }
     if (isset($_POST["txtCatName"])) {
         $Category->setCatName($_POST["txtCatName"]);
     }
     if (isset($_POST["cboDevice"])) {
         $oDevice = new Device($_POST["cboDevice"]);
         $Category->setDevice($oDevice);
     }
     if (isset($_POST["cboBrand"])) {
         $oBrand = new Brand($_POST["cboBrand"]);
         $Category->setBrand($oBrand);
     }
     if ($control == Controls::Insert) {
         $Category->insert();
         $insert = true;
     } else {
         if ($control == Controls::Update) {
             if (isset($_POST["chkStatus"])) {
                 $Category->setStatus($_POST["chkStatus"]);
             } else {
                 $Category->setStatus(0);
             }
             $Category->update();
             $update = true;
         }
     }
 } else {
     if (isset($_GET["CatProID"]) && isset($_GET["control"])) {
         $control->setValue($_GET["control"]);
Example #21
0
 * please see the COPYING and AUTHORS files
 * that were distributed with this source code.
 */
require_once __DIR__ . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('manage/categories.tpl.html');
Auth::checkAuthentication();
$role_id = Auth::getCurrentRole();
if ($role_id < User::ROLE_MANAGER) {
    Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
@($prj_id = $_POST['prj_id'] ? $_POST['prj_id'] : $_GET['prj_id']);
$tpl->assign('project', Project::getDetails($prj_id));
if (@$_POST['cat'] == 'new') {
    $res = Category::insert();
    $tpl->assign('result', $res);
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the category was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the category.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this new category.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'update') {
    $res = Category::update();
    $tpl->assign('result', $res);
    Misc::mapMessages($res, array(1 => array('Thank you, the category was updated successfully.', Misc::MSG_INFO), -1 => array('An error occurred while trying to update the category.', Misc::MSG_ERROR), -2 => array('Please enter the title for this category.', Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'delete') {
    Category::remove();
}
if (@$_GET['cat'] == 'edit') {
    $tpl->assign('info', Category::getDetails($_GET['id']));
}
$tpl->assign('list', Category::getList($prj_id));
$tpl->displayTemplate();
 /**
  * 保存新建国家信息
  * 
  * @access public
  */
 function add_save()
 {
     //查询国家是否已存在
     $category_1 = get_post_value('category_1');
     $category_2_cn = get_post_value('category_2_cn');
     $category_2_th = get_post_value('category_2_th');
     $category_2_url = get_post_value('category_2_url');
     $orders = get_post_value('orders');
     if (!$this->verify()) {
         echo '<br> ' . $category_2_cn . ' 已存在,请核对后重新输入。<a href="javascript:history.go(-1)">返回</a><br>';
         return;
     }
     $field = array('category_1_id' => $category_1, 'category_2_cn' => trim($category_2_cn), 'category_2_th' => trim($category_2_th), 'category_2_url' => trim($category_2_url) == '' ? '#' : trim($category_2_url), 'orders' => $orders, 'status' => '10000', 'created' => date('Y-m-d H:i:s', time()), 'created_name' => '');
     $m = new Category();
     $m->clear();
     $m->setTable('vcb_product_category_2');
     $m->setField($field);
     $data = $m->insert();
     if (!$data) {
         echo '<br>保存失败<br>';
     } else {
         echo '<br>保存成功,<a href="add?category_1=' . $category_1 . '">继续添加</a>,<a href="index">返回</a><br>';
     }
 }
Example #23
0
<?php

session_start();
require "../includes/checkPermission.php";
require "../../deny/connector.php";
require "class/class.Category.php";
require "../includes/injection.php";
$catename = sqlInjection($_POST['cateName']);
$cateparent = sqlInjection($_POST['cateParent']);
$continue = $_POST['continue'];
//echo $catename."<br>".$cateparent."<br>".$continue;
if ($catename == "") {
    $_SESSION['CATEADD'] = "<h4><font color=red face=Verdana>Tên loại sản phẩm không được để trống</font></h4>";
    echo "<meta http-equiv='refresh' content='0;url=../admincp.php?opt=addcategory'>";
} else {
    $cate = new Category();
    $cate->insert($catename, $cateparent);
}
if ($continue == "OK") {
    //echo "<meta http-equiv='refresh' content='0;url=../admincp.php?opt=addcategory'>";
    header("location: ../admincp.php?opt=addcategory");
    exit;
} else {
    //echo "<meta http-equiv='refresh' content='0;url=../admincp.php?opt=listcategory'>";
    header("location: ../admincp.php?opt=listcategory");
    exit;
}