public function formSucceeded(Form $form, $values)
 {
     // priprava managera pro praci s kategoriemi
     $category_manager = new Model\Category($this->database);
     if ($this->id == null) {
         // pridavam novou kategorii
         $category_manager->add($values);
         $form->getPresenter()->flashMessage('Nová kategorie byla přidána.');
     } else {
         $category = $this->database->findById('category', $this->id);
         if ($form['btnedit']->isSubmittedBy()) {
             // upravuji kategorii
             if ($category) {
                 $category_manager->edit($values, $category);
                 $form->getPresenter()->flashMessage('Kategorie byla upravena');
             } else {
                 $form->getPresenter()->flashMessage('Kategorii nebylo možno upravit, pravděpodobně ji někdo smazal.');
             }
         } else {
             // mazu kategorii
             if ($category) {
                 $category_manager->delete($category);
                 $form->getPresenter()->flashMessage('Kategorie byla smazána');
             } else {
                 $form->getPresenter()->flashMessage('Kategorii nebylo možno smazat, pravděpodobně ji někdo smazal.');
             }
         }
     }
     $form->getPresenter()->redirect('Admin:categories');
 }
 public function formSucceeded(Form $form, $values)
 {
     $category_manager = new Model\Category($this->database);
     if ($this->categories != null) {
         $category_manager->deleteGroup($values, $this->categories);
     }
 }
Example #3
0
 public function renderDefault($id)
 {
     $this->template->categories = $this->option->get('show_all_categories') ? $this->category->get_all() : $this->category->get_unread();
     $this->template->current_category = NULL;
     $this->template->feeds = $this->option->get('show_all_feeds') ? $this->feed->get_all() : $this->feed->get_unread();
     $this->template->current_feed = NULL;
     $this->template->unread_count = $this->category->unread_count();
 }
Example #4
0
 /**
  * @param \App\Model\Category $item
  * @param array $data
  */
 protected function preProcessEdit($item, &$data)
 {
     if ($item->id() == 1) {
         $data['parent'] = 0;
         $data['enabled'] = 1;
         $data['name'] = $item->name;
     }
 }
Example #5
0
 /**
  * @param \App\Model\Category $category
  * @return array
  */
 private function getBreadcrumbs(&$category)
 {
     $breadcrumbs = [];
     $parents = $category->parents();
     $breadcrumbs['/'] = 'Home';
     foreach ($parents as $p) {
         $breadcrumbs['/category/view?id=' . $p->categoryID] = $p->name;
     }
     $breadcrumbs[''] = $category->name;
     return $breadcrumbs;
 }
Example #6
0
 public function renderCategory($categoryUrl)
 {
     try {
         $category = $this->categoryModel->findByUrl($categoryUrl);
         $products = $this->productModel->findByCategoryId($category->id);
         $this->render(['category' => $category, 'products' => $products]);
     } catch (Model\NotFoundException $e) {
         // pridat flash message (az potom co je nejak zazracne vynaleznu)
         $this->redirectUrl($this->genUrl('eshop'));
     }
 }
Example #7
0
 public static function setFieldData()
 {
     $fieldData = array();
     $category = new Category();
     $arr = $category->getFillable();
     foreach ($arr as $v) {
         $fieldData[$v] = Input::get($v);
     }
     unset($arr);
     unset($category);
     return $fieldData;
 }
Example #8
0
 public function delete($id)
 {
     Category::find($id)->delete();
     Category::where('pid', $id)->delete();
     $ret['meta']['code'] = 1;
     echo json_encode($ret);
 }
Example #9
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $catArr = Category::getCategoryTree();
     unset($catArr[0]);
     return backendView('edit', ['article' => Article::find($id), 'catArr' => $catArr]);
 }
 public function show($id = 0)
 {
     if (!preg_match("/^[1-9]\\d*\$/", $id)) {
         return Redirect::to('/');
     }
     $type = Category::find($id);
     if (empty($type)) {
         return Redirect::to('/');
     }
     $keywords = $type->keywords;
     $description = $type->description;
     $subs = $type->subs()->get();
     if (count($subs) > 0) {
         $templet = 'sub';
         if ($type->templet_all != '') {
             $templet = $type->templet_all;
         }
         return Theme::view('category.' . $templet, compact('type', 'subs', 'keywords', 'description'));
     } else {
         $templet = 'show';
         if ($type->templet_nosub != '') {
             $templet = $type->templet_nosub;
         }
         $articles = Article::where('category_id', $id)->sortByDesc('id')->paginate(20);
         return Theme::view('category.' . $templet, compact('type', 'articles', 'keywords', 'description'));
     }
 }
