From d7f3313ff4514e38c9f53439cd1a1287e56e45f7 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 11 Nov 2018 17:19:26 +0100 Subject: reboot folder --- w/class/quickcss.php | 291 --------------------------------------------------- 1 file changed, 291 deletions(-) delete mode 100644 w/class/quickcss.php (limited to 'w/class/quickcss.php') diff --git a/w/class/quickcss.php b/w/class/quickcss.php deleted file mode 100644 index dc7dbac..0000000 --- a/w/class/quickcss.php +++ /dev/null @@ -1,291 +0,0 @@ - ['left', 'right', 'center', 'justify'], - 'border-style' => ['solid', 'double', 'outset', 'ridge'], - 'font-family' => ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy'], - 'text-decoration-line' => ['none', 'underline', 'overline', 'line-through', 'underline overline'], - 'display' => ['none', ] - ]; - - - private static function getselect() - { - return array_keys(self::OPTIONS); - } - - private static function getparams() - { - $params = array_merge(self::COLOR, self::SIZE, self::getselect(), self::UNIQUE); - sort($params, SORT_STRING ); - return $params; - } - - public function __construct($data) - { - $this->hydrate($data); } - - public function hydrate($data) - { - foreach ($data as $key => $value) { - $method = 'set' . $key; - - if (method_exists($this, $method)) { - $this->$method($value); - } - } - } - - public function calc() - { - $quickcss = $this->intersect($this->values,$this->active); - $quickcss = $this->merge($quickcss, $this->new); - $quickcss = $this->addunits($quickcss, $this->units); - $quickcss = $this->merge($this->jsoncss, $quickcss); - - $this->quickcss = $quickcss; - } - - - - // _________________________________________ P O S T __________________________________________________ - - public function setvalues($data) - { - if(is_array($data)) { - $this->values = $data; - } - } - - public function setunits($data) - { - if(is_array($data)) { - $this->units = $data; - } - } - - public function setactive($data) - { - if(is_array($data)) { - $this->active = $data; - } - } - - public function setnew($data) - { - if (!empty($data['element']) && !empty($data['param']) && in_array($data['param'], self::getparams())) { - $new = array($data['element'] => array($data['param'] => '')); - $this->new = $new; - } - } - - - public function setjson($jsoncss) - { - if(!empty($jsoncss) && is_string($jsoncss)) { - $jsoncss = json_decode($jsoncss); - if(is_array($jsoncss)) { - $this->jsoncss = $jsoncss; - } else { - $this->jsoncss = []; - } - } - } - - - // _______________________________________ C A L C ___________________________________________________ - - public function intersect($values, $active) - { - $intersect = array_intersect_key($values, $active); - - foreach ($intersect as $element => $css) { - $intersect[$element] = array_intersect_key($values[$element], $active[$element]); - } - return $intersect; - } - - public function merge($quickcss, $new) - { - $quickcss = array_merge_recursive($quickcss, $new); - return $quickcss; - } - - public function addunits($quickcss, $units) - { - foreach ($units as $element => $css) { - foreach ($css as $param => $unit) { - if (array_key_exists($element, $quickcss) && array_key_exists($param, $quickcss[$element])) { - $quickcss[$element][$param] = $quickcss[$element][$param] . $unit; - } - } - } - return $quickcss; - } - - - - // __________________________________________ C O M _________________________________________ - - public function tocss() - { - $string = ''; - foreach ($this->quickcss as $element => $css) { - $string .= PHP_EOL . $element . ' {'; - foreach ($css as $param => $value) { - $string .= PHP_EOL . ' ' . $param . ': ' . $value . ';'; - } - $string .= PHP_EOL . '}' . PHP_EOL; - } - return $string; - } - - public function tojson() - { - return json_encode($this->quickcss); - } - - - - - // _____________________________________________ F O R M ____________________________________________ - - public function form($action) - { - echo '
'; - echo '
'; - $this->inputs($this->quickcss); - echo '
'; - echo '
'; - - } - - public function inputs($quickcss) - { - echo '

Add element

'; - - echo ''; - echo ''; - foreach (array_keys($quickcss) as $element) { - echo ''; - - echo ''; - - foreach ($quickcss as $element => $css) { - echo '

' . $element . '

'; - foreach ($css as $param => $value) { - - echo '
'; - echo ''; - echo ''; - echo '
'; - - echo '
'; - - if (in_array($param, self::COLOR)) { - echo ''; - } - - if (in_array($param, self::SIZE)) { - $this->sizeinput($element, $param, $value); - } - - if (in_array($param, self::getselect())) { - $this->selectinput($element, $param, $value); - } - - if (in_array($param, self::UNIQUE)) { - $method = str_replace('-', '', $param) . 'input'; - if (method_exists($this, $method)) { - $this->$method($element, $param, $value); - } - } - - echo '
'; - } - } - - - } - - - - - - - // ____________________________________ I N P U T __________________________________ - - public function sizeinput($element, $param, $value) - { - echo ''; - - $unit = preg_replace('/\d/', '', $value); - ?> - - '; - - $unit = preg_replace('/\d/', '', $value); - ?> - - '; - } - - public function selectinput($element, $param, $value) - { - echo ''; - } - - -} - - - -?> \ No newline at end of file -- cgit v1.2.3