Пример #1
0
 public function editAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Routing"), $this->view->translate("Expression Alias"), $this->view->translate("Edit Expression Alias %s", $id)));
     $form = $this->getForm();
     $this->view->form = $form;
     $aliasesPersistency = new PBX_ExpressionAliases();
     if ($this->getRequest()->isPost()) {
         $isValid = $form->isValid($_POST);
         if ($isValid) {
             $expression = array("id" => $id, "name" => $_POST['name'], "expressions" => explode(",", $_POST['exprValue']));
             try {
                 $aliasesPersistency->update($expression);
             } catch (Exception $ex) {
                 throw $ex;
             }
             $this->_redirect($this->getRequest()->getControllerName());
         }
     }
     $alias = $aliasesPersistency->fetchRow('id_alias_expression = ' . $id);
     $aliasList = array();
     foreach ($alias->findPBX_Expression() as $row) {
         array_push($aliasList, $row->ds_expression);
     }
     $exprList = $aliasList;
     $expr = "exprObj.addItem(" . count($exprList) . ");\n";
     foreach ($exprList as $index => $value) {
         $expr .= "exprObj.widgets[{$index}].value='{$value}';\n";
     }
     $this->view->dataExprAlias = $expr;
     $form = $this->getForm();
     $form->getElement('name')->setValue($alias['ds_name']);
     $this->renderScript('expression-alias/add_edit.phtml');
 }