Advertisement
Pooky

Untitled

Jul 17th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.06 KB | None | 0 0
  1. class Application_Form_Types_Drevotrieska extends Zend_Form_SubForm
  2. {
  3.  
  4.     public function init()
  5.     {
  6.         // základní skupina políček
  7.         //$this->addSubForm(new Application_Form_Types_Default(array('ident' => Application_Model_Order::DREVOTRIESKA)), 'default');
  8.      
  9.         $this->addElements(array(
  10.             $topEdge = new Zend_Form_Element_Checkbox('top_edge'),
  11.             $bottomEdge = new Zend_Form_Element_Checkbox('bottom_edge'),
  12.             $leftEdge = new Zend_Form_Element_Checkbox('left_edge'),
  13.             $rightEdge = new Zend_Form_Element_Checkbox('right_edge'),
  14.             $atyp = new Zend_Form_Element_File('atyp'),
  15.             $image = new Zend_Form_Element_Image('image'),
  16.             $hinge = new Zend_Form_Element_Select('hinge'),
  17.             $sizes = new Zend_Form_Element_Select('id_size'),
  18.             $decors = new Zend_Form_Element_Select('id_decor'),
  19.         ));
  20.        
  21.         // ABS hrany
  22.         $topEdge->setLabel('ABS horní');
  23.         $bottomEdge->setLabel('ABS spodní');
  24.         $leftEdge->setLabel('ABS levá');
  25.         $rightEdge->setLabel('ABS pravá');
  26.        
  27.         // atyp
  28.         $atyp->setLabel('Přiložte Atyp: ')
  29.              ->setDestination(APPLICATION_PATH . '/../data/atyp')
  30.              ->addFilter('Rename', array('source' => $atyp->getFileName(), 'target' => APPLICATION_PATH . '/../data/atyp/' . uniqid()));
  31.              
  32.        
  33.         // panty
  34.         $hinge->addMultiOptions(array(
  35.             0 => 'Žádný',
  36.             2 => 'Dva',
  37.             3 => 'Tři',
  38.         ));
  39.        
  40.         // dekory
  41.         $decors->addMultiOptions(Application_Model_Decor::getDecorListForm());
  42.         $sizes->addMultiOptions(Application_Model_Decor::getSizeListForm());
  43.        
  44.     }
  45.  
  46.  
  47. }
  48.  
  49.  
  50.  
  51. class OrderController extends Zend_Controller_Action    
  52.  
  53. public function indexAction()
  54.     {
  55.         if (!$this->_orderSession->parts) {
  56.             $this->_orderSession->parts = array();
  57.         }
  58.  
  59.         $this->view->parts = $this->_orderSession->parts;
  60.        
  61.         $type = $this->getRequest()->default['type'];
  62.         if ($this->getRequest()->isPost()) {
  63.            
  64.             $defaultForm = new Application_Form_Types_Default(array('type' => $type));
  65.             $customForm = Application_Model_Order::getForm($type);
  66.             // zjištění který formulář používáme
  67.             $form = new Application_Form_Types_Global(array('defaultForm' => $defaultForm,'customForm' => $customForm));
  68.            
  69.             if ($form->isValid($this->_getAllParams())) {
  70.                
  71.                 // pokud nezadal jméno dokoru přiřadíme mu vlastní
  72.                 if (!$form->default->getValue('name')) {
  73.                     $form->default->name->setValue('Dílec ' . count($this->_orderSession->parts));
  74.                 }
  75.                
  76.                 // pokud jsme u drevotriesky, podíváme se na file
  77.                 if($type == Application_Model_Order::TYPES_DREVOTRIESKA){
  78.                      
  79.                     $fileName = uniqid() . '-' . $customForm->atyp->getValue();
  80.                    
  81.                     $customForm->atyp->receive();  
  82.                     Zend_Registry::get('Firebug')->log($customForm->getValues(), Zend_Log::DEBUG);
  83.                    
  84.                     // vytvoříme jiný název
  85.                     //$rename = new Zend_Filter_File_Rename(array('source' => $customForm->atyp->getFileName(), 'target' => APPLICATION_PATH . '/../data/atyp/' . $fileName));
  86.                     //$rename->filter(APPLICATION_PATH . '/../data/atyp/' . $fileName);
  87.                    
  88.                     //$form->getSubForm('custom')->getElement('atyp')->setValue($fileName);
  89.                 }
  90.                
  91.                 //$this->_orderSession->parts[] = $form->getValues();
  92.                 $this->_helper->FlashMessenger(
  93.                         array('ok' => 'Dílec byl vytvořen.')
  94.                 );
  95.                 //$this->_helper->redirector('index', 'order');
  96.             }
  97.         }
  98.         $this->view->form = $form;
  99.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement