Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching templates logic style #454

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 12 additions & 35 deletions app/view/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,9 @@
<select name="homeredirect" id="homeredirect" form="admin">
<option value="" <?= Wcms\Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option>

<?php
foreach ($pagelist as $page) {
?>
<?php foreach ($pagelist as $page) : ?>
<option value="<?= $page ?>" <?= Wcms\Config::homeredirect() === $page ? 'selected' : '' ?>><?= $page ?></option>
<?php
}


?>
<?php endforeach ?>
</select>


Expand Down Expand Up @@ -120,12 +114,9 @@
<label for="alertlink">Link to this page (for visitors)</label>
<select name="alertlink" id="alertlink" form="admin">
<option value="" <?= empty(Wcms\Config::alertlink()) ? 'selected' : '' ?>>--No link--</option>
<?php
foreach ($pagelist as $page) {
?>
<?php foreach ($pagelist as $page) : ?>
<option value="<?= $page ?>" <?= Wcms\Config::alertlink() === $page ? 'selected' : '' ?>><?= $page ?></option>
<?php }
?>
<?php endforeach ?>
</select>


Expand Down Expand Up @@ -285,25 +276,19 @@
<label for="defaultfavicon">Default favicon</label>
<select name="defaultfavicon" id="defaultfavicon" form="admin">
<option value="">--no favicon--</option>
<?php
foreach ($faviconlist as $favicon) {
?>
<?php foreach ($faviconlist as $favicon) : ?>
<option value="<?= $favicon ?>" <?= Wcms\Config::defaultfavicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option>
<?php
}
?>
<?php endforeach ?>
</select>

<h4>Thumbnail</h4>

<label for="defaultthumbnail">Default thumbnail</label>
<select name="defaultthumbnail" id="defaultthumbnail" form="admin">
<option value="">--no thumbnail--</option>
<?php
foreach ($thumbnaillist as $thumbnail) {
?>
<?php foreach ($thumbnaillist as $thumbnail) : ?>
<option value="<?= $thumbnail ?>" <?= Wcms\Config::defaultthumbnail() === $thumbnail ? 'selected' : '' ?>><?= $thumbnail ?></option>
<?php } ?>
<?php endforeach ?>
</select>

<h2 id="interface">Interface</h2>
Expand All @@ -313,13 +298,9 @@

<label for="theme">select interface theme</label>
<select name="theme" id="theme" form="admin">
<?php
foreach ($themes as $theme) {
?>
<?php foreach ($themes as $theme) : ?>
<option value="<?= $theme ?>" <?= $theme === Wcms\Config::theme() ? 'selected' : '' ?>><?= $theme ?></option>
<?php
}
?>
<?php endforeach ?>
</select>

<p>
Expand Down Expand Up @@ -374,13 +355,9 @@

<label for="dbsrc">Database to duplicate</label>
<select name="dbsrc" id="dbsrc">
<?php
foreach ($pagesdblist as $db) {
?>
<?php foreach ($pagesdblist as $db) : ?>
<option value="<?= $db ?>" <?= $db === Wcms\Config::pagetable() ? 'selected' : '' ?>><?= $db ?></option>
<?php
}
?>
<?php endforeach ?>
</select>

<label for="duplicate">New name</label>
Expand Down
4 changes: 2 additions & 2 deletions app/view/templates/alertcommandnotfound.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<p>👁️ <a href="<?= $this->upage('pageread', $id) ?>">read page</a> <code><?= $this->e($id) ?></code></p>

<?php if (!$user->isvisitor()) { ?>
<?php if (!$user->isvisitor()) : ?>
<p>
💡 You may want to try:
<ul>
Expand All @@ -29,7 +29,7 @@
</li>
</ul>
</p>
<?php } ?>
<?php endif ?>

<?php $this->stop() ?>

8 changes: 4 additions & 4 deletions app/view/templates/alertexistnot.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<?php $this->start('alert') ?>

<?php if ($user->isvisitor() && Wcms\Config::existnotpass()) { ?>
<?php if ($user->isvisitor() && Wcms\Config::existnotpass()) : ?>

<p>
<?php $this->insert('alertform', ['id' => $page->id()]) ?>
</p>

<?php } ?>
<?php endif ?>



<?php if ($user->iseditor()) { ?>
<?php if ($user->iseditor()) : ?>
<p>
<a href="<?= $this->upage('pageadd', $page->id()) ?>">⭐ Create</a>
</p>
Expand All @@ -26,7 +26,7 @@
<p>
<a href="<?= $this->url('home') ?>">🏠 Go back to home</a>
</p>
<?php } ?>
<?php endif ?>



Expand Down
8 changes: 4 additions & 4 deletions app/view/templates/alertlayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
<main class="alert">
<?= !empty(Wcms\Config::alerttitle()) ? '<h1>' . Wcms\Config::alerttitle() . '</h1>' : '' ?>

<?php if (!empty($subtitle)) { ?>
<?php if (!empty($subtitle)) : ?>
<h2>
<?= $subtitle ?>
</h2>
<?php } ?>
<?php endif ?>

<?=$this->section('alert')?>


<?php if(!empty(Wcms\Config::alertlink())) { ?>
<?php if(!empty(Wcms\Config::alertlink())) : ?>
<p>
<a href="<?= $this->upage('pageread', Wcms\Config::alertlink()) ?>">
<?= empty(Wcms\Config::alertlinktext()) ? Wcms\Config::alertlink() : Wcms\Config::alertlinktext() ?>
</a>
</p>
<?php } ?>
<?php endif ?>

</main>
</body>
Expand Down
4 changes: 2 additions & 2 deletions app/view/templates/alertnotpublished.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<?php $this->start('alert') ?>


