|
1 <?php |
|
2 define('CORPUS_URL', 'corpus-app'); |
|
3 define('CORPUS_BACK_URL', '<%= corpus_back_url %>'); |
|
4 define('CORPUS_APP', 'app-client'); |
|
5 define('CORPUS_APP_VERSION', '<%= version %>'); |
|
6 define('CORPUS_ENV', '<%= environment %>'); |
|
7 define('MODULE_NAME', basename(__FILE__, '.module')); |
|
8 |
|
9 /** |
|
10 * Implements hook_menu(). |
|
11 */ |
|
12 function corpus_menu() { |
|
13 |
|
14 $items[CORPUS_URL] = array( |
|
15 'title' => 'Recherche', |
|
16 'description' => t('Corpus de la parole'), |
|
17 'weight' => -1, |
|
18 'page callback' => 'corpus_page', |
|
19 'access arguments' => array(''), // permission |
|
20 'type' => MENU_NORMAL_ITEM, |
|
21 'menu_name' => 'main-menu', |
|
22 'options' => array( |
|
23 'attributes' => array( |
|
24 'class' => array('corpus-app-menu') |
|
25 ) |
|
26 ), |
|
27 ); |
|
28 $items[CORPUS_URL.'#/langues'] = array( |
|
29 'title' => 'Langues', |
|
30 'description' => t('Corpus de la parole'), |
|
31 'weight' => 0, |
|
32 'page callback' => 'corpus_page', |
|
33 'access arguments' => array(''), // permission |
|
34 'type' => MENU_NORMAL_ITEM, |
|
35 'menu_name' => 'main-menu', |
|
36 'options' => array( |
|
37 'attributes' => array( |
|
38 'class' => array('corpus-app-sub-menu') |
|
39 ) |
|
40 ), |
|
41 ); |
|
42 $items[CORPUS_URL.'#/cartographie'] = array( |
|
43 'title' => 'Cartographie', |
|
44 'description' => t('Corpus de la parole'), |
|
45 'weight' => 1, |
|
46 'page callback' => 'corpus_page', |
|
47 'access arguments' => array(''), // permission |
|
48 'type' => MENU_NORMAL_ITEM, |
|
49 'menu_name' => 'main-menu', |
|
50 'options' => array( |
|
51 'attributes' => array( |
|
52 'class' => array('corpus-app-sub-menu') |
|
53 ) |
|
54 ), |
|
55 ); |
|
56 $items[CORPUS_URL.'#/thematiques'] = array( |
|
57 'title' => 'Thematiques', |
|
58 'description' => t('Corpus de la parole'), |
|
59 'weight' => 2, |
|
60 'page callback' => 'corpus_page', |
|
61 'access arguments' => array(''), // permission |
|
62 'type' => MENU_NORMAL_ITEM, |
|
63 'menu_name' => 'main-menu', |
|
64 'options' => array( |
|
65 'attributes' => array( |
|
66 'class' => array('corpus-app-sub-menu') |
|
67 ) |
|
68 ), |
|
69 ); |
|
70 $items[CORPUS_URL.'#/discours'] = array( |
|
71 'title' => 'Discours', |
|
72 'description' => t('Corpus de la parole'), |
|
73 'weight' => 3, |
|
74 'page callback' => 'corpus_page', |
|
75 'access arguments' => array(''), // permission |
|
76 'type' => MENU_NORMAL_ITEM, |
|
77 'menu_name' => 'main-menu', |
|
78 'options' => array( |
|
79 'attributes' => array( |
|
80 'class' => array('corpus-app-sub-menu') |
|
81 ) |
|
82 ), |
|
83 ); |
|
84 $items[CORPUS_URL.'#/chronologie'] = array( |
|
85 'title' => 'Chronologie', |
|
86 'description' => t('Corpus de la parole'), |
|
87 'weight' => 4, |
|
88 'page callback' => 'corpus_page', |
|
89 'access arguments' => array(''), // permission |
|
90 'type' => MENU_NORMAL_ITEM, |
|
91 'menu_name' => 'main-menu', |
|
92 'options' => array( |
|
93 'attributes' => array( |
|
94 'class' => array('corpus-app-sub-menu') |
|
95 ) |
|
96 ), |
|
97 ); |
|
98 return $items; |
|
99 } |
|
100 |
|
101 /** |
|
102 * The page callback function. Loads the Ember app |
|
103 */ |
|
104 function corpus_page() { |
|
105 |
|
106 $app = CORPUS_APP; |
|
107 $path = drupal_get_path('module', MODULE_NAME) . '/' . $app; |
|
108 |
|
109 $appEnvironment = array( |
|
110 "rootElement" => "#corpus-app", |
|
111 "modulePrefix" => CORPUS_APP, |
|
112 "environment" => CORPUS_ENV, |
|
113 "rootURL" => drupal_get_path('module', MODULE_NAME), |
|
114 "locationType" => "hash", |
|
115 "EmberENV" => array( |
|
116 "FEATURES" => array() |
|
117 ), |
|
118 "APP" => array( |
|
119 "backRootURL" => "/".CORPUS_BACK_URL."/", |
|
120 "name" => "app-client", |
|
121 "version" => CORPUS_APP_VERSION |
|
122 ), |
|
123 "exportApplicationGlobal" => false |
|
124 ); |
|
125 if(CORPUS_ENV === 'development') { |
|
126 $appEnvironment["ember-cli-mirage"] = array( |
|
127 "usingProxy" => false, |
|
128 "useDefaultPassthroughs" => true |
|
129 ); |
|
130 } |
|
131 |
|
132 $element = array( |
|
133 '#tag' => 'meta', // The #tag is the html tag - <link /> |
|
134 '#attributes' => array( // Set up an array of attributes inside the tag |
|
135 'name' => 'app-client/config/environment', |
|
136 'content' => urlencode(json_encode($appEnvironment)) |
|
137 ), |
|
138 ); |
|
139 |
|
140 drupal_add_html_head($element, 'ember_init'); |
|
141 |
|
142 // drupal_add_css("{$path}/assets/vendor.css"); |
|
143 // drupal_add_css("{$path}/assets/{$app}.css"); |
|
144 drupal_add_js( |
|
145 "if(typeof jQuery !== 'undefined') { |
|
146 var jQueryOriginal = jQuery.noConflict(true); |
|
147 |
|
148 }", |
|
149 array( |
|
150 'type' => 'inline', |
|
151 'scope' => 'footer', |
|
152 'group' => JS_THEME+1, |
|
153 'weight' => 1, |
|
154 'every_page' => true, |
|
155 'requires_jquery' => false |
|
156 ) |
|
157 ); |
|
158 drupal_add_js( |
|
159 "{$path}/assets/vendor.js", |
|
160 array( |
|
161 'type' => 'file', |
|
162 'scope' => 'footer', |
|
163 'group' => JS_THEME+1, |
|
164 'weight' => 2, |
|
165 'every_page' => true, |
|
166 'requires_jquery' => false |
|
167 ) |
|
168 ); |
|
169 drupal_add_js("{$path}/assets/{$app}.js", |
|
170 array( |
|
171 'type' => 'file', |
|
172 'scope' => 'footer', |
|
173 'group' => JS_THEME+1, |
|
174 'weight' => 3, |
|
175 'every_page' => true, |
|
176 'requires_jquery' => false |
|
177 ) |
|
178 ); |
|
179 drupal_add_js( |
|
180 "if(typeof jQueryOriginal !== 'undefined') { |
|
181 $ = jQueryOriginal; |
|
182 jQuery = jQueryOriginal; |
|
183 |
|
184 }", |
|
185 array( |
|
186 'type' => 'inline', |
|
187 'scope' => 'footer', |
|
188 'group' => JS_THEME+1, |
|
189 'weight' => 4, |
|
190 'every_page' => true, |
|
191 'requires_jquery' => false |
|
192 ) |
|
193 ); |
|
194 |
|
195 return "<div id='corpus-app' class='corpus-app'></div>"; |
|
196 } |