Overview
Comment:Merge trunk into sharing
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | sharing
Files: files | file ages | folders
SHA3-256: 608090b2babf4101e32b40fe22078c3e7fc3b1c786cf9d116f7dc5abcd049b73
User & Date: bohwaz on 2024-03-18 17:14:39
Other Links: branch diff | manifest | tags
Context
2024-03-18
17:14
Merge trunk into sharing Leaf check-in: 608090b2ba user: bohwaz tags: sharing
2024-03-17
03:00
CSV_Custom: Implement hasRawHeaderColumn to detect some specific CSV files Leaf check-in: a19fb93ba8 user: bohwaz tags: trunk, stable
2024-03-15
03:49
Sharing now works correctly check-in: 58bc762847 user: bohwaz tags: sharing
Changes

Modified src/Makefile from [62d0020613] to [83590c442b].

9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
deps:
	$(eval TMP_KD2=$(shell mktemp -d))
	#cd ${TMP_KD2}

	wget ${KD2FW_URL}zip/${KD2FW_BRANCH}/kd2.zip -O ${TMP_KD2}/kd2.zip

	rm -rf "include/lib/KD2"
	unzip "${TMP_KD2}/kd2.zip" -d include/lib


	rm -rf ${TMP_KD2}

modules:
	wget ${MODULES_URL}zip/${MODULES_BRANCH}/modules.zip -O modules.zip
	unzip -u modules.zip
	rm -f modules.zip







|
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
deps:
	$(eval TMP_KD2=$(shell mktemp -d))
	#cd ${TMP_KD2}

	wget ${KD2FW_URL}zip/${KD2FW_BRANCH}/kd2.zip -O ${TMP_KD2}/kd2.zip

	rm -rf "include/lib/KD2"
	unzip "${TMP_KD2}/kd2.zip" -d ${TMP_KD2}
	mv ${TMP_KD2}/kd2/src/lib/KD2 include/lib

	rm -rf ${TMP_KD2}

modules:
	wget ${MODULES_URL}zip/${MODULES_BRANCH}/modules.zip -O modules.zip
	unzip -u modules.zip
	rm -f modules.zip

