1<?php
2
3/* format the output */
4
5/*go on with the given value from <pot ? >*/
6$formatedsettings = $pothelper->_formatsettings($potsettings);
7
8/*check if we have to set pagedefault and set it to cargo*/
9if (isset($formatedsettings['set'])) {
10	$none = preg_replace('/\s*display\s*=\s*none\s*/', 'display=inline', $formatedsettings['pagedefault']); //replace var and field to avoid circles ?
11	$this->cargo['settings'][$formatedsettings['set']] = $none;
12}
13
14/*check if we have a shortcut set, use the pagedefault needed */
15$defsettings = array();
16if (isset($formatedsettings['defaultsettings'])) {
17	$def = $this->cargo['settings'][$formatedsettings['defaultsettings']];
18	$defsettings = $pothelper->_formatsettings($def);
19}
20
21/* start with some default */
22// default TODO: get it from config
23/* last we create the array from the config default */
24$configdefault = $this->getConf('default_settings');
25$configdefault = $pothelper->_formatsettings($configdefault);
26$backupdefault = "potid=pot_1 | decimals=0 | currency= | width=0 | formula=false | display=flex | sepmil=. | sepdec=,";
27$backupdefault = $pothelper->_formatsettings($backupdefault);
28$defaultsettings = array_merge($backupdefault, $configdefault);
29
30
31/*set potid,check if it is unique, set it from input or ad a new number at the end */
32$forpotid = $formatedsettings['potid'];
33if (array_key_exists('potid', $formatedsettings)) {
34	if (array_key_exists($forpotid, $this->cargo)) {
35		$timestamp = time();
36		$potid = $forpotid."_".uniqid();
37		$this->cargo[$potid]['output']['error'] = "potid already exists: $forpotid ";
38
39	} else {
40		$potid = $formatedsettings['potid'];
41	}
42} else {
43	preg_match('/^(.*?)(\d*?)$/', $this->cargo['pot'], $potidarr);
44	$potidval = $potidarr[1];
45	$potidnr = intval($potidarr[2]) + 1;
46	$potid = $potidval.$potidnr;
47}
48
49/* merge general default and pagedefault and potsettings */
50$finalsettings = array_merge($defaultsettings, $defsettings, $formatedsettings);
51
52$this->cargo['pot'] = $potid; // set the var to use it global
53$finalsettings['potid'] = $potid; // yes this value is double , why?
54$this->cargo[$potid]['settings'] = $finalsettings; // set the var to use it global