/** * Initialize the object * * @param array $arrAttributes An optional attributes array */ public function __construct($arrAttributes = null) { parent::__construct($arrAttributes); if (\Environment::get('isAjaxRequest')) { $this->generateAjax(\Input::post('action'), $this->objDca); } }
public function generateAjax($strAction, \DataContainer $objDca) { // no tagsinput action --> return if (!$this->isValidAjaxActions($strAction)) { return; } $strField = $objDca->field = \Input::post('name'); \Controller::loadDataContainer($objDca->table); $objActiveRecord = \HeimrichHannot\Haste\Dca\General::getModelInstance($objDca->table, $objDca->id); if ($objActiveRecord === null) { $this->log('No active record for "' . $strField . '" found (possible SQL injection attempt)', __METHOD__, TL_ERROR); header('HTTP/1.1 400 Bad Request'); die('Bad Request'); } $strField = \Input::post('name'); $objDca->activeRecord = $objActiveRecord; $arrData = $GLOBALS['TL_DCA'][$objDca->table]['fields'][$strField]; if (!is_array($arrData)) { $this->log('No valid field configuration (dca) found for "' . $objDca->table . '.' . $strField . '" (possible SQL injection attempt)', __METHOD__, TL_ERROR); header('HTTP/1.1 400 Bad Request'); die('Bad Request'); } $return = ''; switch ($strAction) { case static::ACTION_FETCH_REMOTE_OPTIONS: $objWidget = new \TagsInput(\Widget::getAttributesFromDca($arrData, $strField, $objActiveRecord->{$strField}, $strField, $this->strTable, $objDca)); $return = array_values($objWidget->getRemoteOptionsFromQuery(\Input::post('query'))); break; } die(json_encode($return)); }