3 * Laconica - the distributed open-source microblogging tool
4 * Copyright (C) 2009, Control Yourself, Inc.
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.
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.
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/>.
20 if (!defined('LACONICA')) {
25 * Table Definition for design
28 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
29 require_once INSTALLDIR . '/lib/webcolor.php';
31 class Design extends Memcached_DataObject
34 /* the code below is auto generated do not remove the above tag */
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)
46 function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
48 /* the code above is auto generated do not remove the tag below */
51 function showCSS($out)
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);
61 } catch (WebColorException $e) {
62 // This shouldn't happen
63 common_log(LOG_ERR, "Unable to create color for design $id.",
67 $css = 'html, body { background-color: #' . $bgcolor->hexValue() . '} ' . "\n";
68 $css .= '#content, #site_nav_local_views .current a { background-color: #';
69 $css .= $ccolor->hexValue() . '} '."\n";
70 $css .= '#aside_primary { background-color: #'. $sbcolor->hexValue() . '} ' . "\n";
71 $css .= 'html body { color: #'. $tcolor->hexValue() . '} '. "\n";
72 $css .= 'a { color: #' . $lcolor->hexValue() . '} ' . "\n";
74 if (!empty($this->backgroundimage)) {
76 $css .= 'body { background-image:url(' .
77 Design::url($this->backgroundimage) .
78 '); background-repeat:no-repeat; }' . "\n";
81 $out->element('style', array('type' => 'text/css'), $css);
85 static function filename($id, $extension, $extra=null)
87 return $id . (($extra) ? ('-' . $extra) : '') . $extension;
90 static function path($filename)
92 $dir = common_config('background', 'dir');
94 if ($dir[strlen($dir)-1] != '/') {
98 return $dir . $filename;
101 static function url($filename)
103 $path = common_config('background', 'path');
105 if ($path[strlen($path)-1] != '/') {
109 if ($path[0] != '/') {
113 $server = common_config('background', 'server');
115 if (empty($server)) {
116 $server = common_config('site', 'server');
121 return 'http://'.$server.$path.$filename;