diff options
Diffstat (limited to 'app/class')
-rw-r--r-- | app/class/art2.php | 6 | ||||
-rw-r--r-- | app/class/controllerhome.php | 19 | ||||
-rw-r--r-- | app/class/opt.php | 32 | ||||
-rw-r--r-- | app/class/optlist.php | 114 | ||||
-rw-r--r-- | app/class/routes.php | 1 |
5 files changed, 153 insertions, 19 deletions
diff --git a/app/class/art2.php b/app/class/art2.php index 56bc74e..a43d35e 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -296,7 +296,11 @@ class Art2 public function customhead($type = "string") { - return $this->customhead; + if($type === 'string') { + return $this->customhead; + } elseif($type === 'int') { + return substr_count($this->customhead, PHP_EOL) + 1; + } } public function footer($type = "string") diff --git a/app/class/controllerhome.php b/app/class/controllerhome.php index 043ac3e..c053270 100644 --- a/app/class/controllerhome.php +++ b/app/class/controllerhome.php @@ -5,6 +5,8 @@ class Controllerhome extends Controller /** @var Modelhome */ protected $modelhome; protected $opt; + /** @var Optlist */ + protected $optlist; public function __construct($render) { parent::__construct($render); @@ -20,6 +22,8 @@ class Controllerhome extends Controller $this->routedirect('artread/', ['art' => Config::homeredirect()]); } else { + + $table = $this->modelhome->getlister(); $this->opt = $this->modelhome->optinit($table); @@ -27,8 +31,19 @@ class Controllerhome extends Controller $table2 = $this->modelhome->table2($table, $this->opt); $columns = $this->modelhome->setcolumns($this->user->columns()); + + $vars = ['user' => $this->user, 'table2' => $table2, 'opt' => $this->opt, 'columns' => $columns]; + + if(isset($_POST['query']) && $this->user->iseditor()) { + $datas = array_merge($_POST, $_SESSION['opt']); + $this->optlist = new Optlist(Art2::classvarlist()); + $this->optlist->settaglist($table); + $this->optlist->setauthorlist($table); + $this->optlist->hydrate($datas); + $vars['optlist'] = $this->optlist; + } - $this->showtemplate('home', ['user' => $this->user, 'table2' => $table2, 'opt' =>$this->opt, 'columns' => $columns]); + $this->showtemplate('home', $vars); } @@ -37,7 +52,7 @@ class Controllerhome extends Controller public function columns() { if(isset($_POST['columns']) && $this->user->iseditor()) { - $user =$this->usermanager->get($this->user->id()); + $user = $this->usermanager->get($this->user->id()); $user->hydrate($_POST); $this->usermanager->add($user); $this->usermanager->writesession($user); diff --git a/app/class/opt.php b/app/class/opt.php index 9eddf9f..0761782 100644 --- a/app/class/opt.php +++ b/app/class/opt.php @@ -1,21 +1,21 @@ <?php class Opt { - private $sortby = 'id'; - private $order = 1; - private $tagfilter = []; - private $tagcompare = 'OR'; - private $authorfilter = []; - private $authorcompare = 'OR'; - private $secure = 4; - private $linkto = ['min' => '0', 'max' => '0']; - private $linkfrom = ['min' => '0', 'max' => '0']; - private $col = ['id']; - private $taglist = []; - private $authorlist = []; - private $invert = 0; - - private $artvarlist; + protected $sortby = 'id'; + protected $order = 1; + protected $tagfilter = []; + protected $tagcompare = 'OR'; + protected $authorfilter = []; + protected $authorcompare = 'OR'; + protected $secure = 4; + protected $linkto = ['min' => '0', 'max' => '0']; + protected $linkfrom = ['min' => '0', 'max' => '0']; + protected $col = ['id']; + protected $taglist = []; + protected $authorlist = []; + protected $invert = 0; + + protected $artvarlist; public function __construct(array $donnees = []) { @@ -202,7 +202,7 @@ class Opt public function setsortby($sortby) { - if (is_string($sortby) && in_array($sortby, $this->artvarlist())) { + if (is_string($sortby) && in_array($sortby, $this->artvarlist)) { $this->sortby = strtolower(strip_tags($sortby)); } } diff --git a/app/class/optlist.php b/app/class/optlist.php new file mode 100644 index 0000000..cf68fa7 --- /dev/null +++ b/app/class/optlist.php @@ -0,0 +1,114 @@ +<?php + +class Optlist extends Opt +{ + private $description = 0; + private $thumbnail = 0; + private $date = 0; + private $author = 0; + private $style = 0; + + + /** + * New constructor dedicated to parse input string + * + * @param string|array $parsedstring parsed query string + */ + public function __construct($datas = []) + { + if(is_string($datas)) { + $datas = parse_str($this->options, $datas); + + } + $this->hydrate($datas); + } + + + /** + * Get the query as http string + * + * @return string The resulted query + */ + public function getquery() : string + { + $class = get_class_vars(get_class($this)); + $object = get_object_vars($this); + $class['artvarlist'] = $object['artvarlist']; + $class['taglist'] = $object['taglist']; + $class['authorlist'] = $object['authorlist']; + $query = array_diff_assoc_recursive($object, $class); + + return urldecode(http_build_query($query)); + } + + /** + * Get the code to insert directly + */ + public function getcode() : string + { + return '%LIST?' . $this->getquery() . '%'; + } + + + + // _______________________________________ G E T _____________________________________ + + + public function description() + { + return $this->description; + } + + public function thumbnail() + { + return $this->thumbnail; + } + + public function date() + { + return $this->date; + } + + public function author() + { + return $this->author; + } + + public function style() + { + return $this->style; + } + + + + // _______________________________________ S E T _____________________________________ + + public function setdescription($description) + { + $this->description = intval($description); + } + + public function setthumbnail($thumbnail) + { + $this->thumbnail = intval($thumbnail); + } + + public function setdate($date) + { + $this->date = intval($date); + } + + public function setauthor($author) + { + $this->author = intval($author); + } + + public function setstyle($style) + { + $this->style = intval($style); + } +} + + + +?>
\ No newline at end of file diff --git a/app/class/routes.php b/app/class/routes.php index bad6e19..f960582 100644 --- a/app/class/routes.php +++ b/app/class/routes.php @@ -15,6 +15,7 @@ class Routes $router->addMatchTypes(array('cid' => '[a-zA-Z0-9-_+,\'!%@&.$€=\(\|\)]+')); $router->addRoutes([ ['GET', '/', 'Controllerhome#desktop', 'home'], + ['POST', '/', 'Controllerhome#desktop', 'homequery'], ['POST', '/columns', 'Controllerhome#columns', 'homecolumns'], ['POST', '/upload', 'Controllerart#upload', 'artupload'], ['POST', '/!co', 'Controllerconnect#log', 'log'], |