aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-11-28 07:58:55 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-11-28 07:58:55 +0100
commit0660c99cb9e2dae3b0e41975f643609231258147 (patch)
tree247deb88055b330e063179dec3d74465eb9cccac
parentd46c05b12b9dcd65d2d9cd230bf45b5bdf6fa8bd (diff)
downloadwcms-0660c99cb9e2dae3b0e41975f643609231258147.tar.gz
wcms-0660c99cb9e2dae3b0e41975f643609231258147.zip
minor changes
-rw-r--r--app/class/art2.php2
-rw-r--r--app/class/modelrender.php46
-rw-r--r--app/class/modeluser.php2
-rw-r--r--app/class/routes.php2
-rw-r--r--app/view/templates/edit.php4
-rw-r--r--app/view/templates/edittabs.php14
-rw-r--r--app/view/templates/home.php2
-rw-r--r--app/view/templates/layout.php2
-rw-r--r--assets/css/edit.css4
9 files changed, 50 insertions, 28 deletions
diff --git a/app/class/art2.php b/app/class/art2.php
index e8ae061..8c48dee 100644
--- a/app/class/art2.php
+++ b/app/class/art2.php
@@ -315,6 +315,8 @@ class Art2
$linkfrom = $this->linkfrom;
} elseif ($option == 'sort') {
return count($this->linkfrom);
+ } elseif ($option == 'string') {
+ return implode(', ', $this->linkfrom);
}
return $linkfrom;
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 3fb1f81..e00dcc8 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -5,6 +5,7 @@ class Modelrender extends Modelart
protected $router;
protected $artlist;
protected $linkfrom = [];
+ protected $sum = [];
const SUMMARY = '%SUMMARY%';
@@ -56,7 +57,6 @@ class Modelrender extends Modelart
}
$text = $this->article($text);
$text = $this->autotaglistupdate($text);
- $text = $this->desctitle($text, $art->description(), $art->title());
$text = $this->markdown($text);
$elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $text . PHP_EOL . '</' . $element . '>' . PHP_EOL;
@@ -165,16 +165,19 @@ class Modelrender extends Modelart
public function parser(Art2 $art, string $text)
{
-
+ $text = $this->headerid($text);
$text = str_replace(self::SUMMARY, $this->sumparser($text), $text);
$text = $this->wurl($text);
$text = $this->wikiurl($text);
+ $text = $this->desctitle($text, $art->description(), $art->title());
+
+
$text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
- $text = str_replace('<img src="/', '<img src="'. Model::mediapath(), $text);
- $text = str_replace('<a href="/', '<a href="'. Model::mediapath(), $text);
+ $text = str_replace('<img src="/', '<img class="local" src="'. Model::mediapath(), $text);
+ $text = str_replace('<a href="/', '<a class="media" target="_blank" href="'. Model::mediapath(), $text);
$text = $this->autourl($text);
@@ -193,14 +196,14 @@ class Modelrender extends Modelart
$linkfrom = [];
$rend = $this;
$text = preg_replace_callback(
- '%href="([\w-]+)"%',
+ '%href="([\w-]+)\/?(#?[a-z-_]*)"%',
function ($matches) use ($rend, &$linkfrom) {
$matchart = $rend->get($matches[1]);
if (!$matchart) {
return 'href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal"';
} else {
$linkfrom[] = $matchart->id();
- return 'href="' . $rend->uart($matches[1]) . '" title="' . $matchart->description() . '" class="internal"';
+ return 'href="' . $rend->uart($matches[1]) . $matches[2]. '" title="' . $matchart->description() . '" class="internal"';
}
},
$text
@@ -214,14 +217,14 @@ class Modelrender extends Modelart
$linkfrom = [];
$rend = $this;
$text = preg_replace_callback(
- '%\[([\w-]+)\]%',
+ '%\[([\w-]+)\/?#?([a-z-_]*)\]%',
function ($matches) use ($rend, &$linkfrom) {
$matchart = $rend->get($matches[1]);
if (!$matchart) {
return '<a href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal">' . $matches[1] . '</a>';
} else {
$linkfrom[] = $matchart->id();
- return '<a href="' . $rend->uart($matches[1]) . '" title="' . $matchart->description() . '" class="internal">' . $matchart->title() . '</a>';
+ return '<a href="' . $rend->uart($matches[1]) . $matches[2].'" title="' . $matchart->description() . '" class="internal">' . $matchart->title() . '</a>';
}
},
$text
@@ -230,14 +233,29 @@ class Modelrender extends Modelart
return $text;
}
+ public function headerid($text)
+ {
+ $sum = [];
+ $text = preg_replace_callback('/<h([1-6])(\s+(\s*\w+="\w+")*)?\s*>(.+)<\/h[1-6]>/mU',
+ function ($matches) use (&$sum) {
+ $cleanid = idclean($matches[4]);
+ $sum[$cleanid][$matches[1]] = $matches[4];
+ return '<h'.$matches[1] . $matches[2] . ' id="'.$cleanid.'">'.$matches[4].'</h'.$matches[1].'>';
+ },
+ $text
+ );
+ $this->sum = $sum;
+ return $text;
+ }
+
public function markdown($text)
{
//use Michelf\MarkdownExtra;
$fortin = new Michelf\MarkdownExtra;
// id in headers
- $fortin->header_id_func = function ($header) {
- return preg_replace('/[^\w]/', '', strtolower($header));
- };
+ // $fortin->header_id_func = function ($header) {
+ // return preg_replace('/[^\w]/', '', strtolower($header));
+ // };
$fortin->hard_wrap = true;
$text = $fortin->transform($text);
return $text;
@@ -267,10 +285,8 @@ class Modelrender extends Modelart
preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out);
- $sum = [];
- foreach ($out[2] as $key => $value) {
- $sum[$value][$out[1][$key]] = $out[3][$key];
- }
+ $sum = $this->sum;
+
$sumstring = '';
diff --git a/app/class/modeluser.php b/app/class/modeluser.php
index 1644a35..9dc2af1 100644
--- a/app/class/modeluser.php
+++ b/app/class/modeluser.php
@@ -46,7 +46,7 @@ class Modeluser extends Model
}
}
- public function invitetest()
+ public function invitetest($pass)
{
$invitepasslist = [];
if(in_array($pass, $invitepasslist)) {
diff --git a/app/class/routes.php b/app/class/routes.php
index d2658a5..384d274 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -26,7 +26,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'],
+ //['GET', '/[cid:art]/[*]', 'Controllerart#artdirect', 'artread/etoile'],
]);
$match = $router->match();
diff --git a/app/view/templates/edit.php b/app/view/templates/edit.php
index a729302..8071964 100644
--- a/app/view/templates/edit.php
+++ b/app/view/templates/edit.php
@@ -19,7 +19,7 @@
<div id="workspace">
<?php $this->insert('editleftbar', ['art' => $art, 'tablist' => $tablist, 'artlist' => $artlist, 'showleftpanel' => $showleftpanel]) ?>
- <?php $this->insert('edittabs', ['tablist' => $tablist, 'opentab' => $art->interface()]) ?>
+ <?php $this->insert('edittabs', ['tablist' => $tablist, 'opentab' => $art->interface(), 'template' => $art->template()]) ?>
<?php $this->insert('editrightbar', ['art' => $art, 'artlist' => $artlist, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts]) ?>
</div>
@@ -29,4 +29,4 @@
</section>
</body>
-<?php $this->stop() ?> \ No newline at end of file
+<?php $this->stop('page') ?> \ No newline at end of file
diff --git a/app/view/templates/edittabs.php b/app/view/templates/edittabs.php
index 4980354..5d74ef1 100644
--- a/app/view/templates/edittabs.php
+++ b/app/view/templates/edittabs.php
@@ -3,12 +3,14 @@
<?php
foreach ($tablist as $key => $value) {
echo '<div class="tab">';
- if ($key == $opentab) {
- echo '<input name="interface" type="radio" value="'.$key.'" id="tab' . $key . '" class="checkboxtab" checked>';
- } else {
- echo '<input name="interface" type="radio" value="'.$key.'" id="tab' . $key . '" class="checkboxtab">';
- }
- echo '<label for="tab' . $key . '">' . $key . '</label>';
+ ?>
+
+ <input name="interface" type="radio" value="<?= $key ?>" id="tab<?= $key ?>" class="checkboxtab" <?= $key == $opentab ? 'checked' : '' ?> >
+
+ <label for="tab<?= $key ?>"><?= empty($template[$key]) ? $key : '<a class="templatetooltip" title="'.$template[$key].'" >*</a>'.$key ?> </label>
+
+ <?php
+
echo '<div class="content">';
if ($key == $opentab) {
echo '<textarea name="' . $key . '" id="' . $key . '" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus >' . $value . '</textarea>';
diff --git a/app/view/templates/home.php b/app/view/templates/home.php
index a11f9e3..0d09238 100644
--- a/app/view/templates/home.php
+++ b/app/view/templates/home.php
@@ -74,7 +74,7 @@
<td><a title="<?= $item->tag('string') ?>"><?= $item->tag('sort') ?></a></td>
<td><?= $item->description() ?></td>
<td><?= $item->linkto('sort') ?></td>
- <td><?= $item->linkfrom('sort') ?></td>
+ <td><a title="<?= $item->linkfrom('string') ?>" ><?= $item->linkfrom('sort') ?></a></td>
<td><?= $item->datemodif('hrdi') ?></td>
<td><?= $item->datecreation('hrdi') ?></td>
<td><?= $item->secure('string') ?></td>
diff --git a/app/view/templates/layout.php b/app/view/templates/layout.php
index c20264d..4131350 100644
--- a/app/view/templates/layout.php
+++ b/app/view/templates/layout.php
@@ -7,8 +7,6 @@
<link rel="shortcut icon" href="./media/logo.png" type="image/x-icon">
<title><?= $title ?></title>
<link rel="stylesheet" href="<?= $css ?>">
- <?=$this->section('customhead')?>
- <?=$this->section('arthead')?>
</head>
diff --git a/assets/css/edit.css b/assets/css/edit.css
index 6262aba..b3cb30d 100644
--- a/assets/css/edit.css
+++ b/assets/css/edit.css
@@ -199,6 +199,10 @@ a {
text-decoration: none;
}
+a.templatetooltip {
+ color: white;
+}
+
a:hover {
color: white;
}