diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-10-18 01:08:46 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-10-18 01:08:46 +0200 |
commit | 7b2e48276b2a3ceff83c906d38077f8d0479c3df (patch) | |
tree | 0fc26bb1cbae5a30583292fbfb2b752fb623a94d /class/class.w.opt.php | |
parent | 65796d4a2349e71ca05f5f298d6f94ff792d88b2 (diff) | |
download | wcms-7b2e48276b2a3ceff83c906d38077f8d0479c3df.tar.gz wcms-7b2e48276b2a3ceff83c906d38077f8d0479c3df.zip |
2.92 new architecture + quickcss class
Diffstat (limited to 'class/class.w.opt.php')
-rw-r--r-- | class/class.w.opt.php | 272 |
1 files changed, 0 insertions, 272 deletions
diff --git a/class/class.w.opt.php b/class/class.w.opt.php deleted file mode 100644 index 7164cb7..0000000 --- a/class/class.w.opt.php +++ /dev/null @@ -1,272 +0,0 @@ -<?php -class Opt -{ - private $sortby = 'id'; - private $order = 1; - private $tagfilter = []; - private $tagcompare = 'OR'; - private $secure = 4; - private $liento = ['min' => '0', 'max' => '0']; - private $lienfrom = ['min' => '0', 'max' => '0']; - private $col = ['id']; - private $taglist = []; - private $invert = 0; - - private $artvarlist; - - public function __construct(array $donnees = []) - { - $this->hydrate($donnees); - } - - public function hydrate(array $donnees) - { - foreach ($donnees as $key => $value) { - $method = 'set' . $key; - - if (method_exists($this, $method)) { - $this->$method($value); - } - } - } - - - public function resetall() - { - $varlist = get_class_vars(__class__); - - foreach ($varlist as $var => $default) { - $method = 'set' . $var; - $this->$method($default); - } - } - - 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() - { - return $this->sortby; - } - - public function order() - { - return $this->order; - } - - public function secure() - { - return $this->secure; - } - - public function tagfilter($type = 'array') - { - return $this->tagfilter; - } - - public function tagcompare() - { - return $this->tagcompare; - } - - public function liento($type = 'array') - { - return $this->liento; - } - - public function lienfrom($type = 'array') - { - return $this->lienfrom; - } - - public function col($type = 'array') - { - if ($type == 'string') { - return implode(', ', $this->col); - } else { - return ($this->col); - } - } - - public function taglist() - { - return $this->taglist; - } - - public function invert() - { - return $this->invert; - } - - public function artvarlist() - { - return $this->artvarlist; - } - - - // __________________________________________________ S E T _____________________________________________ - - public function setsortby($sortby) - { - if (is_string($sortby) && in_array($sortby, $this->artvarlist())) { - $this->sortby = strtolower(strip_tags($sortby)); - } - } - - public function setorder($order) - { - $order = intval($order); - if (in_array($order, [-1, 0, 1])) { - $this->order = $order; - } - } - - public function settagfilter($tagfilter) - { - if (!empty($tagfilter) && is_array($tagfilter)) { - $tagfilterverif = []; - foreach ($tagfilter as $tag) { - if(array_key_exists($tag, $this->taglist)) { - $tagfilterverif[] = $tag; - } - } - $this->tagfilter = $tagfilterverif; - } - } - - public function settagcompare($tagcompare) - { - if (in_array($tagcompare, ['OR', 'AND'])) { - $this->tagcompare = $tagcompare; - } - } - - public function setsecure($secure) - { - if ($secure >= 0 && $secure <= 5) { - $this->secure = intval($secure); - } - } - - public function setliento($range) - { - $this->liento = $range; - } - - public function setlienfrom($range) - { - $this->lienfrom = $range; - } - - public function setlientomin($min) - { - $this->liento['min'] = intval($min); - } - - public function setlientomax($max) - { - $this->liento['max'] = intval($max); - } - - public function setlienfrommin($min) - { - $this->lienfrom['min'] = intval($min); - } - - public function setlienfrommax($max) - { - $this->lienfrom['max'] = intval($max); - } - - public function setcol($col) - { - if (is_array($col)) { - $this->col = array_intersect($this->artvarlist(), $col); - } - } - - - 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]++; - } - } - } - $taglistsorted = arsort($taglist); - $this->taglist = $taglist; - } - - public function setinvert(int $invert) - { - if ($invert == 0 || $invert == 1) { - $this->invert = $invert; - } else { - $this->invert = 0; - } - } - - - public function setartvarlist(array $artvarlist) - { - $this->artvarlist = $artvarlist; - } - - -} - - - - -?>
\ No newline at end of file |