CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

10402_v2.patch

Reinhard Führicht, 2010-11-05 10:45

Download (13.8 kB)

 
Classes/Finisher/Tx_Formhandler_Finisher_SubmittedOK.php (working copy)
46 46
		
47 47
		//set session value to prevent another validation or finisher circle. Formhandler will call only this Finisher if the user reloads the page.
48 48
		Tx_Formhandler_Session::set('submittedOK', TRUE);
49
		
50
		$action = $this->gp['action'];
51
		if($action) {
52
			
53
			$this->processAction($action);
54
		}
55 49

  
56 50
		//read template file
57 51
		$this->templateFile = Tx_Formhandler_Globals::$templateCode;
......
72 66
		$view->setComponentSettings($this->settings);
73 67
		return $view->render($this->gp, array());
74 68
	}
75
	
76
	protected function processAction($action) {
77
		if(is_array($this->settings['actions.'])) {
78
			foreach($this->settings['actions.'] as $key=>$options) {
79
				if(strpos($key, '.') !== FALSE) {
80
					$currentAction = str_replace('.', '', $key);
81
					if($currentAction === $action) {
82
						$class = $options['class'];
83
						if($class) {
84
							$class = Tx_Formhandler_StaticFuncs::prepareClassName($class);
85
							$object = $this->componentManager->getComponent($class);
86
							$object->init($this->gp, $options['config.']);
87
							$object->process();
88
						}
89
					}
90
				}
91
			}
92
		}
93
	}
94 69

  
95 70
}
96 71
?>
Classes/Controller/Tx_Formhandler_Controller_Form.php (working copy)
183 183
		
184 184
		$this->processFileRemoval();
185 185

  
186
		//not submitted
187
		if(!$this->submitted) {
188
			
186
		$action = t3lib_div::_GP('action');
187
		if(Tx_Formhandler_Globals::$formValuesPrefix) {
188
			$temp = t3lib_div::_GP(Tx_Formhandler_Globals::$formValuesPrefix);
189
			$action = $temp['action'];
190
		}
191
		if($action) {
192
			$this->processAction($action);
193
		}
194
		
195
		if($this->submittedOK) {
196
			return $this->processSubmittedOK();
197
		} elseif(!$this->submitted) {
189 198
			return $this->processNotSubmitted();
190
			
191
			//submitted
192 199
		} else {
193
			if($this->submittedOK) {
194
				
195
				return $this->processSubmittedOK();
200
			return $this->processSubmitted();
201
		}
196 202

  
197
			} else {
198
		
199
				return $this->processSubmitted();
200
				
203
	}
204
	
205
	protected function processAction($action) {
206
		$gp = $_GET;
207
		if(Tx_Formhandler_Globals::$formValuesPrefix) {
208
			$gp = t3lib_div::_GP(Tx_Formhandler_Globals::$formValuesPrefix);
209
		}
210
		if(is_array($this->settings['finishers.'])) {
211
			$finisherConf = array();
212
			foreach($this->settings['finishers.'] as $key => $config) {
213
				if(strpos($key, '.') !== FALSE) {
214
					$className = Tx_Formhandler_StaticFuncs::prepareClassName($config['class']);
215
					if($className === 'Tx_Formhandler_Finisher_SubmittedOK' && is_array($config['config.']['actions.'])) {
216
						$finisherConf = $config['config.']['actions.'];
217
					}
218
				}
219
			}
220
			if($finisherConf[$action . '.']) {
221
				$tstamp = $GLOBALS['TYPO3_DB']->fullQuoteStr($gp['tstamp']);
222
				$hash = $GLOBALS['TYPO3_DB']->fullQuoteStr($gp['hash']);
223
				if($tstamp && $hash) {
224
					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'tx_formhandler_log', 'tstamp=' . $tstamp . ' AND key_hash=' . $hash);
225
					if($res && $GLOBALS['TYPO3_DB']->sql_num_rows($res) === 1) {
226
						$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
227
						$GLOBALS['TYPO3_DB']->sql_free_result($res);
228
						$params = unserialize($row['params']);
229
						$class = $finisherConf[$action . '.']['class'];
230
						if($class) {
231
							$class = Tx_Formhandler_StaticFuncs::prepareClassName($class);
232
							$object = $this->componentManager->getComponent($class);
233
							$object->init($params, $finisherConf[$action . '.']['config.']);
234
							$object->process();
235
						}
236
					}
237
				}
201 238
			}
202 239
		}
203

  
204 240
	}
