Project

General

Profile

« Previous | Next » 

Revision 86b65fa0

Added by Andreas Kohlbecker almost 9 years ago

module update and some bugfixes for #3316 (dataportal debug box as table and as block)

View differences:

.gitattributes
1045 1045
7.x/modules/cdm_dataportal/js/cluetip/jquery.dimensions.js -text
1046 1046
7.x/modules/cdm_dataportal/js/cluetip/jquery.hoverIntent.js -text
1047 1047
7.x/modules/cdm_dataportal/js/cluetip/wait.gif -text
1048
7.x/modules/cdm_dataportal/js/colorbox-master.zip -text svneol=unset#unset
1049 1048
7.x/modules/cdm_dataportal/js/colorbox/README.md -text
1050 1049
7.x/modules/cdm_dataportal/js/colorbox/colorbox.css -text
1051 1050
7.x/modules/cdm_dataportal/js/colorbox/colorbox.jquery.json -text
7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
114 114

  
115 115
    _add_js_ws_debug();
116 116

  
117
    $block['subject'] = t('CDM Debug');
118
    // cannot use theme_tabel() since table footer is not jet supported in D7
117
    $block['subject'] = ''; // no subject, title in content for having a defined element id
118
    // otherwise it would depend on the theme
119 119
    $block['content'] =
120
        '<table id="cdm-ws-debug-table">'
120
        '<h4 id="cdm-ws-debug-button">' . t('CDM Debug') . '</h4>'
121
          // cannot use theme_table() since table footer is not jet supported in D7
122
        . '<div id="cdm-ws-debug-table-container"><table id="cdm-ws-debug-table">'
121 123
        . $header
122 124
        . '<tbody>' . join('', $rows) . '</tbody>'
123 125
        . $footer
124
        . '</table>';
126
        . '</table></div>';
125 127

  
126 128
    return $block;
127 129
  }
7.x/modules/cdm_dataportal/cdm_dataportal.css
7 7
 * See also http://groups.drupal.org/node/6355.
8 8
 */
9 9

  
10

  
10 11
#block-cdm-api-cdm-ws-debug {
11
  background-color: #252525;
12
  background-color: #373737;
12 13
  color: #fff;
13
  border: 1px solid #b8d3e5;
14
  border: 1px solid #fff;
15
  -moz-box-shadow: inset 0 0 3px 2px #fff;
16
  -webkit-box-shadow: inset 0 0 3px 2px #fff;
17
  box-shadow: inset 0 0 3px 2px #fff;
14 18
}
15 19

  
16
#block-cdm-api-cdm-ws-debug h2 {
17
  margin: 0;
20
#cdm-ws-debug-table-container {
21
  display: none;
22
}
23

  
24
#block-cdm-api-cdm-ws-debug h4 {
25
  margin: 3px;
26
  padding: 0;
27
}
28

  
29
#cdm-ws-debug-table {
30
  width: 100%;
18 31
}
19 32

  
20 33
#cdm-ws-debug-table td.data_links a {
7.x/modules/cdm_dataportal/cdm_dataportal.install
127 127
 * update for RELEASE 3.2.2:
128 128
 *  - migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image['show']
129 129
 *  - enabling required module file
130
 *  - enable new debug block for all dataportals
130 131
 */
131 132
function cdm_dataportal_update_7304() {
132 133

  
133 134
    module_enable(array('file'), TRUE);
134 135
    $tasks_performed[] = 'module file enabled';
135 136

  
136
    $cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT);
137
    $cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0);
138
    variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings);
139
    variable_del('cdm_dataportal_show_default_image');
140
    $tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']';
137
    if(!variable_get(CDM_TAXON_PROFILE_IMAGE, FALSE)){
138
      $cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT);
139
      $cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0);
140
      variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings);
141
      variable_del('cdm_dataportal_show_default_image');
142
      $tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']';
143
    }
144

  
145
    $cdm_admin_role = user_role_load_by_name('CDM admin');
146
    $admin_role = user_role_load_by_name("admin");
147
    if(!$admin_role){
148
      $admin_role = user_role_load_by_name("administrator");
149
    }
150
    user_multiple_role_edit(array(1), 'add_role', $admin_role->rid);
151
    $tasks_performed[] = 'admin user (uid=1) added to role ' . $admin_role->name;
152

  
153
    // CDM web service debug block
