Exemple #1
0
 public function __construct(Website $website)
 {
     parent::__construct($website->getDatabase());
     $this->widgetDirectory = $website->getUriWidgets();
     $this->documentIdField = new Field(Field::TYPE_INT, "documentId", "sidebar_id");
     $this->widgetDataField = new Field(Field::TYPE_JSON, "widgetData", "widget_data");
     $this->widgetIdField = new Field(Field::TYPE_PRIMARY_KEY, "id", "widget_id");
     $this->widgetNameField = new Field(Field::TYPE_STRING, "widgetName", "widget_naam");
     $this->widgetPriorityField = new Field(Field::TYPE_INT, "priority", "widget_priority");
 }
Exemple #2
0
 /**
  * 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);
 }