Package base :: Package themes :: Package garland :: Module template
[hide private]

Source Code for Module base.themes.garland.template

  1  #!/usr/bin/env python 
  2  # Id: template.php,v 1.19 2008/06/25 09:12:25 dries Exp $ 
  3   
  4  """ 
  5    Garland theme template override file 
  6   
  7    @package includes 
  8    @see <a href='http://drupy.net'>Drupy Homepage</a> 
  9    @see <a href='http://drupal.org'>Drupal Homepage</a> 
 10    @note Drupy is a port of the Drupal project. 
 11    @note This file was ported from Drupal's themes/garland/template.php 
 12    @author Brendon Crawford 
 13    @copyright 2008 Brendon Crawford 
 14    @contact message144 at users dot sourceforge dot net 
 15    @created 2008-01-10 
 16    @version 0.1 
 17    @note License: 
 18   
 19      This program is free software; you can redistribute it and/or 
 20      modify it under the terms of the GNU General Public License 
 21      as published by the Free Software Foundation; either version 2 
 22      of the License, or (at your option) any later version. 
 23   
 24      This program is distributed in the hope that it will be useful, 
 25      but WITHOUT ANY WARRANTY; without even the implied warranty of 
 26      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 27      GNU General Public License for more details. 
 28   
 29      You should have received a copy of the GNU General Public License 
 30      along with this program; if not, write to: 
 31       
 32      The Free Software Foundation, Inc., 
 33      51 Franklin Street, Fifth Floor, 
 34      Boston, MA  02110-1301, 
 35      USA 
 36  """ 
 37   
 38  __version__ = "$Revision: 1 $" 
 39   
 40  from lib.drupy import DrupyPHP as php 
 41  from includes import bootstrap as lib_bootstrap 
 42  from includes import common as lib_common 
 43  from includes import plugin as lib_plugin 
 44   
45 -def theme_breadcrumb(breadcrumb):
46 """ 47 Return a themed breadcrumb trail. 48 49 @param breadcrumb 50 An array containing the breadcrumb links. 51 @return a string containing the breadcrumb output. 52 """ 53 if (not php.empty(breadcrumb)): 54 return '<div class="breadcrumb">' + \ 55 php.implode(' &#8250; ', breadcrumb) + '</div>'
56 57
58 -def theme_comment_wrapper(content, node):
59 """ 60 Allow themable wrapping of all comments. 61 """ 62 if (not content or node.type_ == 'forum'): 63 return '<div id="comments">' + content + '</div>' 64 else: 65 return '<div id="comments"><h2 class="comments">' + \ 66 lib_common.t('Comments') + '</h2>' + content + '</div>'
67 68 69
70 -def theme_preprocess_page(vars_):
71 """ 72 Override or insert variables into the page template. 73 """ 74 php.Reference.check(vars_) 75 vars_['tabs2'] = menu_secondary_local_tasks() 76 vars_['primary_nav'] = (lib_theme.theme('links', \ 77 vars_['main_menu'], {'class' : 'links main-menu'}) if \ 78 php.isset(vars_, 'main_menu') else False) 79 vars_['secondary_nav'] = (lib_theme.theme('links', \ 80 vars_['secondary_menu'], \ 81 {'class' : 'links secondary-menu'}) if \ 82 php.isset(vars_, 'secondary_menu') else False) 83 vars_['ie_styles'] = get_ie_styles() 84 # Prepare header 85 site_fields = [] 86 if (not php.empty(vars_['site_name'])): 87 site_fields.append( check_plain(vars_['site_name']) ) 88 if (not php.empty(vars_['site_slogan'])): 89 site_fields.append( check_plain(vars_['site_slogan']) ) 90 vars_['site_title'] = php.implode(' ', site_fields) 91 if (not php.empty(site_fields)): 92 site_fields[0] = '<span>' + site_fields[0] + '</span>' 93 vars_['site_html'] = php.implode(' ', site_fields) 94 # Hook into color.module 95 if (lib_plugin.exists('color')): 96 lib_plugin.plugins['color']._page_alter(vars_)
97 98 99
100 -def theme_menu_local_tasks():
101 """ 102 Returns the rendered local tasks. The default implementation renders 103 them as tabs. Overridden to split the secondary tasks. 104 """ 105 return menu_primary_local_tasks()
106 107
108 -def drupytemplate_comment_submitted(comment):
109 """ 110 Format the Submitted by username on date/time' for each comment. 111 """ 112 return lib_common.t('not datetime &#8212; not username', 113 { 114 'not username' : lib_theme.theme('username', comment), 115 'not datetime' : php.format_date(comment.timestamp) 116 })
117 118 119
120 -def theme_node_submitted(node):
121 """ 122 Format the 'Submitted by username on date/time' for each node. 123 """ 124 return lib_common.t('not datetime &#8212; not username', 125 { 126 'not username' : lib_theme.theme('username', node), 127 'not datetime' : php.format_date(node.created), 128 })
129 130 131
132 -def theme_get_ie_styles():
133 """ 134 Generates IE CSS links for LTR and RTL languages. 135 """ 136 ie_styles = '<link type="text/css" rel="stylesheet" media="all" href="' + \ 137 lib_bootstrap.base_path() + lib_theme.path_to_theme() + \ 138 '/fix-ie.css" />' + "\n" 139 if (lib_plugin.exists('locale') and \ 140 lib_bootstrap.language.direction == \ 141 lib_plugin.plugins['locale'].LANGUAGE_RTL): 142 ie_styles += \ 143 ' <style type="text/css" media="all">@import "' + \ 144 lib_bootstrap.base_path() + lib_theme.path_to_theme() + \ 145 '/fix-ie-rtl.css";</style>' + "\n" 146 return ie_styles
147