-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextjs.module
106 lines (97 loc) · 2.92 KB
/
extjs.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* @file
*
* A Drupal wrapper for the Sencha ExtJS Library
*/
define('EXTJS_MIN_COMPRESSION', 'min');
define('EXTJS_DEV_COMPRESSION', 'dev');
define('EXTJS_DEBUG_COMPRESSION', 'debug');
define('EXTJS_DEBUG_COMMENTS_COMPRESSION', 'debug-w-comments');
define('EXTJS_THEME_NEPTUNE', 'neptune');
/**
* Implements hook_menu().
*/
function extjs_menu() {
return array(
'admin/settings/extjs' => array(
'title' => t('Sencha ExtJS Settings'),
'description' => t('Sencha ExtJS Settings.'),
'file' => 'extjs.admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('extjs_admin_settings_form', 3),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
)
);
}
/**
* Adds a single javascript file that will take advantage of ExtJS ability to asynchronously load the javascript files it requires.
* Typically this is all that you require.
*
* This shouldn't be used in conjunction with ext_add_all().
*/
function extjs_add_seed() {
module_load_include('inc', 'extjs', 'extjs.utils');
extjs_add_drupal_reset_css_files();
extjs_add_css_file('ext-all-scoped');
extjs_add_js_file('ext'); // @todo: look into the theme layer more.
}
/**
* Adds the ext-all js so that no other javascript is need or loaded dynamically.
*
* This shouldn't be used in conjuntion with extjs_add_seed().
*/
function extjs_add_all() {
module_load_include('inc', 'extjs', 'extjs.utils');
extjs_add_drupal_reset_css_files();
extjs_add_css_file('ext-all-scoped');
extjs_add_js_file('ext-all');
}
/**
* Subject to change in the future... be wary your code may have to change with this
* as the theme layer get's spec'd out.
*/
function extjs_load_app(array $css, array $js, $all = TRUE){
module_load_include('inc', 'extjs', 'extjs.utils');
extjs_add_drupal_reset_css_files();
foreach($css as $file) {
drupal_add_css($file);
}
extjs_add_default_settings();
extjs_add_settings_js_file();
$all ? extjs_add_js_file('ext-all') : extjs_add_js_file('ext');
foreach($js as $file) {
drupal_add_js($file, 'module', 'header', TRUE);
}
}
/**
* Fetchs and processes the applications definition.
*/
function extjs_get_app($app_id) {
$args = func_get_args();
$app = call_user_func_array($app_id, $args);
$app['__drupal_alter_by_ref'] = array(&$args);
drupal_alter('extjs_app_' . $app_id, $app);
extjs_process_app($app_id, $app);
// Render to a div or to an iframe? choose at a later time.
}
/**
* Generates the JSON definition for the application.
*/
function extjs_process_app($app_id, $app) {
$definition = array(
'id' => $app_id
);
$json = array(
'extjs' => array(
'applications' => array(
$app_id => $definition
)
)
);
drupal_add_js($json, 'settings');
}
/*
Basically we need to take an array definition of a ExtJS application transform it into a JSON object and dynamically create it client side.
*/