/**
  * Homepage:default.
  * @param string $order
  */
 public function actionDefault($order)
 {
     $this->notes = $this->noteManager->findAll();
     if ($order) {
         $this->notes->order(OrderHelper::translateParameterToColumns($order));
     }
 }
 /**
  * Creates a DeleteNoteForm.
  * @param int $id Id of the note to be deleted.
  * @return Form
  */
 public function create($id)
 {
     $form = new Form();
     $form->addProtection();
     // Adds CSRF protection
     $form->addSubmit('submit', 'Yes, I want to delete this note');
     $form->onSuccess[] = function (Form $form) use($id) {
         if (!$this->noteManager->delete($id)) {
             $form->addError("Failed to delete note");
         }
     };
     return $form;
 }
Example #3
0
 /**
  * Creates an EditNoteForm.
  * @param int    $id
  * @param string $name
  * @param string $text
  * @param int    $pad
  * @return Form
  */
 public function create($id, $name, $text, $pad)
 {
     $form = new Form();
     $form->addText('name', 'Name')->setDefaultValue($name)->setRequired('%label is required');
     $form->addTextArea('text', 'Text')->setDefaultValue($text)->setRequired('%label is required');
     $form->addSelect('pad', 'Pad', $this->padManager->findAll()->fetchPairs('id', 'name'))->setPrompt('Select pad')->setDefaultValue($pad);
     $form->addSubmit('submit', 'Save');
     $form->onSuccess[] = function (Form $form, $values) use($id) {
         if (!$this->noteManager->update($id, $values->name, $values->text, $values->pad)) {
             $form->addError("Failed to edit pad");
         }
     };
     return $form;
 }
Example #4
0
 /**
  * Loads note with given id and if not found, throws BadRequestException.
  * @param int $id
  * @throws BadRequestException
  */
 private function loadNote($id)
 {
     $this->id = $id;
     $this->note = $this->noteManager->find($this->id);
     if (!$this->note) {
         throw new BadRequestException("Pad with given id not found");
     }
 }
Example #5
0
 /**
  * Pad:default.
  * @param int         $id
  * @param string|null $order
  * @throws BadRequestException
  */
 public function actionDefault($id, $order)
 {
     $this->loadPad($id);
     $this->notes = $this->noteManager->findByPad($id);
     if ($order) {
         $this->notes->order(OrderHelper::translateParameterToColumns($order));
     }
 }
 /**
  * Callback for NewNoteForm onSuccess event.
  * @param Form      $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     if (!$this->noteManager->add($values->name, $values->text, $values->pad)) {
         $form->addError("Failed to create pad");
     }
 }