205 241
	
206 242
	protected function processSubmitted() {
......
445 481
	}
446 482
	
447 483
	protected function processSubmittedOK() {
484
		
485
		$gp = $_GET;
486
		if(Tx_Formhandler_Globals::$formValuesPrefix) {
487
			$gp = t3lib_div::_GP(Tx_Formhandler_Globals::$formValuesPrefix);
488
		}
489
		$tstamp = $GLOBALS['TYPO3_DB']->fullQuoteStr($gp['tstamp']);
490
		$hash = $GLOBALS['TYPO3_DB']->fullQuoteStr($gp['hash']);
491
		if($tstamp && $hash) {
492
			$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'tx_formhandler_log', 'tstamp=' . $tstamp . ' AND key_hash=' . $hash);
493
			if($res && $GLOBALS['TYPO3_DB']->sql_num_rows($res) === 1) {
494
				$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
495
				$GLOBALS['TYPO3_DB']->sql_free_result($res);
496
				$this->gp = unserialize($row['params']);
497
			}
498
		}
499
		
448 500
		$this->loadSettingsForStep($this->currentStep);
449 501
		$this->parseConditions();
450 502
		$this->view->setLangFiles($this->langFiles);
......
781 833
		Tx_Formhandler_Session::set('startblock', NULL);
782 834
		Tx_Formhandler_Session::set('endblock', NULL);
783 835
		Tx_Formhandler_Session::set('currentStep', 1);
836
		Tx_Formhandler_Session::set('inserted_uid', NULL);
837
		Tx_Formhandler_Session::set('inserted_tstamp', NULL);
838
		Tx_Formhandler_Session::set('key_hash', NULL);
784 839
		$this->gp = array();
840
		$this->currentStep = 1;
785 841
		Tx_Formhandler_Globals::$gp = $this->gp;
786 842
		Tx_Formhandler_StaticFuncs::debugMessage('cleared_session');
787 843
	}
......
1042 1098
		$this->submittedOK = Tx_Formhandler_Session::get('submittedOK');
1043 1099
		
1044 1100
		if(!$this->submittedOK) {
1101
			$this->submittedOK = $this->gp['submitted_ok'];
1102
		}
1103
		
1104
		if(!$this->submittedOK) {
1045 1105
			$this->submittedOK = t3lib_div::_GP('submitted_ok');
1046 1106
		}
1047 1107
		
Classes/Logger/Tx_Formhandler_Logger_DB.php (working copy)
56 56
		//query the database
57 57
		$res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fields);
58 58
		$insertedUID = $GLOBALS['TYPO3_DB']->sql_insert_id();
59
		$lastId = Tx_Formhandler_Session::set('inserted_uid', $insertedUID);
60

  
59
		Tx_Formhandler_Session::set('inserted_uid', $insertedUID);
60
		Tx_Formhandler_Session::set('inserted_tstamp', $fields['tstamp']);
61
		Tx_Formhandler_Session::set('key_hash', $hash);
