ckeditor.drush.inc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * CKEditor - The text editor for the Internet - http://ckeditor.com
  4. * Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
  5. *
  6. * == BEGIN LICENSE ==
  7. *
  8. * Licensed under the terms of any of the following licenses of your
  9. * choice:
  10. *
  11. * - GNU General Public License Version 2 or later (the "GPL")
  12. * http://www.gnu.org/licenses/gpl.html
  13. *
  14. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15. * http://www.gnu.org/licenses/lgpl.html
  16. *
  17. * - Mozilla Public License Version 1.1 or later (the "MPL")
  18. * http://www.mozilla.org/MPL/MPL-1.1.html
  19. *
  20. * == END LICENSE ==
  21. *
  22. * @file
  23. * Drush integration for the CKEditor module.
  24. */
  25. /**
  26. * Implements hook_drush_command().
  27. */
  28. function ckeditor_drush_command() {
  29. $items['ckeditor-download'] = array(
  30. 'callback' => 'ckeditor_drush_download',
  31. 'description' => dt('Downloads the required CKEditor library from svn.ckeditor.com.'),
  32. 'arguments' => array(
  33. 'path' => dt('Optional. The path to the download folder. If omitted, Drush will use the default location (<code>sites/all/libraries/ckeditor</code>).'),
  34. ),
  35. );
  36. return $items;
  37. }
  38. /**
  39. * Downloads
  40. */
  41. function ckeditor_drush_download() {
  42. $args = func_get_args();
  43. if ($args[0]) {
  44. $path = $args[0];
  45. }
  46. else {
  47. $path = drush_get_context('DRUSH_DRUPAL_ROOT') . '/sites/all/libraries/ckeditor';
  48. }
  49. $svn_cmd = 'svn checkout http://svn.ckeditor.com/CKEditor/releases/stable/ ' . $path;
  50. if (drush_shell_exec($svn_cmd)) {
  51. drush_log(dt('CKEditor was downloaded to !path.', array('!path' => '<code>' . $path . '</code>')), 'success');
  52. }
  53. else {
  54. drush_log(dt('Drush was unable to download CKEditor to !path.', array('!path' => '<code>' . $path . '</code>')) . '<br/>' . dt('Attempted command: !svn_cmd.', array('!svn_cmd' => '<code>' . $svn_cmd . '</code>')), 'error');
  55. }
  56. }
  57. /**
  58. * Implements drush_MODULE_post_COMMAND().
  59. */
  60. function drush_ckeditor_post_enable() {
  61. $modules = func_get_args();
  62. if (in_array('ckeditor', $modules) && !drush_get_option('skip')) {
  63. ckeditor_drush_download();
  64. }
  65. }