Example #11
0
 public function run()
 {
     $categories = [['name' => 'Деловая литература', 'slug' => 'detectivesThrillers'], ['name' => 'Детское', 'slug' => 'for_childern'], ['name' => 'Документальная литература', 'slug' => 'nonfiction'], ['name' => 'Компьютеры и Интернет', 'slug' => 'computers_and_internet'], ['name' => 'Любовные романы', 'slug' => 'romance'], ['name' => 'Поэзия и Драматургия', 'slug' => 'science_and_education'], ['name' => 'Приключения', 'slug' => 'adventure'], ['name' => 'Проза', 'slug' => 'prose'], ['name' => 'Прочее', 'slug' => 'other'], ['name' => 'Фантастика', 'slug' => 'fiction']];
     foreach ($categories as $category) {
         \App\Model\Category::create($category);
     }
 }
Example #12
0
 public function show()
 {
     $data['categories'] = Category::where('pid', 0)->get();
     $data['activity_classification'] = ActivityClassification::all();
     $data['free_post'] = FreePost::all();
     return view('admin.goods.index', $data);
 }
Example #13
0
 public function edit(Request $request)
 {
     $id = $request->route('id');
     $cats = CategoryModel::where("cat_status_cd", "ACT")->get(["cat_id", "cat_desc"]);
     $page = PageModel::findOrFail($id);
     return view('pages.edit', compact('page', 'cats'));
 }
Example #14
0
 public function show($id = 0)
 {
     if (!preg_match("/^[1-9]\\d*\$/", $id)) {
         return Redirect::to('/');
     }
     $article = Article::find($id);
     if (empty($article)) {
         return Redirect::to('/');
     }
     $type = Category::find($article->category_id);
     if (empty($type)) {
         return Redirect::to('/');
     }
     ++$article->views;
     $article->save();
     $keywords = $article->keywords;
     $description = $article->description;
     if ($article->url != '') {
         return Redirect::to($article->url);
     }
     $templet = 'show';
     if ($type->templet_article != '') {
         $templet = $type->templet_article;
     }
     return Theme::view('article.' . $templet, compact('article', 'type', 'keywords', 'description'));
 }
Example #15
0
 public function run()
 {
     DB::table('categories')->delete();
     $categoryList = array("HTML", "CSS", "PHP", "MYSQL", "javascript", "jQuery", "jQuery UI", "CakePHP", "仕事", "java", "CentOS", "ネットワーク", "Excel", "VBA", "ECサイト", "車", "git", "AWS", "laravel", "phalcon");
     for ($i = 0; $i < count($categoryList); $i++) {
         Category::create(['user_id' => 1, 'name' => $categoryList[$i]]);
     }
 }
Example #16
0
 public function getCategoryAttribute()
 {
     $category = Category::select('id', 'name', 'pid')->find($this->category_id);
     if ($category == null) {
         return '';
     }
     return $category->toArray();
 }
Example #17
0
 public function renderList($catid = NULL)
 {
     $this->template->raceid = $this->raceid;
     $this->template->race = $this->race->getRaceInfo();
     $this->template->categories = $this->category->listAll()->order('name');
     $this->template->addFilter('startorder', function ($s) {
         return self::$start_order[$s];
     });
     if ($catid) {
         $form = $this['categoryForm'];
         $category = $this->category->load($catid);
         if (!$category) {
             $this->error('Záznam nenalezen!');
         }
         $form->setDefaults($category);
     }
 }
Example #18
0
 private function getDropboxOfCategories()
 {
     $categories = Category::all();
     $map = [];
     foreach ($categories as $category) {
         $map[$category->id] = $category->name;
     }
     return $map;
 }
Example #19
0
 public function postPost(CategoryRequest $request)
 {
     $category = new catdb();
     $category->title = $request->title;
     $category->slug = $request->slug;
     $category->description = $request->description;
     $filename = "";
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = $file->getClientOriginalName();
         $destinationPath = public_path() . '/uploads/category/';
         $file->move($destinationPath, $filename);
     }
     $category->image = asset('uploads/category/' . $filename);
     $category->save();
     Session::flash('success', "La catégorie {$category->title} est injecté dans la BDD.");
     return Redirect::route('category.index');
 }
 /**
  * Get or create root category.
  * @return null|Category
  */
 protected function getRoot()
 {
     if (!$this->rootCategory) {
         $this->rootCategory = $this->createCategory(['name' => '0_ROOT', 'enabled' => 1]);
         $this->rootCategory->refresh();
         $this->rootCategory->parent = 0;
         $this->rootCategory->save();
     }
     return $this->rootCategory;
 }
 /**
  * @param $result
  * @return IHolder
  */
 public function populate($result)
 {
     $holder = new \App\Holder\Results\Respondent\Category();
     if (isset($result["category_id_category"])) {
         $holder->setCategory(Service::populateEntity($result, \App\Model\Category::getClassName(), "category"));
     }
     if (isset($result["entitycategory_id_entity_category"])) {
         $holder->setEntitycategory(Service::populateEntity($result, EntityCategory::getClassName(), "entitycategory"));
     }
     return $holder;
 }
