Overview
Comment:Transform page into category
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable | 1.1.7
Files: files | file ages | folders
SHA3-256: 32af6fd82634220be1ee4475602ef9d77758bd5df1349999e6e1840180b22087
User & Date: bohwaz on 2021-06-02 19:44:26
Other Links: manifest | tags
Context
2021-06-02
19:51
Don't forget to remove old table check-in: 2be45a66b0 user: bohwaz tags: trunk, stable, 1.1.7
19:44
Transform page into category check-in: 32af6fd826 user: bohwaz tags: trunk, stable, 1.1.7
16:11
Fix [d04db0a0f3147b2a5375da475c2bc076b589efc9]: proper tree of categories check-in: 51f40f8343 user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Entities/Web/Page.php from [a7ec198f09] to [0f694d7210].

431
432
433
434
435
436
437
438





439
440
441
442
443
444











445




446
447
448
449
450
451
452
	{
		if (!$this->importFromRaw($file->fetch())) {
			throw new \LogicException('Invalid page content: ' . $file->parent);
		}

		$this->set('modified', $file->modified);

		foreach (Files::list($file->parent) as $subfile) {





			if ($subfile->type == File::TYPE_DIRECTORY) {
				$this->set('type', self::TYPE_CATEGORY);
				return;
			}
		}












		$this->set('type', self::TYPE_PAGE); // Default




	}

	static public function fromFile(File $file): self
	{
		$page = new self;

		// Path is relative to web root







|
>
>
>
>
>

|
<



>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>







431
432
433
434
435
436
437
438
439
440
441
442
443
444
445

446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
	{
		if (!$this->importFromRaw($file->fetch())) {
			throw new \LogicException('Invalid page content: ' . $file->parent);
		}

		$this->set('modified', $file->modified);

		$this->set('type', $this->checkRealType());
	}

	public function checkRealType(): int
	{
		foreach (Files::list(Utils::dirname($this->filepath())) as $subfile) {
			if ($subfile->type == File::TYPE_DIRECTORY) {
				return self::TYPE_CATEGORY;

			}
		}

		return self::TYPE_PAGE;
	}

	public function toggleType(): void
	{
		$real_type = $this->checkRealType();

		if ($real_type == self::TYPE_CATEGORY) {
			$this->set('type', $real_type);
		}
		elseif ($this->type == self::TYPE_CATEGORY) {
			$this->set('type', self::TYPE_PAGE);
		}
		else {
			$this->set('type', self::TYPE_CATEGORY);
		}
	}

	static public function fromFile(File $file): self
	{
		$page = new self;

		// Path is relative to web root

Modified src/templates/web/page.tpl from [419cb9b89a] to [3803091252].

2
3
4
5
6
7
8




9
10
11
12
13
14
15

<nav class="tabs">
	{if $page.type == $page::TYPE_CATEGORY}
	<aside>
		{linkbutton shape="plus" label="Nouvelle page" href="new.php?type=%d&parent=%d"|args:$type_page,$page.path}
		{linkbutton shape="plus" label="Nouvelle catégorie" href="new.php?type=%d&parent=%d"|args:$type_category,$page.path}
	</aside>




	{/if}
	<ul>
		<li><a href="{$admin_url}web/?p={$page.parent}">Retour à la liste</a></li>
		{if $session->canAccess($session::SECTION_WEB, $session::ACCESS_WRITE)}
			<li><a href="{$admin_url}web/edit.php?p={$page.path}">Modifier</a></li>
		{/if}
		{if $page.status == $page::STATUS_ONLINE && !$config.site_disabled}







>
>
>
>







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

<nav class="tabs">
	{if $page.type == $page::TYPE_CATEGORY}
	<aside>
		{linkbutton shape="plus" label="Nouvelle page" href="new.php?type=%d&parent=%d"|args:$type_page,$page.path}
		{linkbutton shape="plus" label="Nouvelle catégorie" href="new.php?type=%d&parent=%d"|args:$type_category,$page.path}
	</aside>
	{else}
	<aside>
		{linkbutton href="?p=%s&toggle_type"|args:$page.path label="Transformer en catégorie" shape="reset"}
	</aside>
	{/if}
	<ul>
		<li><a href="{$admin_url}web/?p={$page.parent}">Retour à la liste</a></li>
		{if $session->canAccess($session::SECTION_WEB, $session::ACCESS_WRITE)}
			<li><a href="{$admin_url}web/edit.php?p={$page.path}">Modifier</a></li>
		{/if}
		{if $page.status == $page::STATUS_ONLINE && !$config.site_disabled}

Modified src/www/admin/web/page.php from [c7ad7078d0] to [da153abd6b].

8
9
10
11
12
13
14






15
16
17
18
19
20
21
require_once __DIR__ . '/_inc.php';

$page = Web::get(qg('p'));

if (!$page) {
	throw new UserException('Page inconnue');
}







$membres = new Membres;

$tpl->assign('breadcrumbs', $page->getBreadcrumbs());

$images = $page->getImageGallery(true);
$files = $page->getAttachmentsGallery(true);







>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require_once __DIR__ . '/_inc.php';

$page = Web::get(qg('p'));

if (!$page) {
	throw new UserException('Page inconnue');
}

if (qg('toggle_type') !== null) {
	$page->toggleType();
	$page->save();
	Utils::redirect('!web/page.php?p=' . $page->path);
}

$membres = new Membres;

$tpl->assign('breadcrumbs', $page->getBreadcrumbs());

$images = $page->getImageGallery(true);
$files = $page->getAttachmentsGallery(true);