i18n_select.variable.inc 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. * Variable information
  5. */
  6. /**
  7. * Implements hook_variable_info().
  8. */
  9. function i18n_select_variable_info($options = array()) {
  10. $variables['i18n_select_nodes'] = array(
  11. 'title' => t('Select nodes by language', array(), $options),
  12. 'type' => 'boolean',
  13. 'default' => TRUE,
  14. 'group' => 'i18n',
  15. );
  16. $variables['i18n_select_taxonomy'] = array(
  17. 'title' => t('Select taxonomy terms by language', array(), $options),
  18. 'type' => 'boolean',
  19. 'default' => TRUE,
  20. 'group' => 'i18n',
  21. 'element' => array('#disabled' => !module_exists('i18n_taxonomy')),
  22. );
  23. // Enable / disable for specific pages
  24. $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'), $options);
  25. if (module_exists('php')) {
  26. $title = t('Pages or PHP code');
  27. $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'), $options);
  28. }
  29. else {
  30. $title = t('Pages', array(), $options);
  31. }
  32. $variables['i18n_select_page_mode'] = array(
  33. 'type' => 'select',
  34. 'options callback' => 'i18n_select_variable_option_list',
  35. 'default' => I18N_SELECT_PAGE_NOTLISTED,
  36. );
  37. $variables['i18n_select_page_list'] = array(
  38. 'type' => 'text',
  39. 'title' => $title,
  40. 'default' => 'admin/*',
  41. 'description' => $description,
  42. );
  43. $variables['i18n_select_page_block'] = array(
  44. 'type' => 'boolean',
  45. 'title' => t('Enable always for block content though it may be disabled for the page', array(), $options),
  46. 'default' => TRUE,
  47. );
  48. $variables['i18n_select_skip_tags'] = array(
  49. 'title' => t('Skip tags', array(), $options),
  50. 'type' => 'string',
  51. 'default' => 'views',
  52. 'group' => 'i18n',
  53. 'description' => t('Skip queries with these tags. Enter a list of tags separated by commas.'),
  54. 'localize' => FALSE,
  55. );
  56. return $variables;
  57. }
  58. /**
  59. * Options for page selection mode
  60. */
  61. function i18n_select_variable_option_list($variable, $options = array()) {
  62. $options = array(
  63. I18N_SELECT_PAGE_NOTLISTED => t('All pages except those listed', array(), $options),
  64. I18N_SELECT_PAGE_LISTED => t('Only the listed pages', array(), $options),
  65. );
  66. if (module_exists('php')) {
  67. $options += array(I18N_SELECT_PAGE_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
  68. }
  69. return $options;
  70. }