TYPO3 CMS  TYPO3_6-2
ValueSlider.php
Go to the documentation of this file.
1 <?php
3 
18 
24 class ValueSlider {
25 
34  public function renderWizard(&$params, &$pObj) {
35  $pObj->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/ValueSlider.js');
36  $field = $params['field'];
37  $value = $params['row'][$field];
38  // If Slider is used in a flexform
39  if (!empty($params['flexFormPath'])) {
40  $flexFormTools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
41  $flexFormValue = $flexFormTools->getArrayValueByPath($params['flexFormPath'], GeneralUtility::xml2array($value));
42  if ($flexFormValue !== NULL) {
43  $value = $flexFormValue;
44  }
45  }
46  $itemName = $params['itemName'];
47  // Set default values (which correspond to those of the JS component)
48  $min = 0;
49  $max = 10000;
50  // Use the range property, if defined, to set min and max values
51  if (isset($params['fieldConfig']['range'])) {
52  $min = isset($params['fieldConfig']['range']['lower']) ? (int)$params['fieldConfig']['range']['lower'] : 0;
53  $max = isset($params['fieldConfig']['range']['upper']) ? (int)$params['fieldConfig']['range']['upper'] : 10000;
54  }
55  $elementType = $params['fieldConfig']['type'];
56  $step = $params['wConf']['step'] ?: 1;
57  $width = (int)$params['wConf']['width'] ?: 400;
58  $type = 'null';
59  if (isset($params['fieldConfig']['eval'])) {
60  $eval = GeneralUtility::trimExplode(',', $params['fieldConfig']['eval'], TRUE);
61  if (in_array('time', $eval)) {
62  $type = 'time';
63  $value = (int)$value;
64  } elseif (in_array('int', $eval)) {
65  $type = 'int';
66  $value = (int)$value;
67  } elseif (in_array('double2', $eval)) {
68  $type = 'double';
69  $value = (double) $value;
70  }
71  }
72  if (isset($params['fieldConfig']['items'])) {
73  $type = 'array';
74  $value = (int)$value;
75  }
76  $callback = $params['fieldChangeFunc']['TBE_EDITOR_fieldChanged'];
77  $getField = $params['fieldChangeFunc']['typo3form.fieldGet'];
78  $id = 'slider-' . $params['md5ID'];
79  $contents = '<div id="' . $id . '"></div>';
80  $js = '
81  new TYPO3.Components.TcaValueSlider({
82  minValue: ' . $min . ',
83  maxValue: ' . $max . ',
84  value: ' . $value . ',
85  increment: ' . $step . ',
86  renderTo: "' . $id . '",
87  itemName: "' . $itemName . '",
88  changeCallback: "' . $callback . '",
89  getField: "' . $getField . '",
90  width: "' . $width . '",
91  type: "' . $type . '",
92  elementType: "' . $elementType . '"
93  });
94  ';
96  $pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
97  $pageRenderer->addExtOnReadyCode($js);
98  return $contents;
99  }
100 
101 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static xml2array($string, $NSprefix='', $reportDocTag=FALSE)