| 1 |
<?php
|
| 2 |
// Adds active/inactive to primary tabs
|
| 3 |
function phptemplate_menu_local_task($link, $active = FALSE) {
|
| 4 |
return '<li '. ($active ? 'class="active" ' : 'class="inactive"') .'>'. $link ."</li>\n";
|
| 5 |
}
|
| 6 |
|
| 7 |
// Add span to tabs menu
|
| 8 |
function phptemplate_menu_item_link($link) {
|
| 9 |
if (empty($link['localized_options'])) {
|
| 10 |
$link['localized_options'] = array();
|
| 11 |
}
|
| 12 |
|
| 13 |
if ($link['tab_root']) {
|
| 14 |
$options = array(
|
| 15 |
$link['localized_options'],
|
| 16 |
'HTML' => TRUE,
|
| 17 |
);
|
| 18 |
return l('<span class="tab">'.$link['title'].'</span>', $link['href'], array('html' => TRUE));
|
| 19 |
} else {
|
| 20 |
return l($link['title'], $link['href'], $link['localized_options']);
|
| 21 |
}
|
| 22 |
}
|
| 23 |
|
| 24 |
// Add first/last/active classes to links
|
| 25 |
function phptemplate_links($links, $attributes = array('class' => 'links')) {
|
| 26 |
$output = '';
|
| 27 |
|
| 28 |
if (count($links) > 0) {
|
| 29 |
$output = '<ul'. drupal_attributes($attributes) .'>';
|
| 30 |
|
| 31 |
$num_links = count($links);
|
| 32 |
$i = 1;
|
| 33 |
|
| 34 |
foreach ($links as $key => $link) {
|
| 35 |
$class = $key;
|
| 36 |
|
| 37 |
// Add first, last and active classes to the list of links to help out themers.
|
| 38 |
if ($i == 1) {
|
| 39 |
$class .= ' first';
|
| 40 |
}
|
| 41 |
if ($i == $num_links) {
|
| 42 |
$class .= ' last';
|
| 43 |
}
|
| 44 |
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
|
| 45 |
$class .= ' active';
|
| 46 |
} else {
|
| 47 |
$class .= ' inactive';
|
| 48 |
}
|
| 49 |
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
|
| 50 |
|
| 51 |
if (isset($link['href'])) {
|
| 52 |
// Pass in $link as $options, they share the same keys.
|
| 53 |
$output .= l($link['title'], $link['href'], $link);
|
| 54 |
}
|
| 55 |
else if (!empty($link['title'])) {
|
| 56 |
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
|
| 57 |
if (empty($link['html'])) {
|
| 58 |
$link['title'] = check_plain($link['title']);
|
| 59 |
}
|
| 60 |
$span_attributes = '';
|
| 61 |
if (isset($link['attributes'])) {
|
| 62 |
$span_attributes = drupal_attributes($link['attributes']);
|
| 63 |
}
|
| 64 |
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
|
| 65 |
}
|
| 66 |
$i++;
|
| 67 |
$output .= "</li>\n";
|
| 68 |
}
|
| 69 |
|
| 70 |
$output .= '</ul>';
|
| 71 |
}
|
| 72 |
|
| 73 |
return $output;
|
| 74 |
}
|
| 75 |
|
| 76 |
/**
|
| 77 |
* Split out taxonomy terms by vocabulary
|
| 78 |
*/
|
| 79 |
function phptemplate_print_terms($nid) {
|
| 80 |
$vocabularies = taxonomy_get_vocabularies();
|
| 81 |
$output = '<ul class="taxonomy">';
|
| 82 |
foreach($vocabularies as $vocabulary) {
|
| 83 |
if ($vocabularies) {
|
| 84 |
$terms = taxonomy_node_get_terms_by_vocabulary($nid, $vocabulary->vid);
|
| 85 |
if ($terms) {
|
| 86 |
$links = array();
|
| 87 |
$output .= '<li class="vocab ' . $vocabulary->name . '"><span class="vocab-name">' . $vocabulary->name . ': </span>';
|
| 88 |
foreach ($terms as $term) {
|
| 89 |
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
|
| 90 |
}
|
| 91 |
$output .= implode(', ', $links);
|
| 92 |
$output .= '</li>';
|
| 93 |
}
|
| 94 |
}
|
| 95 |
}
|
| 96 |
$output .= '</ul>';
|
| 97 |
return $output;
|
| 98 |
}
|
| 99 |
|
| 100 |
// Add first/last classes to blocks
|
| 101 |
function phptemplate_blocks($region) {
|
| 102 |
$output = '';
|
| 103 |
|
| 104 |
if ($list = block_list($region)) {
|
| 105 |
$i = 1;
|
| 106 |
$count = count($list);
|
| 107 |
foreach ($list as $key => $block) {
|
| 108 |
// $key == <i>module</i>_<i>delta</i>
|
| 109 |
if ($i == 1){ // is this the first block in this region?
|
| 110 |
$block->first_last = 'first';
|
| 111 |
}
|
| 112 |
if ($i == $count){ // is this the last block in this region?
|
| 113 |
$block->first_last = 'last';
|
| 114 |
}
|
| 115 |
$output .= theme('block', $block);
|
| 116 |
$i++;
|
| 117 |
}
|
| 118 |
}
|
| 119 |
|
| 120 |
// Add any content assigned to this region through drupal_set_content() calls.
|
| 121 |
$output .= drupal_get_content($region);
|
| 122 |
|
| 123 |
return $output;
|
| 124 |
}
|
| 125 |
|
| 126 |
// Override color module form to change color semantics and if necessary remove the preview
|
| 127 |
function phptemplate_color_scheme_form($form) {
|
| 128 |
|
| 129 |
$form['palette']['base']['#title'] = 'Primary Color';
|
| 130 |
$form['palette']['link']['#title'] = 'Secondary Color';
|
| 131 |
$form['palette']['top']['#title'] = 'Tertiary Color';
|
| 132 |
$form['palette']['bottom']['#title'] = 'Headings Color';
|
| 133 |
|
| 134 |
// Include stylesheet
|
| 135 |
$theme = $form['theme']['#value'];
|
| 136 |
$info = $form['info']['#value'];
|
| 137 |
drupal_add_css($theme_path . $info['preview_css']);
|
| 138 |
|
| 139 |
// Wrapper
|
| 140 |
$output .= '<div class="color-form clear-block">';
|
| 141 |
|
| 142 |
// Color schemes
|
| 143 |
$output .= drupal_render($form['scheme']);
|
| 144 |
|
| 145 |
// Palette
|
| 146 |
$output .= '<div id="palette" class="clear-block">';
|
| 147 |
foreach (element_children($form['palette']) as $name) {
|
| 148 |
$output .= drupal_render($form['palette'][$name]);
|
| 149 |
}
|
| 150 |
$output .= '</div>';
|
| 151 |
|
| 152 |
// Preview
|
| 153 |
$output .= drupal_render($form);
|
| 154 |
$output .= '<div class="hide">'; // It's not possible to just remove the preview output, will cause javascript errors and will break form completely in ie
|
| 155 |
$output .= '<h2>'. t('Preview') .'</h2>';
|
| 156 |
$output .= '<div id="preview"><div id="text"><h2>Lorem ipsum dolor</h2><p>Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud <a href="#">exercitation ullamco</a> laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div><div id="img" style="background-image: url('. base_path() . $path . $info['preview_image'] .')" alt=""></div></div>';
|
| 157 |
$output .= '</div>';
|
| 158 |
|
| 159 |
// Close wrapper
|
| 160 |
$output .= '</div>';
|
| 161 |
|
| 162 |
return $output;
|
| 163 |
}
|