public function init(Website $website, Request $request) { $isStaff = $website->isLoggedInAsStaff(true); $documentRepo = new DocumentRepository($website->getDatabase(), $isStaff); $this->documents = $documentRepo->getAll(); $this->editLinks = $isStaff; }
/** * Creates a new widget based on the request paramaters, or throws an * exception on error. * @param Website $website The website object. * @param Request $request The request. * @return PlacedWidget A new widget, still needs to be saved in the database. * @throws NotFoundException If the document or widget type in the request * is non-existant. */ private function getNewWidget(Website $website, Request $request) { $directoryName = $request->getRequestString("directory_name", ""); if ($directoryName === "") { throw new NotFoundException(); } // Get document $documentRepo = new DocumentRepository($website->getDatabase(), true); $documentId = $request->getRequestInt("document_id", 0); $document = $documentRepo->getDocumentOrWidgetArea($website->getWidgets(), $website->getText(), $documentId); return PlacedWidget::newPlacedWidget($website->getUriWidgets(), $directoryName, $document); }
public function init(Website $website, Request $request) { $isStaff = $website->isLoggedInAsStaff(); $id = $request->getParamInt(0); $this->editLinks = $website->isLoggedInAsStaff(true); // Load document $documentRepo = new DocumentRepository($website->getDatabase(), $isStaff); $this->document = $documentRepo->getDocument($id); // Load document widgets $this->widgetLoader = $website->getWidgets(); $widgetRepo = new WidgetRepository($website); $this->widgets = $widgetRepo->getWidgetsInDocumentWithId($id); }
public function init(Website $website, Request $request) { $documentId = $request->getParamInt(0, 0); $documentRepo = new DocumentRepository($website->getDatabase(), true); $this->document = $documentRepo->getDocument($documentId); if (Validate::requestToken($request)) { $widgetRepo = new WidgetRepository($website); $documentRepo->deleteDocument($this->document, $widgetRepo); $text = $website->getText(); $text->addMessage($text->t("main.document") . ' ' . $text->t("editor.is_deleted")); $this->deleted = true; } $this->requestToken = RequestToken::generateNew(); $this->requestToken->saveToSession(); }
private function retrieveDocument(Website $website, DocumentRepository $documentRepo, $id, User $user) { if ($id === 0) { // New document return Document::createNew("", "", $user); } return $documentRepo->getDocumentOrWidgetArea($website->getWidgets(), $website->getText(), $id); }