本文整理汇总了PHP中Category::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::add方法的具体用法?PHP Category::add怎么用?PHP Category::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyCategories
/**
* modifyCategories muokkaa kategorioita poistamalla ja lisäämällä uusia
*/
public static function modifyCategories()
{
$params = $_POST;
if (!empty($params['categories'])) {
Category::remove($params['categories']);
}
if (!empty($params['newcategory'])) {
Category::add($params['newcategory']);
}
}
示例2: init
function init()
{
$obj = new Category();
$func = array_shift($this->param);
$id = array_shift($this->param);
if ($func != '') {
$_SERVER['REQUEST_METHOD'] = 'POST';
switch ($func) {
case 'add':
$data['parent_id'] = $id;
$data['name'] = $_POST['name'];
$data['active'] = true;
try {
$obj->add($data);
} catch (Exception $e) {
}
header('Location: /admin_categories');
exit;
break;
case 'save':
$data['name'] = $_POST['name'];
try {
$obj->update($id, $data);
} catch (Exception $e) {
}
header('Location: /admin_categories');
exit;
break;
case 'delete':
try {
$obj->delete($id);
} catch (Exception $e) {
}
header('Location: /admin_categories');
exit;
break;
case 'activate':
try {
$obj->invert($id);
} catch (Exception $e) {
}
header('Location: /admin_categories');
exit;
break;
}
}
}
示例3: Category
<!--head-->
<script type="text/javascript" src="../js/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="../js/tinymce/tinymce.init.js"></script>
<!--//head-->
<?php
if (isset($_POST['sveCategory']) && Tools::getRequest('sveCategory') == 'add') {
$cmscategory = new Category();
$cmscategory->copyFromPost();
$cmscategory->add();
if (is_array($cmscategory->_errors) and count($cmscategory->_errors) > 0) {
$errors = $cmscategory->_errors;
} else {
$_GET['id'] = $cmscategory->id;
UIAdminAlerts::conf('创建分类成功');
}
}
if (isset($_GET['id'])) {
$id = (int) $_GET['id'];
$obj = new Category($id);
}
if (isset($_POST['sveCategory']) && Tools::getRequest('sveCategory') == 'edit') {
if (Tools::getRequest('id_parent') == $obj->id) {
$obj->_errors[] = '父分类不能为当前分类!';
} elseif (Validate::isLoadedObject($obj)) {
$obj->copyFromPost();
$obj->update();
}
if (is_array($obj->_errors) and count($obj->_errors) > 0) {
$errors = $obj->_errors;
} else {
UIAdminAlerts::conf('更新分类成功');
示例4: productImport
public function productImport()
{
global $cookie;
$this->receiveTab();
$handle = $this->openCsvFile();
$defaultLanguageId = (int) Configuration::get('PS_LANG_DEFAULT');
self::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) {
if (Tools::getValue('convert')) {
$line = $this->utf8_encode_array($line);
}
$info = self::getMaskedRow($line);
if (array_key_exists('id', $info) and (int) $info['id'] and Product::existsInDatabase((int) $info['id'], 'product')) {
$product = new Product((int) $info['id']);
$categoryData = Product::getProductCategories((int) $product->id);
foreach ($categoryData as $tmp) {
$product->category[] = $tmp;
}
} else {
$product = new Product();
}
self::setEntityDefaultValues($product);
self::array_walk($info, array('AdminImport', 'fillInfo'), $product);
if ((int) $product->id_tax_rules_group != 0) {
if (Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group))) {
$product->tax_rate = TaxRulesGroup::getTaxesRate((int) $product->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0);
} else {
$this->_addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, Tools::displayError('Invalid tax rule group ID, you first need a group with this ID.'));
}
}
if (isset($product->manufacturer) and is_numeric($product->manufacturer) and Manufacturer::manufacturerExists((int) $product->manufacturer)) {
$product->id_manufacturer = (int) $product->manufacturer;
} elseif (isset($product->manufacturer) and is_string($product->manufacturer) and !empty($product->manufacturer)) {
if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) {
$product->id_manufacturer = (int) $manufacturer;
} else {
$manufacturer = new Manufacturer();
$manufacturer->name = $product->manufacturer;
if (($fieldError = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $manufacturer->add()) {
$product->id_manufacturer = (int) $manufacturer->id;
} else {
$this->_errors[] = $manufacturer->name . (isset($manufacturer->id) ? ' (' . $manufacturer->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
if (isset($product->supplier) and is_numeric($product->supplier) and Supplier::supplierExists((int) $product->supplier)) {
$product->id_supplier = (int) $product->supplier;
} elseif (isset($product->supplier) and is_string($product->supplier) and !empty($product->supplier)) {
if ($supplier = Supplier::getIdByName($product->supplier)) {
$product->id_supplier = (int) $supplier;
} else {
$supplier = new Supplier();
$supplier->name = $product->supplier;
if (($fieldError = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $supplier->add()) {
$product->id_supplier = (int) $supplier->id;
} else {
$this->_errors[] = $supplier->name . (isset($supplier->id) ? ' (' . $supplier->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
if (isset($product->price_tex) and !isset($product->price_tin)) {
$product->price = $product->price_tex;
} elseif (isset($product->price_tin) and !isset($product->price_tex)) {
$product->price = $product->price_tin;
// If a tax is already included in price, withdraw it from price
if ($product->tax_rate) {
$product->price = (double) number_format($product->price / (1 + $product->tax_rate / 100), 6, '.', '');
}
} elseif (isset($product->price_tin) and isset($product->price_tex)) {
$product->price = $product->price_tex;
}
if (isset($product->category) and is_array($product->category) and sizeof($product->category)) {
$product->id_category = array();
// Reset default values array
foreach ($product->category as $value) {
if (is_numeric($value)) {
if (Category::categoryExists((int) $value)) {
$product->id_category[] = (int) $value;
} else {
$categoryToCreate = new Category();
$categoryToCreate->id = (int) $value;
$categoryToCreate->name = self::createMultiLangField($value);
$categoryToCreate->active = 1;
$categoryToCreate->id_parent = 1;
// Default parent is home for unknown category to create
if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) {
$product->id_category[] = (int) $categoryToCreate->id;
} else {
$this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
} elseif (is_string($value) and !empty($value)) {
$category = Category::searchByName($defaultLanguageId, $value, true);
if ($category['id_category']) {
$product->id_category[] = (int) $category['id_category'];
} else {
$categoryToCreate = new Category();
//.........这里部分代码省略.........
示例5: productImportCreateCat
public function productImportCreateCat($default_language_id, $category_name, $id_parent_category = null)
{
$category_to_create = new Category();
$shop_is_feature_active = Shop::isFeatureActive();
if (!$shop_is_feature_active) {
$category_to_create->id_shop_default = 1;
} else {
$category_to_create->id_shop_default = (int) Context::getContext()->shop->id;
}
$category_to_create->name = AdminImportController::createMultiLangField(trim($category_name));
$category_to_create->active = 1;
$category_to_create->id_parent = (int) $id_parent_category ? (int) $id_parent_category : (int) Configuration::get('PS_HOME_CATEGORY');
// Default parent is home for unknown category to create
$category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
$category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) !== true || ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) !== true || !$category_to_create->add()) {
$this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $category_to_create->name[$default_language_id], isset($category_to_create->id) && !empty($category_to_create->id) ? $category_to_create->id : 'null');
if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
}
}
}
示例6: install
public function install()
{
if (!method_exists('Tools', 'jsonDecode') || !method_exists('Tools', 'jsonEncode')) {
return false;
}
foreach ($this->available_languages as $iso => $lang) {
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'CERTIFICATE_' . strtoupper($iso), Tools::htmlentitiesUTF8(Tools::jsonEncode(array('stateEnum' => '', 'typeEnum' => '', 'url' => '', 'tsID' => '', 'user' => '', 'password' => ''))));
}
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'SHOPSW', '');
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'ET_CID', '');
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'ET_LID', '');
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'ENV_API', TSBuyerProtection::ENV_PROD);
$req = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . TSBuyerProtection::DB_ITEMS . '` (
`id_item` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`id_product` INT NOT NULL,
`ts_id` VARCHAR( 33 ) NOT NULL,
`id` INT NOT NULL,
`currency` VARCHAR( 3 ) NOT NULL ,
`gross_fee` DECIMAL( 20, 6 ) NOT NULL ,
`net_fee` DECIMAL( 20, 6 ) NOT NULL ,
`protected_amount_decimal` INT NOT NULL ,
`protection_duration_int` INT NOT NULL ,
`ts_product_id` TEXT NOT NULL ,
`creation_date` VARCHAR( 25 ) NOT NULL
);
';
Db::getInstance()->Execute($req);
$req = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . TSBuyerProtection::DB_APPLI . '` (
`id_application` INT NOT NULL PRIMARY KEY,
`ts_id` VARCHAR( 33 ) NOT NULL,
`id_order` INT NOT NULL,
`statut_number` INT NOT NULL DEFAULT \'0\',
`creation_date` DATETIME NOT NULL,
`last_update` DATETIME NOT NULL
);
';
Db::getInstance()->Execute($req);
//add hidden category
$category = new Category();
$languages = Language::getLanguages(true);
foreach ($this->available_languages as $iso => $lang) {
$category->name[Language::getIdByIso(strtolower($iso))] = 'Trustedshops';
$category->link_rewrite[Language::getIdByIso(strtolower($iso))] = 'trustedshops';
}
// If the default lang is different than available languages :
// (Bug occurred otherwise)
if (!array_key_exists(Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT')), $this->available_languages)) {
$category->name[(int) Configuration::get('PS_LANG_DEFAULT')] = 'Trustedshops';
$category->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')] = 'trustedshops';
}
$category->id_parent = 0;
$category->level_depth = 0;
$category->active = 0;
$category->add();
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'CAT_ID', intval($category->id));
Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'SECURE_KEY', strtoupper(Tools::passwdGen(16)));
return true;
}
示例7: productImport
public function productImport()
{
global $cookie;
$this->receiveTab();
$handle = $this->openCsvFile();
$defaultLanguageId = intval(Configuration::get('PS_LANG_DEFAULT'));
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) {
if (Tools::getValue('convert')) {
$this->utf8_encode_array($line);
}
$info = self::getMaskedRow($line);
if (array_key_exists('id', $info) and intval($info['id']) and Product::existsInDatabase(intval($info['id']))) {
$product = new Product(intval($info['id']));
if ($product->reduction_from == '0000-00-00') {
$product->reduction_from = date('Y-m-d');
}
if ($product->reduction_to == '0000-00-00') {
$product->reduction_to = date('Y-m-d');
}
$categoryData = Product::getIndexedCategories(intval($product->id));
foreach ($categoryData as $tmp) {
$product->category[] = $tmp['id_category'];
}
} else {
$product = new Product();
}
self::setEntityDefaultValues($product);
self::array_walk($info, array('AdminImport', 'fillInfo'), $product);
// Find id_tax corresponding to given values for product taxe
if (isset($product->tax_rate)) {
$product->id_tax = intval(Tax::getTaxIdByRate(floatval($product->tax_rate)));
}
if (isset($product->tax_rate) and !$product->id_tax) {
$tax = new Tax();
$tax->rate = floatval($product->tax_rate);
$tax->name = self::createMultiLangField(strval($product->tax_rate));
if (($fieldError = $tax->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $tax->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $tax->add()) {
$product->id_tax = intval($tax->id);
} else {
$this->_errors[] = 'TAX ' . $tax->name[$defaultLanguageId] . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
if (isset($product->manufacturer) and is_numeric($product->manufacturer) and Manufacturer::manufacturerExists(intval($product->manufacturer))) {
$product->id_manufacturer = intval($product->manufacturer);
} elseif (isset($product->manufacturer) and is_string($product->manufacturer) and !empty($product->manufacturer)) {
if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) {
$product->id_manufacturer = intval($manufacturer);
} else {
$manufacturer = new Manufacturer();
$manufacturer->name = $product->manufacturer;
if (($fieldError = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $manufacturer->add()) {
$product->id_manufacturer = intval($manufacturer->id);
} else {
$this->_errors[] = $manufacturer->name . (isset($manufacturer->id) ? ' (' . $manufacturer->id . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
if (isset($product->supplier) and is_numeric($product->supplier) and Supplier::supplierExists(intval($product->supplier))) {
$product->id_supplier = intval($product->supplier);
} elseif (isset($product->supplier) and is_string($product->supplier) and !empty($product->supplier)) {
if ($supplier = Supplier::getIdByName($product->supplier)) {
$product->id_supplier = intval($supplier);
} else {
$supplier = new Supplier();
$supplier->name = $product->supplier;
if (($fieldError = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $supplier->add()) {
$product->id_supplier = intval($supplier->id);
} else {
$this->_errors[] = $supplier->name . (isset($supplier->id) ? ' (' . $supplier->id . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
if (isset($product->price_tex) and !isset($product->price_tin)) {
$product->price = $product->price_tex;
} elseif (isset($product->price_tin) and !isset($product->price_tex)) {
$product->price = $product->price_tin;
// If a tax is already included in price, withdraw it from price
if ($product->tax_rate) {
$product->price = floatval(number_format($product->price / (1 + $product->tax_rate / 100), 6));
}
} elseif (isset($product->price_tin) and isset($product->price_tex)) {
$product->price = $product->price_tex;
}
if (isset($product->category) and is_array($product->category) and sizeof($product->category)) {
$product->id_category = array();
// Reset default values array
foreach ($product->category as $value) {
if (is_numeric($value)) {
if (Category::categoryExists(intval($value))) {
$product->id_category[] = intval($value);
} else {
$categoryToCreate = new Category();
$categoryToCreate->id = intval($value);
$categoryToCreate->name = self::createMultiLangField($value);
$categoryToCreate->active = 1;
$categoryToCreate->id_parent = 1;
// Default parent is home for unknown category to create
//.........这里部分代码省略.........
示例8: dirname
<?php
require_once dirname(__FILE__) . '/../vendor/autoload.php';
//autoload packages
$db = new Database();
$category = new Category($db->conn);
//dump($vendors);
if ($_POST) {
//dump($_FILES);
$category->name = $_POST['name'];
$category->status = isset($_POST['status']) ? 1 : 0;
$num = 0;
//exit;
$state = false;
if ($category->add()) {
$state = true;
unset($_POST);
}
}
include 'templates/header.php';
include 'templates/sidemenu.php';
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Add vendor Item
<small>Add New vendor Items to the system</small>
</h1>
示例9: action_saveimg
/**
* 自动远程保存图片
*
*/
public function action_saveimg()
{
$source = $this->getQuery('src');
if (!URL::ping($source)) {
echo $source;
die;
}
$title = trim($this->getQuery('title'));
$data = @file_get_contents($source);
$filename = basename($source);
$extension = strtolower(strtolower(substr(strrchr($filename, '.'), 1)));
$saveName = str_replace('.', '', microtime(true));
// 保存的文件名
$disk = ORM::factory('img_disk')->where('is_use', '=', 1)->find();
$save_dir = ORM::factory('user', $this->auth['uid'])->save_dir;
$savefile = Io::strip(Io::mkdir(DOCROOT . $disk->disk_name . '/' . $save_dir) . '/' . $saveName . ".{$extension}");
$filesize = @file_put_contents($savefile, $data);
//保存文件,返回文件的size
if ($filesize == 0) {
//保存失败
@unlink($savefile);
throw new Exception('文件保存到本地目录时失败');
}
list($w, $h, $t, ) = getimagesize($savefile);
$filetype = image_type_to_mime_type($t);
if (!preg_match('/^image\\/.+/i', $filetype)) {
throw new Exception('转存文件并非有效的图片文件');
}
$category = ORM::factory('img_category')->where('cate_name', '=', '产品搬家')->where('uid', '=', $this->auth['uid'])->find();
$cate = new Category();
if (empty($category->cate_name)) {
$cate_id = $cate->add(array('cate_name' => '产品搬家', 'uid' => $this->auth['uid']));
} else {
$cate_id = $category->cate_id;
}
$movehomeSession = Session::instance()->get('movehome_id', false);
if (!empty($title)) {
if (empty($movehomeSession)) {
$cate_id = $cate->add(array('cate_name' => $title, 'uid' => $this->auth['uid'], 'parent_id' => $cate_id));
Session::instance()->set('movehome_id', $cate_id);
} else {
$cate_id = $movehomeSession;
}
}
$img = ORM::factory('img');
$img->picname = $saveName . ".{$extension}";
$img->filename = $filename;
$img->filesize = $filesize;
$img->userid = $this->auth['uid'];
$img->cate_id = $cate_id;
$img->disk_id = $disk->disk_domain;
$img->disk_name = $disk->disk_name . '/' . $save_dir;
$img->custom_name = $saveName;
$img->save();
$url = "http://" . $disk->disk_domain . '.wal8.com/' . $disk->disk_name . '/' . $save_dir . '/' . $saveName . ".{$extension}";
// 统计数据
$num = $img->where('userid', '=', $this->auth['uid'])->where('cate_id', '=', $cate_id)->count_all();
DB::update('img_categories')->set(array('img_num' => $num))->where('uid', '=', $this->auth['uid'])->where('cate_id', '=', $cate_id)->execute();
$rows = DB::select(array('sum("filesize")', 'total_size'), array('count("userid")', 'total_num'))->from('imgs')->where('userid', '=', $this->auth['uid'])->execute()->current();
DB::update('users')->set(array('use_space' => $rows['total_size'], 'count_img' => $rows['total_num']))->where('uid', '=', $this->auth['uid'])->execute();
$result = array('status' => true, 'source' => $source, 'url' => $url);
echo $url;
$this->auto_render = false;
}
示例10: addCategory
public function addCategory()
{
// Get category name from PARAMS
$categoryName = $this->f3->get('PARAMS.name');
// setup result object
$result = array('success' => false, 'status' => '', 'message' => '', 'records' => array());
// Check if category name already exists
$category = new Category($this->db);
$existingCategory = $category->filterByName($categoryName);
if ($existingCategory >= 1) {
$result[status] = 'error';
$result[message] = 'Category name already exists';
} else {
// try insert
$this->f3->set('POST.categoryName', $categoryName);
$category->add();
// Change status and message
$result[status] = 'success';
$result[success] = true;
$result[message] = 'Successfully added new category';
// return new set of categories for client
$categories = $category->all();
foreach ($categories as $category) {
$result[records][] = array('id' => $category->categoryId, 'text' => $category->categoryName);
}
}
header('Content-Type: application/json');
echo json_encode($result, JSON_NUMERIC_CHECK);
exit;
}
示例11: addCategory
public function addCategory($name, $parent_cat = false, $group_ids, $ishotel = false, $hotel_id = false)
{
if (!$parent_cat) {
$parent_cat = Category::getRootCategory()->id;
}
if ($ishotel && $hotel_id) {
$cat_id_hotel = Db::getInstance()->getValue('SELECT `id_category` FROM `' . _DB_PREFIX_ . 'htl_branch_info` WHERE id=' . $hotel_id);
if ($cat_id_hotel) {
$obj_cat = new Category($cat_id_hotel);
$obj_cat->name = array();
$obj_cat->description = array();
$obj_cat->link_rewrite = array();
foreach (Language::getLanguages(true) as $lang) {
$obj_cat->name[$lang['id_lang']] = $name;
$obj_cat->description[$lang['id_lang']] = $this->l('this category are for hotels only');
$obj_cat->link_rewrite[$lang['id_lang']] = $this->l(Tools::link_rewrite($name));
}
$obj_cat->id_parent = $parent_cat;
$obj_cat->groupBox = $group_ids;
$obj_cat->save();
$cat_id = $obj_cat->id;
return $cat_id;
}
}
$check_category_exists = Category::searchByNameAndParentCategoryId($this->context->language->id, $name, $parent_cat);
if ($check_category_exists) {
return $check_category_exists['id_category'];
} else {
$obj = new Category();
$obj->name = array();
$obj->description = array();
$obj->link_rewrite = array();
foreach (Language::getLanguages(true) as $lang) {
$obj->name[$lang['id_lang']] = $name;
$obj->description[$lang['id_lang']] = $this->l('this category are for hotels only');
$obj->link_rewrite[$lang['id_lang']] = $this->l(Tools::link_rewrite($name));
}
$obj->id_parent = $parent_cat;
$obj->groupBox = $group_ids;
$obj->add();
$cat_id = $obj->id;
return $cat_id;
}
}
示例12: header
* Created by PhpStorm.
* User: Hoan
* Date: 10/28/2015
* Time: 12:50 AM
* Thêm mới danh mục sản phẩm.
*/
//Khởi động session
session_start();
//Kiểm tra nếu chưa đăng nhập thì quay về trang đăng nhập
if (!isset($_SESSION['user'])) {
header('location:../user/login.php');
}
require '../../config/Config.php';
require '../../models/Category.php';
date_default_timezone_set('Asia/Ho_Chi_Minh');
if ($_POST) {
$data = array('name' => $_POST['name'], 'status' => isset($_POST['status']) ? 1 : 0, 'created' => date('Y-m-d H:i:s'), 'modified' => date('Y-m-d H:i:s'));
$categoryModel = new Category();
//Thêm mới
if ($categoryModel->add($data)) {
//Tạo session để lưu cờ thông báo thành công
$_SESSION['success'] = true;
//Tải lại trang (Mục đích là để reset form)
header('location:list.php');
//Ngừng thực thi
exit;
} else {
echo "That bai";
}
}
require '../../views/category/v_add.php';
示例13: action_addcate
/**
* 增加相册
*
*/
public function action_addcate()
{
$this->checkSpace();
//空间验证
if ($this->isPost()) {
$post = Validate::factory($this->getPost())->filter(TRUE, 'trim')->rule('cate_name', 'not_empty');
if ($post->check()) {
$cate = new Category();
$arr = array('cate_name' => trim($this->getPost('cate_name')), 'uid' => $this->auth['uid'], 'parent_id' => (int) $this->getPost('parent_id'));
try {
$lastId = $cate->add($arr);
$this->request->redirect('/category/list?cate_id=' . $lastId);
} catch (Exception $e) {
$this->show_message('操作失败:' . $e->getMessage());
}
} else {
$e = $post->errors('');
$this->show_message($e);
}
}
$this->auto_render = false;
}
示例14: install
public function install()
{
global $cookie;
if (!parent::install() or !Configuration::updateValue('SOCOLISSIMO_ID', NULL) or !Configuration::updateValue('SOCOLISSIMO_KEY', NULL) or !Configuration::updateValue('SOCOLISSIMO_VERSION', '1.9') or !Configuration::updateValue('SOCOLISSIMO_URL', 'https://ws.colissimo.fr/pudo-fo-frame/storeCall.do') or !Configuration::updateValue('SOCOLISSIMO_PREPARATION_TIME', 1) or !Configuration::updateValue('SOCOLISSIMO_EXP_BEL', false) or !Configuration::updateValue('SOCOLISSIMO_OVERCOST', 3.01) or !$this->registerHook('extraCarrier') or !$this->registerHook('AdminOrder') or !$this->registerHook('updateCarrier') or !Configuration::updateValue('SOCOLISSIMO_COST_SELLER', 0) or !$this->registerHook('newOrder') or !Configuration::updateValue('SOCOLISSIMO_SUP_URL', 'http://ws.colissimo.fr/supervision-pudo-frame/supervision.jsp') or !Configuration::updateValue('SOCOLISSIMO_SUP', true)) {
return false;
}
//creat config table in database
$sql = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'socolissimo_delivery_info` (
`id_cart` int(10) NOT NULL,
`id_customer` int(10) NOT NULL,
`delivery_mode` varchar(3) NOT NULL,
`prid` text(10) NOT NULL,
`prname` varchar(64) NOT NULL,
`prfirstname` varchar(64) NOT NULL,
`prcompladress` text NOT NULL,
`pradress1` text NOT NULL,
`pradress2` text NOT NULL,
`pradress3` text NOT NULL,
`pradress4` text NOT NULL,
`przipcode` text(10) NOT NULL,
`prtown` varchar(64) NOT NULL,
`cecountry` varchar(10) NOT NULL,
`cephonenumber` varchar(10) NOT NULL,
`ceemail` varchar(64) NOT NULL,
`cecompanyname` varchar(64) NOT NULL,
`cedeliveryinformation` text NOT NULL,
`cedoorcode1` varchar(10) NOT NULL,
`cedoorcode2` varchar(10) NOT NULL,
PRIMARY KEY (`id_cart`,`id_customer`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;';
if (!Db::getInstance()->Execute($sql)) {
return false;
}
//add carrier in back office
if (!$this->createSoColissimoCarrier($this->_config)) {
return false;
}
// add carrier for cost seller
if (!$this->createSoColissimoCarrierSeller($this->_config)) {
return false;
}
//add hidden category
$category = new Category();
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$category->name[$language['id_lang']] = 'SoColissimo';
$category->link_rewrite[$language['id_lang']] = 'socolissimo';
}
if ($language['iso_code'] == 'en') {
$category->name[$language['id_lang']] = 'SoColissimo';
$category->link_rewrite[$language['id_lang']] = 'socolissimo';
}
}
$category->link_rewrite = 'socolissimo';
$category->id_parent = 0;
$category->level_depth = 0;
$category->active = 0;
$category->add();
Configuration::updateValue('SOCOLISSIMO_CAT_ID', intval($category->id));
//add hidden product
$product = new Product();
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$product->name[$language['id_lang']] = 'Surcoût RDV';
$product->link_rewrite[$language['id_lang']] = 'overcost';
}
if ($language['iso_code'] == 'en') {
$product->name[$language['id_lang']] = 'Overcost';
$product->link_rewrite[$language['id_lang']] = 'overcost';
}
}
$product->quantity = 10;
$product->price = 0;
$product->id_category_default = intval($category->id);
$product->active = true;
$product->id_tax = 0;
$product->add();
Configuration::updateValue('SOCOLISSIMO_PRODUCT_ID', intval($product->id));
//add hidden product overcots belgium
$product = new Product();
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$product->name[$language['id_lang']] = 'Surcoût belgique';
$product->link_rewrite[$language['id_lang']] = 'belgium';
}
if ($language['iso_code'] == 'en') {
$product->name[$language['id_lang']] = 'Overcost Belgium';
$product->link_rewrite[$language['id_lang']] = 'belgium';
}
}
$product->quantity = 10;
$product->price = 0;
$product->id_category_default = intval($category->id);
$product->active = true;
$product->id_tax = 0;
$product->add();
Configuration::updateValue('SOCOLISSIMO_PRODUCT_ID_BELG', intval($product->id));
//.........这里部分代码省略.........
示例15: loadCategory
public function loadCategory($str_category)
{
$categoryArr = explode($this->limit, $str_category);
array_pop($categoryArr);
array_shift($categoryArr);
$id_parent = 1;
$category_paths = array();
foreach ($categoryArr as $name) {
if (!($result = $this->_catelogExists($name, $id_parent))) {
$category = new Category();
$category->copyFromPost();
$category->name = pSQL($name);
$category->active = 1;
$category->id_parent = (int) $id_parent;
$category->rewrite = pSQL(preg_replace("/[^-0-9a-zA-Z]+/", "", str_replace(' ', '-', trim($name))));
$category->add();
$id_parent = $category->id;
unset($category);
} else {
$id_parent = $result;
}
$category_paths[] = $id_parent;
}
return $category_paths;
}