/[drupal]/contributions/themes/Amor_Azul/template.php
ViewVC logotype

Contents of /contributions/themes/Amor_Azul/template.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Fri Aug 29 06:59:44 2008 UTC (15 months ago) by evakoss
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +131 -84 lines
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 // Amor_Azul
3
4 /**
5 * Declare the available regions implemented by this engine.
6 *
7 * @return
8 * An array of regions. The first array element will be used as the default region for themes.
9 * Each array element takes the format: variable_name => t('human readable name')
10 */
11 function Amor_Azul_regions() {
12 return array(
13 'top_menu' => t('top menu'),
14 'header_image' => t('header image'),
15 'header_text' => t('header text'),
16 'content_top' => t('content top'),
17 'sidebar_left' => t('sidebar left'),
18 'sidebar_right' => t('sidebar right'),
19 'content_bottom' => t('content bottom'),
20 'footer_links' => t('footer_links')
21 );
22 }
23
24 /**
25 * Adjust content width according to the absence or presence of sidebars.
26 *
27 * If only one sidebar is active, the mainContent width will expand to fill
28 * the space of the missing sidebar.
29 */
30 function Amor_Azul_get_mainContent_width($sidebar_left, $sidebar_right) {
31 $width = 430;
32 if (!$sidebar_left || arg(0)=='admin') {
33 $width = $width + 180;
34 }
35 if (!$sidebar_right) {
36 $width = $width + 180;
37 }
38 return $width;
39 }
40 function Amor_Azul_get_sideBars_width($sidebar_left, $sidebar_right) {
41 $width = 415;
42 if (!$sidebar_left || arg(0)=='admin') {
43 $width = $width - 205;
44 }
45 if (!$sidebar_right) {
46 $width = $width - 205;
47 }
48 return $width;
49 }
50
51 /**
52 * Return a themed breadcrumb trail.
53 *
54 * @param $breadcrumb
55 * An array containing the breadcrumb links.
56 * @return a string containing the breadcrumb output.
57 */
58 function phptemplate_breadcrumb($breadcrumb) {
59 if (!empty($breadcrumb)) {
60 return '<div class="breadcrumb">'. implode(' :: ', $breadcrumb) .'</div>';
61 }
62 }
63
64 /**
65 * Catch the theme_links function
66 */
67 function phptemplate_links($links, $attributes = array('class' => 'links')) {
68 $output = '';
69
70 if (count($links) > 0) {
71 $output = '<ul'. drupal_attributes($attributes) .'>';
72
73 $num_links = count($links);
74 $i = 1;
75
76 foreach ($links as $key => $link) {
77 $class = '';
78
79 // Automatically add a class to each link and also to each LI
80 if (isset($link['attributes']) && isset($link['attributes']['class'])) {
81 $link['attributes']['class'] .= ' ' . $key;
82 $class = $key;
83 }
84 else {
85 $link['attributes']['class'] = $key;
86 $class = $key;
87 }
88
89 // Add first and last classes to the list of links to help out themers.
90 $extra_class = '';
91 if ($i == 1) {
92 $extra_class .= 'first ';
93 }
94 if ($i == $num_links) {
95 $extra_class .= 'last ';
96 }
97 $output .= '<li class="'. $extra_class . $class .'">';
98
99 // Is the title HTML?
100 $html = isset($link['html']) && $link['html'];
101
102 // Initialize fragment and query variables.
103 $link['query'] = isset($link['query']) ? $link['query'] : NULL;
104 $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
105
106 if (isset($link['href'])) {
107 $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
108 }
109 else if ($link['title']) {
110 //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
111 if (!$html) {
112 $link['title'] = check_plain($link['title']);
113 }
114 $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
115 }
116
117 $i++;
118 $output .= "</li>\n";
119 }
120
121 $output .= '</ul>';
122 }
123
124 return $output;
125 }
126
127 /**
128 * Customize a TinyMCE theme.
129 *
130 * @param init
131 * An array of settings TinyMCE should invoke a theme. You may override any
132 * of the TinyMCE settings. Details here:
133 *
134 * http://tinymce.moxiecode.com/wrapper.php?url=tinymce/docs/using.htm
135 *
136 * @param textarea_name
137 * The name of the textarea TinyMCE wants to enable.
138 *
139 * @param theme_name
140 * The default tinymce theme name to be enabled for this textarea. The
141 * sitewide default is 'simple', but the user may also override this.
142 *
143 * @param is_running
144 * A boolean flag that identifies id TinyMCE is currently running for this
145 * request life cycle. It can be ignored.
146 */
147 function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
148
149 switch ($textarea_name) {
150 // Disable tinymce for these textareas
151 case 'log': // book and page log
152 case 'img_assist_pages':
153 case 'caption': // signature
154 case 'pages':
155 case 'access_pages': //TinyMCE profile settings.
156 case 'user_mail_welcome_body': // user config settings
157 case 'user_mail_approval_body': // user config settings
158 case 'user_mail_pass_body': // user config settings
159 case 'synonyms': // taxonomy terms
160 case 'description': // taxonomy terms
161 unset($init);
162 break;
163
164 // Force the 'simple' theme for some of the smaller textareas.
165 case 'signature':
166 case 'site_mission':
167 case 'site_footer':
168 case 'site_offline_message':
169 case 'page_help':
170 case 'user_registration_help':
171 case 'user_picture_guidelines':
172 $init['theme'] = 'simple';
173 foreach ($init as $k => $v) {
174 if (strstr($k, 'theme_advanced_')) unset($init[$k]);
175 }
176 break;
177 }
178
179 // Add some extra features when using the advanced theme.
180 // If $init is available, we can extend it
181 if (isset($init)) {
182 switch ($theme_name) {
183 case 'advanced':
184 $init['width'] = '100%';
185 break;
186
187 }
188 }
189
190 // Always return $init
191 return $init;
192 }
193
194
195 function Amor_Azul_search_theme_form($form) {
196
197 //$form['search_theme_form_keys']['#value'] =t('SEARCH');
198 //$form['search_theme_form_keys']['#attributes'] = array('onFocus'=>'this.value=""');
199 //$form['submit']['#value'] ='';
200
201 $form['submit']['#attributes'] =array('class'=>'SW');
202 $form['submit']['#value'] =t('Go');
203 //print_r($form);
204
205 //return $form;
206
207 return drupal_render($form);
208
209 }
210
211
212
213 function get_link($menu_path)
214 {
215 if($menu_path=='-')
216 {
217 $return = '#';
218 }
219 else
220 {
221 global $base_url;
222 $menu_path = trim($menu_path);
223 $db_links = "select * from url_alias where src='".$menu_path."'";
224 $rs_links = db_query($db_links);
225 if(db_num_rows($rs_links)>0)
226 {
227 $row_links = db_fetch_object($rs_links);
228 $return = $base_url.'/'.$row_links->dst;
229 }else
230 {
231 if($menu_path=='<front>')
232 {
233 $return = $base_url.'/';
234 }elseif(strstr($menu_path,'http://'))
235 {
236 $return = $menu_path;
237 }
238 else
239 {
240 $return = $base_url.'/'.$menu_path;
241 }
242 }
243 }
244 return $return;
245 }
246
247 function _get_class(&$node,$path)
248 {
249 $return = 'sub';
250 /* print 'Node: '.$node;
251 print '<br>';
252 print 'Node Path: '.$node->path;
253 print '<br>';
254 print 'Menu Path: '.$path.'<hr>';
255 */
256 if($node->path == trim($path) || (($path == '<front>' || $path == 'node/1') && !$node) && arg(0) != 'image')
257 {
258 $return = 'current';
259 }else if(trim('node/'.$node->nid) == trim($path))
260 {
261 $return = 'current';
262 }else if(trim($path) == 'image' && !$node && arg(0) == 'image')
263 {
264 $return = 'current';
265 }
266 return $return;
267 }
268
269 function _get_second_leval($parent_id,$menu_type)
270 {
271 $all_menu_1 = '';
272 $db_main_menu_1 = "select * from {menu} where pid=".$parent_id." and type IN (".$menu_type.") order by weight";
273 $rs_main_menu_1 = db_query($db_main_menu_1);
274 if(db_num_rows($rs_main_menu_1)>0)
275 {
276 $all_menu_1 .= '<ul>';
277 while($row_main_menu_1 = db_fetch_object($rs_main_menu_1))
278 {
279 $all_menu_1 .= '<li>';
280 if(strstr($row_main_menu_1->path,'http://'))
281 {
282 $all_menu_1 .= '<a href="'.get_link($row_main_menu_1->path).'" target="_blank" title="'.$row_main_menu_1->description.'">'.$row_main_menu_1->title.'</a>';
283 }
284 else
285 {
286 $all_menu_1 .= '<a href="'.get_link($row_main_menu_1->path).'" title="'.$row_main_menu_1->description.'">'.$row_main_menu_1->title.'</a>';
287 }
288 $all_menu_1 .= '</li>';
289 }
290 $all_menu_1 .= '</ul>';
291 }
292 return $all_menu_1;
293 }
294
295 function _get_menus($parent_id,$menu_type, $node = '<front>')
296 {
297 $menu_type = explode("|",$menu_type);
298 $menu_type = implode(",",$menu_type);
299 $all_menu = '';
300 $db_main_menu = "select * from {menu} where pid=".$parent_id." and type IN (".$menu_type.") order by weight";
301 $rs_main_menu = db_query($db_main_menu);
302 if(db_num_rows($rs_main_menu)>0)
303 {
304 while($row_main_menu = db_fetch_object($rs_main_menu))
305 {
306 $all_menu .= '<li class="top">';
307 $class = _get_class($node,$row_main_menu->path);
308 if(strstr($row_main_menu->path,'http://'))
309 {
310 $all_menu .= '<a href="'.get_link($row_main_menu->path).'" target="_blank" title="'.$row_main_menu->description.'" class="top_link"><span>'.$row_main_menu->title.'</span><!--[if IE 7]><!--></a><!--<![endif]-->';
311 }
312 else
313 {
314 $all_menu .= '<a href="'.get_link($row_main_menu->path).'" title="'.$row_main_menu->description.'" class="top_link"><span>'.$row_main_menu->title.'</span><!--[if IE 7]><!--></a><!--<![endif]-->';
315 }
316 $all_menu .= '<!--[if lte IE 6]><table><tr><td><![endif]-->';
317 $all_menu .= _get_second_leval($row_main_menu->mid,$menu_type);
318 $all_menu .= '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
319 $all_menu .= '</li>';
320 }
321 }
322 return $all_menu;
323 }
324 if(check_block(3,'Amor_Azul'))
325 {
326 db_query(
327 "INSERT INTO {blocks} (module,delta,theme,status,weight,region,custom,throttle,visibility,pages,title)
328 VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s')",
329 'block', '3', 'Amor_Azul', '1', '0', 'header_text', '0', '0', '0', '', ''
330 );
331 db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')",
332 '3',
333 '<h1 class="header-title">Leo eu adipiscing eleifend</h1>
334
335 Leo eu adipiscing eleifend, magna urna mattis nibh, sed consequat nisi nibh sit amet nunc. Nam neque. Nam a odio sed tellus mattis posuere. Cras mattis viverra metus. Fusce feugiat elementum metus. Maecenas euismod dignissim diam. Aliquam felis. Nulla augue turpis, euismod id, dictum sed, mollis et, quam. Pellentesque nisl. Cras faucibus ante in sem. Aenean porta diam molestie urna',
336 'header text',
337 '3'
338 );
339 }
340 if(check_block(4,'Amor_Azul'))
341 {
342
343 db_query(
344 "INSERT INTO {blocks} (module,delta,theme,status,weight,region,custom,throttle,visibility,pages,title)
345 VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s')",
346 'block', '4', 'Amor_Azul', '1', '0', 'header_image', '0', '0', '0', '', ''
347 );
348 db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')",
349 '4',
350 '<img src="'.base_path().path_to_theme().'/images/header-image.jpg" alt="Girl" />',
351 'header images',
352 '3'
353 );
354 }
355 if(check_block(1,'Amor_Azul'))
356 {
357
358 db_query(
359 "INSERT INTO {blocks} (module,delta,theme,status,weight,region,custom,throttle,visibility,pages,title)
360 VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s')",
361 'block', '1', 'Amor_Azul', '1', '0', 'footer_links', '0', '0', '0', '', ''
362 );
363 db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')",
364 '1',
365 '<a href="#">Home</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">About Us</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">Services</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">Contact Us</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
366 'Footer Links',
367 '3'
368 );
369 }
370 if(check_block(2,'Amor_Azul'))
371 {
372
373 db_query(
374 "INSERT INTO {blocks} (module,delta,theme,status,weight,region,custom,throttle,visibility,pages,title)
375 VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s')",
376 'block', '2', 'Amor_Azul', '1', '0', 'content_top', '0', '0', '1', '<front>', ''
377 );
378 db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')",
379 '2',
380 '<div class="cont-top1">
381
382 <h3>Cum sociis natoque penatibus</h3>
383
384 <img src="'.base_path().path_to_theme().'/images/home-top-img1.jpg" align="right" alt="image" />Nunc nisi elit, sollicitudin volutpat, adipiscing eu, rutrum sed, ligula.
385
386 </div>
387
388 <div class="cont-top2">
389
390 <h3>Cum sociis natoque penatibus</h3>
391
392 <img src="'.base_path().path_to_theme().'/images/home-top-img2.jpg" align="right" alt="image" />Nunc nisi elit, sollicitudin volutpat, adipiscing eu, rutrum sed, ligula.
393
394 </div>
395
396 <div class="cont-top2">
397
398 <h3>Cum sociis natoque penatibus</h3>
399
400 <img src="'.base_path().path_to_theme().'/images/home-top-img3.jpg" align="right" alt="image" />Nunc nisi elit, sollicitudin volutpat, adipiscing eu, rutrum sed, ligula.
401
402 </div>',
403 'content top',
404 '3'
405 );
406 }
407 function check_block($bid,$theme)
408 {
409 $result = db_query("SELECT * FROM {blocks} WHERE delta = %d and theme = '%s' and module = 'block'", $bid, $theme);
410 if(db_num_rows($result)>0)
411 {
412 return false;
413 }
414 else
415 {
416 return true;
417 }
418 }

  ViewVC Help
Powered by ViewVC 1.1.2