Наследование: extends Controller
Пример #1
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('product');
     $product_name = new Zend_Form_Element_Text('product_name');
     $product_name->setLabel('Product Name: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $id = new Zend_Form_Element_Hidden('id');
     $ProductIdExists = new Zend_Validate_Db_NoRecordExists(array('table' => 'products', 'field' => 'product_id'));
     $ProductIdExists->setMessage('This Product ID is already taken');
     $product_id = new Zend_Form_Element_Text('product_id');
     $product_id->setLabel('Product ID: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator($ProductIdExists)->addValidator('NotEmpty');
     $category = new Category();
     $categoriesList = $category->getCategoriesList();
     $category_id = new Zend_Form_Element_Select('category_id');
     $category_id->setLabel('Category: ')->addMultiOptions($categoriesList)->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $product_desc = new Zend_Form_Element_Text('product_desc');
     $product_desc->setLabel('Description ')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $product_img = new Zend_Form_Element_File('product_image');
     $product_img->setLabel('Upload an image:')->setDestination(PUBLIC_PATH . '/images');
     // ensure only 1 file
     $product_img->addValidator('Count', false, 1);
     // limit to 100K
     $product_img->addValidator('Size', false, 102400);
     // only JPEG, PNG, and GIFs
     $product_img->addValidator('Extension', false, 'jpg,png,gif');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->addElements(array($product_name, $product_id, $product_desc, $product_img, $id, $category_id, $submit));
 }
 public function testNestedCategories()
 {
     $category = new Category('Root');
     $child1 = $category->addChild('Child 1');
     $child2 = $child1->addChild('Child 2');
     $this->dm->persist($category);
     $this->dm->flush();
     $this->dm->clear();
     $category = $this->dm->find(__NAMESPACE__ . '\\Category', $category->getId());
     $this->assertNotNull($category);
     $category->setName('Root Changed');
     $children = $category->getChildren();
     $children[0]->setName('Child 1 Changed');
     $children[0]->getChild('Child 2')->setName('Child 2 Changed');
     $category->addChild('Child 2');
     $this->dm->flush();
     $this->dm->clear();
     $category = $this->dm->find(__NAMESPACE__ . '\\Category', $category->getId());
     $children = $category->getChildren();
     $this->assertEquals('Child 1 Changed', $children[0]->getName());
     $this->assertEquals('Child 2 Changed', $children[0]->getChild(0)->getName());
     $this->assertEquals('Root Changed', $category->getName());
     $this->assertEquals(2, count($category->getChildren()));
     $test = $this->dm->getDocumentCollection(__NAMESPACE__ . '\\Category')->findOne();
     $this->assertFalse(isset($test['children'][0]['children'][0]['children']));
 }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete category: ' . $this->data_object->GetName()));
        if ($this->deleted) {
            ?>
			<p>The category has been deleted.</p>
			<p><a href="/yesnosorry/categorylist.php">View all categories</a></p>
			<?php 
        } else {
            if ($this->has_permission) {
                ?>
				<p>Deleting a category cannot be undone.</p>
				<ul>
					<li>Its competitions will not be listed in a category</li>
				</ul> 
					
				<p>Are you sure you want to delete this category?</p>
				<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteCategoryUrl());
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete category" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this category.</p>
				<p><a href="/yesnosorry/categorylist.php">Go back to the list of categories</a></p>
				<?php 
            }
        }
    }
