TYPO3 CMS  TYPO3_6-2
WizardView.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
33  public $doc;
34 
38  protected $pageRenderer;
39 
52  public function __construct(\TYPO3\CMS\Form\Domain\Repository\ContentRepository $repository) {
53  parent::__construct($repository);
54  $GLOBALS['LANG']->includeLLFile('EXT:form/Resources/Private/Language/locallang_wizard.xlf');
55  $GLOBALS['SOBE'] = $this;
56  // Define the document template object
57  $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
58  $this->doc->backPath = $GLOBALS['BACK_PATH'];
59  $this->doc->setModuleTemplate('EXT:form/Resources/Private/Templates/Wizard.html');
60  $this->pageRenderer = $this->doc->getPageRenderer();
61  }
62 
70  public function render() {
71  $docHeaderButtons = array();
72  // Check if the referenced record is available
73  $this->recordIsAvailable = $this->repository->hasRecord();
74  if ($this->recordIsAvailable) {
75  // Load necessary JavaScript
76  $this->loadJavascript();
77  // Load necessary CSS
78  $this->loadCss();
79  // Load the settings
80  $this->loadSettings();
81  // Localization
82  $this->loadLocalization();
83  // Setting up the buttons and markers for docheader
84  $docHeaderButtons = $this->getButtons();
85  $markers['CSH'] = $docHeaderButtons['csh'];
86  // Hook
87  $this->callRenderHook();
88  }
89  // Getting the body content
90  $markers['CONTENT'] = $this->getBodyContent();
91  // Build the HTML for the module
92  $content = $this->doc->startPage($GLOBALS['LANG']->getLL('title', TRUE));
93  $content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
94  $content .= $this->doc->endPage();
95  $content = $this->doc->insertStylesAndJS($content);
96 
97  echo $content;
98  die;
99  }
100 
108  protected function loadJavascript() {
109  $compress = TRUE;
110  $javascriptFiles = array(
111  'Initialize.js',
112  'Ux/Ext.ux.merge.js',
113  'Ux/Ext.ux.isemptyobject.js',
114  'Ux/Ext.ux.spinner.js',
115  'Ux/Ext.ux.form.spinnerfield.js',
116  'Ux/Ext.ux.form.textfieldsubmit.js',
117  'Ux/Ext.ux.grid.CheckColumn.js',
118  'Ux/Ext.ux.grid.SingleSelectCheckColumn.js',
119  'Ux/Ext.ux.grid.ItemDeleter.js',
120  'Helpers/History.js',
121  'Helpers/Element.js',
122  'Elements/ButtonGroup.js',
123  'Elements/Container.js',
124  'Elements/Elements.js',
125  'Elements/Dummy.js',
126  'Elements/Basic/Button.js',
127  'Elements/Basic/Checkbox.js',
128  'Elements/Basic/Fieldset.js',
129  'Elements/Basic/Fileupload.js',
130  'Elements/Basic/Form.js',
131  'Elements/Basic/Hidden.js',
132  'Elements/Basic/Password.js',
133  'Elements/Basic/Radio.js',
134  'Elements/Basic/Reset.js',
135  'Elements/Basic/Select.js',
136  'Elements/Basic/Submit.js',
137  'Elements/Basic/Textarea.js',
138  'Elements/Basic/Textline.js',
139  'Elements/Predefined/Email.js',
140  'Elements/Predefined/CheckboxGroup.js',
141  'Elements/Predefined/Name.js',
142  'Elements/Predefined/RadioGroup.js',
143  'Elements/Content/Header.js',
144  'Elements/Content/Textblock.js',
145  'Viewport.js',
146  'Viewport/Left.js',
147  'Viewport/Right.js',
148  'Viewport/Left/Elements.js',
149  'Viewport/Left/Elements/ButtonGroup.js',
150  'Viewport/Left/Elements/Basic.js',
151  'Viewport/Left/Elements/Predefined.js',
152  'Viewport/Left/Elements/Content.js',
153  'Viewport/Left/Options.js',
154  'Viewport/Left/Options/Dummy.js',
155  'Viewport/Left/Options/Panel.js',
156  'Viewport/Left/Options/Forms/Attributes.js',
157  'Viewport/Left/Options/Forms/Label.js',
158  'Viewport/Left/Options/Forms/Legend.js',
159  'Viewport/Left/Options/Forms/Options.js',
160  'Viewport/Left/Options/Forms/Various.js',
161  'Viewport/Left/Options/Forms/Filters.js',
162  'Viewport/Left/Options/Forms/Filters/Filter.js',
163  'Viewport/Left/Options/Forms/Filters/Dummy.js',
164  'Viewport/Left/Options/Forms/Filters/Alphabetic.js',
165  'Viewport/Left/Options/Forms/Filters/Alphanumeric.js',
166  'Viewport/Left/Options/Forms/Filters/Currency.js',
167  'Viewport/Left/Options/Forms/Filters/Digit.js',
168  'Viewport/Left/Options/Forms/Filters/Integer.js',
169  'Viewport/Left/Options/Forms/Filters/LowerCase.js',
170  'Viewport/Left/Options/Forms/Filters/RegExp.js',
171  'Viewport/Left/Options/Forms/Filters/RemoveXSS.js',
172  'Viewport/Left/Options/Forms/Filters/StripNewLines.js',
173  'Viewport/Left/Options/Forms/Filters/TitleCase.js',
174  'Viewport/Left/Options/Forms/Filters/Trim.js',
175  'Viewport/Left/Options/Forms/Filters/UpperCase.js',
176  'Viewport/Left/Options/Forms/Validation.js',
177  'Viewport/Left/Options/Forms/Validation/Rule.js',
178  'Viewport/Left/Options/Forms/Validation/Dummy.js',
179  'Viewport/Left/Options/Forms/Validation/Alphabetic.js',
180  'Viewport/Left/Options/Forms/Validation/Alphanumeric.js',
181  'Viewport/Left/Options/Forms/Validation/Between.js',
182  'Viewport/Left/Options/Forms/Validation/Date.js',
183  'Viewport/Left/Options/Forms/Validation/Digit.js',
184  'Viewport/Left/Options/Forms/Validation/Email.js',
185  'Viewport/Left/Options/Forms/Validation/Equals.js',
186  'Viewport/Left/Options/Forms/Validation/FileAllowedTypes.js',
187  'Viewport/Left/Options/Forms/Validation/FileMaximumSize.js',
188  'Viewport/Left/Options/Forms/Validation/FileMinimumSize.js',
189  'Viewport/Left/Options/Forms/Validation/Float.js',
190  'Viewport/Left/Options/Forms/Validation/GreaterThan.js',
191  'Viewport/Left/Options/Forms/Validation/InArray.js',
192  'Viewport/Left/Options/Forms/Validation/Integer.js',
193  'Viewport/Left/Options/Forms/Validation/Ip.js',
194  'Viewport/Left/Options/Forms/Validation/Length.js',
195  'Viewport/Left/Options/Forms/Validation/LessThan.js',
196  'Viewport/Left/Options/Forms/Validation/RegExp.js',
197  'Viewport/Left/Options/Forms/Validation/Required.js',
198  'Viewport/Left/Options/Forms/Validation/Uri.js',
199  'Viewport/Left/Form.js',
200  'Viewport/Left/Form/Behaviour.js',
201  'Viewport/Left/Form/Attributes.js',
202  'Viewport/Left/Form/Prefix.js',
203  'Viewport/Left/Form/PostProcessor.js',
204  'Viewport/Left/Form/PostProcessors/PostProcessor.js',
205  'Viewport/Left/Form/PostProcessors/Dummy.js',
206  'Viewport/Left/Form/PostProcessors/Mail.js',
207  'Viewport/Left/Form/PostProcessors/Redirect.js'
208  );
209  // Load ExtJS
210  $this->pageRenderer->loadExtJS();
211  // Load the wizards javascript
212  $baseUrl = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('form') . 'Resources/Public/JavaScript/Wizard/';
213  foreach ($javascriptFiles as $javascriptFile) {
214  $this->pageRenderer->addJsFile($baseUrl . $javascriptFile, 'text/javascript', $compress, FALSE);
215  }
216  }
217 
225  protected function loadCss() {
226  // TODO Set to TRUE when finished
227  $compress = FALSE;
228  $cssFiles = array(
229  'Wizard/Form.css',
230  'Wizard/Wizard.css'
231  );
232  $baseUrl = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('form') . 'Resources/Public/CSS/';
233  // Load the wizards css
234  foreach ($cssFiles as $cssFile) {
235  $this->pageRenderer->addCssFile($baseUrl . $cssFile, 'stylesheet', 'all', '', $compress, FALSE);
236  }
237  }
238 
246  protected function loadSettings() {
247  $record = $this->repository->getRecord();
248  $pageId = $record->getPageId();
249  $modTSconfig = BackendUtility::getModTSconfig($pageId, 'mod.wizards.form');
250  $settings = $modTSconfig['properties'];
251  $this->removeTrailingDotsFromTyposcript($settings);
252  $this->doc->JScode .= $this->doc->wrapScriptTags('TYPO3.Form.Wizard.Settings = ' . json_encode($settings) . ';');
253  }
254 
260  protected function loadLocalization() {
261  $wizardLabels = $GLOBALS['LANG']->includeLLFile('EXT:form/Resources/Private/Language/locallang_wizard.xlf', FALSE, TRUE);
262  $controllerLabels = $GLOBALS['LANG']->includeLLFile('EXT:form/Resources/Private/Language/locallang_controller.xlf', FALSE, TRUE);
264  $this->pageRenderer->addInlineLanguageLabelArray($controllerLabels['default']);
265  }
266 
275  protected function callRenderHook() {
276  $params = array();
277  if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['form']['hooks']['renderWizard'])) {
278  foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['form']['hooks']['renderWizard'] as $funcRef) {
280  }
281  }
282  }
283 
290  protected function removeTrailingDotsFromTyposcript(array &$array) {
291  foreach ($array as $key => $value) {
292  if (is_array($value)) {
293  $this->removeTrailingDotsFromTyposcript($value);
294  }
295  if (substr($key, -1) === '.') {
296  $newKey = substr($key, 0, -1);
297  unset($array[$key]);
298  $array[$newKey] = $value;
299  }
300  }
301  }
302 
309  protected function getButtons() {
310  $buttons = array(
311  'csh' => '',
312  'csh_buttons' => '',
313  'close' => '',
314  'save' => '',
315  'save_close' => '',
316  'reload' => ''
317  );
318  // CSH
319  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz', $GLOBALS['BACK_PATH'], '');
320  // CSH Buttons
321  $buttons['csh_buttons'] = BackendUtility::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_buttons', $GLOBALS['BACK_PATH'], '');
322  // Close
323  $getPostVariables = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('P');
324  $buttons['close'] = '<a href="#" onclick="' . htmlspecialchars(('jumpToUrl(unescape(\'' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl($getPostVariables['returnUrl'])) . '\')); return false;')) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-close', array(
325  'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE)
326  )) . '</a>';
327  return $buttons;
328  }
329 
338  protected function getBodyContent() {
339  if ($this->recordIsAvailable) {
340  $bodyContent = '';
341  } else {
343  $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('errorMessage', TRUE), $GLOBALS['LANG']->getLL('errorTitle', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
344  $bodyContent = $flashMessage->render();
345  }
346  return $bodyContent;
347  }
348 
349 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
removeTrailingDotsFromTyposcript(array &$array)
Definition: WizardView.php:290
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
die
Definition: index.php:6
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
__construct(\TYPO3\CMS\Form\Domain\Repository\ContentRepository $repository)
Definition: WizardView.php:52
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]