61 62
		if(!$this->settings['nodebug']) {
62 63
			Tx_Formhandler_StaticFuncs::debugMessage('logging', $table, implode(',', $fields));
63 64
			if(strlen($GLOBALS['TYPO3_DB']->sql_error()) > 0) {
Classes/Generator/FE/Tx_Formhandler_Generator_PdfGenerator.php (working copy)
14 14
	
15 15
	
16 16
	public function getLink($linkGP) {
17
		$params = array();
18

  
19
		$url = Tx_Formhandler_StaticFuncs::getHostname() . $this->cObj->getTypolink_URL($GLOBALS['TSFE']->id, $linkGP);
20 17

  
21
        $target = '_blank';
22
        if($this->settings['target']) {
23
            $target = $this->settings['target'];
24
        }
18
		$text = $this->getLinkText();
19
		
20
		$target = '_blank';
21
		if($this->settings['target']) {
22
			$target = $this->settings['target'];
23
		}
25 24

  
26
        $type = 123;
27
        if($this->settings['type']) {
28
            $type = $this->settings['type'];
29
        }
25
		$type = 123;
26
		if($this->settings['type']) {
27
			$type = $this->settings['type'];
28
		}
30 29

  
31 30
		$params = array(
32 31
			'type' => $type,
33
			'no_cache' => 1,
34 32
			'submitted_ok' => 1
35 33
		);
36

  
37
        $params = array_merge($params, $linkGP);
34
		
35
		if($prefix) {
36
			$params[$prefix]['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
37
			$params[$prefix]['hash'] = Tx_Formhandler_Session::get('key_hash');
38
		} else {
39
			$params['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
40
			$params['hash'] = Tx_Formhandler_Session::get('key_hash');
41
		}
38 42

  
39
		return $this->cObj->getTypolink('PDF', $GLOBALS['TSFE']->id, $params, $target);
43
		return $this->cObj->getTypolink($text, $GLOBALS['TSFE']->id, $params, $target);
40 44
	}
41 45
}
42 46

  
Classes/Generator/FE/Tx_Formhandler_Generator_TcPdf.php (working copy)
64 64
			}
65 65
			$downloadpath = str_replace(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '', $downloadpath);
66 66
			header('Location: ' . $downloadpath);
67
			exit;
67 68
		} else {
68
			$this->pdf->Output('formhandler.pdf','I');
69
			
69
			$this->pdf->Output('formhandler.pdf','D');
70
			exit;
70 71
		}
71 72
	}
72 73
	
......
74 75
		$linkGP = array();
75 76
		$prefix = Tx_Formhandler_Globals::$formValuesPrefix;
76 77
		
78
		$text = $this->getLinkText();
79
		
77 80
		$target = '_blank';
78
        if($this->settings['target']) {
79
            $target = $this->settings['target'];
80
        }
81
        
81
		if($this->settings['target']) {
82
			$target = $this->settings['target'];
83
		}
84

  
85
		$linkGP = array();
86
		$prefix = Tx_Formhandler_Globals::$formValuesPrefix;
82 87
		if($prefix) {
83 88
			$linkGP[$prefix]['action'] = 'pdf';
84
			$linkGP[$prefix]['submitted'] = '1';
85
			$linkGP[$prefix]['submitted_ok'] = '1';
89
			$linkGP[$prefix]['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
90
			$linkGP[$prefix]['hash'] = Tx_Formhandler_Session::get('key_hash');
86 91
		} else {
87 92
			$linkGP['action'] = 'pdf';
88
			$linkGP['submitted'] = '1';
89
			$linkGP['submitted_ok'] = '1';
93
			$linkGP['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
94
			$linkGP['hash'] = Tx_Formhandler_Session::get('key_hash');
90 95
		}
91
		$linkGP['no_cache'] = 1;
92
		$linkGP['dontReset'] = 1;
93
		
94

  
95
		return $this->cObj->getTypolink('PDF', $GLOBALS['TSFE']->id, $linkGP, $target);
96
		return $this->cObj->getTypolink($text, $GLOBALS['TSFE']->id, $linkGP, $target);
96 97
	}
97 98
}
98 99

  
Classes/Generator/FE/Tx_Formhandler_Generator_Csv.php (working copy)
10 10
	public function process() {
11 11
		$params = $this->gp;
12 12
		require_once(t3lib_extMgm::extPath('formhandler') . 'Resources/PHP/parsecsv.lib.php');
13

  
13
		$exportParams = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'exportParams');
14
		if(!is_array($exportParams)) {
15
			$exportParams = t3lib_div::trimExplode(',', $exportParams);
16
		}
14 17
		//build data
