.

DeleteDialogController Class Reference
[DeleteDialog]

This controller catches delete commands. More...

Inheritance diagram for DeleteDialogController:
ControllerBase IController IEventSink

List of all members.

Public Member Functions

  action_deletedialog_approve (PageData $page_data, $_model_, $id)
  Handle link approval.
  action_deletedialog_approve_status (PageData $page_data, $_model_, $id)
  Handle link approval.
  action_deletedialog_cmd_handler (PageData $page_data, $model, $id)
  HAndle the command, that is: Display an approval dialog.
  action_deletedialog_status_cmd_handler (PageData $page_data, $model, $id)
  Handle the command, that is: Display an approval dialog.
  get_routes ()
  returns array of routes

Protected Member Functions

  create_formhandler ()
  Create a formhandler.
  get_instance ($model, $id)
  Returns instance passed as coded string.
  render_view (PageData $page_data, FormHandler $formhandler, $instance)
  Create an render approval view.
  render_view_status (PageData $page_data, FormHandler $formhandler, $instance)
  Create an render approval view.

Detailed Description

This controller catches delete commands.

Author:
Gerd Riesselmann

Definition at line 8 of file deletedialog.controller.php.


Member Function Documentation

DeleteDialogController::action_deletedialog_approve ( PageData page_data,
_model_,
id  
)

Handle link approval.

Parameters:
PageData  $page_data
string  $_model_
string  $id

Definition at line 107 of file deletedialog.controller.php.

00107                                                                                         {
00108                 $page_data->in_history = false;
00109                 
00110                 $dao = $this->get_instance($_model_, $id);
00111                 if ($dao === false) {
00112                         return CONTROLLER_NOT_FOUND;
00113                 }
00114                 
00115                 $cmd = CommandsFactory::create_command($dao, 'delete', false);
00116                 if (!$cmd->can_execute(false)) {
00117                         return CONTROLLER_ACCESS_DENIED;
00118                 }
00119                 
00120                 $formhandler = $this->create_formhandler();
00121                 if ($page_data->has_post_data()) {
00122                         $err = $formhandler->validate();
00123                         if ($err->is_ok()) {
00124                                 if ($page_data->get_post()->get_item('cancel', false) !== false) {
00125                                         $err = new Message(tr('Deletion has been canceled by user', 'deletedialog'));
00126                                 }
00127                                 else {
00128                                         $err->merge($cmd->execute());
00129                                 }
00130                         }
00131                         $formhandler->finish($err, tr('The instance has been deleted', 'deletedialog'));
00132                 }
00133                 else {
00134                         $this->render_view($page_data, $formhandler, $dao);     
00135                 }
00136         }
DeleteDialogController::action_deletedialog_approve_status ( PageData page_data,
_model_,
id  
)

Handle link approval.

Parameters:
PageData  $page_data
string  $_model_
string  $id

Definition at line 48 of file deletedialog.controller.php.

00048                                                                                                {
00049                 $page_data->in_history = false;
00050                 
00051                 $dao = $this->get_instance($_model_, $id);
00052                 if ($dao === false) {
00053                         return CONTROLLER_NOT_FOUND;
00054                 }
00055                 
00056                 $cmd = CommandsFactory::create_command($dao, 'status', 'DELETED');
00057                 if (!$cmd->can_execute(false)) {
00058                         return CONTROLLER_ACCESS_DENIED;
00059                 }
00060                 
00061                 $formhandler = $this->create_formhandler();
00062                 if ($page_data->has_post_data()) {
00063                         $err = $formhandler->validate();
00064                         if ($err->is_ok()) {
00065                                 if ($page_data->get_post()->get_item('cancel', false) !== false) {
00066                                         $err = new Message(tr('Deletion has been canceled by user', 'deletedialog'));
00067                                 }
00068                                 else {
00069                                         $err->merge($cmd->execute());
00070                                 }
00071                         }
00072                         $instance_string = 'instance';
00073                         $instance = $dao->get_table_name();
00074                         $instance_string =  substr($instance, 0, strlen($instance)-1);
00075                         $formhandler->finish($err, tr('The '.$instance_string.' has been deleted', 'deletedialog'));
00076                 }
00077                 else {
00078                         $this->render_view_status($page_data, $formhandler, $dao);      
00079                 }
00080         }
DeleteDialogController::action_deletedialog_cmd_handler ( PageData page_data,
model,
id  
)

