Source for file Actions.php
Documentation is available at Actions.php
* Standard Action classes
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
* Construct the action object
* @return boolean true on success, false if an error occured
* Action class with support for miWebForm
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
* Returns a web form object
$this->_view->getViewMapperController()->setWebForm($this->_webForm);
* @param miWebForm $form the webform object
* @param string $templateName the template name
* @param boolean $isEditable if the form will contain the editable fields/widgets
protected function showForm(&$form, $templateName, $isEditable)
$table =
$this->_view->getTable();
$params =
$table->getFeatureValues();
$form->addMainPageElements($this->_view->getMainPageElements());
$html =
$form->parse($templateName, $isEditable);
$this->_view->addControllerCommand($cmd);
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
$vmController =
$this->_view->getViewMapperController();
$this->_view->callPlugin($this, 'preShowForm');
$vmController->setDataToWebForm();
* Show the page for creating a new record in the database
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
$this->_view->callPlugin($this, 'preShowForm');
* Takes the values from the user input and create a new record in the database
* @copyright Copyright (c) 2006 Mirchev Ideas Ltd. All rights reserved.
$vmController =
$this->_view->getViewMapperController();
$isOk =
$form->processSubmit();
$vmController->setDataFromWebForm();
$vmController->updateSubmittedForm($form);
parent::doAction(); // Call miCreateAction
$this->_view->callPlugin($this, 'preCreate');
$recordId =
$vmController->insert();
$this->_view->callPlugin($this, 'postCreate');
$msg =
$this->_view->getMessage('MI_RECORD_CREATE_FAILED_MSG');
$this->_view->addRedirectToListControllerCommand($msg .
$exception->getMessage(), miMessage::MSG_TYPE_ERROR);
$msg =
sprintf($this->_view->getMessage('MI_RECORD_CREATED_SUCCESSFULLY_MSG'), $recordId);
$this->_view->addRedirectToListControllerCommand($msg, miMessage::MSG_TYPE_INFO);
* Show the page for updating a record in the database
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
$vmController =
$this->_view->getViewMapperController();
$this->_view->callPlugin($this, 'preShowForm');
$vmController->setDataToWebForm();
$msg =
$this->_view->getMessage('MI_RECORD_EDIT_FAILED_MSG');
$this->_view->addRedirectToListControllerCommand($msg .
$exception->getMessage(), miMessage::MSG_TYPE_ERROR);
* Takes the values from the user input and update a record in the database
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
$vmController =
$this->_view->getViewMapperController();
$isOk =
$form->processSubmit();
$vmController->setDataFromWebForm();
$vmController->updateSubmittedForm($form);
$this->_view->callPlugin($this, 'preShowForm');
$this->_view->callPlugin($this, 'preUpdate');
$recordId =
$vmController->update();
$this->_view->callPlugin($this, 'postUpdate');
$msg =
$this->_view->getMessage('MI_RECORD_UPDATE_FAILED_MSG');
$this->_view->addRedirectToListControllerCommand($msg .
$exception->getMessage(), miMessage::MSG_TYPE_ERROR);
$msg =
sprintf($this->_view->getMessage('MI_RECORD_UPDATED_SUCCESSFULLY_MSG'), $recordId);
$this->_view->addRedirectToListControllerCommand($msg, miMessage::MSG_TYPE_INFO);
* Delete a record in the table
* @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
$vmController =
$this->_view->getViewMapperController();
$this->_view->callPlugin($this, 'preDelete');
$recordId =
$vmController->delete();
$this->_view->callPlugin($this, 'postDelete');
$msg =
$this->_view->getMessage('MI_RECORD_DELETE_FAILED_MSG');
$this->_view->addRedirectToListControllerCommand($msg .
$exception->getMessage(), miMessage::MSG_TYPE_ERROR);
$msg =
sprintf($this->_view->getMessage('MI_RECORD_DELETED_SUCCESSFULLY_MSG'), $recordId);
$this->_view->addRedirectToListControllerCommand($msg, miMessage::MSG_TYPE_INFO);
* Shows data from the database in a table format
* @copyright Copyright (c) 2006 Mirchev Ideas Ltd. All rights reserved.
* Sets the current page to show and the number of records per page
* @param int $page current page to show
* @param int $recordsPerPage define how many rows to show in each page
protected function setPage($page, $recordsPerPage)
$recordset =
$this->_view->getRecordset();
$totalRecords =
$recordset->getRecordsCount();
if (($page-
1) *
$recordsPerPage >=
$totalRecords)
$page =
intval(($totalRecords-
1) /
$recordsPerPage) +
1;
$this->_view->getTablePagerObj()->setPagerLocation($page, $recordsPerPage, $totalRecords);
$from =
intval($page -
1) *
$recordsPerPage;
$recordset->setRecordsLimit($from, $recordsPerPage);
// Add main page elements
$table =
$this->_view->getTable();
// Set the page and records per page
$page =
$this->_view->getTablePagerObj()->getPageParam();
$this->setPage($page, $this->_view->getTablePagerObj()->getRecordsPerPageParam());
$table->addMainPageElements($this->_view->getMainPageElements());
$html =
$table->parse($this->_view->getTemplateFileName(miDefaultView::TEMPLATE_ID_LIST));
$this->_view->addControllerCommand($cmd);
$table =
$this->_view->getTable();
$table->setState($stateObj->getArray());
$this->_view->initTable($table);
$recordSet =
$this->_view->getTable()->getRecordset();
$filterObjects =
$this->_view->getTableFilterObj()->getFilterObjs();
$recordSet->addFilters($filterObjects);
$this->_view->callPlugin($this, 'preList');
// TODO: we probably shouldn't die here
$msg =
$this->_view->getMessage('MI_RECORD_LIST_FAILED_MSG');
die($msg .
$exception->getMessage());
Documentation generated on Thu, 08 May 2008 16:57:04 +0300 by phpDocumentor 1.4.1