/**
  * Get fields for the form's SObject type
  * @param object
  * @return array
  */
 public function getSObjectFields($dc)
 {
     $arrOptions = array();
     $objFormField = \FormFieldModel::findByPk($dc->id);
     if ($objFormField === null) {
         return $arrOptions;
     }
     $objForm = \FormModel::findByPk($objFormField->pid);
     if ($objForm === null) {
         return $arrOptions;
     }
     if ($objForm->useSalesforce && $objForm->salesforceAPIConfig && $objForm->salesforceSObject) {
         try {
             $objClient = Salesforce::getClient($objForm->salesforceAPIConfig);
             $arrConfig = $GLOBALS['TL_SOBJECTS'][$objForm->salesforceSObject];
             $strClass = $arrConfig['class'];
             if (class_exists($strClass)) {
                 $objResults = $objClient->describeSObjects(array($strClass::getType()));
                 $arrFields = $objResults[0]->getFields();
                 foreach ($arrFields as $field) {
                     if (!$field->isCreateable()) {
                         continue;
                     }
                     $arrOptions[$field->getName()] = $field->getName();
                 }
             }
         } catch (\Exception $e) {
         }
     }
     return $arrOptions;
 }
 /**
  * Show a hint if a JavaScript library needs to be included in the page layout
  */
 public function showJsLibraryHint($dc)
 {
     //if ($_POST || Input::get('act') != 'edit')
     //return;
     $objFfm = FormFieldModel::findByPk($dc->id);
     if ($objFfm === null) {
         return;
     }
     if ($objFfm->type == 'textarea' && $objFfm->fag_enabled) {
         Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplates'], 'moo_autogrow', 'j_autogrow'));
     }
 }
 public static function doCreateOptions($formFieldId, $formFieldEventId)
 {
     $objEvents = HeimrichHannot\CalendarPlus\CalendarPlusEventsModel::findPublishedSubEvents($formFieldEventId);
     if ($objEvents !== null) {
         $options = array();
         while ($objEvents->next()) {
             $options[] = array('label' => $objEvents->shortTitle ? $objEvents->shortTitle : $objEvents->title, 'value' => specialchars($objEvents->id));
         }
         $objFormField = \FormFieldModel::findByPk($formFieldId);
         $objFormField->event = $formFieldEventId;
         $objFormField->options = serialize($options);
         $objFormField->save();
     }
 }
 /**
  * Add column set field to the colsetStart content element.
  *
  * We need to do it dynamically because subcolumns creates its palette dynamically.
  *
  * @param \DataContainer $dataContainer The data container driver.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function appendColumnsetIdToPalette($dataContainer)
 {
     if ($dataContainer->table == 'tl_content') {
         $model = \ContentModel::findByPK($dataContainer->id);
         if ($model->sc_type > 0) {
             \MetaPalettes::appendFields($dataContainer->table, 'colsetStart', 'colset', array('bootstrap_grid'));
         }
     } elseif ($dataContainer->table == 'tl_form_field') {
         $model = \FormFieldModel::findByPk($dataContainer->id);
         if ($model->fsc_type > 0) {
             $GLOBALS['TL_DCA']['tl_form_field']['palettes']['formcolstart'] = str_replace('fsc_color,', 'fsc_color,bootstrap_grid,', $GLOBALS['TL_DCA']['tl_form_field']['palettes']['formcolstart']);
         }
     } else {
         $model = \ModuleModel::findByPk($dataContainer->id);
         if ($model->sc_type > 0) {
             $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns'] = str_replace('sc_type,', 'sc_type,columnset_id,', $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns']);
         }
     }
 }
Exemple #5
0
 /**
  * Replace {{option_label::*}} insert tag
  *
  * use case:
  *
  * {{option_label::ID::value}}
  *
  * @param array $arrTag
  */
 private function replaceOptionsLabel($arrTag)
 {
     $id = $arrTag[1];
     $value = $arrTag[2];
     $field = \FormFieldModel::findByPk($id);
     if (null === $field) {
         return $value;
     }
     $options = deserialize($field->options);
     if (empty($options) || !is_array($options)) {
         return $value;
     }
     foreach ($options as $option) {
         if ($value == $option['value']) {
             return $option['label'];
         }
     }
     return $value;
 }
 /**
  * Store the data of a sub form field.
  *
  * @param int      $fieldId   The field id.
  * @param int|bool $leadStore The lead store field or setting.
  *
  * @return void
  */
 private function storeSubformFieldData($fieldId, $leadStore)
 {
     $field = \FormFieldModel::findByPK($fieldId);
     $data = array();
     if ($this->hasLeadMaster()) {
         $masterField = \FormFieldModel::findByPk($leadStore);
         if (!$masterField) {
             return;
         }
         $fieldName = $masterField->name;
         $masterId = $masterField->id;
     } else {
         $fieldName = $field->name;
         $masterId = $field->id;
     }
     // Regular data
     if (isset($this->postData[$field->name])) {
         $value = \Leads::prepareValue($this->postData[$field->name], $field);
         $label = \Leads::prepareLabel($value, $field);
         $data = array('pid' => $this->leadId, 'sorting' => $field->sorting, 'tstamp' => time(), 'master_id' => $masterId, 'field_id' => $field->id, 'name' => $fieldName, 'value' => $value, 'label' => $label);
     }
     // Files
     if (isset($this->files[$field->name]) && $this->files[$field->name]['uploaded']) {
         $value = \Leads::prepareValue($this->files[$field->name], $field);
         $label = \Leads::prepareLabel($value, $field);
         $data = array('pid' => $this->leadId, 'sorting' => $field->sorting, 'tstamp' => time(), 'master_id' => $field->master_id, 'field_id' => $field->id, 'name' => $field->name, 'value' => $value, 'label' => $label);
     }
     $this->insertIntoDatabase($field, $data);
 }