Exemplo n.º 1
0
 public function renderCalendar($params)
 {
     $id = $this->getParam($params, "id");
     $classes = $this->getParam($params, "class");
     $calendarOptions = $this->getParam($params, "options", []);
     $attributes = $this->getParam($params, "attr", []);
     if (!is_array($calendarOptions)) {
         throw new SmartyPluginException(sprintf("The 'calendar' smarty function 'options' argument must be an array"));
     }
     if (!is_array($attributes)) {
         throw new SmartyPluginException(sprintf("The 'calendar' smarty function 'attr' argument must be an array"));
     }
     if (null === $id) {
         $id = sprintf(static::DEFAULT_ID, $this->currentCallWithoutId++);
     }
     if (!is_array($classes)) {
         $classes = explode(" ", $classes);
     }
     if (!in_array(static::DEFAULT_CLASS, $classes)) {
         $classes[] = static::DEFAULT_CLASS;
     }
     if (FullCalendar::getConfigValue(FullCalendarConfigValue::ENABLE_PREVENT_SCROLL)) {
         $calendarOptions["handleWindowResize"] = false;
     }
     $this->calendars[$id] = $calendarOptions;
     $tag = sprintf(static::CALENDAR_TAG_TEMPLATE, $id, implode($classes), $this->formatAttributes($attributes));
     return $tag;
 }
 public function saveAction()
 {
     $baseForm = $this->createForm("fullcalendar.configuration");
     $errorMessage = null;
     try {
         $form = $this->validateForm($baseForm);
         $data = $form->getData();
         FullCalendar::setConfigValue(FullCalendarConfigValue::ENABLE_PREVENT_SCROLL, is_bool($data["enable_prevent_scroll"]) ? (int) $data["enable_prevent_scroll"] : $data["enable_prevent_scroll"]);
     } catch (FormValidationException $ex) {
         // Invalid data entered
         $errorMessage = $this->createStandardFormValidationErrorMessage($ex);
     } catch (\Exception $ex) {
         // Any other error
         $errorMessage = $this->getTranslator()->trans('Sorry, an error occurred: %err', ['%err' => $ex->getMessage()], [], FullCalendar::MESSAGE_DOMAIN);
     }
     if (null !== $errorMessage) {
         // Mark the form as with error
         $baseForm->setErrorMessage($errorMessage);
         // Send the form and the error to the parser
         $this->getParserContext()->addForm($baseForm)->setGeneralError($errorMessage);
     } else {
         $this->getParserContext()->set("success", true);
     }
     return $this->defaultAction();
 }