psf
css.php
1 <?php
2 
3 // Part of php simple framework (psf)
4 
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 
15 // Copyright (c) Petr Bena <petr@bena.rocks> 2015 - 2018
16 
17 if (!defined("PSF_ENTRY_POINT"))
18  die("Not a valid psf entry point");
19 
20 require_once (dirname(__FILE__) . "/../object.php");
21 
22 class CSS extends PsfObject
23 {
24  public $items = array();
25  public $BackgroundColor = NULL;
26 
27  /*function __construct()
28  {
29  $this->items['*']['font-family'] = 'Helvetica, Arial';
30  }*/
31 
32  protected function Load()
33  {
34  if ($this->BackgroundColor !== NULL)
35  $this->items['body']['background-color'] = $this->BackgroundColor;
36  }
37 
41  public function AutoInit($element)
42  {
43 
44  }
45 
46  public function FetchCss($n)
47  {
48  return $this->ToCss($n);
49  }
50 
51  public function ToCss($n = 0)
52  {
53  $buff = '';
54  $indentation = '';
55  $this->Load();
56  while ($n-- > 0)
57  $indentation .= ' ';
58  foreach ($this->items as $name => $values)
59  {
60  $buff .= $indentation . $name . " {\n";
61  foreach ($values as $vn => $xx)
62  {
63  $buff .= $indentation . ' ' . $vn . ': ' . $xx . ";\n";
64  }
65  $buff .= $indentation . "}\n";
66  }
67  return $buff;
68  }
69 }
Base class used for every single PSF object.
Definition: object.php:21
Definition: css.php:22
AutoInit($element)
This is just a skeleton function that can be overriden in order to auto-initialize style for certain ...
Definition: css.php:41