コード例 #1
0
 public function editAction()
 {
     $idAction = $this->getRequest()->getParam('id');
     if (!class_exists($idAction)) {
         throw new PBX_Exception_BadArg("Invalid Argument");
     } else {
         $action = new $idAction();
         $registry = PBX_Registry::getInstance($idAction);
         if ($action->getDefaultConfigXML() != "") {
             $actionConfig = new PBX_Rule_ActionConfig($action->getDefaultConfigXML());
             if ($this->getRequest()->isPost()) {
                 $newConfig = $actionConfig->parseConfig($_POST);
                 foreach ($newConfig as $key => $value) {
                     $registry->{$key} = $value;
                     $registry->setContext(get_class($action));
                 }
                 // Cleaning values no longer used
                 $previousValues = $registry->getAllValues();
                 foreach ($previousValues as $key => $value) {
                     if (!key_exists($key, $newConfig)) {
                         unset($registry->{$key});
                     }
                 }
                 $this->view->success = true;
             }
             $action->setDefaultConfig($registry->getAllValues());
             $actionConfig = new PBX_Rule_ActionConfig($action->getDefaultConfigXML());
             $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Routing"), $this->view->translate("Default Configs"), $action->getName()));
             $actionForm = $actionConfig->getForm();
             $actionForm->getElement('cancel')->setAttrib("onclick", "location.href='{$this->getFrontController()->getBaseUrl()}/action-configs/'");
             $actionForm->getElement('cancel')->setLabel('Voltar');
             $this->view->form = $actionForm;
         } else {
             throw new PBX_Exception_BadArg("No Configurable Action");
         }
     }
 }
コード例 #2
0
ファイル: ActionConfig.php プロジェクト: rootzig/SNEP
 /**
  * Faz o parse do XML e gera o formulário.
  */
 protected function parseForm()
 {
     $form = parent::parseForm();
     $form->setElementsBelongTo($this->getActionId());
     return $form;
 }