Example #22
0
 /**
  * カテゴリー削除
  */
 public function postDelete(Request $request)
 {
     $category = Category::findOrFail($request->id);
     DB::transaction(function () use($category) {
         $category->delete();
         Post::where('category_id', $category->id)->delete();
     });
     $category->delete();
     \Session::flash('flash_message', '削除しました。');
     return redirect('/categories');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     viewInit();
     $category = Category::getCatInfoModelByAsName($id);
     if (empty($category)) {
         return redirect(url(route('article.index')));
     }
     $article = Article::getNewsArticle($category->id, 10);
     return homeView('category', ['category' => $category, 'article' => $article]);
 }
Example #24
0
 protected function getSearchCategory($className)
 {
     switch ($className) {
         case 'Category':
             $category = new Category($this->pixie);
             $search_category = $category->getPageTitle($this->request->param('id'));
             $value = $this->request->param('id');
             break;
         case 'Search':
             $value = $this->request->getWrap("id");
             $category = new Category($this->pixie);
             $search_category = $category->getPageTitle($this->request->getWrap('id'));
             $search_category = $search_category == "" ? "All" : $search_category;
             break;
         default:
             $search_category = 'All';
             $value = '';
             break;
     }
     return ['value' => $value, 'label' => $search_category];
 }
Example #25
0
 public function getDone(Request $request)
 {
     $id = $request->get('paymentId');
     $token = $request->get('token');
     $payer_id = $request->get('PayerID');
     $payment = PayPal::getById($id, $this->_apiContext);
     $paymentExecution = PayPal::PaymentExecution();
     $paymentExecution->setPayerId($payer_id);
     $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
     \Cart::clear();
     return view('frontend.checkout.done')->with('categories', Category::all())->with('pay', $executePayment);
 }
 public function show($id)
 {
     if (!preg_match("/^[1-9]\\d*\$/", $id)) {
         return Redirect::to('/');
     }
     $type = Category::find($id);
     if (!$type) {
         return Redirect::to(route('admin.projects.index'));
     }
     $projects = Project::where('category_id', $id)->sortByDesc('id')->paginate(20);
     return Theme::view('admin.projects.show', compact('projects', 'type'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     //
     viewInit();
     $category = Category::getCatInfoModelByAsName($id);
     if (empty($category)) {
         return redirect(url(route('article.index')));
     }
     $article = Article::getArticleListByCatId($category->id, 10);
     $page = new EndaPage($article['page']);
     return homeView('category', ['category' => $category, 'articleList' => $article, 'page' => $page]);
 }
Example #28
0
 protected function getSearchCategory($className)
 {
     $params = $this->pixie->config->get("parameters");
     switch ($className) {
         case 'Category':
             $category = new Category($this->pixie);
             $search_category = $category->getPageTitle($this->request->param('id'));
             $value = $this->request->param('id');
             break;
         case 'Search':
             $value = $this->request->get("id");
             $category = new Category($this->pixie);
             $search_category = $category->getPageTitle($this->request->get('id'));
             $search_category = $search_category == "" ? $params['root_category_name'] ?: "All" : $search_category;
             break;
         default:
             $search_category = $params['root_category_name'] ?: 'All';
             $value = '';
             break;
     }
     return ['value' => $value, 'label' => $search_category];
 }
 public function run()
 {
     $category = Category::where('id', 1)->first();
     if (!$category) {
         $category = new Category();
         $category->title = '技术漫谈';
         $category->sort = 0;
         $category->info = '';
         $category->cover = '';
         $category->thumb = '';
         $category->parent_id = 0;
         $category->root_id = 0;
         $category->is_nav_show = 1;
         $category->keywords = '';
         $category->description = '';
         $category->templet_all = '';
         $category->templet_nosub = '';
         $category->templet_article = '';
         $category->save();
     }
     $category = Category::where('id', 2)->first();
     if (!$category) {
         $category = new Category();
         $category->title = '说天道地';
         $category->sort = 0;
         $category->info = '';
         $category->cover = '';
         $category->thumb = '';
         $category->parent_id = 0;
         $category->root_id = 0;
         $category->is_nav_show = 1;
         $category->keywords = '';
         $category->description = '';
         $category->templet_all = '';
         $category->templet_nosub = '';
         $category->templet_article = '';
         $category->save();
     }
 }
Example #30
0
 public function destroy($id)
 {
     //
     $son = Category::where('parent_id', '=', $id)->get()->toArray();
     if (!empty($son)) {
         Notification::error('请先删除下级分类');
         return redirect()->route('backend.cate.index');
     }
     if (Category::destroy($id)) {
         Notification::success('删除成功');
         return redirect()->route('backend.cate.index');
     }
 }