Пример #4
0
 /**
  * Builds the form
  */
 protected function build_create()
 {
     $this->addElement('header', get_lang('MakeLink'));
     $select = $this->addElement('select', 'select_link', get_lang('ChooseLink'), null, array('onchange' => 'document.create_link.submit()'));
     $linkTypes = LinkFactory::get_all_types();
     $select->addoption('[' . get_lang('ChooseLink') . ']', 0);
     $courseCode = $this->category_object->get_course_code();
     foreach ($linkTypes as $linkType) {
         // The hot potatoe link will be added "inside" the exercise option.
         if ($linkType == LINK_HOTPOTATOES) {
             continue;
         }
         $link = $this->createLink($linkType, $courseCode);
         // disable this element if the link works with a dropdownlist
         // and if there are no links left
         if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
             $select->addoption($link->get_type_name(), $linkType, 'disabled');
         } else {
             if ($link->get_type() == LINK_EXERCISE) {
                 // Adding exercise
                 $select->addoption($link->get_type_name(), $linkType);
                 // Adding hot potatoes
                 $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
                 $select->addoption('&nbsp;&nbsp;&nbsp;' . $linkHot->get_type_name(), LINK_HOTPOTATOES);
             } else {
                 $select->addoption($link->get_type_name(), $linkType);
             }
         }
     }
     if (isset($this->extra)) {
         $this->setDefaults(array('select_link' => $this->extra));
     }
 }
