Example #1
0
 /**
  * Default action for database updating.
  *
  * @access   public
  * @return   View
  * @since    2014-08-17
  * @version  1.2.0-dev
  */
 public function actionDefault()
 {
     $this->addToTitle('Database updating module');
     // create update form
     $oForm = new Form('db_update');
     $oForm->setSubmitValue(__('make update'));
     // check if update button has been clicked
     if ($oForm->isSubmittedAndValid()) {
         $sUpdateOutput = static::makeUpdateNoExec();
         Cache::set($sUpdateOutput, 'output', 'dbupdate');
         Session::flash(Router::getCurrentUrl(), __('Database updated successfully.'));
     }
     // return View
     return View::factory('db_update/backend/default')->bind('oForm', $oForm);
 }
Example #2
0
 /**
  * If form is submitted and valid, send new data (from Form) to database.
  *
  * @access   public
  * @param    Form $oForm
  * @return   boolean
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function sendDataToModel(Form &$oForm)
 {
     if (!$oForm->isSubmittedAndValid()) {
         return FALSE;
     }
     // transfer data from Form to Model
     foreach ($oForm->getFields() as $oFormField) {
         /* @var $oFormField Form\Field */
         if ($oFormField->isDisabled()) {
             continue;
         }
         $oModel = $this->getModel();
         $oMetadata = $oModel->getMetadata();
         $oMetadataLocales = $oModel->getLocalesMetadata();
         $sName = $oFormField->getName();
         $sFieldModel = $oMetadata->getFieldName($sName);
         $sFieldLocales = $oMetadataLocales !== FALSE ? $oMetadataLocales->getFieldName($sName) : NULL;
         $sField = NULL;
         if ($oMetadata->hasField($sFieldModel) || $oMetadata->hasAssociation($sFieldModel)) {
             $sField = $sFieldModel;
         } elseif ($oModel->hasLocales() && ($oMetadataLocales->hasField($sFieldLocales) || $oMetadataLocales->hasAssociation($sFieldLocales))) {
             $sField = $sFieldLocales;
         }
         if ($sField !== NULL) {
             $aValue = $this->getValueAfterValidation($oFormField);
             $this->makeDataTransfer($sField, $aValue, $oFormField);
             //				$oFormField->afterValidationModelOperations($this->getModel());
         }
     }
     // make data save
     if (!$this->getConfig()->isManualSave()) {
         $this->makeSave($oForm);
     }
     return TRUE;
 }
Example #3
0
 /**
  * ACTION - Backend delete action.
  *
  * @access     public
  * @return    View
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public function actionDelete()
 {
     try {
         $this->loadModelForActions();
     } catch (Exception $oExc) {
         $this->addToTitle(__('Error'));
         $this->addSystemMessage('XXX', 'error');
         die('TODO');
     }
     // check permissions
     $this->checkPermissions('delete');
     // add title ad breadcrumb
     $this->alterBreadcrumbsTitleDelete();
     // confirm message
     $sMessage = __('Are you sure that want to remove item <b>:name</b> with ' . 'id <b>:id</b> from <b>:section</b> section?', ['name' => $this->getModel()->getEntityTitle(), 'id' => $this->getModel()->getId(), 'section' => __(strtolower(Router::getControllerName()))]);
     $this->addSystemMessage($sMessage, 'danger');
     // delete form
     $oForm = new Form('delete_form');
     $oForm->setSubmitValue(__('delete'));
     // if form submitted
     if ($oForm->isSubmittedAndValid()) {
         $this->alterDeleteUpdateSort();
         $this->alterDelete();
     }
     // return View
     return View::factory($this->sViewForm)->bind('oForm', $oForm)->set('sTitle', $this->getTitle());
 }