public function show()
 {
     global $objPage;
     $back = \Controller::generateFrontendUrl($objPage->row(), null, null, true);
     $blnAjax = false;
     $objModal = new Modal($this->objModal, $this->arrConfig);
     $objModal->setBackLink($back);
     $objResponse = new ResponseSuccess();
     $objResponse->setResult(new ResponseData($objModal->generate(), array('id' => $this->objModal->id)));
     $objResponse->setUrl(AjaxAction::removeAjaxParametersFromUrl(Request::getInstance()->getRequestUri()));
     return $objResponse;
 }
 /**
  * Toggle Subpalette
  * @param      $id
  * @param      $strField
  * @param bool $blnLoad
  *
  * @return ResponseError|ResponseSuccess
  */
 function toggleSubpalette($id, $strField, $blnLoad = false)
 {
     if (!$this->dc->isSubmitted()) {
         return;
     }
     $varValue = Request::getPost($strField) ?: 0;
     if (!is_array($this->dca['palettes']['__selector__']) || !in_array($strField, $this->dca['palettes']['__selector__'])) {
         \Controller::log('Field "' . $strField . '" is not an allowed selector field (possible SQL injection attempt)', __METHOD__, TL_ERROR);
         return new ResponseError();
     }
     $arrData = $this->dca['fields'][$strField];
     if (!Validator::isValidOption($varValue, $arrData, $this->dc)) {
         \Controller::log('Field "' . $strField . '" value is not an allowed option (possible SQL injection attempt)', __METHOD__, TL_ERROR);
         return new ResponseError();
     }
     if (empty(FormHelper::getFieldOptions($arrData, $this->dc))) {
         $varValue = intval($varValue) ? 1 : '';
     }
     $this->dc->setSkipValidation(true);
     // do not validate fields
     $this->dc->setDoNotSubmit(true);
     $this->dc->activeRecord->{$strField} = $varValue;
     $objResponse = new ResponseSuccess();
     if ($blnLoad) {
         $objResponse->setResult(new ResponseData($this->dc->edit(false, $id)));
     }
     return $objResponse;
 }
 public function upload()
 {
     // check for the request token
     if (!\Input::post('requestToken') || !RequestToken::validate(\Input::post('requestToken'))) {
         $objResponse = new ResponseError();
         $objResponse->setMessage('Invalid Request Token!');
         $objResponse->output();
     }
     $objTmpFolder = new \Folder(MultiFileUpload::UPLOAD_TMP);
     $arrUuids = null;
     $varReturn = null;
     // Dropzone Upload
     if (!empty($_FILES)) {
         if (!isset($_FILES[$this->name])) {
             return;
         }
         $strField = $this->name;
         $varFile = $_FILES[$strField];
         // Multi-files upload at once
         if (is_array($varFile['name'])) {
             for ($i = 0; $i < count($varFile['name']); $i++) {
                 $arrFiles = array();
                 foreach (array_keys($varFile) as $strKey) {
                     $arrFiles[$strKey] = $varFile[$strKey][$i];
                 }
                 $arrFile = $this->uploadFile($arrFiles, $objTmpFolder->path, $strField);
                 $varReturn[] = $arrFile;
                 $arrUuids[] = $arrFile['uuid'];
             }
         } else {
             $varReturn = $this->uploadFile($varFile, $objTmpFolder->path, $strField);
             $arrUuids[] = $varReturn['uuid'];
         }
         if ($varReturn !== null) {
             $this->varValue = $arrUuids;
             $objResponse = new ResponseSuccess();
             $objResult = new ResponseData();
             $objResult->setData($varReturn);
             $objResponse->setResult($objResult);
             return $objResponse;
         }
     }
 }