| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_help().
|
| 6 |
*/
|
| 7 |
function taxonomy_vtn_help($path, $arg) {
|
| 8 |
$path_taxonomy_vtn = base_path() . drupal_get_path('module', 'taxonomy_vtn');
|
| 9 |
|
| 10 |
switch ($path) {
|
| 11 |
case 'admin/help#taxonomy_vtn':
|
| 12 |
$output = '<h3>1. '. t('Screenshots') .'</h3>'."\n";
|
| 13 |
|
| 14 |
$output .= '<p><hr /><br /></p>'."\n";
|
| 15 |
|
| 16 |
$output .= '<p><img src="'. $path_taxonomy_vtn .'/images/taxonomy_vtn_vocabulary.png" alt="'. t('Screenshot of vocabulary.') .'" style="float:right;"><strong>'. t('Sample vocabulary index') .'</strong></p>'."\n";
|
| 17 |
$output .= '<p style=" clear: both;"></p>'."\n";
|
| 18 |
|
| 19 |
$output .= '<p><hr /><br /></p>'."\n";
|
| 20 |
|
| 21 |
$output .= '<p><img src="'. $path_taxonomy_vtn .'/images/taxonomy_vtn_terms.png" alt="'. t('Screenshot of terms.') .'" style="float:right;"><strong>'. t('Sample terms index') .'</strong></p>'."\n";
|
| 22 |
$output .= '<p style=" clear: both;"></p>'."\n";
|
| 23 |
|
| 24 |
$output .= '<p><hr /><br /></p>'."\n";
|
| 25 |
|
| 26 |
$output .= '<p><img src="'. $path_taxonomy_vtn .'/images/taxonomy_vtn_nodes.png" alt="'. t('Screenshot of nodes.') .'" style="float:right;"><strong>'. t('Sample nodes index') .'</strong></p>'."\n";
|
| 27 |
$output .= '<p style=" clear: both;"></p>'."\n";
|
| 28 |
|
| 29 |
$output .= '<p><hr /><br /></p>'."\n";
|
| 30 |
|
| 31 |
$output .= '<h3> 2. '. t('Features') .'</h3>'."\n";
|
| 32 |
$output .= '<p class="warning">'. t('I\'m open for sugestions.') .'</p><br />'."\n";
|
| 33 |
break;
|
| 34 |
|
| 35 |
case 'admin/settings/taxonomy_vtn':
|
| 36 |
$output .= '<p>'. t("Define your prefered setting to use this module.") .'</p>';
|
| 37 |
}
|
| 38 |
return $output;
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Implementation of hook_init().
|
| 43 |
*/
|
| 44 |
function taxonomy_vtn_init() {
|
| 45 |
$path = drupal_get_path( 'module', 'taxonomy_vtn' );
|
| 46 |
drupal_add_css( $path .'/taxonomy_vtn.css', 'module', 'all', FALSE );
|
| 47 |
drupal_add_js( $path .'/taxonomy_vtn.js');
|
| 48 |
}
|
| 49 |
|
| 50 |
/**
|
| 51 |
* Implementation of hook_perm().
|
| 52 |
*/
|
| 53 |
function taxonomy_vtn_perm() {
|
| 54 |
return array('administer taxonomy_vtn', 'access taxonomy_vtn');
|
| 55 |
}
|
| 56 |
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Implementation of hook_menu().
|
| 60 |
*/
|
| 61 |
function taxonomy_vtn_menu() {
|
| 62 |
|
| 63 |
$items = array();
|
| 64 |
|
| 65 |
$items['admin/settings/taxonomy_vtn'] = array(
|
| 66 |
'title' => t('Taxonomy VTN settings'),
|
| 67 |
'description' => t('Customize Taxonomy VTN settings'),
|
| 68 |
'page callback' => 'drupal_get_form',
|
| 69 |
'page arguments' => array('taxonomy_vtn_settings'),
|
| 70 |
'access arguments' => array('administer taxonomy_vtn')
|
| 71 |
);
|
| 72 |
|
| 73 |
$items['taxonomy_vtn'] = array(
|
| 74 |
'title' => t('Vocabularies'),
|
| 75 |
'page callback' => 'taxonomy_vtn_show_vocabularies',
|
| 76 |
'access arguments' => array('access taxonomy_vtn'),
|
| 77 |
'file' => 'taxonomy_vtn.pages.inc'
|
| 78 |
);
|
| 79 |
|
| 80 |
$items['taxonomy_vtn/voc'] = array(
|
| 81 |
'title' => t('Terms'),
|
| 82 |
'page callback' => 'taxonomy_vtn_show_terms',
|
| 83 |
'access arguments' => array('access taxonomy_vtn'),
|
| 84 |
'type' => MENU_CALLBACK,
|
| 85 |
'file' => 'taxonomy_vtn.pages.inc'
|
| 86 |
);
|
| 87 |
|
| 88 |
$items['taxonomy_vtn/term'] = array(
|
| 89 |
'title' => t('Term Nodes'),
|
| 90 |
'page callback' => 'taxonomy_vtn_show_nodes',
|
| 91 |
'access arguments' => array('access taxonomy_vtn'),
|
| 92 |
'type' => MENU_CALLBACK,
|
| 93 |
'file' => 'taxonomy_vtn.pages.inc'
|
| 94 |
);
|
| 95 |
|
| 96 |
$items['taxonomy_vtn/clear_cache'] = array(
|
| 97 |
'page callback' => 'taxonomy_vtn_clear_cache',
|
| 98 |
'access arguments' => array('administer taxonomy_vtn'),
|
| 99 |
'type' => MENU_CALLBACK
|
| 100 |
);
|
| 101 |
|
| 102 |
return $items;
|
| 103 |
}
|
| 104 |
|
| 105 |
|
| 106 |
/**
|
| 107 |
* Define the settings form
|
| 108 |
*/
|
| 109 |
function taxonomy_vtn_settings() {
|
| 110 |
// if we use caching or now this is turn off
|
| 111 |
// and change some setting then cache should be cleared
|
| 112 |
$caching = variable_get('taxonomy_vtn_caching', FALSE);
|
| 113 |
$post_caching = $_POST['taxonomy_vtn_caching'];
|
| 114 |
if ( ($post_caching == 1) || ($caching && $_POST && $post_caching == 0) ) {
|
| 115 |
cache_clear_all('taxonomy_vtn_', 'cache', TRUE);
|
| 116 |
drupal_set_message('Cache has cleared.');
|
| 117 |
}
|
| 118 |
|
| 119 |
$path = drupal_get_path( 'module', 'taxonomy_vtn' );
|
| 120 |
|
| 121 |
// cache
|
| 122 |
$form['global'] = array(
|
| 123 |
'#type' => 'fieldset',
|
| 124 |
'#title' => t('Global'),
|
| 125 |
'#collapsible' => TRUE,
|
| 126 |
'#collapsed' => FALSE
|
| 127 |
);
|
| 128 |
|
| 129 |
// caching
|
| 130 |
$desc = t('When using caching entire index pages are being cached and changes on terms, nodes or vocabularies won\'t have any effect until the cache is rebuilt') .'<br /><strong>'. t('Note') .':</strong> '. t('Now this module support operations') .': <strong>'. t('insert, update, delete') .'</strong> '. t('for nodes, terms and vocabularies and rebuild automaticaly own cache. In most case this is safe choice. However you can !link', array('!link' => l(t('clear cache now'), 'taxonomy_vtn/clear_cache')) );
|
| 131 |
|
| 132 |
$form['global']['taxonomy_vtn_caching'] = array(
|
| 133 |
'#type' => 'checkbox',
|
| 134 |
'#title' => t('Caching'),
|
| 135 |
'#description' => $desc,
|
| 136 |
'#default_value' => variable_get('taxonomy_vtn_caching', FALSE),
|
| 137 |
);
|
| 138 |
|
| 139 |
// setlocale
|
| 140 |
if ( $server_support_setlocale = variable_get('taxonomy_vtn_server_support_setlocale', 0) ) {
|
| 141 |
$info = '<div class="messages info">'. theme_image( 'misc/watchdog-ok.png', 'alt', 'title') .' '. t('!setlocale is supported. <br />This mean that sort index alphabetical with specific letters like !letters can be really sorted with your language. Enjoy.', array('!setlocale' => '<strong>setlocale</strong>', '!letters' => '<em>ą ę ń</em>')) .'</div>';
|
| 142 |
}
|
| 143 |
else {
|
| 144 |
$info = '<div class="messages warning">'. theme_image( 'misc/watchdog-warning.png', 'alt', 'title') .' '. t('Your server not support !setlocale. <br />This mean that sort index alphabetical with specific letters like !letters can\'t be really sorted with your language.', array('!setlocale' => '<strong>setlocale</strong>', '!letters' => '<em>ą ę ń</em>')) .'</div>';
|
| 145 |
}
|
| 146 |
|
| 147 |
$form['global']['taxonomy_vtn_use_setlocale'] = array(
|
| 148 |
'#type' => 'checkbox',
|
| 149 |
'#title' => t('Use setlocale'),
|
| 150 |
'#description' => t('If you have some trouble, turn off this option.'),
|
| 151 |
'#default_value' => ($server_support_setlocale == 1) ? variable_get('taxonomy_vtn_use_setlocale', 1) : 0,
|
| 152 |
'#disabled' => ($server_support_setlocale == 0)
|
| 153 |
);
|
| 154 |
|
| 155 |
$form['global']['info_support_setlocale'] = array(
|
| 156 |
'#type' => 'markup',
|
| 157 |
'#value' => $info
|
| 158 |
);
|
| 159 |
|
| 160 |
|
| 161 |
// vocabularies
|
| 162 |
$form['vocabularies'] = array(
|
| 163 |
'#type' => 'fieldset',
|
| 164 |
'#title' => t('Vocabularies'),
|
| 165 |
'#description' => t('Set how show the vocabularies index'),
|
| 166 |
'#collapsible' => TRUE,
|
| 167 |
'#collapsed' => FALSE
|
| 168 |
);
|
| 169 |
$form['vocabularies']['taxonomy_vtn_vocabularies_show_voc_desc'] = array(
|
| 170 |
'#type' => 'checkbox',
|
| 171 |
'#title' => t('Show descriptions'),
|
| 172 |
'#default_value' => variable_get('taxonomy_vtn_vocabularies_show_voc_desc', 1),
|
| 173 |
);
|
| 174 |
$form['vocabularies']['taxonomy_vtn_vocabularies_show_count_terms'] = array(
|
| 175 |
'#type' => 'checkbox',
|
| 176 |
'#title' => t('Show count'),
|
| 177 |
'#default_value' => variable_get('taxonomy_vtn_vocabularies_show_count_terms', 1),
|
| 178 |
);
|
| 179 |
$form['vocabularies']['taxonomy_vtn_vocabularies_show_empty_vocs'] = array(
|
| 180 |
'#type' => 'checkbox',
|
| 181 |
'#title' => t('Show empty'),
|
| 182 |
'#default_value' => variable_get('taxonomy_vtn_vocabularies_show_empty_vocs', 1),
|
| 183 |
);
|
| 184 |
|
| 185 |
$options = array(
|
| 186 |
'1' => t('One'),
|
| 187 |
'2' => t('Two'),
|
| 188 |
'3' => t('Three')
|
| 189 |
);
|
| 190 |
$form['vocabularies']['taxonomy_vtn_vocabularies_count_group_vocabularies'] = array(
|
| 191 |
'#type' => 'select',
|
| 192 |
'#title' => t('Letters to group'),
|
| 193 |
'#description' => t('This settings make index grouped like, Example:') .' <em>A B C</em> '. t('or') .' <em>AB CD CE</em>',
|
| 194 |
'#default_value' => variable_get('taxonomy_vtn_vocabularies_count_group_vocabularies', 1),
|
| 195 |
'#options' => $options
|
| 196 |
);
|
| 197 |
|
| 198 |
$options = array(
|
| 199 |
'1' => t('One'),
|
| 200 |
'2' => t('Two'),
|
| 201 |
'3' => t('Three')
|
| 202 |
);
|
| 203 |
$form['vocabularies']['taxonomy_vtn_vocabularies_count_column_vocs'] = array(
|
| 204 |
'#type' => 'select',
|
| 205 |
'#title' => t('Nnumber of columns'),
|
| 206 |
'#default_value' => variable_get('taxonomy_vtn_vocabularies_count_column_vocs', 2),
|
| 207 |
'#options' => $options
|
| 208 |
);
|
| 209 |
|
| 210 |
$form['vocabularies']['taxonomy_vtn_vocabularies_goto_terms_if_one'] = array(
|
| 211 |
'#type' => 'checkbox',
|
| 212 |
'#title' => t('Direct go to terms if is the only one vocabulary'),
|
| 213 |
'#default_value' => variable_get('taxonomy_vtn_vocabularies_goto_terms_if_one', '0'),
|
| 214 |
);
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
// terms
|
| 220 |
$form['terms'] = array(
|
| 221 |
'#type' => 'fieldset',
|
| 222 |
'#title' => t('Terms'),
|
| 223 |
'#description' => t('Set how show the terms index'),
|
| 224 |
'#collapsible' => TRUE,
|
| 225 |
'#collapsed' => FALSE
|
| 226 |
);
|
| 227 |
$form['terms']['taxonomy_vtn_terms_show_term_desc'] = array(
|
| 228 |
'#type' => 'checkbox',
|
| 229 |
'#title' => t('Show descriptions'),
|
| 230 |
'#default_value' => variable_get('taxonomy_vtn_terms_show_term_desc', 1)
|
| 231 |
);
|
| 232 |
$form['terms']['taxonomy_vtn_terms_show_count_nodes'] = array(
|
| 233 |
'#type' => 'checkbox',
|
| 234 |
'#title' => t('Show count'),
|
| 235 |
'#default_value' => variable_get('taxonomy_vtn_terms_show_count_nodes', 1)
|
| 236 |
);
|
| 237 |
$form['terms']['taxonomy_vtn_terms_show_empty_terms'] = array(
|
| 238 |
'#type' => 'checkbox',
|
| 239 |
'#title' => t('Show empty'),
|
| 240 |
'#default_value' => variable_get('taxonomy_vtn_terms_show_empty_terms', 1)
|
| 241 |
);
|
| 242 |
$form['terms']['taxonomy_vtn_terms_show_synonyms'] = array(
|
| 243 |
'#type' => 'checkbox',
|
| 244 |
'#title' => t('Show synonyms'),
|
| 245 |
'#default_value' => variable_get('taxonomy_vtn_terms_show_synonyms', 1)
|
| 246 |
);
|
| 247 |
|
| 248 |
$options = array(
|
| 249 |
'1' => t('One'),
|
| 250 |
'2' => t('Two'),
|
| 251 |
'3' => t('Three')
|
| 252 |
);
|
| 253 |
$form['terms']['taxonomy_vtn_terms_count_group_terms'] = array(
|
| 254 |
'#type' => 'select',
|
| 255 |
'#title' => t('Letters to group'),
|
| 256 |
'#description' => t('This settings make index grouped like, Example:') .' <em>A B C</em> '. t('or') .' <em>AB CD CE</em>',
|
| 257 |
'#default_value' => variable_get('taxonomy_vtn_terms_count_group_terms', 1),
|
| 258 |
'#options' => $options
|
| 259 |
);
|
| 260 |
|
| 261 |
$options = array(
|
| 262 |
'1' => t('One'),
|
| 263 |
'2' => t('Two'),
|
| 264 |
'3' => t('Three')
|
| 265 |
);
|
| 266 |
$form['terms']['taxonomy_vtn_terms_count_column_terms'] = array(
|
| 267 |
'#type' => 'select',
|
| 268 |
'#title' => t('Number of columns'),
|
| 269 |
'#default_value' => variable_get('taxonomy_vtn_terms_count_column_terms', 2),
|
| 270 |
'#options' => $options
|
| 271 |
);
|
| 272 |
|
| 273 |
|
| 274 |
// nodes
|
| 275 |
$form['nodes'] = array(
|
| 276 |
'#type' => 'fieldset',
|
| 277 |
'#title' => t('Nodes'),
|
| 278 |
'#description' => t('Set how show the nodes index'),
|
| 279 |
'#collapsible' => TRUE,
|
| 280 |
'#collapsed' => FALSE
|
| 281 |
);
|
| 282 |
$form['nodes']['taxonomy_vtn_nodes_show_count_comments'] = array(
|
| 283 |
'#type' => 'checkbox',
|
| 284 |
'#title' => t('Show count comments'),
|
| 285 |
'#default_value' => variable_get('taxonomy_vtn_nodes_show_count_comments', 1)
|
| 286 |
);
|
| 287 |
$form['nodes']['taxonomy_vtn_nodes_show_empty_count_comments'] = array(
|
| 288 |
'#type' => 'checkbox',
|
| 289 |
'#title' => t('Show count for nodes with no comments'),
|
| 290 |
'#default_value' => variable_get('taxonomy_vtn_nodes_show_empty_count_comments', 0)
|
| 291 |
);
|
| 292 |
|
| 293 |
$options = array(
|
| 294 |
'1' => t('One'),
|
| 295 |
'2' => t('Two')
|
| 296 |
);
|
| 297 |
$form['nodes']['taxonomy_vtn_nodes_count_column_nodes'] = array(
|
| 298 |
'#type' => 'select',
|
| 299 |
'#title' => t('Number of columns'),
|
| 300 |
'#default_value' => variable_get('taxonomy_vtn_nodes_count_column_nodes', 2),
|
| 301 |
'#options' => $options
|
| 302 |
);
|
| 303 |
$form['nodes']['taxonomy_vtn_nodes_show_nodes_index'] = array(
|
| 304 |
'#type' => 'checkbox',
|
| 305 |
'#title' => t('Show index if number of columns are set to one column'),
|
| 306 |
'#default_value' => variable_get('taxonomy_vtn_nodes_show_nodes_index', 0)
|
| 307 |
);
|
| 308 |
|
| 309 |
return system_settings_form($form);
|
| 310 |
}
|
| 311 |
|
| 312 |
|
| 313 |
/**
|
| 314 |
* Implementation of hook_taxonomy()
|
| 315 |
*/
|
| 316 |
function taxonomy_vtn_taxonomy($op, $type, $array) {
|
| 317 |
// clear all taxonomy_vtn_* cache because some changes are made
|
| 318 |
cache_clear_all('taxonomy_vtn_', 'cache', TRUE);
|
| 319 |
}
|
| 320 |
|
| 321 |
/**
|
| 322 |
* Implementation of hook_nodeapi()
|
| 323 |
*/
|
| 324 |
function taxonomy_vtn_nodeapi(&$node, $op) {
|
| 325 |
switch ($op) {
|
| 326 |
case 'insert':
|
| 327 |
case 'update':
|
| 328 |
case 'delete':
|
| 329 |
// clear all taxonomy_vtn_* cache because some changes are made
|
| 330 |
// example: we changed the category for current node
|
| 331 |
cache_clear_all('taxonomy_vtn_', 'cache', TRUE);
|
| 332 |
}
|
| 333 |
}
|
| 334 |
|
| 335 |
/**
|
| 336 |
* Implementation of taxonomy_vtn_clear_cache()
|
| 337 |
*/
|
| 338 |
function taxonomy_vtn_clear_cache() {
|
| 339 |
cache_clear_all('taxonomy_vtn_', 'cache', TRUE);
|
| 340 |
drupal_set_message('Cache has cleared.');
|
| 341 |
drupal_goto(referer_uri());
|
| 342 |
}
|
| 343 |
|