15 18
		foreach($params as $key => &$value) {
16 19
			if(is_array($value)) {
......
24 27

  
25 28
		// create new parseCSV object.
26 29
		$csv = new parseCSV();
27
		$csv->output('formhandler.csv', $data, $exportParams);
30
		$csv->output('formhandler.csv', $data, $params);
28 31
		die();
29 32
	}
30 33
	
......
33 36
		$prefix = Tx_Formhandler_Globals::$formValuesPrefix;
34 37
		if($prefix) {
35 38
			$linkGP[$prefix]['action'] = 'csv';
36
			$linkGP[$prefix]['submitted'] = '1';
37
			$linkGP[$prefix]['submitted_ok'] = '1';
39
			$linkGP[$prefix]['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
40
			$linkGP[$prefix]['hash'] = Tx_Formhandler_Session::get('key_hash');
38 41
		} else {
39 42
			$linkGP['action'] = 'csv';
40
			$linkGP['submitted'] = '1';
41
			$linkGP['submitted_ok'] = '1';
43
			$linkGP['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
44
			$linkGP['hash'] = Tx_Formhandler_Session::get('key_hash');
42 45
		}
43
		$linkGP['no_cache'] = 1;
44
		$linkGP['dontReset'] = 1;
46
		
45 47
		return $this->cObj->getTypolink('CSV', $GLOBALS['TSFE']->id, $linkGP);
46 48
	}
47 49
}
Classes/Generator/FE/Tx_Formhandler_Generator_WebkitPdf.php (working copy)
57 57
	
58 58
	public function getLink($linkGP) {
59 59
		$params = array();
60
		
61
		$url = Tx_Formhandler_StaticFuncs::getHostname() . $this->cObj->getTypolink_URL($GLOBALS['TSFE']->id, $linkGP);
62
		
63
		$config = $this->readWebkitPdfConf();
64
		$text = 'Save as PDF';
65
		if($config['linkText']) {
66
			$text = Tx_Formhandler_StaticFuncs::getSingle($config, 'linkText');
60
		$prefix = Tx_Formhandler_Globals::$formValuesPrefix;
61
		$linkGP = array();
62
		if($prefix) {
63
			$linkGP['submitted_ok'] = 1;
64
			$linkGP[$prefix]['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
65
			$linkGP[$prefix]['hash'] = Tx_Formhandler_Session::get('key_hash');
66
		} else {
67
			$linkGP['submitted_ok'] = 1;
68
			$linkGP['tstamp'] = Tx_Formhandler_Session::get('inserted_tstamp');
69
			$linkGP['hash'] = Tx_Formhandler_Session::get('key_hash');
67 70
		}
71
		$url = Tx_Formhandler_StaticFuncs::getHostname() . $this->cObj->getTypolink_URL($GLOBALS['TSFE']->id, $linkGP);
72
		$text = $this->getLinkText();
68 73
		
69 74
		$params = array(
70 75
			'tx_webkitpdf_pi1' => array(
......
73 78
				)
74 79
			),
75 80
			'no_cache' => 1,
76
			'submitted_ok' => 1
77 81
		);
78
		
79 82
		return $this->cObj->getTypolink($text, $this->settings['pid'], $params);
80 83
	}
84
	
85
	protected function getLinkText() {
86
		$config = $this->readWebkitPdfConf();
87
		$text = 'Save as PDF';
88
		if($config['linkText']) {
89
			$text = Tx_Formhandler_StaticFuncs::getSingle($config, 'linkText');
90
		}
91
		return $text;
92
	}
81 93
}
82 94

  
83 95
?>
Classes/Generator/FE/Tx_Formhandler_AbstractGenerator.php (working copy)
2 2
abstract class Tx_Formhandler_AbstractGenerator extends Tx_Formhandler_AbstractComponent {
3 3
	
4 4
	abstract public function getLink($linkGP);
5
	
6
	protected function getLinkText() {
7
		$config = $this->settings;
8
		$text = 'Save as PDF';
9
		if($config['linkText']) {
10
			$text = Tx_Formhandler_StaticFuncs::getSingle($config, 'linkText');
11
		}
12
		return $text;
13
	}
5 14
}
6 15
?>