Overview
Comment:Put methods back in old order, easier for diffs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | templates
Files: files | file ages | folders
SHA3-256: c91650a21fd9190c543b88bf7d2c644d491ed8bfd978fa22a3e46011132008e3
User & Date: bohwaz on 2022-07-29 04:04:50
Other Links: branch diff | manifest | tags
Context
2022-08-08
00:44
Fix calls for CommonModifiers::input check-in: cbabcb84cc user: bohwaz tags: templates
2022-07-29
04:04
Put methods back in old order, easier for diffs check-in: c91650a21f user: bohwaz tags: templates
03:42
Merge trunk into templates check-in: 32f3af939e user: bohwaz tags: templates
Changes

Modified src/include/lib/Garradin/Web/Skeleton.php from [556415611b] to [bd3e31e44c].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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





70
71
72
73
74
75
76
class Skeleton
{
	const TEMPLATE_TYPES = '!^(?:text/(?:html|plain)|\w+/(?:\w+\+)?xml)$!';

	protected ?string $path;
	protected ?File $file = null;

	static public function isValidPath(string $path)
	{
		return (bool) preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!i', $path);
	}

	static public function list(): array
	{
		$sources = [];

		$path = ROOT . '/skel-dist/web';
		$i = new \DirectoryIterator($path);

		foreach ($i as $file) {
			if ($file->isDot() || $file->isDir()) {
				continue;
			}

			$mime = mime_content_type($file->getRealPath());

			$sources[$file->getFilename()] = ['is_text' => substr($mime, 0, 5) == 'text/', 'changed' => null];
		}

		unset($i);

		$list = Files::list(File::CONTEXT_SKELETON . '/web');

		foreach ($list as $file) {
			if ($file->type != $file::TYPE_FILE) {
				continue;
			}

			$sources[$file->name] = ['is_text' => substr($file->mime, 0, 5) == 'text/', 'changed' => $file->modified];
		}

		ksort($sources);

		return $sources;
	}

	public function __construct(string $path)
	{
		if (!self::isValidPath($path)) {
			throw new \InvalidArgumentException('Invalid skeleton name');
		}

		$this->path = $path;
	}






	public function defaultPath(): ?string
	{
		$path = ROOT . '/skel-dist/web/' . $this->path;

		if (file_exists($path)) {
			return $path;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








>
>
>
>
>







16
17
18
19
20
21
22







































23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Skeleton
{
	const TEMPLATE_TYPES = '!^(?:text/(?:html|plain)|\w+/(?:\w+\+)?xml)$!';

	protected ?string $path;
	protected ?File $file = null;








































	public function __construct(string $path)
	{
		if (!self::isValidPath($path)) {
			throw new \InvalidArgumentException('Invalid skeleton name');
		}

		$this->path = $path;
	}

	static public function isValidPath(string $path)
	{
		return (bool) preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!i', $path);
	}

	public function defaultPath(): ?string
	{
		$path = ROOT . '/skel-dist/web/' . $this->path;

		if (file_exists($path)) {
			return $path;
295
296
297
298
299
300
301
302


































	static public function resetSelected(array $selected)
	{
		foreach ($selected as $file) {
			$f = new self($file);
			$f->reset();
		}
	}
}









































|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
	static public function resetSelected(array $selected)
	{
		foreach ($selected as $file) {
			$f = new self($file);
			$f->reset();
		}
	}

	static public function list(): array
	{
		$sources = [];

		$path = ROOT . '/skel-dist/web';
		$i = new \DirectoryIterator($path);

		foreach ($i as $file) {
			if ($file->isDot() || $file->isDir()) {
				continue;
			}

			$mime = mime_content_type($file->getRealPath());

			$sources[$file->getFilename()] = ['is_text' => substr($mime, 0, 5) == 'text/', 'changed' => null];
		}

		unset($i);

		$list = Files::list(File::CONTEXT_SKELETON . '/web');

		foreach ($list as $file) {
			if ($file->type != $file::TYPE_FILE) {
				continue;
			}

			$sources[$file->name] = ['is_text' => substr($file->mime, 0, 5) == 'text/', 'changed' => $file->modified];
		}

		ksort($sources);

		return $sources;
	}
}