Esempio n. 1
0
 public function routeDelete()
 {
     $ids = $this->config->param['ids'];
     $ids = $ids ? explode(',', $ids) : array();
     if (!$ids) {
         $id = $this->config->param['id'];
         $ids = $id ? array($id) : array();
     }
     if ($this->config->tree && @$ids[0]) {
         $where = $this->config->where ? $this->config->where->toArray() : array();
         $where['`id` = ?'] = $ids[0];
         $pid = (string) $this->config->model->fetchOne($this->config->tree_field, $where);
         $s = new Zend_Session_Namespace();
         $s->control['history'][$this->config->controller]['oid'] = $pid;
     }
     $cnt = 0;
     if ($ids) {
         foreach ($ids as $el) {
             $where = $this->config->where ? $this->config->where->toArray() : array();
             $where['`id` = ?'] = $el;
             $data = $this->config->model->fetchControlCard($where);
             $data = $this->view->override()->overrideSingle($data, $this->config->controller, array('multilang_nofall' => true, 'module_nofall' => true));
             $this->config->data->set($data->toArray());
             $this->config->skip = false;
             $this->config->func_check;
             if (!$this->config->skip) {
                 if ($this->config->use_db) {
                     if ($this->config->delete_mode == 'db') {
                         $ok = $this->config->model->deleteControl($where);
                     } else {
                         $this->config->model->updateControl(array($this->config->delete_mode => 0), $where);
                         $ok = true;
                     }
                 } else {
                     $ok = true;
                 }
                 if ($ok) {
                     $form = $this->buildForm();
                     $els = $form->getElements();
                     if ($els) {
                         foreach ($els as $k => $v) {
                             if ($v->getType() == 'Zkernel_Form_Element_Uploadify') {
                                 if (isset($v->destination) && isset($this->config->data->{$k})) {
                                     @unlink($v->destination . '/' . $this->config->data->{$k});
                                 }
                             }
                         }
                     }
                     $cnt++;
                 }
             }
         }
         if ($cnt) {
             $this->config->info[] = $this->config->control_lang_current['element_deleted'] . $cnt;
         }
     } else {
         $this->config->info[] = $this->config->control_lang_current['no_sel'];
     }
     if ($cnt) {
         $this->config->func_success;
         $this->view->inlineScript('script', 'c.go("' . $this->config->request_ok->controller . '", "' . $this->config->request_ok->action . '", ' . Zend_Json::encode(Zkernel_Common::url2array($this->config->request_ok->param)) . ');');
     } else {
         $this->config->stop_frame = true;
     }
     echo $this->view->render($this->config->view);
     return $this;
 }