154
    $cdm_ws_debug_block = array(
155
        'block' => array(
156
            'module' => 'cdm_api',
157
            'delta' => 'cdm_ws_debug',
158
            'theme' => NULL,
159
            'status' => 1,
160
            'weight' => -50,
161
            'region' => 'sidebar_first',
162
            'pages' => '',
163
            'cache' => -1,
164
        ),
165
        'block_role' =>
166
            array(
167
                array(
168
                  'module' => 'cdm_api',
169
                  'delta' => 'cdm_ws_debug',
170
                  'rid' => $cdm_admin_role->rid
171
               ),
172
                array(
173
                  'module' => 'cdm_api',
174
                  'delta' => 'cdm_ws_debug',
175
                  'rid' => $admin_role->rid
176
               )
177
        )
178
    );
179
    // clean up existing block configuration which might be set by drupal automatically, we need to override this
180
    db_delete('block')->condition('module', 'cdm_api')->execute();
181
    db_delete('block_role')->condition('module', 'cdm_api')->execute();
182
    // insert
183
    $block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
184
    $block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid'));
185

  
186
    $themes = system_list('theme');
187
    foreach ($themes as $theme) {
188
      if($theme->status == "1"){ // only for enabled themes
189
        $cdm_ws_debug_block['block']['theme'] = $theme->name;
190
        $block_insert->values($cdm_ws_debug_block['block']);
191
      }
192
    }
193
    foreach($cdm_ws_debug_block['block_role'] as $block_role){
194
      $block_role_insert->values($block_role);
195
    }
196
    $block_insert->execute();
197
    $block_role_insert->execute();
198
    $tasks_performed[] = 'CDM web service debug block enabled for \'CDM admin\' users in all themes';
199
    $tasks_performed[] = _remove_variable('cdm_webservice_debug');
200
    $tasks_performed[] = _remove_variable('cdm_webservice_isStub');
141 201

  
142 202
    return  join(', ',$tasks_performed);
143 203
}
......
161 221
    $success = TRUE;
162 222
  }
163 223

  
164
  return "Variable \'$old_name\' to \'$new_name\' renamed. ";
224
  return "Variable '$old_name' to '$new_name' renamed. ";
165 225
}
166 226

  
167 227
/**
......
174 234
 */
175 235
function _remove_variable($name) {
176 236
  variable_del($name);
177
  return "Variable \'$name\' removed. ";
237
  return "Variable '$name' removed. ";
178 238
}
179 239

  
180 240
/**
......
187 247
 */
188 248
function _create_variable($name, $value) {
189 249
  variable_set($name, $value);
190
  return "Variable \'$name\' created with value: \'$value\'. ";
250
  return "Variable '$name' created with value: '$value'. ";
191 251
}
192 252

  
193 253
/**
7.x/modules/cdm_dataportal/js/ws_debug_block.js
4 4
 */
5 5
jQuery(document).ready(function($) {
6 6

  
7
    $('#block-cdm-api-cdm-ws-debug .content').hide(); // hide parent element
8

  
9 7
    $('#cdm-ws-debug-table').dataTable({
10 8
        "bPaginate" : false,
11 9
        "bFilter" : true,
......
26 24
                    for(var rowIndex = iStart; rowIndex < iEnd; rowIndex++){
27 25
                        sum += Number(aData[rowIndex][colIndex]);
28 26
                    }
29
                    newHtml = sum;
27
                    newHtml = sum.toFixed(3);
30 28
                } else if(colums_to_sum_up[colIndex]) {
31 29
                    newHtml = colums_to_sum_up[colIndex];
32 30
                }
......
38 36
        }
39 37
    });
