Beispiel #1
0
 public function init(Website $website, Request $request)
 {
     $categoryId = $request->getParamInt(0, 0);
     $categoriesRepo = new CategoryRepository($website->getDatabase());
     $this->category = $categoriesRepo->getCategory($categoryId);
     $articlesRepo = new ArticleRepository($website);
     $this->articles = $articlesRepo->getArticlesData($categoryId);
     $this->showArticleEditLinks = $website->isLoggedInAsStaff();
     $this->showCategoryEditLinks = $website->isLoggedInAsStaff(true);
 }
Beispiel #2
0
 public function init(Website $website, Request $request)
 {
     $categoryId = $request->getParamInt(0, 0);
     $categoriesRepo = new CategoryRepository($website->getDatabase());
     if ($categoryId === 0) {
         $this->category = new Category(0, "");
     } else {
         $this->category = $categoriesRepo->getCategory($categoryId);
     }
     if (Validate::requestToken($request)) {
         $this->updateCategory($categoriesRepo, $request, $website->getText());
     }
     $this->requestToken = RequestToken::generateNew();
     $this->requestToken->saveToSession();
     $this->richEditor = new CKEditor($website->getText(), $website->getConfig(), $website->getThemeManager());
 }
Beispiel #3
0
 public function init(Website $website, Request $request)
 {
     $categoriesRepo = new CategoryRepository($website->getDatabase());
     $categoryId = $request->getParamInt(0, 0);
     $this->category = $categoriesRepo->getCategory($categoryId);
     if ($this->category->isStandardCategory()) {
         $text = $website->getText();
         $editCategory = Link::of($text->getUrlPage("edit_category", $this->category->getId()), $text->t("categories.edit"));
         $viewAll = Link::of($text->getUrlPage("category_list"), $text->t("categories.view_all"));
         $text->addError($text->t("categories.delete.cannot_remove_default"), $editCategory, $viewAll);
         return;
     }
     if (Validate::requestToken($request)) {
         $articlesRepo = new ArticleRepository($website);
         $this->deleteCategory($categoriesRepo, $articlesRepo, $website->getText());
     }
     $this->requestToken = RequestToken::generateNew();
     $this->requestToken->saveToSession();
 }
Beispiel #4
0
 private function categoryExists(CategoryRepository $repo, $id)
 {
     try {
         $repo->getCategory($id);
         return true;
     } catch (NotFoundException $ex) {
         return false;
     }
 }