示例#1
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());
 }
示例#2
0
文件: main.php 项目: rutgerkok/rCMS
 public function getEditor(Website $website, $id, $data)
 {
     $title = isset($data["title"]) ? $data["title"] : "";
     $text = isset($data["text"]) ? $data["text"] : "";
     $oEditor = new CKEditor($website->getText(), $website->getConfig(), $website->getThemeManager());
     // Title
     $textToDisplay = "<p>\n";
     $textToDisplay .= '<label for="title_' . $id . '">';
     $textToDisplay .= $website->t("widgets.title") . "</label>:<br />\n";
     $textToDisplay .= '<input type="text" name="title_' . $id . '" id="title_' . $id . '"';
     $textToDisplay .= 'value="' . htmlSpecialChars($title) . '" />' . "\n";
     $textToDisplay .= "</p>\n";
     // Text input
     $textToDisplay .= "<p>\n";
     $textToDisplay .= '<label for="text_' . $id . '">' . $website->t("editor.message") . "</label>:";
     $textToDisplay .= '<span class="required">*</span><br />' . "\n";
     $textToDisplay .= $oEditor->getEditor("text_" . $id, $text);
     $textToDisplay .= "</p>\n";
     return $textToDisplay;
 }
示例#3
0
 public function init(Website $website, Request $request)
 {
     $text = $website->getText();
     $currentUser = $website->getAuth()->getCurrentUser();
     $articleId = $request->getParamInt(0);
     $articleRepository = new ArticleRepository($website);
     $article = $this->getArticle($articleRepository, $currentUser, $articleId);
     $articleEditor = new ArticleEditor($article);
     $this->articleEditor = $articleEditor;
     $categoryRepository = new CategoryRepository($website->getDatabase());
     $this->allCategories = $categoryRepository->getCategories();
     $this->richEditor = new CKEditor($website->getText(), $website->getConfig(), $website->getThemeManager());
     // Validate token, then save new one to session
     $validToken = Validate::requestToken($request);
     $this->token = RequestToken::generateNew();
     $this->token->saveToSession();
     // Now check input
     if (!$articleEditor->processInput($website->getText(), $request, $categoryRepository)) {
         return;
     }
     if ($request->hasRequestValue("submit") && $validToken) {
         // Try to save
         $article = $articleEditor->getArticle();
         if ($articleRepository->saveArticle($article)) {
             $viewArticleLink = Link::of($website->getUrlPage("article", $article->getId()), $website->t("articles.view"));
             if ($articleId == 0) {
                 // New article created
                 $text->addMessage($text->t("main.article") . " " . $text->t("editor.is_created"), $viewArticleLink);
             } else {
                 // Article updated
                 $text->addMessage($text->t("main.article") . " " . $text->t("editor.is_edited"), $viewArticleLink);
             }
             // Check for redirect
             if ($request->getRequestString("submit") == $website->t("editor.save_and_quit")) {
                 $this->redirectUrl = $website->getUrlPage("article", $article->getId());
             }
         }
     }
 }