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