From 64ec4e6c67d0aa31bf4f5997e9b7b3d3cf5cd955 Mon Sep 17 00:00:00 2001 From: Julien Bidoret Date: Sat, 19 Oct 2024 17:23:44 +0200 Subject: [PATCH 1/4] Switching templates logic style to if:else:endif and foreach:endforeach (no re-indent) --- app/view/templates/alertcommandnotfound.php | 4 ++-- app/view/templates/alertexistnot.php | 8 ++++---- app/view/templates/alertlayout.php | 8 ++++---- app/view/templates/alertnotpublished.php | 4 ++-- app/view/templates/alertprivate.php | 4 ++-- app/view/templates/backtopbar.php | 20 ++++++++++---------- app/view/templates/edit.php | 4 ++-- app/view/templates/editrightbar.php | 8 ++++---- app/view/templates/edittabs.php | 4 ++-- app/view/templates/homebookmark.php | 12 ++++++------ app/view/templates/macro_tablesort.php | 4 ++-- app/view/templates/userconfirmdelete.php | 12 +++--------- 12 files changed, 43 insertions(+), 49 deletions(-) diff --git a/app/view/templates/alertcommandnotfound.php b/app/view/templates/alertcommandnotfound.php index 74309941..99e12be4 100644 --- a/app/view/templates/alertcommandnotfound.php +++ b/app/view/templates/alertcommandnotfound.php @@ -8,7 +8,7 @@

👁️ read page e($id) ?>

-isvisitor()) { ?> +isvisitor()) : ?>

💡 You may want to try:

- + stop() ?> diff --git a/app/view/templates/alertexistnot.php b/app/view/templates/alertexistnot.php index f89d49e9..687b7c73 100644 --- a/app/view/templates/alertexistnot.php +++ b/app/view/templates/alertexistnot.php @@ -2,17 +2,17 @@ start('alert') ?> -isvisitor() && Wcms\Config::existnotpass()) { ?> +isvisitor() && Wcms\Config::existnotpass()) : ?>

insert('alertform', ['id' => $page->id()]) ?>

- + -iseditor()) { ?> +iseditor()) : ?>

⭐ Create

@@ -26,7 +26,7 @@

🏠 Go back to home

- + diff --git a/app/view/templates/alertlayout.php b/app/view/templates/alertlayout.php index c34fb797..4b0c3889 100644 --- a/app/view/templates/alertlayout.php +++ b/app/view/templates/alertlayout.php @@ -31,22 +31,22 @@
' . Wcms\Config::alerttitle() . '' : '' ?> - +

- + section('alert')?> - +

- +
diff --git a/app/view/templates/alertnotpublished.php b/app/view/templates/alertnotpublished.php index a04073a9..82d33a8f 100644 --- a/app/view/templates/alertnotpublished.php +++ b/app/view/templates/alertnotpublished.php @@ -3,13 +3,13 @@ start('alert') ?> -isvisitor() && Wcms\Config::notpublishedpass()) { ?> +isvisitor() && Wcms\Config::notpublishedpass()) : ?>

insert('alertform', ['id' => $page->id()]) ?>

- + stop() ?> diff --git a/app/view/templates/alertprivate.php b/app/view/templates/alertprivate.php index 7010fc12..a12d3398 100644 --- a/app/view/templates/alertprivate.php +++ b/app/view/templates/alertprivate.php @@ -3,13 +3,13 @@ start('alert') ?> -isvisitor() && Wcms\Config::privatepass()) { ?> +isvisitor() && Wcms\Config::privatepass()) : ?>

insert('alertform', ['id' => $page->id()]) ?>

