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)
44 public $tile; // tinyint(1)
47 function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
49 /* the code above is auto generated do not remove the tag below */
52 function showCSS($out)
56 $bgcolor = new WebColor($this->backgroundcolor);
57 $ccolor = new WebColor($this->contentcolor);
58 $sbcolor = new WebColor($this->sidebarcolor);
59 $tcolor = new WebColor($this->textcolor);
60 $lcolor = new WebColor($this->linkcolor);
62 } catch (WebColorException $e) {
63 // This shouldn't happen
64 common_log(LOG_ERR, "Unable to create color for design $id.",
68 $css = 'html, body { background-color: #' . $bgcolor->hexValue() . '} ' . "\n";
69 $css .= '#content, #site_nav_local_views .current a { background-color: #';
70 $css .= $ccolor->hexValue() . '} '."\n";
71 $css .= '#aside_primary { background-color: #'. $sbcolor->hexValue() . '} ' . "\n";
72 $css .= 'html body { color: #'. $tcolor->hexValue() . '} '. "\n";
73 $css .= 'a { color: #' . $lcolor->hexValue() . '} ' . "\n";
75 if (!empty($this->backgroundimage)) {
77 $repeat = ($this->tile) ? 'background-repeat:repeat;' :
78 'background-repeat:no-repeat;';
80 $css .= 'body { background-image:url(' .
81 Design::url($this->backgroundimage) .
82 '); ' . $repeat . ' }' . "\n";
85 $out->element('style', array('type' => 'text/css'), $css);
89 static function filename($id, $extension, $extra=null)
91 return $id . (($extra) ? ('-' . $extra) : '') . $extension;
94 static function path($filename)
96 $dir = common_config('background', 'dir');
98 if ($dir[strlen($dir)-1] != '/') {
102 return $dir . $filename;
105 static function url($filename)
107 $path = common_config('background', 'path');
109 if ($path[strlen($path)-1] != '/') {
113 if ($path[0] != '/') {
117 $server = common_config('background', 'server');
119 if (empty($server)) {
120 $server = common_config('site', 'server');
125 return 'http://'.$server.$path.$filename;