adaptivetheme.drush.inc

  1. cis7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  2. cle7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  3. ecd7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  4. elmsmedia7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  5. harmony7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  6. icor7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  7. meedjum_blog7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
  8. mooc7 sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc

Contains functions only needed for drush integration.

Usage: drush adaptivetheme "Foobar Theme" foobartheme

Functions

Namesort descending Description
adaptivetheme_copy Copy a directory recursively.
adaptivetheme_drush_command Implementation of hook_drush_command().
adaptivetheme_file_str_replace Replace strings in a file.
drush_adaptivetheme Create a adaptivetheme sub-theme using the starter kit.

File

sites/all/themes/ulmus/adaptivetheme/at_core/adaptivetheme.drush.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains functions only needed for drush integration.
  5. *
  6. * Usage: drush adaptivetheme "Foobar Theme" foobartheme
  7. */
  8. /**
  9. * Implementation of hook_drush_command().
  10. */
  11. function adaptivetheme_drush_command() {
  12. $items = array();
  13. $items['adaptivetheme'] = array(
  14. 'description' => 'Create a theme using adaptivetheme.',
  15. 'arguments' => array(
  16. 'name' => 'A name for your theme.',
  17. 'machine_name' => '[optional] A machine-readable name for your theme.',
  18. ),
  19. 'options' => array(
  20. 'name' => 'A name for your theme.',
  21. 'machine-name' => '[a-z, 0-9] A machine-readable name for your theme.',
  22. 'description' => 'A description of your theme.',
  23. 'without-rtl' => 'Remove all RTL stylesheets.',
  24. // @TODO potentially add settings defaults?
  25. ),
  26. 'examples' => array(
  27. 'drush adaptivetheme "My theme name"' => 'Create a sub-theme, using the default options.',
  28. 'drush adaptivetheme "My theme name" my_theme' => 'Create a sub-theme with a specific machine name.',
  29. ),
  30. );
  31. return $items;
  32. }
  33. /**
  34. * Create a adaptivetheme sub-theme using the starter kit.
  35. */
  36. function drush_adaptivetheme($name = NULL, $machine_name = NULL) {
  37. // Determine the theme name.
  38. if (!isset($name)) {
  39. if (!$name = drush_get_option('name')) {
  40. drush_print(dt('Please specify a name!' . "\n" . 'e.g., drush adaptivetheme "Your Theme Name" yourthemename'));
  41. return;
  42. }
  43. }
  44. // Determine the machine name.
  45. if (!isset($machine_name)) {
  46. $machine_name = drush_get_option('machine-name');
  47. }
  48. if (!$machine_name) {
  49. $machine_name = $name;
  50. }
  51. $machine_name = str_replace(' ', '_', strtolower($machine_name));
  52. $search = array(
  53. '/[^a-z0-9_]/', // Remove characters not valid in function names.
  54. '/^[^a-z]+/', // Functions must begin with an alpha character.
  55. );
  56. $machine_name = preg_replace($search, '', $machine_name);
  57. // Determine the path to the new subtheme by finding the path to adaptivetheme.
  58. $adaptivetheme_path = drush_locate_root() . '/' . drupal_get_path('theme', 'adaptivetheme');
  59. $subtheme_path = explode('/', $adaptivetheme_path);
  60. array_pop($subtheme_path);
  61. array_pop($subtheme_path);
  62. $subtheme_path = implode('/', $subtheme_path) . '/' . str_replace('_', '-', $machine_name);
  63. // Make a fresh copy of the original subtheme.
  64. drush_op('adaptivetheme_copy', $adaptivetheme_path . '/../' .'at_subtheme', $subtheme_path);
  65. // Rename the .info file.
  66. $subtheme_info_file = $subtheme_path . '/' . $machine_name . '.info';
  67. drush_op('rename', $subtheme_path . '/adaptivetheme_subtheme.info', $subtheme_info_file);
  68. // Alter the contents of the .info file based on the command options.
  69. $alterations = array(
  70. '= AT Subtheme' => '= ' . $name,
  71. 'project = "adaptivetheme"' => '', // attempt to strip out the project name added by the drupal packing script
  72. );
  73. if ($description = drush_get_option('description')) {
  74. $alterations['Starter subtheme for Adaptivetheme. Copy this subtheme to get started building your own Drupal theme. For help see our <b><a href="http://adaptivethemes.com/documentation/adaptivethemes-documentation" title="Adaptivethemes.com - Rocking the hardest since 2006">documentation</a></b>. If you have a problem and need additional help please use the <b><a href="http://drupal.org/project/issues/adaptivetheme">issue queue</a></b>.'] = $description;
  75. }
  76. drush_op('adaptivetheme_file_str_replace', $subtheme_info_file, array_keys($alterations), $alterations);
  77. // Replace all occurrences of 'adaptivetheme_subtheme' with the machine name of our sub theme.
  78. drush_op('adaptivetheme_file_str_replace', $subtheme_path . '/theme-settings.php', 'adaptivetheme_subtheme', $machine_name);
  79. drush_op('adaptivetheme_file_str_replace', $subtheme_path . '/template.php', 'adaptivetheme_subtheme', $machine_name);
  80. // Notify user of the newly created theme.
  81. drush_print(dt('New Subtheme for "!name" created in: !path', array(
  82. '!name' => $name,
  83. '!path' => $subtheme_path,
  84. )));
  85. //system_rebuild_theme_data(); // potentially execute this here, see http://drupal.org/node/1235942
  86. }
  87. /**
  88. * Copy a directory recursively.
  89. */
  90. function adaptivetheme_copy($source_dir, $target_dir, $ignore = '/^(\.(\.)?|CVS|\.svn|\.git|\.DS_Store)$/') {
  91. if (!is_dir($source_dir)) {
  92. drush_die(dt('The directory "!directory" was not found.', array('!directory' => $source_dir)));
  93. }
  94. $dir = opendir($source_dir);
  95. @mkdir($target_dir);
  96. while($file = readdir($dir)) {
  97. if (!preg_match($ignore, $file)) {
  98. if (is_dir($source_dir . '/' . $file)) {
  99. adaptivetheme_copy($source_dir . '/' . $file, $target_dir . '/' . $file, $ignore);
  100. }
  101. else {
  102. copy($source_dir . '/' . $file, $target_dir . '/' . $file);
  103. }
  104. }
  105. }
  106. closedir($dir);
  107. }
  108. /**
  109. * Replace strings in a file.
  110. */
  111. function adaptivetheme_file_str_replace($file_path, $find, $replace) {
  112. $file_contents = file_get_contents($file_path);
  113. $file_contents = str_replace($find, $replace, $file_contents);
  114. file_put_contents($file_path, $file_contents);
  115. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.