Modified src/include/lib/Paheko/CSV_Custom.php from [0064126572] to [9886541e24].

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
	public function getLine(int $i): ?\stdClass
	{
		if (!isset($this->csv[$i])) {
			return null;
		}

		if (!isset($this->_default)) {
			$this->_default = array_map(function ($a) { return null; }, array_flip($this->translation));
		}

		$row = $this->_default;

		foreach ($this->csv[$i] as $col => $value) {
			if (!isset($this->translation[$col])) {
				continue;







|







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
	public function getLine(int $i): ?\stdClass
	{
		if (!isset($this->csv[$i])) {
			return null;
		}

		if (!isset($this->_default)) {
			$this->_default = array_fill_keys(array_flip($this->translation), null);
		}

		$row = $this->_default;

		foreach ($this->csv[$i] as $col => $value) {
			if (!isset($this->translation[$col])) {
				continue;
354
355
356
357
358
359
360
361















		foreach ($this->translation as $i => $name) {
			$out[$name] = $this->columns[$name];
		}

		return $out;
	}
}





















|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375

		foreach ($this->translation as $i => $name) {
			$out[$name] = $this->columns[$name];
		}

		return $out;
	}

	public function getRawHeader(): ?array
	{
		if (!$this->loaded()) {
			return null;
		}

		return reset($this->csv) ?: null;
	}

	public function hasRawHeaderColumn(string $label)
	{
		return in_array($label, $this->getRawHeader(), true);
	}
}

Modified src/include/lib/Paheko/DynamicList.php from [81d1307f17] to [75fe7f1809].

42
43
44
45
46
47
48
49


50
51
52








53
54
55
56
57
58
59
	/**
	 * Default order column (must reference a valid key of $columns)
	 */
	protected string $order;

	/**
	 * Modifier callback function
	 * This will be called for each row


	 */
	protected $modifier;









	/**
	 * Export modifier callback function
	 * Called for each row, for export only
	 */
	protected $export_callback;

	/**







|
>
>



>
>
>
>
>
>
>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	/**
	 * Default order column (must reference a valid key of $columns)
	 */
	protected string $order;

	/**
	 * Modifier callback function
	 * This will be called for each row.
	 * This can also insert new rows after current one by using "yield"
	 * (useful for eg. stepped totals)
	 */
	protected $modifier;

	/**
	 * Final callback function
	 * This will be called after the last row.
	 * This can insert new rows after current one by using "yield"
	 * (useful for eg. last total number)
	 */
	protected $final_generator;

	/**
	 * Export modifier callback function
	 * Called for each row, for export only
	 */
	protected $export_callback;

	/**
132
133
134
135
136
137
138






139
140
141
142
143
144
145
146
147
148
149
150




151
152
153
154
155
156
157
	{
		$this->preference_hash_elements[$name] = $enable;
	}

	public function setParameter($key, $value) {
		$this->parameters[$key] = $value;
	}







	public function setTitle(string $title) {
		$this->title = $title;
	}

	public function getTitle(): string {
		return $this->title;
	}

	public function setModifier(callable $fn) {
		$this->modifier = $fn;
	}





	public function setExportCallback(callable $fn) {
		$this->export_callback = $fn;
	}

	public function setPageSize(?int $size) {
		$this->per_page = $size;







>
>
>
>
>
>












>
>
>
>







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
	{
		$this->preference_hash_elements[$name] = $enable;
	}

	public function setParameter($key, $value) {
		$this->parameters[$key] = $value;
	}

	public function setParameters(array $parameters) {
		foreach ($parameters as $key => $value) {
			$this->parameters[$key] = $value;
		}
	}

	public function setTitle(string $title) {
		$this->title = $title;
	}

	public function getTitle(): string {
		return $this->title;
	}

	public function setModifier(callable $fn) {
		$this->modifier = $fn;
	}

	public function setFinalGenerator(callable $fn) {
		$this->final_generator = $fn;
	}

	public function setExportCallback(callable $fn) {
		$this->export_callback = $fn;
	}

	public function setPageSize(?int $size) {
		$this->per_page = $size;
295
296
297
298
299
300
301


302
303
304
305



306
307
308
309
310
311
312
313
314
315
316
317
318








319
320
321
322
323
324
325
	{
		if ($this->entity) {
			$list = EM::getInstance($this->entity)->iterate($this->SQL());
		}
		else {
			$list = DB::getInstance()->iterate($this->SQL(), $this->parameters);
		}



		foreach ($list as $row_key => $row) {
			if ($this->modifier) {
				call_user_func_array($this->modifier, [&$row]);



			}

			// Hide columns without a label in results
			if (!$this->entity) {
				foreach ($this->columns as $key => $config) {
					if (empty($config['label']) && !$include_hidden) {
						unset($row->$key);
					}
				}
			}

			yield $row_key => $row;
		}








	}

	public function SQL()
	{
		$start = ($this->page - 1) * $this->per_page;
		$db = DB::getInstance();








>
>



|
>
>
>













>
>
>
>
>
>
>
>







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
	{
		if ($this->entity) {
			$list = EM::getInstance($this->entity)->iterate($this->SQL());
		}
		else {
			$list = DB::getInstance()->iterate($this->SQL(), $this->parameters);
		}

		$row = null;

		foreach ($list as $row_key => $row) {
			if ($this->modifier) {
				$r = call_user_func_array($this->modifier, [&$row]);
				if (is_array($r) || $r instanceof \Generator) {
					yield from $r;
				}
			}

			// Hide columns without a label in results
			if (!$this->entity) {
				foreach ($this->columns as $key => $config) {
					if (empty($config['label']) && !$include_hidden) {
						unset($row->$key);
					}
				}
			}

			yield $row_key => $row;
		}

		if ($this->final_generator) {
			$r = call_user_func($this->final_generator, $row);

			if (is_array($r) || $r instanceof \Generator) {
				yield from $r;
			}
		}
	}

	public function SQL()
	{
		$start = ($this->page - 1) * $this->per_page;
		$db = DB::getInstance();

Modified src/www/admin/config/ext/delete.php from [2da7be8aa3] to [8fa57ec0af].

39
40
41
42
43
44
45

46
47
48
49
50
51
52
			$module->deleteData();
		}
		elseif ($mode === 'reset') {
			$module->resetChanges();
		}
		else {
			$module->delete();

		}
	}, $csrf_key, '!config/ext/');
}

$tpl->assign(compact('plugin', 'module', 'csrf_key', 'mode'));

$tpl->display('config/ext/delete.tpl');







>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
			$module->deleteData();
		}
		elseif ($mode === 'reset') {
			$module->resetChanges();
		}
		else {
			$module->delete();
			Utils::redirectDialog('!config/ext/');
		}
	}, $csrf_key, '!config/ext/');
}

$tpl->assign(compact('plugin', 'module', 'csrf_key', 'mode'));

$tpl->display('config/ext/delete.tpl');