migrateunfuddle.module 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @file
  4. * Import an Unfuddle dump into a Drupal Casetracker instance
  5. *
  6. * @copyright Coyright (c) 2011 Ouest Systèmes Informatiques (OSI, OSInet)
  7. * @license Licensed under the General Public License version 2 and later, and
  8. * the CeCILL 2.0 license.
  9. */
  10. /**
  11. * Implements hook_migrate_api().
  12. */
  13. function migrateunfuddle_migrate_api() {
  14. $api = array(
  15. 'api' => 2,
  16. );
  17. return $api;
  18. }
  19. /**
  20. * Implements hook_views_api().
  21. */
  22. function migrateunfuddle_views_api() {
  23. $ret = array(
  24. 'api' => '3.0',
  25. 'path' => drupal_get_path('module', 'migrateunfuddle') . '/views',
  26. );
  27. return $ret;
  28. }
  29. /**
  30. * Implements hook_views_default_views().
  31. *
  32. * No need to create a .views_default.inc just for this
  33. */
  34. function migrateunfuddle_views_default_views() {
  35. $info = migrateunfuddle_views_api();
  36. $ret = array();
  37. $files = file_scan_directory($info['path'], '.*\.view\.inc', array(), NULL, FALSE);
  38. foreach ($files as $file) {
  39. require_once $file->filename;
  40. $ret[$view->name] = $view;
  41. }
  42. return $ret;
  43. }
  44. /**
  45. * Convert a string to a SEO-passable slug.
  46. *
  47. * Lifted from Drupal 7
  48. *
  49. * @param string $identifier
  50. * @param array $filter
  51. *
  52. * @return string
  53. */
  54. function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '')) {
  55. // By default, we filter using Drupal's coding standards.
  56. $identifier = strtr($identifier, $filter);
  57. // Valid characters in a CSS identifier are:
  58. // - the hyphen (U+002D)
  59. // - a-z (U+0030 - U+0039)
  60. // - A-Z (U+0041 - U+005A)
  61. // - the underscore (U+005F)
  62. // - 0-9 (U+0061 - U+007A)
  63. // - ISO 10646 characters U+00A1 and higher
  64. // We strip out any character not in the above list.
  65. $identifier = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier);
  66. return $identifier;
  67. }