public function setup()
 {
     $this->setWidgets(array('idNodes' => new sfWidgetFormInputHidden(), 'idPare' => new sfWidgetFormChoice(array('choices' => NodesPeer::selectNodesPares($this->getOption('IDS'))), array()), 'TitolMenu' => new sfWidgetFormInputText(array(), array('style' => 'width:400px')), 'Nivell' => new sfWidgetFormChoice(array('choices' => array(0 => 'Fora de menú', 1 => 'Principal', 2 => 'Secundari', 3 => 'Terciari'))), 'Ordre' => new sfWidgetFormChoice(array('choices' => NodesPeer::selectOrdre($this->getOption('IDS'), $this->isNew()))), 'isCategoria' => new sfWidgetFormChoice(array('choices' => array(1 => 'Sí', 0 => 'No')), array()), 'isPhp' => new sfWidgetFormInputHidden(), 'isActiva' => new sfWidgetFormChoice(array('choices' => array(1 => 'Sí', 0 => 'No')), array()), 'HTML' => new sfWidgetFormInputHidden(), 'Url' => new sfWidgetFormInputText(array(), array('style' => 'width:400px')), 'Categories' => new sfWidgetFormChoice(array('choices' => ActivitatsPeer::selectCategoriaActivitat($this->getOption('IDS'), true)), array())));
     $this->setValidators(array('idNodes' => new sfValidatorPropelChoice(array('model' => 'Nodes', 'column' => 'idNodes', 'required' => false)), 'idPare' => new sfValidatorPropelChoice(array('model' => 'Nodes', 'column' => 'idNodes', 'required' => false)), 'TitolMenu' => new sfValidatorString(array('required' => false)), 'HTML' => new sfValidatorString(array('required' => false)), 'isCategoria' => new sfValidatorBoolean(), 'isPhp' => new sfValidatorPass(), 'isActiva' => new sfValidatorBoolean(), 'Ordre' => new sfValidatorInteger(array('required' => false)), 'Nivell' => new sfValidatorInteger(), 'Url' => new sfValidatorString(array('required' => false)), 'Categories' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setDefaults(array('TitolMenu' => 'Entreu el títol...', 'Nivell' => '1', 'Ordre' => '1', 'isCategoria' => false, 'isActiva' => true, 'Url' => "", 'Categories' => "Tipus"));
     $this->widgetSchema->setLabels(array('TitolMenu' => 'Títol', 'Nivell' => 'Nivell', 'Ordre' => 'Ordre', 'isCategoria' => 'És només títol?', 'isActiva' => 'Visible?', 'URL' => 'Adreça?'));
     $this->widgetSchema->setNameFormat('nodes[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
Esempio n. 2
0
 public function executeGEstructura(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     $this->IDN = $request->getParameter('idN', 0);
     $this->ERRORS = array();
     $this->NOU = false;
     $this->EDICIO = false;
     $this->HTML = false;
     $accio = $request->getParameter('accio');
     if ($request->hasParameter('SaveHTML')) {
         $accio = 'SAVE_HTML';
     } elseif ($request->hasParameter('BSAVE')) {
         $accio = 'SAVE';
     } elseif ($request->hasParameter('BDELETE')) {
         $accio = 'D';
     }
     switch ($accio) {
         case 'N':
             $this->FNode = NodesPeer::initialize($this->IDN, $this->IDS);
             $this->NOU = true;
             break;
         case 'E':
             $this->FNode = NodesPeer::initialize($this->IDN, $this->IDS);
             $this->EDICIO = true;
             break;
         case 'H':
             $this->FHtml = NodesPeer::initialize($this->IDN, $this->IDS, true);
             $this->HTML = true;
             break;
         case 'D':
             $this->FNode = NodesPeer::initialize($this->IDN, $this->IDS);
             $this->NODE = $this->FNode->getObject();
             $this->NODE->setActiu(false);
             $this->NODE->save();
             $this->getUser()->addLogAction('delete', 'gEstructura', $this->NODE);
             break;
         case 'CC':
             $this->getUser()->addLogAction('inside', 'gEstructura');
             break;
         case 'SAVE':
             $RP = $request->getParameter('nodes');
             $this->IDN = $RP['idNodes'];
             $this->FNode = NodesPeer::initialize($this->IDN, $this->IDS);
             $this->FNode->bind($RP);
             if ($this->FNode->isValid()) {
                 $this->FNode->save();
                 $this->getUser()->addLogAction('save', 'gEstructura', null, $this->FNode->getObject());
             }
             $this->EDICIO = false;
             break;
         case 'SAVE_HTML':
             $RP = $request->getParameter('editor');
             $this->IDN = $RP['idNodes'];
             $this->FHtml = NodesPeer::initialize($this->IDN, $this->IDS, true);
             $this->FHtml->bind($RP);
             if ($this->FHtml->isValid()) {
                 $this->FHtml->save();
                 $this->getUser()->addLogAction('saveHTML', 'gEstructura', $this->FHtml->getObject());
             }
             $this->HTML = true;
             break;
     }
     $this->NODES = NodesPeer::selectNodesPares($this->IDS, true);
     // $this->NODES = NodesPeer::retornaMenu($this->IDS,true);
 }