]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Design.php
Some fixups to the CSS output of showCSS()
[quix0rs-gnu-social.git] / classes / Design.php
1 <?php
2 /*
3  * Laconica - the distributed open-source microblogging tool
4  * Copyright (C) 2009, Control Yourself, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('LACONICA')) {
21     exit(1);
22 }
23
24 /**
25  * Table Definition for design
26  */
27
28 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
29 require_once INSTALLDIR . '/lib/webcolor.php';
30
31 class Design extends Memcached_DataObject
32 {
33     ###START_AUTOCODE
34     /* the code below is auto generated do not remove the above tag */
35
36     public $__table = 'design';                          // table name
37     public $id;                              // int(4)  primary_key not_null
38     public $backgroundcolor;                 // int(4)
39     public $contentcolor;                    // int(4)
40     public $sidebarcolor;                    // int(4)
41     public $textcolor;                       // int(4)
42     public $linkcolor;                       // int(4)
43     public $backgroundimage;                 // varchar(255)
44
45     /* Static get */
46     function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
47
48     /* the code above is auto generated do not remove the tag below */
49     ###END_AUTOCODE
50
51     function showCSS($out)
52     {
53         try {
54
55             $bgcolor = new WebColor($this->backgroundcolor);
56             $ccolor  = new WebColor($this->contentcolor);
57             $sbcolor = new WebColor($this->sidebarcolor);
58             $tcolor  = new WebColor($this->textcolor);
59             $lcolor  = new WebColor($this->linkcolor);
60
61         } catch (WebColorException $e) {
62             // This shouldn't happen
63             common_log(LOG_ERR, "Unable to create color for design $id.",
64                 __FILE__);
65         }
66
67         $out->element('style', array('type' => 'text/css'),
68                       'html, body { background-color: #' . $bgcolor->hexValue() . '} '."\n".
69                       '#content { background-color: #' . $ccolor->hexValue() . '} '."\n".
70                       '#aside_primary { background-color: #'. $sbcolor->hexValue() .'} '."\n".
71                       'html body { color: #'. $tcolor->hexValue() .'} '."\n".
72                       'a { color: #' . $lcolor->hexValue() . '} '."\n");
73     }
74 }