/**
  * Returns a single input form field.
  * This is just a switch between the specific methods.
  *
  * @param string $fieldName Name of the field
  * @param array $fieldConfig Configuration for this field
  * @param string $fieldValue Current value of this field
  *
  * @return string Result of the specific field methods (usually a html string)
  */
 protected function getInputField($fieldName, array $fieldConfig, $fieldValue = '')
 {
     $content = '';
     switch (strtolower($fieldConfig['type'])) {
         case 'select':
             $content .= $this->getSelectInputField($fieldName, $fieldConfig, $fieldValue);
             break;
         case 'static_info_tables':
             $selected = $fieldValue != '' ? $fieldValue : $fieldConfig['default'];
             $content .= $this->staticInfo->buildStaticInfoSelector($fieldConfig['field'], $this->prefixId . '[' . $fieldName . ']', $fieldConfig['cssClass'], $selected, '', '', '', '', $fieldConfig['select'], $this->getFrontendController()->tmpl->setup['config.']['language']);
             break;
         case 'check':
             $content .= $this->getCheckboxInputField($fieldName, $fieldConfig, $fieldValue);
             break;
         case 'single':
         default:
             $content .= $this->getSingleInputField($fieldName, $fieldConfig, $fieldValue);
     }
     /**
      * Hook for processing the content
      */
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['getInputField'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['getInputField'] as $classRef) {
             $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
             if (method_exists($hookObj, 'postGetInputField')) {
                 $content = $hookObj->postGetInputField($content, $fieldName, $fieldConfig, $fieldValue, $this);
             }
         }
     }
     return $content;
 }
Example #2
0
 /**
  * Parses raw data array from db and replace keys with matching values (select
  * fields) like country in address data
  *
  * @param array $data Address data
  * @param array $typoScript TypoScript for addresshandling for this type
  *
  * @return array Address data
  * @throws Exception If configuration is not correct
  */
 public function parseRawData(array $data = array(), array $typoScript)
 {
     if (!is_array($data)) {
         return array();
     }
     $database = $this->getDatabaseConnection();
     $this->debug($typoScript, '$typoScript', __FILE__ . ' ' . __LINE__);
     $newdata = array();
     foreach ($data as $key => $value) {
         $newdata[$key] = $value;
         $fieldConfig = $typoScript[$key . '.'];
         // Get the value from database if the field is a select box
         if (in_array($fieldConfig['type'], array('select', 'static_info_country')) && strlen($fieldConfig['table'])) {
             $table = $fieldConfig['table'];
             $select = $fieldConfig['value'] . ' = ' . $database->fullQuoteStr($value, $table) . $this->cObj->enableFields($table);
             $fields = $fieldConfig['label'] . ' AS label,';
             $fields .= $fieldConfig['value'] . ' AS value';
             $res = $database->exec_SELECTquery($fields, $table, $select);
             $value = $database->sql_fetch_assoc($res);
             $newdata[$key] = $value['label'];
         } elseif ($fieldConfig['type'] == 'select' && is_array($fieldConfig['values.'])) {
             $newdata[$key] = $fieldConfig['values.'][$value];
         } elseif ($fieldConfig['type'] == 'select') {
             throw new Exception('Neither table nor value-list defined for select field ' . $key, 1304333953);
         }
         if ($fieldConfig['type'] == 'static_info_tables') {
             $field = $fieldConfig['field'];
             $valueHidden = $this->staticInfo->getStaticInfoName($field, $value);
             $newdata[$key] = $valueHidden;
         }
     }
     return $newdata;
 }
 /**
  * Returns a single input form field.
  * This is just a switch between the specific methods.
  *
  * @param string $fieldName Name of the field
  * @param array  $fieldConfig Configuration for this field
  * @param string $fieldValue Current value of this field
  *
  * @return string Result of the specific field methods (usually a html string)
  */
 protected function getInputField($fieldName, array $fieldConfig, $fieldValue = '')
 {
     $content = '';
     switch (strtolower($fieldConfig['type'])) {
         case 'select':
             $content .= $this->getSelectInputField($fieldName, $fieldConfig, $fieldValue);
             break;
         case 'static_info_tables':
             $selected = $fieldValue != '' ? $fieldValue : $fieldConfig['default'];
             $content .= $this->staticInfo->buildStaticInfoSelector($fieldConfig['field'], $this->prefixId . '[' . $fieldName . ']', $fieldConfig['cssClass'], $selected, '', '', '', '', $fieldConfig['select'], $this->getFrontendController()->tmpl->setup['config.']['language']);
             break;
         case 'check':
             $content .= $this->getCheckboxInputField($fieldName, $fieldConfig, $fieldValue);
             break;
         case 'single':
         default:
             $content .= $this->getSingleInputField($fieldName, $fieldConfig, $fieldValue);
     }
     /*
      * Hook for processing the content
      */
     $hooks = HookFactory::getHooks('Controller/AddressesController', 'getInputField');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'postGetInputField')) {
             $content = $hook->postGetInputField($content, $fieldName, $fieldConfig, $fieldValue, $this);
         }
     }
     return $content;
 }