From 67b20c49ec4e5efb4526fc64ef679dfb6dd41e30 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Thu, 4 Oct 2018 05:10:51 +0200 Subject: 2.8 auto-tag-update + help + tabs --- class/class.w.aff.php | 232 +++++++++++++++++++++++++++++++++++------------ class/class.w.app.php | 54 ++++++----- class/class.w.art.php | 48 +++++++++- class/class.w.config.php | 14 +++ 4 files changed, 259 insertions(+), 89 deletions(-) (limited to 'class') diff --git a/class/class.w.aff.php b/class/class.w.aff.php index 0c7aa24..d14e682 100644 --- a/class/class.w.aff.php +++ b/class/class.w.aff.php @@ -94,80 +94,171 @@ class Aff } } - public function edit(Art $art, App $app, $list) + public function edit(Art $art, App $app, $list, $fontsize, $imagelist) { + if ($app->session() >= self::$edit) { ?>
- - - -
- Infos -
- - - - - - - - - - -
-
-
- CSS -
- - + + + + 👁 + + id() ?> + + + + +
+
+
+ Quick CSS +
+ + $art->couleurtext(), 'lien' => $art->couleurlien(), 'lienblank' => $art->couleurlienblank(), 'bkg' => $art->couleurbkg()]; + foreach ($colorlist as $element => $color) { + echo ''; + } + + + + ?> + + + + +
+
+
+ Help +
+

Help !

+

To save your article, clic on the HOME, UPDATE, or DISPLAY buttons. You can use the keyboard shortcuts as well.

+
ALT + W : home
+
ALT + X : update
+
ALT + C : display
+

Markdown

+

The html section use Markdown encoding : synthax. But the following strategies are specific to W.

+

Links

+
[text](=article_id)
+

where article_id is the article's id you want to point to.

+

Images

+
[altimage](/img_id.extension)
+

Where img_id is the id of your image and its extension.

+

Tricks

+
%TITLE%
+

Show the title of your article.

+
%DESCRIPTION%
+

Show the description (intro) of your article.

+
%%tag_name%%
+

Generate a list of links to all articles under this tag.

+

vv

+

vv

+

vv

+

+
+
+ + + + + + + + '; + foreach ($tablist as $key => $value) { + echo '
'; + if ($key == $opentab) { + echo ''; + } else { + echo ''; + } + echo ''; + echo '
'; + echo ''; + echo '
'; + echo '
'; + } + + echo ''; +} + + public function copy(Art $art, $list) { diff --git a/class/class.w.app.php b/class/class.w.app.php index 82e2bef..d8751ab 100644 --- a/class/class.w.app.php +++ b/class/class.w.app.php @@ -11,6 +11,7 @@ class App const SQL_READ_DIR = '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR; const MEDIA_DIR = '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR; const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf'); + const MEDIA_TYPES = ['image', 'video', 'sound', 'other']; const ADMIN = 10; @@ -176,7 +177,6 @@ class App public function update(Art $art) { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); - $art->updatelien(); $q = $this->bdd->prepare('UPDATE ' . $this->arttable . ' SET titre = :titre, soustitre = :soustitre, intro = :intro, tag = :tag, datecreation = :datecreation, datemodif = :datemodif, css = :css, html = :html, secure = :secure, couleurtext = :couleurtext, couleurbkg = :couleurbkg, couleurlien = :couleurlien, couleurlienblank = :couleurlienblank, lien = :lien, template = :template WHERE id = :id'); @@ -326,7 +326,26 @@ class App $req->closeCursor(); return $donnees; + } + public function tag(array $artlist, $tagchecked) + { + $artcheckedlist = []; + foreach($artlist as $art) { + if (in_array($tagchecked, $art->tag('array'))) { + $artcheckedlist[] = $art; + } + } + return $artcheckedlist; + } + + public function taglist(array $artlist, array $tagcheckedlist) + { + $taglist = []; + foreach ($tagcheckedlist as $tag) { + $taglist[$tag] = $this->tag($artlist, $tag); + } + return $taglist; } public function count() @@ -497,39 +516,26 @@ class App } - public function getlistermedia($dir) + public function getlistermedia($dir, $type="all") { if ($handle = opendir($dir)) { $list = []; while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { - - // var_dump($entry); - - // $fileinfo = pathinfo($entry); - - // var_dump($fileinfo); - - - // $filepath = $dir . $fileinfo['filename'] . '.' . $fileinfo['extension']; - - // list($width, $height, $type, $attr) = getimagesize($filepath); - // $filesize = filesize($filepath); - - // $donnees = array( - // 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']), - // 'path' => dirname($entry), - // 'extension' => $fileinfo['extension'] - // ); - - // $media = new Media($donnees); - $media = $this->getmedia($entry, $dir); $media->analyse(); - $list[] = $media; + + if(in_array($type, self::MEDIA_TYPES)) { + if($media->type() == $type) { + $list[] = $media; + } + } else { + $list[] = $media; + } + } } diff --git a/class/class.w.art.php b/class/class.w.art.php index 2238f71..12ff1e3 100644 --- a/class/class.w.art.php +++ b/class/class.w.art.php @@ -73,7 +73,9 @@ class Art public function updatelien() { - $this->lien = search($this->md(true), self::DEBUT, self::FIN); + $this->lien = []; + $this->lien = array_unique(search($this->md(true), self::DEBUT, self::FIN)); + } public static function classvarlist() @@ -100,6 +102,38 @@ class Art } + public function autotaglist() + { + $pattern = "/%%(\w*)%%/"; + preg_match_all($pattern, $this->md(), $out); + return $out[1]; + + } + + public function autotaglistupdate($taglist) + { + foreach ($taglist as $tag => $artlist) { + $replace = ''; + $this->html = str_replace('%%' . $tag . '%%', $replace, $this->html); + } + } + + public function autotaglistcalc($taglist) + { + foreach ($taglist as $tag => $artlist) { + foreach ($artlist as $art) { + if(!in_array($art->id(), $this->lien('array')) && $art->id() != $this->id()) { + $this->lien[] = $art->id(); + } + } + } + } + + // _____________________________________________________ G E T ____________________________________________________ public function id($type = 'string') @@ -181,7 +215,7 @@ class Art public function md($expand = false) { - if($expand == true) { + if ($expand == true) { $md = str_replace('](=', '](?id=', $this->html); } else { $md = $this->html; @@ -192,6 +226,7 @@ class Art public function html(App $app) { $html = Markdown::defaultTransform($this->html); + $html = str_replace('href="=', 'href="?id=', $html); foreach ($this->lien('array') as $id) { $title = "Cet article n'existe pas encore"; @@ -205,7 +240,10 @@ class Art $html = str_replace($lien, $titlelien, $html); } - $html = str_replace('href="=', 'href="?id=', $html); + + + $html = str_replace('%TITLE%', $this->titre(), $html); + $html = str_replace('%DESCRIPTION%', $this->intro(), $html); $html = str_replace('href="../media/', ' class="file" target="_blank" href="../media/', $html); $html = str_replace('href="http', ' class="external" target="_blank" href="http', $html); $html = str_replace('tag = $taglist; diff --git a/class/class.w.config.php b/class/class.w.config.php index 1d5f7b5..68b0987 100644 --- a/class/class.w.config.php +++ b/class/class.w.config.php @@ -16,6 +16,7 @@ class Config private $read; private $cssread; private $color4; + private $fontsize = 6; // _______________________________________ F U N _______________________________________ @@ -105,6 +106,11 @@ class Config return $this->color4; } + public function fontsize() + { + return $this->fontsize; + } + // __________________________________________ S E T ______________________________________ @@ -171,6 +177,14 @@ class Config } } + public function setfontsize($fontsize) + { + $fontsize = intval($fontsize); + if($fontsize > 1) { + $this->fontsize = $fontsize; + } + } + } -- cgit v1.2.3