- + diff --git a/app/view/templates/backtopbar.php b/app/view/templates/backtopbar.php index d52b248b..d940d50f 100644 --- a/app/view/templates/backtopbar.php +++ b/app/view/templates/backtopbar.php @@ -6,20 +6,20 @@ iseditor() ? '' : '' ?> - iseditor()) { ?> + iseditor()) : ?> - + - + - + - iseditor()) { ?> + iseditor()) : ?> > @@ -32,13 +32,13 @@ - + - isadmin()) { ?> + isadmin()) : ?> > @@ -50,7 +50,7 @@ admin - + > documentation @@ -69,10 +69,10 @@
- + - +
diff --git a/app/view/templates/edit.php b/app/view/templates/edit.php index afeb157d..f92fc141 100644 --- a/app/view/templates/edit.php +++ b/app/view/templates/edit.php @@ -30,7 +30,7 @@ - + - + stop('page') ?> diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php index 9e06fe88..6696d516 100644 --- a/app/view/templates/editrightbar.php +++ b/app/view/templates/editrightbar.php @@ -12,10 +12,10 @@ class="toggle"
- iseditor()) { ?> + iseditor()) : ?>

Authors

- +
- + - + diff --git a/app/view/templates/edittabs.php b/app/view/templates/edittabs.php index 826936a3..ee7b88c9 100644 --- a/app/view/templates/edittabs.php +++ b/app/view/templates/edittabs.php @@ -1,6 +1,6 @@
- $value) { ?> + $value) : ?>
> @@ -21,6 +21,6 @@ class="editorarea" >e($value) ?>
- +
diff --git a/app/view/templates/homebookmark.php b/app/view/templates/homebookmark.php index 67cc22eb..a528ac06 100644 --- a/app/view/templates/homebookmark.php +++ b/app/view/templates/homebookmark.php @@ -7,7 +7,7 @@ - + - +
- ispublished()){ ?> + ispublished()) : ?> - +

personal

- + - +
diff --git a/app/view/templates/macro_tablesort.php b/app/view/templates/macro_tablesort.php index d6fa96b9..200ce683 100644 --- a/app/view/templates/macro_tablesort.php +++ b/app/view/templates/macro_tablesort.php @@ -1,3 +1,3 @@ -sortby() === $th) { ?> +sortby() === $th) : ?> - \ No newline at end of file + \ No newline at end of file diff --git a/app/view/templates/userconfirmdelete.php b/app/view/templates/userconfirmdelete.php index 462f093a..38f7e9e5 100644 --- a/app/view/templates/userconfirmdelete.php +++ b/app/view/templates/userconfirmdelete.php @@ -1,7 +1,5 @@ - +

Delete User

@@ -24,9 +22,7 @@ - +

You can't delete this user

@@ -37,6 +33,4 @@
Go back to users - + From 879cfd71fe2b4df446770b9d2b2041504776ca47 Mon Sep 17 00:00:00 2001 From: Julien Bidoret Date: Sat, 19 Oct 2024 17:31:17 +0200 Subject: [PATCH 2/4] Switching templates logic style to if:else:endif and foreach:endforeach (with re-indent!) --- app/view/templates/admin.php | 47 +-- app/view/templates/connect.php | 22 +- app/view/templates/delete.php | 5 +- app/view/templates/editleftbar.php | 64 ++-- app/view/templates/edittopbar.php | 12 +- app/view/templates/forbidden.php | 18 +- app/view/templates/home.php | 594 +++++++++++++++-------------- app/view/templates/homemenu.php | 145 ++++--- app/view/templates/homeopt.php | 42 +- app/view/templates/layout.php | 33 +- app/view/templates/media.php | 266 +++++++------ app/view/templates/mediamenu.php | 22 +- app/view/templates/user.php | 8 +- 13 files changed, 603 insertions(+), 675 deletions(-) diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php index 8e9e21b9..0432274d 100644 --- a/app/view/templates/admin.php +++ b/app/view/templates/admin.php @@ -65,15 +65,9 @@ @@ -120,12 +114,9 @@ @@ -285,13 +276,9 @@

Thumbnail

@@ -299,11 +286,9 @@

Interface

@@ -313,13 +298,9 @@

@@ -374,13 +355,9 @@ diff --git a/app/view/templates/connect.php b/app/view/templates/connect.php index ae288e2d..a6139ff6 100644 --- a/app/view/templates/connect.php +++ b/app/view/templates/connect.php @@ -6,15 +6,13 @@

