aboutsummaryrefslogtreecommitdiff
path: root/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-10-07 05:55:26 +0200
committervincent-peugnet <v.peugnet@free.fr>2018-10-07 05:55:26 +0200
commit74ccedd6544daac0845a044b5e6d71d577578c69 (patch)
tree2ec348bfc818fbc2859922ac71f866c407ce0a7b /class
parent67b20c49ec4e5efb4526fc64ef679dfb6dd41e30 (diff)
downloadwcms-74ccedd6544daac0845a044b5e6d71d577578c69.tar.gz
wcms-74ccedd6544daac0845a044b5e6d71d577578c69.zip
2.9 map + filter fix + markdownextra
Diffstat (limited to 'class')
-rw-r--r--class/class.w.aff.php92
-rw-r--r--class/class.w.app.php51
-rw-r--r--class/class.w.art.php15
-rw-r--r--class/class.w.opt.php81
4 files changed, 193 insertions, 46 deletions
diff --git a/class/class.w.aff.php b/class/class.w.aff.php
index d14e682..14b653e 100644
--- a/class/class.w.aff.php
+++ b/class/class.w.aff.php
@@ -172,10 +172,10 @@ class Aff
$templatelist = ['header' => 0, 'section' => 0, 'nav' => 0, 'aside' => 0, 'footer' => 0, 'quickcss' => 1, 'css' => 1];
foreach ($templatelist as $template => $check) {
- if($check == 1) {
- echo '<li><input type="checkbox" name="template'.$template.'" id="template'.$template.'" checked><label for="template'.$template.'">'.$template.'</label></li>';
+ if ($check == 1) {
+ echo '<li><input type="checkbox" name="template' . $template . '" id="template' . $template . '" checked><label for="template' . $template . '">' . $template . '</label></li>';
} else {
- echo '<li><input type="checkbox" name="template'.$template.'" id="template'.$template.'"><label for="template'.$template.'">'.$template.'</label></li>';
+ echo '<li><input type="checkbox" name="template' . $template . '" id="template' . $template . '"><label for="template' . $template . '">' . $template . '</label></li>';
}
}
?>
@@ -189,10 +189,10 @@ class Aff
<?php
$colorlist = ['text' => $art->couleurtext(), 'lien' => $art->couleurlien(), 'lienblank' => $art->couleurlienblank(), 'bkg' => $art->couleurbkg()];
foreach ($colorlist as $element => $color) {
- echo '<label for="couleur'.$element.'">Couleur du '.$element.' :</label><input type="color" name="couleur'.$element.'" value="'.$color.'" id="couleur'.$element.'">';
+ echo '<label for="couleur' . $element . '">Couleur du ' . $element . ' :</label><input type="color" name="couleur' . $element . '" value="' . $color . '" id="couleur' . $element . '">';
}
-
+
?>
@@ -209,9 +209,9 @@ class Aff
}
foreach ($imagelist as $image) {
if ($image->id() == $artbkgimage) {
- echo '<option value="' . $image->id() . '.'.$image->extension().'" selected >' . $image->id() . '.'.$image->extension().'</option>';
+ echo '<option value="' . $image->id() . '.' . $image->extension() . '" selected >' . $image->id() . '.' . $image->extension() . '</option>';
} else {
- echo '<option value="' . $image->id() . '.'.$image->extension().'">' . $image->id() . '.'.$image->extension().'</option>';
+ echo '<option value="' . $image->id() . '.' . $image->extension() . '">' . $image->id() . '.' . $image->extension() . '</option>';
}
}
?>
@@ -543,9 +543,12 @@ public function optiontag(Opt $opt)
echo '<fieldset><legend>Tag</legend><ul>';
+
echo '<input type="radio" id="OR" name="tagcompare" value="OR" ' . ($opt->tagcompare() == "OR" ? "checked" : "") . ' ><label for="OR">OR</label>';
echo '<input type="radio" id="AND" name="tagcompare" value="AND" ' . ($opt->tagcompare() == "AND" ? "checked" : "") . '><label for="AND">AND</label>';
+ //echo '<input type="hidden" name="tagfilter[]" value="">';
+
$in = false;
$out = false;
$limit = 1;
@@ -601,22 +604,73 @@ public function optionsort(Opt $opt)
}
-public function map(App $app, $url)
+public function mapheader()
{
- echo '<div class="home"><section>';
+ $selectcurve = isset($_GET['curve']) ? $_GET['curve'] : 'basis';
+ $selectorient = isset($_GET['orient']) ? $_GET['orient'] : 'TD';
+ $curves = ['linear', 'basis', 'natural', 'step', 'stepAfter', 'stepBefore', 'monotoneX', 'monotoneY'];
+ $orients = ['TD', 'LR', 'BT', 'RL'];
+ ?>
+ <h2>Map</h2>
- $map = "";
- $link = "";
- foreach ($app->getlister(['id', 'lien']) as $item) {
- foreach ($item->lien('array') as $lien) {
- $map = $map . ' </br> ' . $item->id() . ' --> ' . $lien;
- }
- $link = $link . '</br>click ' . $item->id() . ' "' . $url . '/w/?id=' . $item->id() . '"';
+ <form action="./" method="get">
+ <label for="curve">Curve style</label>
+ <select name="curve" id="curve">
+ <?php
+ foreach ($curves as $curve) {
+ ?>
+ <option value="<?= $curve ?>" <?= $selectcurve == $curve ? 'selected' : ''?>><?= $curve ?></option>
+ <?php
}
- echo $map;
- echo $link;
+ ?>
+ </select>
+ <label for="orient">Orientation</label>
+ <select name="orient" id="orient">
+ <?php
+ foreach ($orients as $orient) {
+ ?>
+ <option value="<?= $orient ?>" <?= $selectorient == $orient ? 'selected' : ''?>><?= $orient ?></option>
+ <?php
+ }
+ ?>
+ </select>
+ <input type="submit" value="draw" name="map">
+ </form>
+ <?php
+
+}
+
+public function mermaid(string $map)
+{
+ $curve = isset($_GET['curve']) ? $_GET['curve'] : 'basis';
+ $orient = isset($_GET['orient']) ? $_GET['orient'] : 'TD';
+
+
+ ?>
+
+ <script src="../rsc/js/mermaid.min.js"></script>
+
+ <script>
+ mermaid.initialize({
+ startOnLoad:true,
+ themeCSS: ".node circle, .node rect , .node polygon { fill: var(--color1); stroke: var(--color4);} ",
+ flowchart: {
+ curve: '<?= $curve ?>'
+ }
+ });
+
+ </script>
+
+
+ <div class="mermaid">
+
+ graph <?= $orient ?>
+ <?= $map ?>
+ </div>
+
+
+ <?php
- echo '</div></section>';
}
public function aside(App $app)
diff --git a/class/class.w.app.php b/class/class.w.app.php
index d8751ab..0c9d6a3 100644
--- a/class/class.w.app.php
+++ b/class/class.w.app.php
@@ -331,7 +331,7 @@ class App
public function tag(array $artlist, $tagchecked)
{
$artcheckedlist = [];
- foreach($artlist as $art) {
+ foreach ($artlist as $art) {
if (in_array($tagchecked, $art->tag('array'))) {
$artcheckedlist[] = $art;
}
@@ -343,7 +343,7 @@ class App
{
$taglist = [];
foreach ($tagcheckedlist as $tag) {
- $taglist[$tag] = $this->tag($artlist, $tag);
+ $taglist[$tag] = $this->tag($artlist, $tag);
}
return $taglist;
}
@@ -446,12 +446,12 @@ class App
{
$arttable = strip_tags($arttable);
$tablename = str_clean($tablename);
- if($this->tableexist($dbname, $arttable) && !$this->tableexist($dbname, $tablename)) {
+ if ($this->tableexist($dbname, $arttable) && !$this->tableexist($dbname, $tablename)) {
$duplicate = " CREATE TABLE `$tablename` LIKE `$arttable`;";
$alter = "ALTER TABLE `$tablename` ADD PRIMARY KEY (`id`);";
$insert = "INSERT `$tablename` SELECT * FROM `$arttable`;";
-
+
$req = $this->bdd->query($duplicate . $alter . $insert);
return 'tableduplicated';
@@ -516,7 +516,7 @@ class App
}
- public function getlistermedia($dir, $type="all")
+ public function getlistermedia($dir, $type = "all")
{
if ($handle = opendir($dir)) {
$list = [];
@@ -525,12 +525,12 @@ class App
$media = $this->getmedia($entry, $dir);
-
+
$media->analyse();
- if(in_array($type, self::MEDIA_TYPES)) {
- if($media->type() == $type) {
- $list[] = $media;
+ if (in_array($type, self::MEDIA_TYPES)) {
+ if ($media->type() == $type) {
+ $list[] = $media;
}
} else {
$list[] = $media;
@@ -656,6 +656,39 @@ class App
+ // ________________________________________________________ M A P ________________________________________________________
+
+
+ public function map(array $getlister, $lb = PHP_EOL)
+ {
+
+ $map = "";
+ $link = "";
+ $style = "";
+ foreach ($getlister as $item) {
+ if($item->secure() == 2) {
+ $style = $style . $lb . $item->id() . '{' . $item->titre() . '}';
+ } elseif ($item->secure() == 1) {
+ $style = $style . $lb . $item->id() . '(' . $item->titre() . ')';
+
+ } else {
+ $style = $style . $lb . $item->id() . '((' . $item->titre() . '))';
+ }
+ foreach ($item->lien('array') as $lien) {
+ $map = $map . $lb . $item->id() . ' --> ' . $lien;
+ $link = $link . $lb . 'click ' . $lien . ' "./?id=' . $lien . '"';
+
+ }
+ $link = $link . $lb . 'click ' . $item->id() . ' "./?id=' . $item->id() . '"';
+ }
+ return $map . $link . $style;
+
+ }
+
+
+
+
+
//_________________________________________________________ S E S ________________________________________________________
public function login($pass, $config)
diff --git a/class/class.w.art.php b/class/class.w.art.php
index 12ff1e3..4c88987 100644
--- a/class/class.w.art.php
+++ b/class/class.w.art.php
@@ -1,6 +1,6 @@
<?php
-use Michelf\Markdown;
+use Michelf\MarkdownExtra;
class Art
@@ -225,7 +225,15 @@ class Art
public function html(App $app)
{
- $html = Markdown::defaultTransform($this->html);
+
+ $html = str_replace('%TITLE%', $this->titre(), $this->html);
+ $html = str_replace('%DESCRIPTION%', $this->intro(), $html);
+
+ $parser = new MarkdownExtra;
+ $parser->header_id_func = function ($header) {
+ return preg_replace('/[^a-z0-9]/', '', strtolower($header));
+ };
+ $html = $parser->transform($html);
$html = str_replace('href="=', 'href="?id=', $html);
foreach ($this->lien('array') as $id) {
@@ -241,9 +249,6 @@ class Art
}
-
- $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('<img src="/', '<img src="../media/', $html);
diff --git a/class/class.w.opt.php b/class/class.w.opt.php
index 684cb09..7164cb7 100644
--- a/class/class.w.opt.php
+++ b/class/class.w.opt.php
@@ -31,7 +31,7 @@ class Opt
}
- public function reset()
+ public function resetall()
{
$varlist = get_class_vars(__class__);
@@ -41,6 +41,53 @@ class Opt
}
}
+ public function reset($var)
+ {
+ $varlist = get_class_vars(__class__);
+ if(in_array($var, $varlist)) {
+ $this->$var = $varlist[$var];
+ }
+ }
+
+ public function submit()
+ {
+ if(isset($_GET['submit'])) {
+ if ($_GET['submit'] == 'reset') {
+ $_SESSION['opt'] = [];
+ } elseif ($_GET['submit'] == 'filter') {
+ $this->getall();
+ }
+ } else {
+ $this->sessionall();
+ }
+ }
+
+ public function getall()
+ {
+ $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'invert'];
+
+ foreach ($optlist as $method) {
+ if (method_exists($this, $method)) {
+ if(isset($_GET[$method])) {
+ $setmethod = 'set'. $method;
+ $this->$setmethod($_GET[$method]);
+ } else {
+ $this->reset($method);
+ }
+ $_SESSION['opt'][$method] = $this->$method();
+ }
+ }
+ }
+
+ public function sessionall()
+ {
+ if(isset($_SESSION['opt'])) {
+ $this->hydrate($_SESSION['opt']);
+ }
+ }
+
+
+
// _______________________________________________ G E T _______________________________________________
public function sortby()
@@ -122,8 +169,14 @@ class Opt
public function settagfilter($tagfilter)
{
- if (is_array($tagfilter)) {
- $this->tagfilter = $tagfilter;
+ if (!empty($tagfilter) && is_array($tagfilter)) {
+ $tagfilterverif = [];
+ foreach ($tagfilter as $tag) {
+ if(array_key_exists($tag, $this->taglist)) {
+ $tagfilterverif[] = $tag;
+ }
+ }
+ $this->tagfilter = $tagfilterverif;
}
}
@@ -181,24 +234,26 @@ class Opt
public function settaglist(array $artlist)
{
- $taglist = [];
- foreach ($artlist as $art) {
- foreach ($art->tag('array') as $tag) {
- if (!array_key_exists($tag, $taglist)) {
- $taglist[$tag] = 1;
- } else {
- $taglist[$tag]++;
+ $taglist = [];
+ foreach ($artlist as $art) {
+ foreach ($art->tag('array') as $tag) {
+ if (!array_key_exists($tag, $taglist)) {
+ $taglist[$tag] = 1;
+ } else {
+ $taglist[$tag]++;
+ }
}
}
- }
- $taglistsorted = arsort($taglist);
- $this->taglist = $taglist;
+ $taglistsorted = arsort($taglist);
+ $this->taglist = $taglist;
}
public function setinvert(int $invert)
{
if ($invert == 0 || $invert == 1) {
$this->invert = $invert;
+ } else {
+ $this->invert = 0;
}
}