YaWK  24.1
Yet another WebKit
template-theme.php
Go to the documentation of this file.
1 <?php
2 
3 use YAWK\db;
4 use YAWK\language;
5 use YAWK\template;
6 use YAWK\user;
7 
8 /** @var $db db */
9 /** @var $lang language */
10 
11 // new template object if not exists
12 if (!isset($template)) { $template = new template(); }
13 // new user object if not exists
14 if (!isset($user)) { $user = new user($db); }
15 // $_GET['id'] or $_POST['id'] holds the template ID to edit.
16 // If any one of these two is set, we're in "preview mode" - this means:
17 // The user database holds two extra cols: overrideTemplate(int|0,1) and templateID
18 // Any user who is allowed to override the Template, can edit a template and view it
19 // in the frontend. -Without affecting the current active theme for any other user.
20 // This is pretty cool when working on a new design: because you see changes, while others wont.
21 // In theory, thereby every user can have a different frontend template activated.
22 ?>
23 
24 <!-- SETTINGS -->
25 <script>
26  /* increase brightness of given hex color code
27  hex str the hex color code
28  percent int 50 would make it 50% brighter
29  */
30  function getContrast50(hexcolor){
31  // strip the leading # if it's there
32  hexcolor = hexcolor.replace(/^\s*#|\s*$/g, '');
33  return (parseInt(hexcolor, 16) > 0xffffff/2) ? '#000000':'#ffffff';
34  }
35 
36  function increase_brightness(hex, percent)
37  {
38  // strip the leading # if it's there
39  hex = hex.replace(/^\s*#|\s*$/g, '');
40 
41  // convert 3 char codes --> 6, e.g. `E0F` --> `EE00FF`
42  if(hex.length === 3){
43  hex = hex.replace(/(.)/g, '$1$1');
44  }
45  // set rgb values
46  var r = parseInt(hex.substr(0, 2), 16),
47  g = parseInt(hex.substr(2, 2), 16),
48  b = parseInt(hex.substr(4, 2), 16);
49 
50  return '#' +
51  ((0|(1<<8) + r + (256 - r) * percent / 100).toString(16)).substr(1) +
52  ((0|(1<<8) + g + (256 - g) * percent / 100).toString(16)).substr(1) +
53  ((0|(1<<8) + b + (256 - b) * percent / 100).toString(16)).substr(1);
54  }
55 
56  function get_middle(hex1, hex2)
57  {
58  // prepare vars
59  var color1 = hex1;
60  var color2 = hex2;
61  // set ratio
62  var ratio = 0.5;
63  var hex = function(x) {
64  x = x.toString(16);
65  return (x.length === 1) ? '0' + x : x;
66  };
67 
68  var r = Math.ceil(parseInt(color1.substring(0,2), 16) * ratio + parseInt(color2.substring(0,2), 16) * (1-ratio));
69  var g = Math.ceil(parseInt(color1.substring(2,4), 16) * ratio + parseInt(color2.substring(2,4), 16) * (1-ratio));
70  var b = Math.ceil(parseInt(color1.substring(4,6), 16) * ratio + parseInt(color2.substring(4,6), 16) * (1-ratio));
71  var middle = hex(r) + hex(g) + hex(b);
72 
73  c1 = '#'+color1;
74  c2 = '#'+color2;
75  c3 = '#'+middle;
76 
77  return c3;
78 
79  /*
80  $("#color1").css('background-color', c1);
81  $("#color2").css('background-color', c2);
82  $("#color3").css('background-color', c3);
83  */
84  }
85 
86 </script>
87 <script>
88  baseColor1 = '#C02B52';
89  var _1bright1 = increase_brightness(baseColor1, 25); // would make it 50% brighter
90  var _1bright2 = increase_brightness(_1bright1, 50); // would make it 50% brighter
91  var _1bright3 = increase_brightness(_1bright2, 75); // would make it 50% brighter
92  var _1bright4 = increase_brightness(_1bright3, 75); // would make it 50% brighter
93  var contrast = getContrast50(baseColor1);
94  var text = getContrast50(contrast);
95  $("#1-baseColor").css('background-color', baseColor1).append(baseColor1);
96  $("#1-color1").css('background-color', _1bright1).append(_1bright1);
97  $("#1-color2").css('background-color', _1bright2).append(_1bright2);
98  $("#1-color3").css('background-color', _1bright3).append(_1bright3);
99  $("#1-color4").css('background-color', _1bright4).append(_1bright4);
100  $("#1-contrast").css('background-color', contrast).append(contrast).css('text-color', text);
101 
102  baseColor2 = '#3BC068';
103  var _2bright1 = increase_brightness(baseColor2, 25); // would make it 50% brighter
104  var _2bright2 = increase_brightness(_2bright1, 50); // would make it 50% brighter
105  var _2bright3 = increase_brightness(_2bright2, 75); // would make it 50% brighter
106  var _2bright4 = increase_brightness(_2bright3, 75); // would make it 50% brighter
107  var contrast2 = getContrast50(baseColor2);
108  var text2 = getContrast50(contrast2);
109  $("#2-baseColor").css('background-color', baseColor2).append(baseColor2);
110  $("#2-color1").css('background-color', _2bright1).append(_2bright1);
111  $("#2-color2").css('background-color', _2bright2).append(_2bright2);
112  $("#2-color3").css('background-color', _2bright3).append(_2bright3);
113  $("#2-color4").css('background-color', _2bright4).append(_2bright4);
114  $("#2-contrast").css('background-color', contrast2).append(contrast2).css('text-color', text2);
115 
116  // baseColor3 = '#FF8300';
117  baseColor3 = '#9BC060';
118  var _3bright1 = increase_brightness(baseColor3, 25); // would make it 50% brighter
119  var _3bright2 = increase_brightness(_3bright1, 50); // would make it 50% brighter
120  var _3bright3 = increase_brightness(_3bright2, 75); // would make it 50% brighter
121  var _3bright4 = increase_brightness(_3bright3, 75); // would make it 50% brighter
122  var contrast3 = getContrast50(baseColor3);
123  var text3 = getContrast50(contrast3);
124  $("#3-baseColor").css('background-color', baseColor3).append(baseColor3);
125  $("#3-color1").css('background-color', _3bright1).append(_3bright1);
126  $("#3-color2").css('background-color', _3bright2).append(_3bright2);
127  $("#3-color3").css('background-color', _3bright3).append(_3bright3);
128  $("#3-color4").css('background-color', _3bright4).append(_3bright4);
129  $("#3-contrast").css('background-color', contrast3).append(contrast3).css('text-color', text3);
130 </script>
131 
132 <script type="text/css">
133 
134 </script>
135 
136 <?php
137 // TEMPLATE WRAPPER - HEADER & breadcrumbs
138 echo "
139  <!-- Content Wrapper. Contains page content -->
140  <div class=\"content-wrapper\" id=\"content-FX\">
141  <!-- Content Header (Page header) -->
142  <section class=\"content-header\">";
143 // draw Title on top
144 echo \YAWK\backend::getTitle($lang['TPL'], $lang['SET_COLORS']);
145 echo \YAWK\backend::getTemplateBreadcrumbs($lang);
146 echo"</section><!-- Main content -->
147  <section class=\"content\">";
148 /* page content start here */
149 ?>
150 <!-- title header -->
151 <div class="box">
152  <div class="box-body">
153  <div class="col-md-10">
154  <?php echo "<h4><i class=\"fa fa-tint\"></i> &nbsp;$lang[THEME] <small>$lang[SET_COLORS]</small></h4>"; ?>
155  </div>
156  <div class="col-md-2">
157  <button class="btn btn-success pull-right" id="savebutton" name="save" style="margin-top:2px;"><i class="fa fa-check"></i>&nbsp;&nbsp;<?php echo $lang['DESIGN_SAVE']; ?></button>
158  </div>
159  </div>
160 </div>
161 
162 <div class="row animated fadeIn">
163  <!-- col 1 -->
164  <div class="col-md-6">
165  <div class="box box-default">
166  <div class="box-header with-border">
167  <h3 class="box-title"><?php echo "$lang[COLOR] <small>$lang[COLOR]</small>"; ?></h3>
168  </div>
169  <div class="box-body">
170  ...
171  </div>
172  </div>
173  </div>
174  <!-- col 2 -->
175  <div class="col-md-6">
176  <div class="box box-default">
177  <div class="box-header with-border">
178  <h3 class="box-title"><?php echo "$lang[COLOR] <small>$lang[COLOR]</small>"; ?></h3>
179  </div>
180  <div class="box-body">
181  ...
182  </div>
183  </div>
184  </div>
185 </div>
print $lang['FILEMAN_UPLOAD']
Mysqli database class; returns db connection object.
Definition: db.php:16
The language class - support multilingual backend.
Definition: language.php:17
The template controller - get and set template settings.
Definition: template.php:16
The default user class. Provide all functions to handle the user object.
Definition: user.php:17
function b(a)
Definition: browser.js:14
type
Definition: menu-new.php:35
print $page title
Definition: page-edit.php:377
function i(e, t)
Definition: plyr.js:1
function x()
Definition: plyr.js:1
function r(e, t)
Definition: plyr.js:1
function g(e, t, n, r)
Definition: plyr.js:1
function s(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
$template name