<?php if ($user->isvisitor() && Wcms\Config::notpublishedpass()) { ?>
<?php if ($user->isvisitor() && Wcms\Config::notpublishedpass()) : ?>

<p>
<?php $this->insert('alertform', ['id' => $page->id()]) ?>
</p>

<?php } ?>
<?php endif ?>

<?php $this->stop() ?>

4 changes: 2 additions & 2 deletions app/view/templates/alertprivate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<?php $this->start('alert') ?>


<?php if ($user->isvisitor() && Wcms\Config::privatepass()) { ?>
<?php if ($user->isvisitor() && Wcms\Config::privatepass()) : ?>

<p>
<?php $this->insert('alertform', ['id' => $page->id()]) ?>
</p>

<?php } ?>
<?php endif ?>



Expand Down
20 changes: 10 additions & 10 deletions app/view/templates/backtopbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
<input type="submit" name="action" value="read">
<?= $user->iseditor() ? '<input type="submit" name="action" value="edit">' : '' ?>

<?php if($user->iseditor()) { ?>
<?php if($user->iseditor()) : ?>
<datalist id="searchdatalist">
<?php foreach ($pagelist as $id) { ?>
<?php foreach ($pagelist as $id) : ?>
<option value="<?= $id ?>"><?= $id ?></option>
<?php } ?>
<?php endforeach ?>
</datalist>
<?php } ?>
<?php endif ?>

</form>
</span>



<?php if($user->iseditor()) { ?>
<?php if($user->iseditor()) : ?>

<span id="menu">
<a href="<?= $this->url('home') ?>" <?= $tab == 'home' ? 'class="currentpage"' : '' ?>>
Expand All @@ -32,13 +32,13 @@
</a>
</span>

<?php } ?>
<?php endif ?>


<span id="user">

<span>
<?php if($user->isadmin()) { ?>
<?php if($user->isadmin()) : ?>

<a href="<?= $this->url('user') ?>" <?= $tab == 'user' ? 'class="currentpage"' : '' ?>>
<i class="fa fa-users"></i>
Expand All @@ -50,7 +50,7 @@
<span>admin</span>

</a>
<?php } ?>
<?php endif ?>
<a href="<?= $this->url('info') ?>" <?= $tab == 'info' ? 'class="currentpage"' : '' ?>>
<i class="fa fa-book"></i>
<span>documentation</span>
Expand All @@ -69,10 +69,10 @@

<form action="<?= $this->url('log') ?>" method="post" id="connect">
<input type="submit" name="log" value="logout" >
<?php if($tab === 'edit') { ?>
<?php if($tab === 'edit') : ?>
<input type="hidden" name="route" value="pageread">
<input type="hidden" name="id" value="<?= $pageid ?>">
<?php } ?>
<?php endif ?>

</form>

Expand Down
22 changes: 9 additions & 13 deletions app/view/templates/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
<div class="block connect">
<h2>Login</h2>

<?php if($user->isvisitor()) { ?>
<?php if($user->isvisitor()) : ?>

<form action="<?= $this->url('log') ?>" method="post">
<input type="hidden" name="route" value="<?= $route ?>">
<?php
if(in_array($route, ['pageedit', 'pageread', 'pageadd'])) {
echo '<input type="hidden" name="id" value="'. $id .'">';
}
?>
<?php if(in_array($route, ['pageedit', 'pageread', 'pageadd'])) : ?>
<input type="hidden" name="id" value="<?= $id ?>">
<?php endif ?>
<form action="<?= $this->url('log') ?>" method="post" id="connect">
<input type="text" name="user" id="loginuser" autofocus placeholder="user" required>
<input type="password" name="pass" id="loginpass" placeholder="password" required>
Expand All @@ -27,21 +25,19 @@
</form>


<?php } else { ?>
<?php else : ?>

<form action="<?= $this->url('log') ?>" method="post">
<input name="log" type="submit" value="logout">
</form>



<?php } ?>
<?php endif ?>

<?php
if(in_array($route, ['pageedit', 'pageread', 'pageadd'])) {
echo '<p><a href="' . $this->upage('pageread', $id) . '">back to page read view</a></p>';
}
?>
<?php if(in_array($route, ['pageedit', 'pageread', 'pageadd'])) : ?>
<p><a href="<?= $this->upage('pageread', $id) ?>">back to page read view</a></p>
<?php endif ?>
</div>

<?php $this->stop() ?>
5 changes: 3 additions & 2 deletions app/view/templates/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
<li>Number of displays : <?= $page->displaycount() ?></li>
<li>
Page linking to this one : <?= $pageslinkingtocount ?>
<?php if ($pageslinkingtocount > 0) { ?>
<?php if ($pageslinkingtocount > 0) : ?>
<a href="<?= $this->url('home', [], '?linkto=' . $page->id() . '&submit=filter') ?>" title="search for pages linking to this one in home view">
<i class="fa fa-search"></i>
</a>
<?php endif ?>
</li>
</ul>
<?php } ?>
jbidoret marked this conversation as resolved.
Show resolved Hide resolved




Expand Down
4 changes: 2 additions & 2 deletions app/view/templates/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

</div>

<?php if(!Wcms\Config::disablejavascript()) { ?>
<?php if(!Wcms\Config::disablejavascript()) : ?>

<script>
const pageversion = <?= $this->e($page->version()) ?>;
Expand All @@ -41,6 +41,6 @@
</script>
<script type="module" src="<?= Wcms\Model::jspath() ?>edit.bundle.js" async></script>

<?php } ?>
<?php endif ?>

<?php $this->stop('page') ?>
Loading