/**
  * Execute AJAX actions in front end
  * @param array
  */
 public function executeAjaxActions($arrData)
 {
     \Input::setGet('no_ajax', 1);
     // Avoid circular reference
     switch (\Input::post('action')) {
         // Upload the file
         case 'fineuploader_upload':
             $arrData['name'] = \Input::post('name');
             /** @var FormFineUploader $objWidget */
             $objWidget = new $GLOBALS['TL_FFL']['fineUploader']($arrData);
             $strFile = $objWidget->validateUpload();
             if ($objWidget->hasErrors()) {
                 $arrResponse = array('success' => false, 'error' => $objWidget->getErrorAsString(), 'preventRetry' => true);
             } else {
                 $arrResponse = array('success' => true, 'file' => $strFile);
             }
             $response = new \Haste\Http\Response\JsonResponse($arrResponse);
             $response->send();
             break;
     }
 }
 /**
  * Generate the widget and return it as string
  * @return  string
  */
 public function generate()
 {
     $blnNoAjax = \Input::get('noajax');
     $arrIds = deserialize($this->varValue, true);
     if ($arrIds[0] == '') {
         $arrIds = array(0);
     } else {
         $this->blnHasValues = true;
     }
     $this->blnIsAjaxRequest = \Input::get('tableLookupWizard') == $this->strId;
     // Ensure search and list fields have correct aliases
     $this->ensureColumnAliases($this->arrSearchFields);
     $this->ensureColumnAliases($this->arrListFields);
     // Ajax call
     if ($this->blnIsAjaxRequest) {
         // Clean buffer
         while (ob_end_clean()) {
         }
         $this->prepareSelect();
         $this->prepareJoins();
         $this->prepareWhere();
         $this->prepareOrderBy();
         $this->prepareGroupBy();
         $strBuffer = $this->getBody();
         $response = new \Haste\Http\Response\JsonResponse(array('content' => $strBuffer, 'token' => REQUEST_TOKEN));
         $response->send();
     }
     $GLOBALS['TL_CSS'][] = 'system/modules/tablelookupwizard/assets/tablelookup.min.css';
     if (!$blnNoAjax) {
         $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/tablelookupwizard/assets/tablelookup.min.js';
     }
     $this->prepareSelect();
     $this->prepareJoins();
     // Add preselect to WHERE statement
     $this->arrWhereProcedure[] = $this->foreignTable . '.id IN (' . implode(',', $arrIds) . ')';
     $this->prepareWhere();
     $this->prepareOrderBy();
     $this->prepareGroupBy();
     $objTemplate = new \BackendTemplate('be_widget_tablelookupwizard');
     $objTemplate->noAjax = $blnNoAjax;
     $objTemplate->strId = $this->strId;
     $objTemplate->fieldType = $this->fieldType;
     $objTemplate->fallbackEnabled = $this->blnEnableFallback;
     $objTemplate->noAjaxUrl = $this->addToUrl('noajax=1');
     $objTemplate->listFields = $this->arrListFields;
     $objTemplate->colspan = count($this->arrListFields) + (int) $this->blnEnableSorting;
     $objTemplate->searchLabel = $this->searchLabel == '' ? $GLOBALS['TL_LANG']['MSC']['searchLabel'] : $this->searchLabel;
     $objTemplate->columnLabels = $this->getColumnLabels();
     $objTemplate->hasValues = $this->blnHasValues;
     $objTemplate->enableSorting = $this->blnEnableSorting;
     $objTemplate->body = $this->getBody();
     return $objTemplate->parse();
 }