From 93c827446737252c36d6d9daee7e2e7a55eb911b Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 9 Aug 2019 15:58:37 +0200 Subject: New Feature : Alert pages have more options --- app/class/config.php | 130 +++++++++++++-- app/class/controllerart.php | 9 +- app/view/templates/admin.php | 367 ++++++++++++++++++++++++++----------------- app/view/templates/alert.php | 104 ++++++++++++ app/view/templates/read.php | 56 ++----- composer.json | 2 +- 6 files changed, 453 insertions(+), 215 deletions(-) create mode 100644 app/view/templates/alert.php 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 @@ insert('backtopbar', ['user' => $user, 'tab' => 'admin']) ?> -
+
-
+
-
+ -
+
-

Administration

+

Administration

- -
+ +
-
+
-

Home page

+

Home page

-

Here you can set the home-page view for visitors.

+

Here you can set the home-page view for visitors.

-
- > - -
+
+ > + +
-
- > - -
+
+ > + +
-
- > - -
+
+ > + +
- + - - - + + - + ?> + -
+
-
+
-

Page creation

+

Page creation

- - +

What really happend when you create a new page

+ + - - - - - - + + -
+ + + + -
+
+
-

Editing

- - +

Alert pages

+

Common options

-

Render

+ + -
- - > - -
+ + -

Links

- -
- - > - -
-
- - > - -
+ + - (This modifications need re-rendering) -

Edit quick menu

-
- - > - -
+

Un-existing

- - - - + + This will also be shown as a tooltip over links. + -
+
+ + > + +
+

Private

+ + +
+ + > + +
+

Not published

-
+ + -

CSS

+
+ + > + +
- - +

CSS

- - +
+ + > + +
-
+

+ You can use body.alert class to specify style. +

+
+ + +
+ +

Render

+
+ + > + +
+

Links

+
+ + > + +
-
+
+ + > + +
-

Interface

+ (This modifications need re-rendering) -

Set interface Style

+

Edit quick menu

- + > + + + + + + - + } + ?> + +
+ + + + + +
+ +

CSS

+ + + + + + + +
+ + + + + + + +
+ +

Interface

+ +

Set interface Style

+ + -
+
-
+
-

Tracking

+

Tracking

- - + + - (Need rendering to work) + (Need rendering to work) -
+
-
- -
+
+ +
-
+ -
+
-
+
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 @@ +layout('readerlayout') ?> + +start('head'); +?> + + + ' : '' ?> + + + +stop(); +?> + + + +start('page') ?> + + + +
+ + insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); + } + + ?> + + + + + ' . Config::alerttitle() . '' : '' ?> + + +
+ + + + +
+

'; + + + if(!$artexist) { + if(!empty(Config::existnot())) { + echo '

' . Config::existnot() . '

'; + } + if(Config::existnotpass() && !$canedit) { + echo $form; + } + } else { + + + + switch ($art->secure()) { + case 1: + if(!empty(Config::private())) { + echo '

' . Config::private() . '

'; + } + if(Config::privatepass()) { + echo $form; + } + break; + + case 2: + if(!empty(Config::notpublished())) { + echo '

' . Config::notpublished() . '

'; + } + if(Config::notpublishedpass()) { + echo $form; + } + break; + } + } + + + + if ($canedit) { + ?> +

⭐ Create

+ +

+ + + + +
+ + + + +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 @@ 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(); ?> - - - - - - start('page') ?> - - - + - insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); - } - ?> - - insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); + } - if ($canread) { - echo $body; - } else { - echo '

'.$alertprivate.'

'; - } - } else { - if(!empty(Config::existnot())) { - echo '

' . Config::existnot() . '

'; - } - if ($user->iseditor()) { - ?> - ⭐ Create - - ?> - - + 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.*", -- cgit v1.2.3