40 38

  
41
    $('#block-cdm-api-cdm-ws-debug .title').css('cursor', 'pointer').colorbox({
39
    $('#cdm-ws-debug-button').css('cursor', 'pointer').colorbox({
42 40
        "href" : '#cdm-ws-debug-table_wrapper', // wrapper created by dataTable()
43 41
        "inline" : true,
44 42
        "width" : '90%',
7.x/modules/cdm_dataportal/profile/CDM_Portal/CDM_Portal.install
74 74
      'zen_rebuild_registry' => 0,
75 75
  ));
76 76

  
77

  
78
  /****************************************
79
   *  Blocks
80
   ****************************************/
81

  
82
  // >>> admin/structure/block
83
  //    Disable the blocks that were enabled for the dashboard in the standard install.
84
  //    In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
85
  $query = db_update('block')->fields(array('status' => '0'))
86
    ->condition('region', 'dashboard_main', '=')
87
    ->execute();
88
  $query = db_update('block')->fields(array('status' => '0'))
89
    ->condition('region', 'dashboard_sidebar', '=')
90
    ->execute();
91

  
92
  // disable "Search form"  block for all themes
93
  $query = db_update('block')->fields(array('status' => '0'))
94
    ->condition(
95
        db_and()
96
          ->condition('module', 'search', '=')
97
          ->condition('delta', 'form', '=')
98
        )
99
    ->execute();
100

  
101
  // disable the "Powered by Drupal" block for all themes
102
  $query = db_update('block')->fields(array('status' => '0'))
103
    ->condition(
104
        db_and()
105
          ->condition('module', 'system', '=')
106
          ->condition('delta', 'powered-by', '=')
107
        )
108
    ->execute();
109

  
110
  // enable "CDM Search Taxa" block for all themes
111
  $new_blocks = array(
112
      array(
113
          'module' => 'cdm_dataportal',
114
          'delta' => '2',
115
          'theme' => $default_theme,
116
          'status' => 1,
117
          'weight' => -11,
118
          'region' => 'sidebar_first',
119
          'pages' => '',
120
          'cache' => -1,
121
      ),
122
   );
123
  $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
124
  foreach ($new_blocks as $block) {
125
    $query->values($block);
126
  }
127
  $query->execute();
128

  
129

  
130 77
 /****************************************
131 78
  *  Reconfigure Drupal core modules
132 79
  ****************************************/
......
282 229
    ->execute();
283 230

  
284 231
  /****************************************
285
   *  Create the front page
232
   *  Blocks
286 233
   ****************************************/
234

  
235
  // >>> admin/structure/block
236
  //    Disable the blocks that were enabled for the dashboard in the standard install.
237
  //    In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
238
  $query = db_update('block')->fields(array('status' => '0'))
239
  ->condition('region', 'dashboard_main', '=')
240
  ->execute();
241
  $query = db_update('block')->fields(array('status' => '0'))
242
  ->condition('region', 'dashboard_sidebar', '=')
243
  ->execute();
244

  
245
  // disable "Search form"  block for all themes
246
  $query = db_update('block')->fields(array('status' => '0'))
247
  ->condition(
248
      db_and()
249
      ->condition('module', 'search', '=')
250
      ->condition('delta', 'form', '=')
251
  )
252
  ->execute();
253

  
254
  // disable the "Powered by Drupal" block for all themes
255
  $query = db_update('block')->fields(array('status' => '0'))
256
  ->condition(
257
      db_and()
258
      ->condition('module', 'system', '=')
259
      ->condition('delta', 'powered-by', '=')
260
  )
261
  ->execute();
262

  
263
  $new_blocks = array(
264
      // enable "CDM Search Taxa" block for all themes
265
      array(
266
          'block' => array(
267
              'module' => 'cdm_dataportal',
268
              'delta' => '2',
269
              'theme' => $default_theme,
270
              'status' => 1,
271
              'weight' => -11,
272
              'region' => 'sidebar_first',
273
              'pages' => '',
274
              'cache' => -1,
275
          )
276
      ),
277
      // CDM web service debug block
278
      array(
279
          'block' => array(
280
              'module' => 'cdm_api',
281
              'delta' => 'cdm_ws_debug',
282
              'theme' => $default_theme,
283
              'status' => 1,
284
              'weight' => -50,
285
              'region' => 'sidebar_first',
286
              'pages' => '',
287
              'cache' => -1,
288
          ),
289
          'block_role' => array(
290
              'module' => 'cdm_api',
291
              'delta' => 'cdm_ws_debug',
292
              'rid' => $admin_role->rid
293
          )
294
      )
295
  );
296
  $block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
297
  $block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid'));
298
  foreach ($new_blocks as $block) {
299
    $block_insert->values($block['block']);
300
    if(isset($block['block_role'])){
301
      $block_role_insert->values($block['block_role']);
302
    }
303
  }
304
  $block_insert->execute();
305
  $block_role_insert->execute();
306

  
307
 /****************************************
308
  *  Create the front page
309
  ****************************************/
287 310
  $node = new stdClass();
288 311
  $node->uid = 1;
289 312
  $node->type = 'page';

Also available in: Unified diff