aboutsummaryrefslogtreecommitdiff
path: root/app/class
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 /app/class
parentd46c05b12b9dcd65d2d9cd230bf45b5bdf6fa8bd (diff)
downloadwcms-0660c99cb9e2dae3b0e41975f643609231258147.tar.gz
wcms-0660c99cb9e2dae3b0e41975f643609231258147.zip
minor changes
Diffstat (limited to 'app/class')
-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
4 files changed, 35 insertions, 17 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();