diff options
-rw-r--r-- | app/class/config.php | 130 | ||||
-rw-r--r-- | app/class/controllerart.php | 9 | ||||
-rw-r--r-- | app/view/templates/admin.php | 367 | ||||
-rw-r--r-- | app/view/templates/alert.php | 104 | ||||
-rw-r--r-- | app/view/templates/read.php | 56 | ||||
-rw-r--r-- | composer.json | 2 |
6 files changed, 453 insertions, 215 deletions
diff --git a/app/class/config.php b/app/class/config.php index dfeb4d7..59d80eb 100644 --- a/app/class/config.php +++ b/app/class/config.php @@ -6,11 +6,19 @@ abstract class Config { protected static $arttable = 'mystore'; protected static $domain = ''; - protected static $color4; protected static $fontsize = 15; protected static $basepath = ''; - protected static $route404; + protected static $route404; + protected static $alerttitle = ''; + protected static $alertlink = ''; + protected static $alertlinktext = ''; protected static $existnot = 'This page does not exist yet'; + protected static $private = 'This page is private'; + protected static $notpublished = 'This page is not published'; + protected static $existnotpass = false; + protected static $privatepass = false; + protected static $notpublishedpass = false; + protected static $alertcss = false; protected static $defaultbody = '%HEADER%'. PHP_EOL .PHP_EOL . '%NAV%'. PHP_EOL .PHP_EOL . '%ASIDE%'. PHP_EOL .PHP_EOL . '%MAIN%'. PHP_EOL .PHP_EOL . '%FOOTER%'; protected static $defaultart = ''; protected static $defaultfavicon = ''; @@ -115,11 +123,6 @@ abstract class Config return self::$domain; } - public static function color4() - { - return self::$color4; - } - public static function fontsize() { return self::$fontsize; @@ -135,11 +138,56 @@ abstract class Config return self::$route404; } + public static function alerttitle() + { + return self::$alerttitle; + } + + public static function alertlink() + { + return self::$alertlink; + } + + public static function alertlinktext() + { + return self::$alertlinktext; + } + public static function existnot() { return self::$existnot; } + public static function private() + { + return self::$private; + } + + public static function notpublished() + { + return self::$notpublished; + } + + public static function existnotpass() + { + return self::$existnotpass; + } + + public static function privatepass() + { + return self::$privatepass; + } + + public static function notpublishedpass() + { + return self::$notpublishedpass; + } + + public static function alertcss() + { + return self::$alertcss; + } + public static function defaultbody() { return self::$defaultbody; @@ -218,13 +266,6 @@ abstract class Config self::$domain = strip_tags(strtolower($domain)); } - public static function setcolor4($color4) - { - if (strlen($color4) <= 8) { - self::$color4 = $color4; - } - } - public static function setfontsize($fontsize) { $fontsize = intval($fontsize); @@ -245,13 +286,68 @@ abstract class Config } } - public static function setexistnot($description) + public static function setalerttitle($alerttitle) { - if(is_string($description)) { - self::$existnot = strip_tags($description); + if(is_string($alerttitle)) { + self::$alerttitle = strip_tags($alerttitle); } } + public static function setalertlink($alertlink) + { + if(is_string($alertlink)) { + self::$alertlink = idclean(strip_tags($alertlink)); + } + } + + public static function setalertlinktext($alertlinktext) + { + if(is_string($alertlinktext)) { + self::$alertlinktext = strip_tags($alertlinktext); + } + } + + public static function setexistnot($existnot) + { + if(is_string($existnot)) { + self::$existnot = strip_tags($existnot); + } + } + + public static function setprivate($private) + { + if(is_string($private)) { + self::$private = strip_tags($private); + } + } + + public static function setnotpublished($notpublished) + { + if(is_string($notpublished)) { + self::$notpublished = strip_tags($notpublished); + } + } + + public static function setexistnotpass($existnotpass) + { + self::$existnotpass = boolval($existnotpass); + } + + public static function setprivatepass($privatepass) + { + self::$privatepass = boolval($privatepass); + } + + public static function setnotpublishedpass($notpublishedpass) + { + self::$notpublishedpass = boolval($notpublishedpass); + } + + public static function setalertcss($alertcss) + { + self::$alertcss = boolval($alertcss); + } + public static function setdefaultbody($defaultbody) { if(is_string($defaultbody)) { diff --git a/app/class/controllerart.php b/app/class/controllerart.php index 027fc19..ac52043 100644 --- a/app/class/controllerart.php +++ b/app/class/controllerart.php @@ -118,7 +118,6 @@ class Controllerart extends Controller $artexist = $this->importart(); $canread = $this->user->level() >= $this->art->secure(); - $alerts = ['alertnotexist' => 'This page does not exist yet', 'alertprivate' => 'You cannot see this page']; $page = ['head' => '', 'body' => '']; if ($artexist) { @@ -138,9 +137,13 @@ class Controllerart extends Controller } $this->artmanager->update($this->art); } - $data = array_merge($alerts, $page, ['art' => $this->art, 'artexist' => $artexist, 'canread' => $canread, 'readernav' => Config::showeditmenu(), 'canedit' => $this->canedit()]); + $data = array_merge($page, ['art' => $this->art, 'artexist' => $artexist , 'readernav' => Config::showeditmenu(), 'canedit' => $this->canedit()]); - $this->showtemplate('read', $data); + if($artexist && $canread) { + $this->showtemplate('read', $data); + } else { + $this->showtemplate('alert', $data); + } } diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php index c1d7ff4..98027dc 100644 --- a/app/view/templates/admin.php +++ b/app/view/templates/admin.php @@ -8,237 +8,310 @@ <?php $this->insert('backtopbar', ['user' => $user, 'tab' => 'admin']) ?> -<main class="admin"> + <main class="admin"> - <section> + <section> - <form action="<?= $this->url('adminupdate') ?>" method="post"> + <form action="<?= $this->url('adminupdate') ?>" method="post"> - <article> + <article> - <h1>Administration</h1> + <h1>Administration</h1> - <input type="submit" value="Update configuration"> - </article> + <input type="submit" value="Update configuration"> + </article> - <article> + <article> - <h2>Home page</h2> + <h2>Home page</h2> - <p>Here you can set the home-page view for visitors.</p> + <p>Here you can set the home-page view for visitors.</p> - <div class="radio"> - <input type="radio" name="homepage" value="default" id="default" <?= Config::homepage() === 'default' ? 'checked' : '' ?>> - <label for="default">default</label> - </div> + <div class="radio"> + <input type="radio" name="homepage" value="default" id="default" <?= Config::homepage() === 'default' ? 'checked' : '' ?>> + <label for="default">default</label> + </div> - <div class="radio"> - <input type="radio" name="homepage" value="search" id="searchbar" <?= Config::homepage() === 'search' ? 'checked' : '' ?>> - <label for="searchbar">search bar</label> - </div> + <div class="radio"> + <input type="radio" name="homepage" value="search" id="searchbar" <?= Config::homepage() === 'search' ? 'checked' : '' ?>> + <label for="searchbar">search bar</label> + </div> - <div class="radio"> - <input type="radio" name="homepage" value="redirect" id="redirect" <?= Config::homepage() === 'redirect' ? 'checked' : '' ?>> - <label for="redirect">redirect to page</label> - </div> + <div class="radio"> + <input type="radio" name="homepage" value="redirect" id="redirect" <?= Config::homepage() === 'redirect' ? 'checked' : '' ?>> + <label for="redirect">redirect to page</label> + </div> - <select name="homeredirect" id="homeredirect"> - <option value="" <?= Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option> + <select name="homeredirect" id="homeredirect"> + <option value="" <?= Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option> - <?php - foreach ($artlist as $art) { - ?> - <option value="<?= $art ?>" <?= Config::homeredirect() === $art ? 'selected' : '' ?>><?= $art ?></option> - <?php - } + <?php + foreach ($artlist as $art) { + ?> + <option value="<?= $art ?>" <?= Config::homeredirect() === $art ? 'selected' : '' ?>><?= $art ?></option> + <?php + } - ?> - </select> + ?> + </select> - </article> + </article> - <article> + <article> - <h2>Page creation</h2> + <h2>Page creation</h2> - <label for="defaultprivacy">Default privacy</label> - <select name="defaultprivacy" id="defaultprivacy"> - <option value="0" <?= Config::defaultprivacy() == 0 ? 'selected' : '' ?>>public</option> - <option value="1" <?= Config::defaultprivacy() == 1 ? 'selected' : '' ?>>private</option> - <option value="2" <?= Config::defaultprivacy() == 2 ? 'selected' : '' ?>>not published</option> - </select> + <p>What really happend when you create a new page</p> + <label for="defaultprivacy">Default privacy</label> + <select name="defaultprivacy" id="defaultprivacy"> + <option value="0" <?= Config::defaultprivacy() == 0 ? 'selected' : '' ?>>public</option> + <option value="1" <?= Config::defaultprivacy() == 1 ? 'selected' : '' ?>>private</option> + <option value="2" <?= Config::defaultprivacy() == 2 ? 'selected' : '' ?>>not published</option> + </select> - <label for="defaultart">Create new page BODY based on an already existing one</label> - <select name="defaultart" id="defaultart"> - <option value="" <?= Config::defaultart() === '' || !$defaultartexist ? 'selected' : '' ?>>--use default BODY element--</option> - <?php - foreach ($artlist as $art) { - ?> - <option value="<?= $art ?>" <?= Config::defaultart() === $art ? 'selected' : '' ?>><?= $art ?></option> - <?php } - ?> - </select> - <?php - if(empty(!$defaultartexist || Config::defaultart())) { - ?> - <label for="defaultbody">Edit default BODY element</label> - <textarea name="defaultbody" id="defaultbody" cols="30" rows="10"><?= Config::defaultbody() ?></textarea> - <?php - } - ?> + <label for="defaultart">Or, create new page BODY based on an already existing one</label> + <select name="defaultart" id="defaultart"> + <option value="" <?= Config::defaultart() === '' || !$defaultartexist ? 'selected' : '' ?>>--use default BODY element--</option> + <?php + foreach ($artlist as $art) { + ?> + <option value="<?= $art ?>" <?= Config::defaultart() === $art ? 'selected' : '' ?>><?= $art ?></option> + <?php } + ?> + </select> - </article> + <?php + if (empty(!$defaultartexist || Config::defaultart())) { + ?> + <label for="defaultbody">Edit default BODY element</label> + <textarea name="defaultbody" id="defaultbody" cols="30" rows="10"><?= Config::defaultbody() ?></textarea> + <?php + } + ?> - <article> + </article> + <article> - <h2>Editing</h2> - <label for="existnot">Text to show when a page does not exist yet</label> - <input type="text" name="existnot" id="existnot" value="<?= Config::existnot() ?>"> + <h2>Alert pages</h2> + <h4>Common options</h4> - <h4>Render</h4> + <label for="alerttitle">H1 Title</label> + <input type="text" name="alerttitle" id="alerttitle" value="<?= Config::alerttitle() ?>"> - <div class="checkbox"> - <input type="hidden" name="reccursiverender" value="0"> - <input type="checkbox" name="reccursiverender" id="reccursiverender" value="1" <?= Config::reccursiverender() ? 'checked' : '' ?>> - <label for="reccursiverender">Reccursive render</label> - </div> + <label for="alertlink">Link to this page (for visitors)</label> + <select name="alertlink" id="alertlink"> + <option value="" <?= empty(Config::alertlink()) ? 'selected' : '' ?>>--No link--</option> + <?php + foreach ($artlist as $art) { + ?> + <option value="<?= $art ?>" <?= Config::alertlink() === $art ? 'selected' : '' ?>><?= $art ?></option> + <?php } + ?> + </select> - <h4>Links</h4> - - <div class="checkbox"> - <input type="hidden" name="externallinkblank" value="0"> - <input type="checkbox" name="externallinkblank" id="externallinkblank" value="1" <?= Config::externallinkblank() ? 'checked' : '' ?>> - <label for="externallinkblank">Open external links in new tab</label> - </div> - <div class="checkbox"> - <input type="hidden" name="internallinkblank" value="0"> - <input type="checkbox" name="internallinkblank" id="internallinkblank" value="1" <?= Config::internallinkblank() ? 'checked' : '' ?>> - <label for="internallinkblank">Open internal links in new tab</label> - </div> + <label for="alertlinktext">Link text</label> + <input type="text" name="alertlinktext" id="alertlinktext" value="<?= Config::alertlinktext() ?>"> - <i>(This modifications need re-rendering)</i> - <h4>Edit quick menu</h4> - <div class="checkbox"> - <input type="hidden" name="showeditmenu" value="false"> - <input type="checkbox" name="showeditmenu" id="showeditmenu" value="true" <?= Config::showeditmenu() === true ? 'checked' : '' ?>> - <label for="showeditmenu">Show editor menu in top right corner of pages</label> - </div> + <h4>Un-existing</h4> - <?php - if(Config::showeditmenu() === true) { - ?> - <label for="editsymbol">Symbol</label> - <select name="editsymbol" id="editsymbol"> - <?php - foreach (Model::EDIT_SYMBOLS as $symbol) { - ?> - <option value="<?= $symbol ?>" <?= Config::editsymbol() === $symbol ? 'selected' : '' ?>><?= $symbol ?></option> - <?php - } - ?> - </select> - <?php - } - ?> + <label for="existnot">Text to show when a page does not exist yet.</label> + <i>This will also be shown as a tooltip over links.</i> + <input type="text" name="existnot" id="existnot" value="<?= Config::existnot() ?>"> - </article> + <div class="checkbox"> + <input type="hidden" name="existnotpass" value="0"> + <input type="checkbox" name="existnotpass" id="existnotpass" value="1" <?= Config::existnotpass() ? 'checked' : '' ?>> + <label for="existnotpass">Ask for password</label> + </div> + <h4>Private</h4> + <label for="private">Text to show when a page is private.</label> + <input type="text" name="private" id="private" value="<?= Config::private() ?>"> + <div class="checkbox"> + <input type="hidden" name="privatepass" value="0"> + <input type="checkbox" name="privatepass" id="privatepass" value="1" <?= Config::privatepass() ? 'checked' : '' ?>> + <label for="privatepass">Ask for password</label> + </div> + <h4>Not published</h4> - <article> + <label for="notpublished">Text to show when a page is not published.</label> + <input type="text" name="notpublished" id="notpublished" value="<?= Config::notpublished() ?>"> - <h2>CSS</h2> + <div class="checkbox"> + <input type="hidden" name="notpublishedpass" value="0"> + <input type="checkbox" name="notpublishedpass" id="notpublishedpass" value="1" <?= Config::notpublishedpass() ? 'checked' : '' ?>> + <label for="notpublishedpass">Ask for password</label> + </div> - <label for="globalcss">Edit global css that will apply to every pages</label> - <textarea name="globalcss" id="globalcss" cols="30" rows="10"><?= $globalcss ?></textarea> + <h4>CSS</h4> - <label for="defaultfavicon">Default favicon</label> - <select name="defaultfavicon" id="defaultfavicon"> - <option value="">--no favicon--</option> - <?php - foreach ($faviconlist as $favicon) { - ?> - <option value="<?= $favicon ?>" <?= Config::defaultfavicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option> - <?php - } - ?> - </select> + <div class="checkbox"> + <input type="hidden" name="alertcss" value="0"> + <input type="checkbox" name="alertcss" id="alertcss" value="1" <?= Config::alertcss() ? 'checked' : '' ?>> + <label for="alertcss">Use global.css for those page as well</label> + </div> - </article> + <p> + <i>You can use <code>body.alert</code> class to specify style.</i> + </p> + </article> + + + <article> + + <h2>Render</h2> + <div class="checkbox"> + <input type="hidden" name="reccursiverender" value="0"> + <input type="checkbox" name="reccursiverender" id="reccursiverender" value="1" <?= Config::reccursiverender() ? 'checked' : '' ?>> + <label for="reccursiverender">Reccursive render</label> + </div> + <h4>Links</h4> + <div class="checkbox"> + <input type="hidden" name="externallinkblank" value="0"> + <input type="checkbox" name="externallinkblank" id="externallinkblank" value="1" <?= Config::externallinkblank() ? 'checked' : '' ?>> + <label for="externallinkblank">Open external links in new tab</label> + </div> - <article> + <div class="checkbox"> + <input type="hidden" name="internallinkblank" value="0"> + <input type="checkbox" name="internallinkblank" id="internallinkblank" value="1" <?= Config::internallinkblank() ? 'checked' : '' ?>> + <label for="internallinkblank">Open internal links in new tab</label> + </div> - <h2>Interface</h2> + <i>(This modifications need re-rendering)</i> - <p>Set interface Style</p> + <h4>Edit quick menu</h4> - <select name="interfacecss" id="interfacecss"> - <option value="null">--default interface style---</option> - <?php - foreach ($interfacecsslist as $interfacecss) { - ?> - <option value="<?= $interfacecss ?>" <?= $interfacecss === Config::interfacecss() ? 'selected' : '' ?>><?= $interfacecss ?></option> + <div class="checkbox"> + <input type="hidden" name="showeditmenu" value="false"> + <input type="checkbox" name="showeditmenu" id="showeditmenu" value="true" <?= Config::showeditmenu() === true ? 'checked' : '' ?>> + <label for="showeditmenu">Show editor menu in top right corner of pages</label> + </div> + + <?php + if (Config::showeditmenu() === true) { + ?> + <label for="editsymbol">Symbol</label> + <select name="editsymbol" id="editsymbol"> + <?php + foreach (Model::EDIT_SYMBOLS as $symbol) { + ?> + <option value="<?= $symbol ?>" <?= Config::editsymbol() === $symbol ? 'selected' : '' ?>><?= $symbol ?></option> + <?php + } + ?> + </select> <?php - } - ?> - </select> + } + ?> + + </article> + + + + + + <article> + + <h2>CSS</h2> + + <label for="globalcss">Edit global css that will apply to every pages</label> + <textarea name="globalcss" id="globalcss" cols="30" rows="10"><?= $globalcss ?></textarea> + + <label for="defaultfavicon">Default favicon</label> + <select name="defaultfavicon" id="defaultfavicon"> + <option value="">--no favicon--</option> + <?php + foreach ($faviconlist as $favicon) { + ?> + <option value="<?= $favicon ?>" <?= Config::defaultfavicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option> + <?php + } + ?> + </select> + + </article> + + + + + + + + <article> + + <h2>Interface</h2> + + <p>Set interface Style</p> + + <select name="interfacecss" id="interfacecss"> + <option value="null">--default interface style---</option> + <?php + foreach ($interfacecsslist as $interfacecss) { + ?> + <option value="<?= $interfacecss ?>" <?= $interfacecss === Config::interfacecss() ? 'selected' : '' ?>><?= $interfacecss ?></option> + <?php + } + ?> + </select> - </article> + </article> - <article> + <article> - <h2>Tracking</h2> + <h2>Tracking</h2> - <label for="analytics">Google analytics Tracking ID</label> - <input type="text" name="analytics" id="analytics" value="<?= Config::analytics() ?>"> + <label for="analytics">Google analytics Tracking ID</label> + <input type="text" name="analytics" id="analytics" value="<?= Config::analytics() ?>"> - <i>(Need rendering to work)</i> + <i>(Need rendering to work)</i> - </article> + </article> - <article> - <input type="submit" value="Update configuration"> - </article> + <article> + <input type="submit" value="Update configuration"> + </article> - </form> + </form> - </section> + </section> -</main> + </main> </body> <?php $this->stop('page') ?>
\ No newline at end of file diff --git a/app/view/templates/alert.php b/app/view/templates/alert.php new file mode 100644 index 0000000..ff29e30 --- /dev/null +++ b/app/view/templates/alert.php @@ -0,0 +1,104 @@ +<?php + +$this->layout('readerlayout') ?> + +<?php +$this->start('head'); +?> + +<head> + <?= Config::alertcss() ? '<link href="' . Model::globalpath() . 'global.css" rel="stylesheet" />' : '' ?> +</head> + + +<?php +$this->stop(); +?> + + + +<?php $this->start('page') ?> + +<body class="alert"> + +<main class="alert"> + + <?php + if ($readernav) { + $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); + } + + ?> + + + + + <?= !empty(Config::alerttitle()) ? '<h1>' . Config::alerttitle() . '</h1>' : '' ?> + + <?php + + $form = '<p> + <form action="/!co" method="post"> + <input type="password" name="pass" id="loginpass" placeholder="password"> + <input type="hidden" name="route" value="artread/"> + <input type="hidden" name="id" value="' . $art->id() . '"> + <input type="submit" name="log" value="login" id="button"> + </form> + </p>'; + + + if(!$artexist) { + if(!empty(Config::existnot())) { + echo '<h2>' . Config::existnot() . '</h2>'; + } + if(Config::existnotpass() && !$canedit) { + echo $form; + } + } else { + + + + switch ($art->secure()) { + case 1: + if(!empty(Config::private())) { + echo '<h2>' . Config::private() . '</h2>'; + } + if(Config::privatepass()) { + echo $form; + } + break; + + case 2: + if(!empty(Config::notpublished())) { + echo '<h2>' . Config::notpublished() . '</h2>'; + } + if(Config::notpublishedpass()) { + echo $form; + } + break; + } + } + + + + if ($canedit) { + ?> + <p><a href="<?= $this->uart('artadd', $art->id()) ?>">⭐ Create</a></p> + <?php + } elseif(!empty(Config::alertlink())) { + ?> + <p><a href="<?= $this->uart('artread/', Config::alertlink()) ?>"><?= empty(Config::alertlinktext()) ? Config::alertlink() : Config::alertlinktext() ?></a></p> + <?php + } + + + ?> + + + +</main> + + +</body> + +<?php $this->stop() ?>
\ No newline at end of file diff --git a/app/view/templates/read.php b/app/view/templates/read.php index f8201cc..54b137e 100644 --- a/app/view/templates/read.php +++ b/app/view/templates/read.php @@ -3,69 +3,31 @@ <?php $this->start('head'); -if ($artexist) { - if ($canread) { - echo $head; - } else { - $this->insert('arthead', ['title' => $art->title(), 'description' => $art->description()]); - } -} else { - $this->insert('arthead', ['title' => $art->id(), 'description' => $alertnotexist]); -} - - +echo $head; $this->stop(); ?> - - - - - - <?php $this->start('page') ?> - <body> - - +<body> - <?php - if ($readernav) { - $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); - } - ?> - - <?php - - if ($artexist) { + <?php + if ($readernav) { + $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); + } - if ($canread) { - echo $body; - } else { - echo '<h1>'.$alertprivate.'</h1>'; - } - } else { - if(!empty(Config::existnot())) { - echo '<h1>' . Config::existnot() . '</h1>'; - } - if ($user->iseditor()) { - ?> - <a href="<?= $this->uart('artadd', $art->id()) ?>">⭐ Create</a> - <?php - } - } + echo $body; + ?> - ?> - - </body> +</body> <?php $this->stop() ?>
\ No newline at end of file diff --git a/composer.json b/composer.json index b6b86e0..92bed34 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "w-cms", "description": "point'n think", - "version": "1.3.1", + "version": "1.4.0", "require": { "michelf/php-markdown": "^1.8", "league/plates": "3.*", |