HAndle the command, that is: Display an approval dialog.

Parameters:
PageData  $page_data
string  $model
string  $id

Definition at line 90 of file deletedialog.controller.php.

00090                                                                                           {
00091                 $page_data->in_history = false;
00092                 $dao = $this->get_instance($model, $id);
00093                 if ($dao === false) {
00094                         return CONTROLLER_NOT_FOUND;
00095                 }
00096                 
00097                 Url::create(ActionMapper::get_url('deletedialog_approve', $dao))->redirect();
00098         }
DeleteDialogController::action_deletedialog_status_cmd_handler ( PageData page_data,
model,
id  
)

Handle the command, that is: Display an approval dialog.

Parameters:
PageData  $page_data
string  $model
string  $id

Definition at line 32 of file deletedialog.controller.php.

00032                                                                                                  {
00033                 $page_data->in_history = false;
00034                 $dao = $this->get_instance($model, $id);
00035                 if ($dao === false) {
00036                         return CONTROLLER_NOT_FOUND;
00037                 }
00038                 Url::create(ActionMapper::get_url('deletedialog_approve_status', $dao))->redirect();
00039         }
DeleteDialogController::create_formhandler (  )  [protected]

Create a formhandler.

Returns:
FormHandler

Definition at line 167 of file deletedialog.controller.php.

00167                                                 {
00168                 Load::tools('formhandler');
00169                 return new FormHandler('dlgdeleteapprove');             
00170         }
DeleteDialogController::get_instance ( model,
id  
) [protected]

Returns instance passed as coded string.

Parameters:
string  $model
string  $id
Returns:
IDataObject

Definition at line 145 of file deletedialog.controller.php.

00145                                                      {
00146                 $ret = false;
00147                 $dao = DB::create($model);
00148                 if (!empty($dao)) {
00149                         $arr_id = explode(GYRO_COMMAND_ID_SEP, $id);
00150                         foreach ($dao->get_table_keys() as $key => $field) {
00151                                 $dao->$key = array_shift($arr_id);
00152                         }
00153                         
00154                         if ($dao->find(IDataObject::AUTOFETCH) == 1) {
00155                                 // Not zero or many items
00156                                 $ret = $dao;                                    
00157                         }
00158                 }
00159                 return $ret;
00160         }
DeleteDialogController::get_routes (  ) 

returns array of routes

Returns:
array

Reimplemented from ControllerBase.

Definition at line 14 of file deletedialog.controller.php.

00014                                      {
00015                 $ret = array(
00016                         new CommandsRoute('https://process_commands/{model:s}/{id:ui>}/delete', $this, 'deletedialog_cmd_handler'),
00017                         new ParameterizedRoute('https://deletedialog/approve/{_model_:s}/{id:ui>}', $this, 'deletedialog_approve'),                     
00018                         
00019                         new CommandsRoute('https://process_commands/{model:s}/{id:ui>}/status/DELETED', $this, 'deletedialog_status_cmd_handler'),                                                              
00020                         new ParameterizedRoute('https://deletedialog/approve/status/{_model_:s}/{id:ui>}', $this, 'deletedialog_approve_status'),
00021                 );
00022                 return $ret;
00023         }
DeleteDialogController::render_view ( PageData page_data,
FormHandler formhandler,
instance  
) [protected]

Create an render approval view.

Parameters:
FormHandler  $formhandler
IDataObject  $instance

Definition at line 178 of file deletedialog.controller.php.

00178                                                                                                  {
00179                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'deletedialog/approve', $page_data);
00180                 $formhandler->prepare_view($view);
00181                 $view->assign('instance', $instance); 
00182                 $view->render();                
00183         }
DeleteDialogController::render_view_status ( PageData page_data,
FormHandler formhandler,
instance  
) [protected]

Create an render approval view.

Parameters:
FormHandler  $formhandler
IDataObject  $instance

Definition at line 191 of file deletedialog.controller.php.

00191                                                                                                         {
00192                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'deletedialog/approve_status', $page_data);
00193                 $formhandler->prepare_view($view);
00194                 $view->assign('instance', $instance); 
00195                 $view->render();                
00196         }

The documentation for this class was generated from the following file: