Пример #1
0
 /**
  * Execute the action
  * @param  $action A TDataGridAction object
  * @ignore-autocomplete on
  */
 public function onExecute(TDataGridAction $action)
 {
     $selection = $this->view->get_selection();
     if ($selection) {
         list($model, $iter) = $selection->get_selected();
         if ($iter) {
             $activeObject = $this->model->get_value($iter, $this->count);
             $field = $action->getField();
             $label = $action->getLabel();
             if (is_null($field)) {
                 throw new Exception(TAdiantiCoreTranslator::translate('Field for action ^1 not defined', $label) . '.<br>' . TAdiantiCoreTranslator::translate('Use the ^1 method', 'setField' . '()') . '.');
             }
             $array['key'] = $activeObject->{$field};
             $callb = $action->getAction();
             if (is_array($callb)) {
                 if (is_object($callb[0])) {
                     $object = $callb[0];
                     $window_visible = $object->is_visible();
                     // execute action
                     call_user_func($callb, $array);
                     if (method_exists($object, 'show')) {
                     }
                     // if the window wasn't visible before
                     // the operation, shows it.
                     // Forms: window wasn't visible, then show.
                     // SeekBtns: window was visible, do nothing.
                     //           the operation itself closes the window.
                     if (!$window_visible) {
                         if ($object->get_child()) {
                             $object->show();
                         }
                     }
                 } else {
                     $class = $callb[0];
                     $method = $callb[1];
                     TApplication::executeMethod($class, $method, $array);
                 }
             } else {
                 // execute action
                 call_user_func($callb, $array);
             }
         }
     }
 }