-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.php.old
253 lines (227 loc) · 9.24 KB
/
template.php.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?php
// permet template suggestions avec page-
function susy2_pf_cyrano_preprocess(&$vars, $hook)
{
switch($hook)
{
case 'page' :
if (arg(0) == 'node')
{
$vars['template_files'][] = 'page-' . $vars['node']->type;
$vars['template_files'][] = "page-" . $vars['node']->type . "-" . $vars['node']->nid;
//var_dump($vars);
}
break;
}
}
?>
<?php
/*Permet d'attribuer un template de node différent selon terme de taxo et type de contenu
* - NE PAS OUBLIER DE CHANGER LE NOM DU THEME !!!___
http://drupal.org/node/723544 ET http://drupalfr.org/forum/support/developpement/26735-theming-template-commun-95*/
//nettoyage du nom pour usage dans tpl
function valideChaine($term){
$term = preg_replace('<code>\s+</code>', '<em>', trim($term));
$term = str_replace("'", "</em>", $term);
$term = preg_replace('<code>_+</code>', '</em>', trim($term));
$NomTermeValide=strtr($term,"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
"aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
return ($NomTermeValide);
}
function susy2_pf_cyrano_preprocess_node(&$vars, $hook) {
//Pour avoir un template du type node-ID.tpl
$vars['template_files'][] = 'node-'. $vars['node']->nid;
//Partie regions dans node.tpl- ajoute les regions utiles au node.tpl
$vars['pole_bloc_G'] = theme('blocks', 'pole_bloc_G');
$vars['pole_bloc_C'] = theme('blocks', 'pole_bloc_C');
$vars['pole_bloc_D'] = theme('blocks', 'pole_bloc_D');
$vars['node_col_1'] = theme('blocks', 'node_col_1');
$vars['node_col_2'] = theme('blocks', 'node_col_2');
$vars['node_col_3'] = theme('blocks', 'node_col_3');
//Regions custom pour theme PF suite generalisation node.tpl
$vars['centralBloc'] = theme('blocks', 'centralBloc');
$vars['centre_partenaire'] = theme('blocks', 'centre_partenaire');
$vars['formulaire'] = theme('blocks', 'formulaire');
//
//Partie template node.tpl
$node = $vars['node'];
$lesTypes=array('page_fiche_formation', 'page_pole','contenu_actualites');
//ajouter les vids possibles pour chaque quelquesoit le type
$lesVid=array('1','5');// vid 1 pour pole formation, vid 5 pour type actualite
// on regarde si le type est dans le tableau
if ( in_array($node->type,$lesTypes) ) {
if ( ! empty($node->taxonomy) ) {
// Récupération du 1er element du tableau
$term = array_shift($node->taxonomy);
// verifie si l'un des termes appartiennent bien à l'un des vid définis dans le tableau
if ( in_array($term->vid,$lesVid) ) {
$tplfile = 'node-'.$node->type.'-'. $term->vid.'-'.$term->tid ;
$vars['template_files'][] = $tplfile ;
//drupal_set_message('Term name : '.$term->name,'status');
// drupal_set_message('Template file : '.$tplfile.'.tpl.php','status');
}
}
//drupal_set_message('Type du node hors : '.$node->type,'status');
// drupal_set_message('Term name hors : '.$term->name,'status');
}
}
?>
<?php
// fonction pour avoir la possibilité de faire un template pour page recherche
function phptemplate_preprocess_page(&$vars) {
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias != $_GET['q']) {
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$vars['template_files'][] = $template_filename;
}
}
}
}
?>
<?php
// permet le debugage de php avec drupal
function debug_print($var) {
drupal_set_message('<pre>'. print_r($var, TRUE) .'</pre>');
}
//Webform "You have already submitted this form." message off - http://drupal.org/node/1096226
function susy2_pf_cyrano_webform_view_messages($node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles, $closed, $cached) {
return theme_webform_view_messages($node, $teaser, $page, 0, $limit_exceeded, $allowed_roles, $closed, $cached);
}
?>
<?php
/*
// permet de trier la taxonomie - utilisé sur les fiches formations
//pour afficher corrrectement la taxonomie en bas de page via "print cyrano_pf_print_terms"
//http://drupalfr.org/node/23218#comment-35519
*/
function cyrano_pf_print_terms($node, $vid = NULL, $ordered_list = TRUE) {
$vocabularies = taxonomy_get_vocabularies();
if ($ordered_list) $output .= '<ul>'; //checks to see if you want an ordered list
if ($vid) { //checks to see if you've passed a number with vid, prints just that vid
$output = '<div class=tags-'. $vid . '>';
foreach($vocabularies as $vocabulary) {
if ($vocabulary->vid == $vid) {
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
if ($terms) {
$links = array();
$output .= '<span class=only-vocabulary-'. $vocabulary->vid . '>';
if ($ordered_list) $output .= '<li class=vocabulary-'. $vocabulary->vid . '>' . $vocabulary->name . ': ';
foreach ($terms as $term) {
$links[] = '<span class="term-' . $term->tid . '">' . l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description))) .'</span>';
}
$output .= implode(', ', $links);
if ($ordered_list) $output .= '</li>';
$output .= '</span>';
}
}
}
}
else {
$output = '<div class="tags">';
foreach($vocabularies as $vocabulary) {
if ($vocabularies) {
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
if ($terms) {
$links = array();
$output .= '<ul class=vocabulary-'. $vocabulary->vid . '>';
if ($ordered_list) $output .= '<li class=vocabulary-'. $vocabulary->vid . '>' . $vocabulary->name . ': ';
foreach ($terms as $term) {
$links[] = '<span class="term-' . $term->tid . '">' . l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description))) .'</span>';
}
$output .= implode(', ', $links);
if ($ordered_list) $output .= '</li>';
$output .= '</ul>';
}
}
}
}
if ($ordered_list) $output .= '</ul>';
$output .= '</div>';
return $output;
}
?>
<?php
// permet d'ouvrir en blank les fichiers uploadés via filefield
//NE PAS OUBLIER DE CHANGER NOM DU THEME !!!
function susy2_pf_cyrano_filefield_file($file) {
// Views may call this function with a NULL value, return an empty string.
if (empty($file['fid'])) {
return '';
}
$path = $file['filepath'];
$url = file_create_url($path);
$icon = theme('filefield_icon', $file);
// Set options as per anchor format described at
// http://microformats.org/wiki/file-format-examples
// TODO: Possibly move to until I move to the more complex format described
// at http://darrelopry.com/story/microformats-and-media-rfc-if-you-js-or-css
$options = array(
'attributes' => array(
'type' => $file['filemime'] . '; length=' . $file['filesize'],
),
);
// Use the description as the link text if available.
if (empty($file['data']['description'])) {
$link_text = $file['filename'];
}
else {
$link_text = $file['data']['description'];
$options['attributes']['title'] = $file['filename'];
}
//open allfiles in new window
$options['attributes']['target'] = '_blank';
return '<div class="filefield-file clear-block">'. $icon . l($link_text, $url, $options) .'</div>';
}
?>
<?php
/*_______________FONCTIONS POUR ACTION SUR AGGREGATOR____________*/
/* modify link items in the aggregator to open in a new window and
suppress the "blog it" icon & links should the module ever be enabled.
(Code removed--not commented out--from this copy of the original function.)
* drupal.org/node/573054 */
function phptemplate_aggregator_block_item($item, $feed = 0) {
global $user;
$output = '';
// Display the external link to the item.
$output .= '<a href="'. check_url($item->link) .'" target="_blank">'. check_plain($item->title) ."</a>\n";
return $output;
}
/**Enleve le lien en savoir plus - NE PAS OUBLIER DE CHANGER LE NOM DU THEME !!!___*/
function susy2_pf_cyrano_more_link ($url, $title) {
if (stristr( $url, 'aggregator')) {
return "";
}
}
?>
<?php
/* Fonction pour splitter le contenu de $body en plusieurs colonnes
* S'utilise en insérant dans le node.tpl
* $output = cyrano_pf_split_bodycontent ($content);
print $output;
* dans le node-custom.tpl et en ajoutant le tag <columns> dans le corps du node
*/
function susy2_pf_cyrano_split_bodycontent ($colcontent) {
$coloutput = "";
$string = "<columns>";
$columns = explode($string,$colcontent); // cut the text for splitting the body into columns
$i = 0;
foreach($columns as $cle=>$valeur) { //go through the array and add div to contents when necessary
if ($i == 0) {
$coloutput .= $valeur;
$i ++;
}
else if ($i == 1) {
$coloutput .= "<div class=\"column_".$i."\">".$valeur."</div>";
$i = 2;
}
else {
$coloutput .= "<div class=\"column_".$i."\">".$valeur."</div>";
$i = 1;
}
}
return $coloutput;
}
?>