Overview

Namespaces

  • App
    • Components
    • Interfaces
    • Lib
      • Files
      • Forms
        • Controls
      • Html
      • Repair
      • Statics
    • Model
    • Modules
      • BaseModule
        • Presenters
      • PartnersModule
        • Presenters
      • ProductModule
        • Presenters
      • SaleModule
        • Model
        • Presenters
      • SettingsModule
        • Model
        • Presenters
      • StoreModule
        • Model
        • Presenters
    • Presenters
    • Router
  • PHP

Classes

  • DateTime
  • SplFileInfo

Interfaces

  • ArrayAccess
  • Countable
  • Exception
  • Iterator
  • Traversable
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download
  1: <?php
  2: 
  3: /**
  4:  * Project sberp
  5:  *
  6:  * @file RenderPresenters 
  7:  * @author Jaromír Polášek
  8:  * @version 0.7.3.FORM
  9:  * Encoding UTF-8
 10:  */
 11: 
 12: namespace App\Presenters;
 13: 
 14: use App\Interfaces\IPresenter;
 15: 
 16: /**
 17:  * Presenter obsahující základní Render metody
 18:  */
 19: class RenderPresenter extends ComponentPresenter implements IPresenter {
 20: 
 21:     /**
 22:      * Default Render 
 23:      * předává data do šablony
 24:      * @param integer $source Číslo akce
 25:      */
 26:     public function renderDefault($source) {
 27:     $this->source = $source;
 28:     if ($this->params['id']){
 29:         $this->redirect('show', $source, $this->params['id']);
 30:     }
 31:     $this->template->dataType = $this->action->table->type;
 32:     $this->template->name = $this->action->name;
 33:     $this->template->source = $this->action->source;
 34:     }
 35: 
 36:     /**
 37:      * Add Render
 38:      * Přidá záznam do databáze
 39:      * @param integer $source Číslo akce
 40:      */
 41:     public function renderAdd($source) {
 42:     $this->source = $source;
 43:     $this->id = NULL;
 44:     $form = $this['editForm'];
 45:     $form['save']->caption = 'Přidat';
 46:     $form->addProtection();
 47:     $this->template->data = $form;
 48:     }
 49: 
 50:     /**
 51:      * Edit Render
 52:      * Upraví záznam v databázi
 53:      * @param integer $source Číslo akce
 54:      * @param integer $id Id požadovaného objeku
 55:      */
 56:     public function renderEdit($source, $id) {
 57:     $template = $this->template;
 58:     $template->source = $this->source = $source;
 59:     $template->id = $this->id = $id;
 60:     $template->foot = $this->action->jidash;
 61:     $form = $this['editForm'];
 62:     if (!$form->isSubmitted()) {
 63:         $row = $this->action->data;
 64:         if (!$row) {
 65:         $this->error('Záznam nenalezen');
 66:         } else if ($row instanceof \Nette\Database\Table\ActiveRow) {
 67:         $form['form']->setDefaults($row);
 68:         (!isset($form['state']))? : $form->setDefaults(array('state' => $row['state']));
 69:         }
 70:         
 71:     }
 72:     $form->addProtection();
 73:     $template->data = $form;
 74:     }
 75: 
 76:     /**
 77:      * Show Render
 78:      * Zobrazí konkrétní záznam z databáze
 79:      * @param integer $source Číslo akce
 80:      * @param integer $id Id požadovaného objeku
 81:      */
 82:     public function renderShow($source, $id) {
 83:     $template = $this->template;
 84:     $template->source = $this->source = $source;
 85:     $template->id = $this->id = $id;
 86:     $template->foot = $this->action->jidash;
 87:     $template->delete = TRUE;
 88:     $form = $this['showForm'];
 89:     if (!$form->isSubmitted()) {
 90:         $row = $this->action->data;
 91:         if (!$row) {
 92:         $this->error('Záznam nenalezen');
 93:         } else if ($row instanceof \Nette\Database\Table\ActiveRow) {
 94:         $form['form']->setDefaults($row);
 95:         (!isset($form['state']))? : $form->setDefaults(array('state' => $row['state']));
 96:         }
 97:     }
 98:     $template->data = $form;
 99:     }
100: 
101:     /**
102:      * Delete Render
103:      * Smaže záznam v databázi
104:      * @param integer $source Číslo akce
105:      * @param integer $id Id požadovaného objeku
106:      */
107:     public function renderDelete($source, $id) {
108:     $this->source = $source;
109:     $this->id = $id;
110:     $row = $this->action->data;
111:     if (!$row) {
112:         $this->error('Požadovaný záznam nebyl nalezen');
113:     }//else if ($row instanceof \Nette\Database\Table\ActiveRow) {
114:     //$this->action->delete($row);
115:     //}
116:     $this->template->data = $row;
117:     }
118: 
119: }
120: 
sberp API API documentation generated by ApiGen