Login

- isvisitor()) { ?> + isvisitor()) : ?>
- '; - } - ?> + + + @@ -27,7 +25,7 @@
- +
@@ -35,13 +33,11 @@ - + - back to page read view

'; - } - ?> + +

back to page read view

+
stop() ?> diff --git a/app/view/templates/delete.php b/app/view/templates/delete.php index e28cd7a2..691136b6 100644 --- a/app/view/templates/delete.php +++ b/app/view/templates/delete.php @@ -16,13 +16,14 @@
  • Number of displays : displaycount() ?>
  • Page linking to this one : - 0) { ?> + 0) : ?> +
  • - + diff --git a/app/view/templates/editleftbar.php b/app/view/templates/editleftbar.php index 3729a0d0..ed51263d 100644 --- a/app/view/templates/editleftbar.php +++ b/app/view/templates/editleftbar.php @@ -38,11 +38,11 @@ class="toggle" - + - + @@ -51,18 +51,18 @@ class="toggle" - + - + - thumbnail())) { ?> + thumbnail())) : ?>
    - + @@ -92,57 +92,45 @@ class="toggle" Template
    - templatebody())) { ?> + templatebody())) : ?> - + - templatecss())) { ?> + templatecss())) : ?> - + - templatejavascript())) { ?> + templatejavascript())) : ?> - + @@ -163,16 +151,12 @@ class="toggle"
    - externalcss() as $css) { - ?> -
    - - -
    - + externalcss() as $css) : ?> +
    + + +
    + diff --git a/app/view/templates/edittopbar.php b/app/view/templates/edittopbar.php index bd246590..54640292 100644 --- a/app/view/templates/edittopbar.php +++ b/app/view/templates/edittopbar.php @@ -35,14 +35,14 @@ - candeletepage($page)) { ?> + candeletepage($page)) : ?> - - - delete - + + + delete + - + diff --git a/app/view/templates/forbidden.php b/app/view/templates/forbidden.php index c5d14684..e8297439 100644 --- a/app/view/templates/forbidden.php +++ b/app/view/templates/forbidden.php @@ -14,18 +14,16 @@ e($user->level()) ?> -isinvite()) { ?> +isinvite()) : ?>

    Sorry e($user->name()) ?>, you are not allowed to do this.

    - - -back to page read view

    '; -} else { - echo '

    Go back to home'; -} -?> + + + +

    back to page read view

    + +

    Go back to home + stop() ?> diff --git a/app/view/templates/home.php b/app/view/templates/home.php index a7cb2d65..187279e6 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -13,7 +13,7 @@ insert('backtopbar', ['user' => $user, 'tab' => 'home', 'pagelist' => $pagelist]) ?> -iseditor()) { ?> +iseditor()) : ?> @@ -51,7 +51,7 @@

    Pages () - isfiltered()) { ?> + isfiltered()) : ?> @@ -59,10 +59,10 @@ - - + + - + > > @@ -70,309 +70,313 @@

    - + - + -
    - - - > - - > - - - - - -
    +
    +
    + + > + + > + + + + +
    +
    -
    +
    - + - + - + + - - + -
    +
    - pages have geo datas set. + pages have geo datas set. -
    +
    - + + + - - -
    - - - - - -
    -
    - - -
    > - - > - - > - - > - - > - - > - - > - -
    -
    -
    - - - - - -
    - - - - - issupereditor()) { ?> - - + + + + + + + + + + + + + + + + issupereditor()) : ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    x - ico - insert('macro_tablesort', ['opt' => $opt, 'th' => 'favicon']) ?> + + + + + + +
    +
    + + +
    > + + > + + > + + > + + > + + > + + > + +
    +
    +
    + + + + + +
    + + + + issupereditor()) : ?> + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - issupereditor()) { ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    x + ico + insert('macro_tablesort', ['opt' => $opt, 'th' => 'favicon']) ?> + + id + insert('macro_tablesort', ['opt' => $opt, 'th' => 'id']) ?> - id - insert('macro_tablesort', ['opt' => $opt, 'th' => 'id']) ?> - - tag - insert('macro_tablesort', ['opt' => $opt, 'th' => 'tag']) ?> - - title - insert('macro_tablesort', ['opt' => $opt, 'th' => 'title']) ?> - description - linkto - insert('macro_tablesort', ['opt' => $opt, 'th' => 'linkto']) ?> - - - geo - - last modification - insert('macro_tablesort', ['opt' => $opt, 'th' => 'datemodif']) ?> - - date of creation - insert('macro_tablesort', ['opt' => $opt, 'th' => 'datecreation']) ?> - - date - insert('macro_tablesort', ['opt' => $opt, 'th' => 'date']) ?> - - privacy - insert('macro_tablesort', ['opt' => $opt, 'th' => 'secure']) ?> - + tag + insert('macro_tablesort', ['opt' => $opt, 'th' => 'tag']) ?> + + title + insert('macro_tablesort', ['opt' => $opt, 'th' => 'title']) ?> + description + linkto + insert('macro_tablesort', ['opt' => $opt, 'th' => 'linkto']) ?> + geo + last modification + insert('macro_tablesort', ['opt' => $opt, 'th' => 'datemodif']) ?> + + date of creation + insert('macro_tablesort', ['opt' => $opt, 'th' => 'datecreation']) ?> + + date + insert('macro_tablesort', ['opt' => $opt, 'th' => 'date']) ?> + + privacy + insert('macro_tablesort', ['opt' => $opt, 'th' => 'secure']) ?> + authors - insert('macro_tablesort', ['opt' => $opt, 'th' => 'authors']) ?> + insert('macro_tablesort', ['opt' => $opt, 'th' => 'authors']) ?> - visit - insert('macro_tablesort', ['opt' => $opt, 'th' => 'visitcount']) ?> - - edit - insert('macro_tablesort', ['opt' => $opt, 'th' => 'editcount']) ?> - - display - insert('macro_tablesort', ['opt' => $opt, 'th' => 'displaycount']) ?> - - version - insert('macro_tablesort', ['opt' => $opt, 'th' => 'version']) ?> -
    - favicon())) { ?> - - - - - - - - redirection())) { ?> - - - - refresh() !== 0 ? $item->refresh() . 's' : '' ?> - - - - - caneditpage($item)) { ?> - - - - - - - - - - candeletepage($item)) { ?> - - - - - - caneditpage($item)) { ?> - - - - - taglinks($item->tag('array')) ?>description('short') ?>linktolink($item->linkto('array')) ?> - - isgeo() ? '' : '' ?> - - - - - - - - - securelink($item->secure('int') , $item->secure('string')) ?> - password()) ? '' : '' ?> - authorlinks($item->authors('array')) ?>visitcount() ?>editcount() ?>displaycount() ?>version() ?>
    -
    - - + + +
    + visit + insert('macro_tablesort', ['opt' => $opt, 'th' => 'visitcount']) ?> + + edit + insert('macro_tablesort', ['opt' => $opt, 'th' => 'editcount']) ?> + + display + insert('macro_tablesort', ['opt' => $opt, 'th' => 'displaycount']) ?> + + version + insert('macro_tablesort', ['opt' => $opt, 'th' => 'version']) ?> +
    + favicon())) : ?> + + + + + + + + redirection())) : ?> + + + + refresh() !== 0 ? $item->refresh() . 's' : '' ?> + + + + + caneditpage($item)) : ?> + + + + + + + + + + candeletepage($item)) : ?> + + + + + + caneditpage($item)) : ?> + + + + + taglinks($item->tag('array')) ?>description('short') ?>linktolink($item->linkto('array')) ?> + + isgeo() ? '' : '' ?> + + + + + + + + + securelink($item->secure('int') , $item->secure('string')) ?> + password()) ? '' : '' ?> + authorlinks($item->authors('array')) ?>visitcount() ?>editcount() ?>displaycount() ?>version() ?>
    +
    + +
    @@ -383,14 +387,14 @@ class="redirection" insert('footer', ['footer' => $footer]) ?> - + - + - + stop() ?> diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php index 6ba50cc6..bd8a9da1 100644 --- a/app/view/templates/homemenu.php +++ b/app/view/templates/homemenu.php @@ -1,7 +1,7 @@
    @@ -115,7 +113,7 @@
      - authorlist() as $authorfilter => $count) { ?> + authorlist() as $authorfilter => $count) : ?>
    • - -
    + +
    @@ -170,15 +168,11 @@ @@ -226,9 +220,9 @@ - isfiltered()) { ?> + isfiltered()) : ?> - + diff --git a/app/view/templates/layout.php b/app/view/templates/layout.php index 693c6e0c..0284ee59 100644 --- a/app/view/templates/layout.php +++ b/app/view/templates/layout.php @@ -5,29 +5,24 @@ - + - + - + <?= $title ?> - + - + - '; - } - ?> + + + - + - + +if (!empty($flashmessages) && is_array($flashmessages)) : ?>
      - +
    • - +
    - + section('page') ?> diff --git a/app/view/templates/media.php b/app/view/templates/media.php index 032c8205..e9feeac6 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -84,149 +84,145 @@
    - mediadisplay() === Wcms\Workspace::GALLERY) { ?> + mediadisplay() === Wcms\Workspace::GALLERY) : ?> - + -
    + -
    - - - - e($media->getcode()) ?> -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + +
    x - filename - insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'filename']) ?> - - ext - insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'extension']) ?> - - type - insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'type']) ?> - - size - insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'size']) ?> - - date - insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'date']) ?> - userpermsscode
    - issupereditor()) { ?> -
    - - - -
    - - - - - -
    -
    - - - filename() ?> - -
    extension() ?> - - type() === 'image') { ?> - - - - - type() === 'font' && $mediaopt->isfontdir()) { ?> - - - - - - - - - size('hr') ?>date('hrdi') ?>uid('name') ?>permissions() ?> - - - - - e($media->getcode()) ?> -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    x + filename + insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'filename']) ?> + + ext + insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'extension']) ?> + + type + insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'type']) ?> + + size + insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'size']) ?> + + date + insert('macro_tablesort', ['opt' => $mediaopt, 'th' => 'date']) ?> + userpermsscode
    + issupereditor()) : ?> +
    + + + +
    + + + + + +
    +
    + + + filename() ?> + +
    extension() ?> + + type() === 'image') : ?> + + + + + type() === 'font' && $mediaopt->isfontdir()) : ?> + + + + + + + + + size('hr') ?>date('hrdi') ?>uid('name') ?>permissions() ?> + + + + + e($media->getcode()) ?> +
    - + @@ -234,11 +230,11 @@ - + - + diff --git a/app/view/templates/mediamenu.php b/app/view/templates/mediamenu.php index 5e4932aa..1672cb27 100644 --- a/app/view/templates/mediamenu.php +++ b/app/view/templates/mediamenu.php @@ -23,13 +23,13 @@ - +
    - + @@ -53,7 +53,7 @@ - issupereditor()) { ?> + issupereditor()) : ?>

    Delete folder

    @@ -63,7 +63,7 @@
    - +

    Magic folders

    fonts

    @@ -78,7 +78,7 @@ Edit - > +
    > Filter - + @@ -394,7 +394,7 @@ class="redirection" - + stop() ?> From 0e106dfb6a9329da9bfcfa9566eceaea30c12421 Mon Sep 17 00:00:00 2001 From: Julien Bidoret Date: Mon, 21 Oct 2024 17:55:04 +0200 Subject: [PATCH 4/4] Reviewed PHP logic style switching in templates Co-authored-by: Nicolas Peugnet --- app/view/templates/homeopt.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/view/templates/homeopt.php b/app/view/templates/homeopt.php index d593eea7..fba24138 100644 --- a/app/view/templates/homeopt.php +++ b/app/view/templates/homeopt.php @@ -22,9 +22,10 @@ Sort