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')) {
24 define('BACKGROUND_ON', 1);
25 define('BACKGROUND_OFF', 2);
26 define('BACKGROUND_TILE', 4);
29 * Table Definition for design
32 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
33 require_once INSTALLDIR . '/lib/webcolor.php';
35 class Design extends Memcached_DataObject
38 /* the code below is auto generated do not remove the above tag */
40 public $__table = 'design'; // table name
41 public $id; // int(4) primary_key not_null
42 public $backgroundcolor; // int(4)
43 public $contentcolor; // int(4)
44 public $sidebarcolor; // int(4)
45 public $textcolor; // int(4)
46 public $linkcolor; // int(4)
47 public $backgroundimage; // varchar(255)
48 public $disposition; // tinyint(1) default_1
51 function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
53 /* the code above is auto generated do not remove the tag below */
56 function showCSS($out)
60 $bgcolor = new WebColor($this->backgroundcolor);
61 $ccolor = new WebColor($this->contentcolor);
62 $sbcolor = new WebColor($this->sidebarcolor);
63 $tcolor = new WebColor($this->textcolor);
64 $lcolor = new WebColor($this->linkcolor);
66 } catch (WebColorException $e) {
67 // This shouldn't happen
68 common_log(LOG_ERR, "Unable to create color for design $id.",
72 $css = 'body { background-color: #' . $bgcolor->hexValue() . ' }' . "\n";
73 $css .= '#content, #site_nav_local_views .current a { background-color: #';
74 $css .= $ccolor->hexValue() . '} '."\n";
75 $css .= '#aside_primary { background-color: #'. $sbcolor->hexValue() . ' }' . "\n";
76 $css .= 'html body { color: #'. $tcolor->hexValue() . ' }'. "\n";
77 $css .= 'a { color: #' . $lcolor->hexValue() . ' }' . "\n";
79 if (!empty($this->backgroundimage) &&
80 $this->disposition & BACKGROUND_ON) {
82 $repeat = ($this->disposition & BACKGROUND_TILE) ?
83 'background-repeat:repeat;' :
84 'background-repeat:no-repeat;';
86 $css .= 'body { background-image:url(' .
87 Design::url($this->backgroundimage) .
88 '); ' . $repeat . ' background-attachment:fixed; }' . "\n";
91 $out->element('style', array('type' => 'text/css'), $css);
95 static function filename($id, $extension, $extra=null)
97 return $id . (($extra) ? ('-' . $extra) : '') . $extension;
100 static function path($filename)
102 $dir = common_config('background', 'dir');
104 if ($dir[strlen($dir)-1] != '/') {
108 return $dir . $filename;
111 static function url($filename)
113 $path = common_config('background', 'path');
115 if ($path[strlen($path)-1] != '/') {
119 if ($path[0] != '/') {
123 $server = common_config('background', 'server');
125 if (empty($server)) {
126 $server = common_config('site', 'server');
131 return 'http://'.$server.$path.$filename;
134 function setDisposition($on, $off, $tile)
137 $this->disposition |= BACKGROUND_ON;
139 $this->disposition &= ~BACKGROUND_ON;
143 $this->disposition |= BACKGROUND_OFF;
145 $this->disposition &= ~BACKGROUND_OFF;
149 $this->disposition |= BACKGROUND_TILE;
151 $this->disposition &= ~BACKGROUND_TILE;