aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-08-21 13:45:28 +0200
committervincent-peugnet <v.peugnet@free.fr>2019-08-21 13:45:28 +0200
commit73ee4462740c0c7d793bb8e0952e34110dfdb78b (patch)
treee8410a86c76ce8c36239a27847e8ecfa96eab3ae
parent63202efc75a63ef30e58c12d602ea95a960a0976 (diff)
downloadwcms-73ee4462740c0c7d793bb8e0952e34110dfdb78b.tar.gz
wcms-73ee4462740c0c7d793bb8e0952e34110dfdb78b.zip
feature : limit query added
-rw-r--r--app/class/modelhome.php17
-rw-r--r--app/class/opt.php25
-rw-r--r--app/class/user.php13
-rw-r--r--app/view/templates/home.php30
-rw-r--r--app/view/templates/homemenu.php18
-rw-r--r--app/view/templates/homeopt.php8
-rw-r--r--composer.json2
7 files changed, 103 insertions, 10 deletions
diff --git a/app/class/modelhome.php b/app/class/modelhome.php
index 3347edf..c30da44 100644
--- a/app/class/modelhome.php
+++ b/app/class/modelhome.php
@@ -38,14 +38,17 @@ class Modelhome extends Modelart
+ /**
+ * @param array $table
+ * @param Opt $opt
+ */
public function table2($table, $opt)
{
- $listmanager = new Modelart;
- $filtertagfilter = $listmanager->filtertagfilter($table, $opt->tagfilter(), $opt->tagcompare());
- $filterauthorfilter = $listmanager->filterauthorfilter($table, $opt->authorfilter(), $opt->authorcompare());
- $filtersecure = $listmanager->filtersecure($table, $opt->secure());
+ $filtertagfilter = $this->filtertagfilter($table, $opt->tagfilter(), $opt->tagcompare());
+ $filterauthorfilter = $this->filterauthorfilter($table, $opt->authorfilter(), $opt->authorcompare());
+ $filtersecure = $this->filtersecure($table, $opt->secure());
$filter = array_intersect($filtertagfilter, $filtersecure, $filterauthorfilter);
$table2 = [];
@@ -64,7 +67,11 @@ class Modelhome extends Modelart
$table2 = $table2invert;
}
- $listmanager->artlistsort($table2, $opt->sortby(), $opt->order());
+ $this->artlistsort($table2, $opt->sortby(), $opt->order());
+
+ if($opt->limit() !== 0) {
+ $table2 = array_slice($table2, 0, $opt->limit());
+ }
return $table2;
diff --git a/app/class/opt.php b/app/class/opt.php
index 39e2ab8..1cfa299 100644
--- a/app/class/opt.php
+++ b/app/class/opt.php
@@ -14,6 +14,7 @@ class Opt
protected $taglist = [];
protected $authorlist = [];
protected $invert = 0;
+ protected $limit= 0;
protected $artvarlist;
@@ -67,7 +68,7 @@ class Opt
public function getall()
{
- $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'authorcompare', 'authorfilter', 'invert'];
+ $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'authorcompare', 'authorfilter', 'limit','invert'];
foreach ($optlist as $method) {
if (method_exists($this, $method)) {
@@ -91,11 +92,14 @@ class Opt
public function getadress(string $sortby = '')
{
- if ($this->sortby() === $sortby) {
+ if ($this->sortby === $sortby) {
$order = $this->order * -1;
} else {
$order = $this->order;
}
+ if(empty($sortby)) {
+ $sortby = $this->sortby;
+ }
$adress = '?sortby=' . $sortby;
$adress .= '&order=' . $order;
$adress .= '&secure=' . $this->secure;
@@ -110,6 +114,7 @@ class Opt
if ($this->invert == 1) {
$adress .= '&invert=1';
}
+ $adress.= '&limit=' .$this->limit;
$adress .= '&submit=filter';
return $adress;
@@ -213,6 +218,11 @@ class Opt
return $this->artvarlist;
}
+ public function limit()
+ {
+ return $this->limit;
+ }
+
// __________________________________________________ S E T _____________________________________________
@@ -356,6 +366,17 @@ class Opt
}
}
+ public function setlimit($limit)
+ {
+ $limit = intval($limit);
+ if($limit < 0) {
+ $limit = 0;
+ } elseif ($limit >= 10000) {
+ $limit = 9999;
+ }
+ $this->limit = $limit;
+ }
+
public function setartvarlist(array $artvarlist)
{
diff --git a/app/class/user.php b/app/class/user.php
index 68eed91..2b87d62 100644
--- a/app/class/user.php
+++ b/app/class/user.php
@@ -12,6 +12,7 @@ class User
protected $connectcount = 0;
protected $expiredate = false;
protected $bookmark = [];
+ protected $display = ['bookmark' => false];
public function __construct($datas = [])
{
@@ -120,6 +121,11 @@ class User
return $this->bookmark;
}
+ public function display()
+ {
+ return $this->display;
+ }
+
// _______________________ S E T _______________________
@@ -198,6 +204,13 @@ class User
}
}
+ public function setdisplay($display)
+ {
+ if(is_array($display)) {
+ $this->display = $display;
+ }
+ }
+
diff --git a/app/view/templates/home.php b/app/view/templates/home.php
index 824d9f3..867baee 100644
--- a/app/view/templates/home.php
+++ b/app/view/templates/home.php
@@ -181,6 +181,36 @@
</div>
</section>
+
+
+ <?php if($user->display()['bookmark'] && (!empty(Config::bookmark()) || !empty($user->bookmark()))) { ?>
+
+ <section class="hidephone" id="bookmark">
+ <div class="block">
+ <h2>Bookmarks</h2>
+ <div class="scroll">
+ <strong>Public</strong>
+ <ul>
+ <?php foreach (Config::bookmark() as $id => $query) { ?>
+ <li>
+ <a href="<?= $query ?>"><?= $id ?></a>
+ </li>
+ <?php } ?>
+ </ul>
+ <strong><?= $user->id() ?></strong>
+ <ul>
+ <?php foreach ($user->bookmark() as $id => $query) { ?>
+ <li>
+ <a href="<?= $query ?>"><?= $id ?></a>
+ </li>
+ <?php } ?>
+ </ul>
+ </section>
+ </div>
+ </nav>
+
+ <?php } ?>
+
</main>
<?php $this->insert('footer', ['footer' => $footer]) ?>
diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php
index 3ad57ef..46e2308 100644
--- a/app/view/templates/homemenu.php
+++ b/app/view/templates/homemenu.php
@@ -23,14 +23,28 @@
</br>
<input type="submit" value="upload">
</form>
+ <h2>Export database</h2>
+ <p>Future feature</p>
</div>
</details>
- <details class="hidephone" id="columns">
- <summary>Columns</summary>
+ <details class="hidephone" id="display">
+ <summary>Display</summary>
<div class="submenu">
+ <h2>Worksapce</h2>
+ <form action="">
+ <ul>
+ <?php foreach ($user->display() as $id => $setting) { ?>
+ <li>
+ <input type="checkbox" name="display[<?= $id ?>]" id="display_<?= $id ?>" value="true" <?= $setting ? 'checked' : '' ?>>
+ <label for="display_<?= $id ?>"><?= $id ?></label>
+ </li>
+ <?php } ?>
+ </ul>
+ <input type="submit" value="update display">
+ </form>
<h2>Columns</h2>
<form action="<?= $this->url('homecolumns') ?>" method="post">
<ul>
diff --git a/app/view/templates/homeopt.php b/app/view/templates/homeopt.php
index 27d5625..7f42c8e 100644
--- a/app/view/templates/homeopt.php
+++ b/app/view/templates/homeopt.php
@@ -116,6 +116,10 @@
</fieldset>
+ <fieldset>
+ <legend>Other</legend>
+
+
<?php
if ($opt->invert() == 1) {
echo '<input type="checkbox" name="invert" value="1" id="invert" checked>';
@@ -124,6 +128,10 @@
}
echo '<label for="invert">invert</></br>';
?>
+ <input type="number" name="limit" id="limit" value="<?= $opt->limit() ?>" min="0" max="9999">
+ <label for="limit">limit</label>
+
+ </fieldset>
</div>
diff --git a/composer.json b/composer.json
index d6b29ff..6b209cc 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "w-cms",
"description": "point'n think",
- "version": "1.5.0",
+ "version": "1.5.1",
"require": {
"michelf/php-markdown": "^1.8",
"league/plates": "3.*",