From b4c5790ef82a4cc248d40c8403e795089d06ab08 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 14 Nov 2018 10:04:58 +0100 Subject: article-render --- app/class/application.php | 6 +++++- app/class/controllerart.php | 10 ++++++++-- app/class/model.php | 7 ++++--- app/class/modelfont.php | 1 + app/class/modelrender.php | 30 +++++++++++++----------------- app/class/routes.php | 1 + app/view/templates/editrightbar.php | 3 +-- app/view/templates/edittabs.php | 6 +++++- 8 files changed, 38 insertions(+), 26 deletions(-) (limited to 'app') diff --git a/app/class/application.php b/app/class/application.php index 79e9563..8e50c19 100644 --- a/app/class/application.php +++ b/app/class/application.php @@ -9,7 +9,11 @@ class Application public function wakeup() { if(isset($_POST['configinit'])) { - Config::createconfig($_POST['configinit']); + if(Config::readconfig()) { + Config::createconfig($_POST['configinit']); + } else { + Config::hydrate($_POST['configinit']); + } if(!Config::savejson()) { echo 'Cant write config file'; exit; diff --git a/app/class/controllerart.php b/app/class/controllerart.php index e385201..b990237 100644 --- a/app/class/controllerart.php +++ b/app/class/controllerart.php @@ -6,6 +6,7 @@ class Controllerart extends Controller protected $art; protected $artmanager; protected $renderengine; + protected $fontmanager; public function __construct($router) { @@ -13,6 +14,7 @@ class Controllerart extends Controller $this->artmanager = new Modelart(); $this->renderengine = new Modelrender($router); + $this->fontmanager = new Modelfont(); } @@ -97,8 +99,7 @@ class Controllerart extends Controller $showleftpanel = false; $showrightpanel = false; } - $fontmanager = new Modelfont; - $fonts = $fontmanager->list(); + $fonts = []; $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $artlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts]); } else { @@ -166,6 +167,11 @@ class Controllerart extends Controller } + + public function artdirect($id) + { + $this->routedirect('artread/', ['art' => idclean($id)]); + } } diff --git a/app/class/model.php b/app/class/model.php index 6d8aec3..b6e2ee6 100644 --- a/app/class/model.php +++ b/app/class/model.php @@ -1,5 +1,5 @@ $element(); } - $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $this->markdown($text) . PHP_EOL . '' . PHP_EOL; + $text = $this->article($text); + $text = $this->markdown($text); + $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $text . PHP_EOL . '' . PHP_EOL; } @@ -158,8 +160,6 @@ class Modelrender extends Modelart $text = $this->wurl($text); $text = $this->wikiurl($text); - $text = $this->tooltip($art->linkfrom('array'), $text); - $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text); $text = str_replace('getlisterid($linkfrom); - foreach ($artlist as $art) { - $descriptions[$art->id()] = $art->description(); - } - - foreach ($linkfrom as $id) { - if (isset($descriptions[$id])) { - $linkfrom = 'href="?id=' . $id . '"'; - $titlelinkfrom = ' title="' . $descriptions[$id] . '" ' . $linkfrom; - $text = str_replace($linkfrom, $titlelinkfrom, $text); + $pattern = '/(\R\R|^\R|^)[=]{3,}([\w-]*)\R\R(.*)(?=\R\R[=]{3,}[\w-]*\R)/sUm'; + $text = preg_replace_callback($pattern, function($matches) { + if(!empty($matches[2])) { + $id = ' id="'.$matches[2].'" '; + } else { + $id = ' '; } - } + return '
' . PHP_EOL . PHP_EOL . $matches[3] . PHP_EOL . PHP_EOL . '
' . PHP_EOL . PHP_EOL; + } , $text); + $text = preg_replace('/\R\R[=]{3,}([\w-]*)\R/', '', $text); return $text; } diff --git a/app/class/routes.php b/app/class/routes.php index f240f6b..dda30d7 100644 --- a/app/class/routes.php +++ b/app/class/routes.php @@ -25,6 +25,7 @@ class Routes ['POST', '/[cid:art]/edit', 'Controllerart#update', 'artupdate'], ['GET', '/[cid:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'], ['POST', '/[cid:art]/delete', 'Controllerart#delete', 'artdelete'], + ['GET', '/[cid:art]/[*]', 'Controllerart#artdirect', 'artread/etoile'], ]); $match = $router->match(); diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php index 74ba1dd..fa249ef 100644 --- a/app/view/templates/editrightbar.php +++ b/app/view/templates/editrightbar.php @@ -7,8 +7,7 @@ - - + $value) { } echo ''; echo '
'; - echo ''; + if ($key == $opentab) { + echo ''; + } else { + echo ''; + } echo '
'; echo ''; } -- cgit v1.2.3