Пример #5
0
 function action()
 {
     $category = new Category();
     $kdgs = new Kdgs();
     $album = new Album();
     $story_url = new StoryUrl();
     $category_list = $category->get_list("`res_name`='kdgs' and `s_id`='0'");
     foreach ($category_list as $k => $v) {
         $page = 1;
         while (true) {
             $album_list = $kdgs->get_children_category_album_list($v['s_p_id'], $page);
             if (!$album_list) {
                 break;
             }
             foreach ($album_list as $k2 => $v2) {
                 $exists = $album->check_exists("`link_url` = '{$v2['url']}'");
                 if ($exists) {
                     continue;
                 }
                 $album_id = $album->insert(array('title' => $v2['title'], 'min_age' => $v2['min_age'], 'max_age' => $v2['max_age'], 'intro' => '', 's_cover' => $v2['cover'], 'link_url' => $v2['url'], 'add_time' => date('Y-m-d H:i:s')));
                 $story_url->insert(array('res_name' => 'album', 'res_id' => $album_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
             }
             $page++;
         }
     }
 }
Пример #6
0
 function Page()
 {
     parent::BasePage();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents();
     $menu = new Menu();
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category();
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
Пример #7
0
 function index()
 {
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'webboard_quizs' and parents <> 0")->order_by('orderlist', 'asc')->get_page();
     $data['categories']->webboard_quiz->order_by("id", "desc")->get();
     $this->template->build('webboard_index', $data);
 }
Пример #8
0
 function processPost($formvalues)
 {
     $session = SessionWrapper::getInstance();
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('parentid', $formvalues)) {
         unset($formvalues['parentid']);
     }
     if (isArrayKeyAnEmptyString('sectorid', $formvalues)) {
         unset($formvalues['sectorid']);
         if (!isEmptyString($formvalues['parentid'])) {
             $category = new Category();
             $category->populate($formvalues['parentid']);
             $formvalues['sectorid'] = $category->getSectorID();
         }
     }
     if (isArrayKeyAnEmptyString('level', $formvalues)) {
         unset($formvalues['level']);
     }
     if (isArrayKeyAnEmptyString('type', $formvalues)) {
         unset($formvalues['type']);
     }
     if (isArrayKeyAnEmptyString('status', $formvalues)) {
         unset($formvalues['status']);
     }
     if (isArrayKeyAnEmptyString('uneditable', $formvalues)) {
         unset($formvalues['uneditable']);
     }
     if (isArrayKeyAnEmptyString('sortorder', $formvalues)) {
         if (!isEmptyString($formvalues['parentid']) && !isEmptyString($formvalues['sectorid'])) {
             $formvalues['sortorder'] = $this->getNextSortOrder($formvalues['sectorid'], $formvalues['parentid']);
         }
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
 public function load(ObjectManager $manager)
 {
     $category = new Category();
     $category->setName("Category Name");
     $manager->persist($category);
     $manager->flush();
 }
Пример #10
0
 public function insertCategoryFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $category = new Category($this->database);
     $category->setCategory($form->values->title, $form->values->parent_id);
     $redirectTo = $this->presenter->getName();
     $this->presenter->redirect(":" . $redirectTo . ":default", array("id" => $form->values->parent_id));
 }
 /**
  * Displays categories as a tree
  *
  * @param mixed $args
  *
  * This isn't a plugin hook, but a public function call created in the Sidebar plugin.
  */
 public function widget_categories($h)
 {
     $sql = "SELECT * FROM " . TABLE_CATEGORIES . " ORDER BY category_order ASC";
     $the_cats = $h->db->get_results($h->db->prepare($sql));
     require_once LIBS . 'Category.php';
     $catObj = new Category();
     echo "<h2 class='widget_head'>" . $h->lang["categories"] . "</h2>";
     echo "<div class='widget_body'>\n";
     echo "<ul class='categories_widget'>\n";
     foreach ($the_cats as $cat) {
         $cat_level = 1;
         // top level category.
         if ($cat->category_safe_name != "all") {
             echo "<li>";
             if ($cat->category_parent > 1) {
                 $depth = $catObj->getCatLevel($h, $cat->category_id, $cat_level, $the_cats);
                 for ($i = 1; $i < $depth; $i++) {
                     echo "--- ";
                 }
             }
             $category = stripslashes(html_entity_decode(urldecode($cat->category_name), ENT_QUOTES, 'UTF-8'));
             echo "<a href='" . $h->url(array('category' => $cat->category_id)) . "'>";
             echo $category . "</a></li>\n";
         }
     }
     echo "</ul></div>\n";
 }
Пример #12
0
 public function postCategory()
 {
     $category = new Category();
     $category->name = Input::get('name');
     $category->save();
     return Response::json($category);
 }
Пример #13
0
 public function testCategory()
 {
     $category = new Category();
     $category->setDomain('http://do.main')->setTitle('News')->setDomain('https://www.example.com');
     $this->assertEquals('News', $category->getTitle());
     $this->assertEquals('https://www.example.com', $category->getDomain());
 }
Пример #14
0
 public function store()
 {
     $validator = Validator::make(Input::all(), Issue::$rules, Issue::$messages);
     //if($validator->passes()){
     $issue = new Issue();
     $issue->summary = Input::get('summary');
     $issue->detail = Input::get('detail');
     $issue->budget = 0.0;
     $issue->currentState = "TO-DO";
     $issue->points = Input::get('points');
     $issue->labels = Input::get('labels');
     $issue->iterationid = Input::get('iterationid');
     $categoryId = Input::get('categoryid');
     if ($categoryId == 0) {
         //crear categoria
         $category = new Category();
         $category->name = Input::get('category_name');
         $category->save();
         $issue->categoryid = $category->id;
     } else {
         $issue->categoryid = $categoryId;
     }
     $issue->save();
     return Redirect::to('/iterations/' . $issue->iterationid)->with('message', 'Historia creada con exito');
     /*}else{
     			return Redirect::to('iterations/'. Input::get('iterationid'))
     			->with('error', 'Ocurrieron los siguientes errores')
     			->withErrors($validator)
     			->withInput();
     		}*/
 }
Пример #15
0
 /**
  * Creates an Article object based on a DB row.
  *
  * @param array $row The DB row containing Article data.
  * @return \GoodieSotre\Domain\Categorie
  */
 protected function buildDomainObject($row)
 {
     $category = new Category();
     $category->set_cat_id($row['cat_id']);
     $category->set_cat_name($row['cat_name']);
     return $category;
 }
 public function categories($option = 'all')
 {
     if (!($categories = Cache::read('receivable_categories_' . $this->key, 'expenses'))) {
         $category = new Category();
         $categories = $category->find('all', array('conditions' => array('or' => array('Category.user_id' => $this->Authorization->User->id(), 'Category.team_id' => $this->Authorization->User->Team->id()), 'Category.parent_id' => null, 'Category.type' => 'receivables'), 'order' => 'Category.order'));
         Cache::write('receivable_categories_' . $this->key, $categories, 'expenses');
     }
     switch ($option) {
         case 'list':
             $list = array();
             foreach ($categories as $category) {
                 $list[$category['Category']['name']] = array();
                 if (sizeof($category['ChildCategory'])) {
                     foreach ($category['ChildCategory'] as $cildCategory) {
                         $list[$category['Category']['name']][$cildCategory['id']] = $cildCategory['name'];
                     }
                 } else {
                     $list[$category['Category']['name']][$category['Category']['id']] = '&nbsp;' . $category['Category']['name'];
                 }
             }
             return $list;
             break;
         default:
             return $categories;
     }
 }
Пример #17
0
 public function renderContent($setting)
 {
     $t = array('list_type' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200');
     $products = array();
     $setting = array_merge($t, $setting);
     switch ($setting['list_type']) {
         case 'newest':
             $products = Product::getNewProducts($this->lang_id, 0, (int) $setting['limit']);
             break;
         case 'featured':
             $category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id);
             $nb = (int) $setting['limit'];
             $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
             break;
         case 'bestseller':
             $products = ProductSale::getBestSalesLight((int) $this->lang_id, 0, (int) $setting['limit']);
             break;
         case 'special':
             $products = Product::getPricesDrop($this->lang_id, 0, (int) $setting['limit']);
             break;
     }
     $setting['products'] = $products;
     $output = array('type' => 'productlist', 'data' => $setting);
     return $output;
 }
Пример #18
0
function loadCategory($ext_id)
{
    global $db;
    $category = new Category($db);
    $category->loadByExtId($ext_id);
    return $category;
}
Пример #19
0
 public function category()
 {
     $col_name = "placement_category_id";
     $category = null;
     if (isset($this->{$col_name}) && is_numeric($this->{$col_name})) {
         $category_id = $this->{$col_name};
         $entry = $this->entry();
         if (empty($entry)) {
             return null;
         }
         if ($entry->class === 'entry') {
             require_once 'class.mt_category.php';
             $category = new Category();
             $loaded = $category->Load("category_id = {$category_id}");
         } else {
             require_once 'class.mt_folder.php';
             $category = new Folder();
             $loaded = $category->Load("category_id = {$category_id}");
         }
         if (!$loaded) {
             $category = null;
         }
     }
     return $category;
 }
Пример #20
0
 function delete($id = FALSE)
 {
     $c = new Category($id);
     $c->delete();
     $this->session->set_flashdata('msg', '<div class="alert alert-success">Category was succesfully deleted.</div>');
     redirect($this->agent->referrer());
 }
 /**
  * 删除
  */
 public function actionDelete($id)
 {
     $id = (int) $id;
     $Category = new Category();
     $Category->delete(array('cid' => $id));
     WaveCommon::exportResult(true, '成功!');
 }
Пример #22
0
 public function getTree()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 't.lft';
     $catRoot = new Category();
     return $catRoot->findAll($criteria);
 }
Пример #23
0
 /**
  *
  */
 public function renderContent($setting)
 {
     $t = array('categorytab' => '', 'categoryBox' => '', 'limit' => 6, 'itemsperpage' => 4, 'columns' => 4, 'order_by' => 'date_add DESC', 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
     $setting = array_merge($t, $setting);
     $porder = preg_split('#\\s+#', $setting['order_by']);
     if (!isset($porder[1])) {
         $porder[1] = null;
     }
     $output = array();
     $context = Context::getContext();
     $categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false;
     $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array();
     if ($categories) {
         $tg = array();
         foreach ($categories as $id_category) {
             $obj = new Category($id_category, $context->language->id);
             $tg['category_info'] = isset($categorytab[$id_category]) ? $categorytab[$id_category] : '';
             if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['category_info']['icon'])) {
                 $tg['category_info']['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['category_info']['icon'];
             } else {
                 $tg['category_info']['icon'] = '';
             }
             $tg['category_obj'] = $obj;
             $tg['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], $porder[0], $porder[1]);
             $output[] = $tg;
         }
     }
     $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
     $setting['categories_tabs'] = $output;
     $output = array('type' => 'categoriestabs', 'data' => $setting);
     return $output;
 }
Пример #24
0
 public function indexAction()
 {
     $categories = new Category();
     //$this->view->categories = array ('1','2','3','4');
     //$this->view->categories = $categories->fetchAll();
     //$this->_helper->actionStack('detail-list');
     //$this->_forward('detail-list');
     //$this->rrr();
     $front = Zend_Controller_Front::getInstance();
     if ($front->getRequest()->getParam('controller') == 'toy') {
         $toy_id = $front->getRequest()->getParam('toy_id');
         $Product = new Product();
         $toy = $Product->get($toy_id);
         $cat_id = $toy['categoryId'];
         $this->view->current_id = $cat_id;
         $this->view->p_type = 'toy';
     } else {
         $cat_id = $front->getRequest()->getParam('cat_id');
         $cat_id = $cat_id ? $cat_id : 0;
         $this->view->current_id = $cat_id;
         $this->view->p_type = 'category';
     }
     //print_r($cat_id);exit;
     $this->view->categories = $categories->get_sort_categories($cat_id);
 }
Пример #25
0
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6;
     $catids = $setting['categories'] ? $setting['categories'] : array();
     $orderby = $setting['orderby'] ? $setting['orderby'] : 'position';
     $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC';
     $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3;
     $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3;
     $categories = array();
     foreach ($catids as $catid) {
         $category = new Category($catid, (int) Context::getContext()->language->id);
         if ($category->id) {
             $categories[$catid]['id'] = $category->id;
             $categories[$catid]['name'] = $category->name;
             $categories[$catid]['link'] = $category->getLink();
             $products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
             Context::getContext()->controller->addColorsToProductList($products);
             $categories[$catid]['products'] = $products;
         }
     }
     $setting['leocategories'] = $categories;
     $setting['itemsperpage'] = $items_page;
     $setting['columnspage'] = $columns_page;
     $setting['scolumn'] = 12 / $columns_page;
     $setting['myTab'] = 'leocategorytab' . rand(20, rand());
     $output = array('type' => 'categoriestabs', 'data' => $setting);
     return $output;
 }
Пример #26
0
 public function run()
 {
     DB::table('categories')->delete();
     $jsonCat = json_decode(file_get_contents(url('/categories.json')));
     foreach ($jsonCat as $categoriesParent) {
         $cat = new Category();
         $cat->title = $categoriesParent->title;
         $cat->slug = last(explode('/', $categoriesParent->slug));
         $cat->save();
         foreach ($categoriesParent->children as $catChild1) {
             $cat1 = new Category();
             $cat1->title = $catChild1->title;
             $cat1->slug = last(explode('/', $catChild1->slug));
             $cat1->parent_id = $cat->id;
             $cat1->save();
             foreach ($catChild1->children as $catChild2) {
                 $cat2 = new Category();
                 $cat2->title = $catChild2->title;
                 $cat2->slug = last(explode('/', $catChild2->slug));
                 $cat2->parent_id = $cat1->id;
                 $cat2->save();
             }
         }
     }
 }
Пример #27
0
 public function renderContent($setting)
 {
     $t = array('categorytab' => '', 'categoryBox' => '', 'show_image' => 1, 'show_cat_title' => 1, 'show_description' => 0, 'limit_description' => 25, 'show_sub_category' => 0, 'limit_subcategory' => 5, 'show_nb_product' => 0, 'show_products' => 0, 'limit' => 6, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
     $setting = array_merge($t, $setting);
     $context = Context::getContext();
     //$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false;
     $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array();
     //echo "<pre>".print_r($categorytab,1); die;
     $categories = $this->getCategories($setting['categoryBox'], $context->language->id);
     if ($categories) {
         foreach ($categories as &$category) {
             $obj = new Category($category['id_category']);
             $category['nb_products'] = $obj->getProducts($context->language->id, 0, 1, null, null, true);
             $category['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], null, null, false);
             $category['id_image'] = file_exists(_PS_CAT_IMG_DIR_ . (int) $category['id_category'] . '.jpg') ? (int) $category['id_category'] : false;
             $category['subcategories'] = $this->getSubCategories($category['id_category'], $setting['limit_subcategory'], $context->language->id);
             $tg = isset($categorytab[$category['id_category']]) ? $categorytab[$category['id_category']] : '';
             if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['icon'])) {
                 $category['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['icon'];
             } else {
                 $category['icon'] = '';
             }
             $category['icon_class'] = $tg['icon_class'];
         }
     }
     $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
     $setting['categories_info'] = $categories;
     $output = array('type' => 'categoriesinfo', 'data' => $setting);
     return $output;
 }
 public function actionUpdate($id)
 {
     self::checkAdmin();
     $category = new Category();
     $products = new Product();
     $categoriesList = $category->getCategoriesListAdmin();
     $subCategoriesList = $category->getSubCategoriesListAdmin();
     $product = Product::getProductById($id);
     if (isset($_POST['save'])) {
         $options['title'] = $_POST['name'];
         $options['code'] = $_POST['code'];
         $options['price'] = $_POST['price'];
         $options['category_id'] = $_POST['category_id'];
         $options['subcategory_id'] = $_POST['subcategory_id'];
         $options['brand'] = $_POST['brand'];
         $options['info'] = $_POST['info'];
         $options['description'] = $_POST['description'];
         $options['availability'] = $_POST['availability'];
         $options['sale'] = $_POST['sale'];
         $options['is_new'] = $_POST['is_new'];
         $options['is_recommended'] = $_POST['is_recommended'];
         $options['status'] = $_POST['status'];
         if ($products->updateProductById($id, $options)) {
             if (is_uploaded_file($_FILES['image']['tmp_name'])) {
                 move_uploaded_file($_FILES['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/upload/images/products/' . $id . '.jpg');
             }
         }
         header('Location: /admin/product');
     }
     require_once ROOT . '/views/admin_product/update.php';
     return true;
 }
Пример #29
0
 public function indexAction()
 {
     $modelCategory = new Category();
     $order = 'path ASC';
     $categories = $modelCategory->getCategories(null, $order, null);
     $this->view->categories = $categories;
 }
Пример #30
0
function save_website($datas)
{
    global $templatesList;
    load_lib();
    //Etape 1 : sauvegarde du site
    require_once MODELS . DS . 'website.php';
    $websiteModel = new Website();
    $templateId = $datas['template_id'];
    $template = $templatesList[$templateId];
    $datas['tpl_layout'] = $template['layout'];
    $datas['tpl_code'] = $template['code'];
    $datas['search_engine_position'] = 'header';
    $datas['created_by'] = 1;
    $datas['modified_by'] = 1;
    $datas['online'] = 1;
    $websiteModel->save($datas);
    define('CURRENT_WEBSITE_ID', $websiteModel->id);
    //Etape 2 : sauvegarde du menu racine
    require_once MODELS . DS . 'category.php';
    $categoryModel = new Category();
    unset($categoryModel->searches_params);
    ////////////////////////////////////////////////////////
    //   INITIALISATION DE LA CATEGORIE PARENTE DU SITE   //
    $categorie = array('parent_id' => 0, 'type' => 3, 'name' => 'Racine Site ' . $websiteModel->id, 'slug' => 'racine-site-' . $websiteModel->id, 'online' => 1, 'redirect_category_id' => 0, 'display_contact_form' => 0, 'website_id' => $websiteModel->id);
    $categoryModel->save($categorie);
    return $websiteModel->id + $categoryModel->id;
}