Project

General

Profile

Download (8.41 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
  /**
3
 * @file
4
 * Adds helpful messages for website administrators
5
 * and provides documentation in /admin/help.
6
 */
7

    
8
  // Html paths for differents documentation sections:
9
  define('HELP_OVERVIEW', drupal_get_path('module', 'cdm_dataportal') . '/help/overview.html');
10

    
11
  // Comment @WA: @todo: fill these html files with help texts.
12
  // But why to use different help texts here from the ones used in
13
  // the settings forms?
14
  define('HELP_SETTINGS_GENERAL', drupal_get_path('module', 'cdm_dataportal') . '/help/settings_general.html');
15
  define('HELP_SETTINGS_GEO', drupal_get_path('module', 'cdm_dataportal') . '/help/settings_geo.html');
16
  define('HELP_SETTINGS_LAYOUT', drupal_get_path('module', 'cdm_dataportal') . '/help/settings_layout.html');
17
  define('HELP_SETTINGS_CACHE', drupal_get_path('module', 'cdm_dataportal') . '/help/settings_cache.html');
18
  define('HELP_CONDENSED_DISTRIBUTION', drupal_get_path('module', 'cdm_dataportal') . '/help/condensed_distribution.html');
19

    
20
/**
21
 * Used in cdm_dataportal.module.
22
 */
23
function cdm_dataportal_menu_help(&$items) {
24

    
25
  $items['admin/help/cdm_dataportal_general'] = array(
26
    'title' => 'general',
27
    'page callback' => 'cdm_dataportal_file_get_content',
28
    'page arguments' => array(HELP_SETTINGS_GENERAL),
29
    'access callback' => 'user_is_logged_in',
30
    'type' => MENU_LOCAL_TASK,
31
  );
32

    
33
  $items['admin/help/cdm_dataportal_geo'] = array(
34
    'title' => 'geo',
35
    'page callback' => 'cdm_dataportal_file_get_content',
36
    'page arguments' => array(HELP_SETTINGS_GEO),
37
    'access callback' => 'user_is_logged_in',
38
    'type' => MENU_LOCAL_TASK,
39
  );
40

    
41
  $items['admin/help/cdm_dataportal_layout'] = array(
42
    'title' => 'layout',
43
    'page callback' => 'cdm_dataportal_file_get_content',
44
    'page arguments' => array(HELP_SETTINGS_LAYOUT),
45
    'access callback' => 'user_is_logged_in',
46
    'type' => MENU_LOCAL_TASK,
47
  );
48

    
49
  $items['admin/help/cdm_dataportal_cache'] = array(
50
    'title' => 'cache',
51
    'page callback' => 'cdm_dataportal_file_get_content',
52
    'page arguments' => array(HELP_SETTINGS_CACHE),
53
    'access callback' => 'user_is_logged_in',
54
    'type' => MENU_LOCAL_TASK,
55
  );
56

    
57
  $items['cdm_dataportal/help/condensed_distribution'] = array(
58
    'title' => 'Condensed distribution representation',
59
    'page callback' => 'cdm_dataportal_file_get_content',
60
    'page arguments' => array(HELP_CONDENSED_DISTRIBUTION),
61
    'access arguments' => array('access content'),
62
    'type' => MENU_CALLBACK,
63
  );
64
}
65

    
66
/**
67
 * Implements hook_help().
68
 */
69
function cdm_dataportal_help($path, $arg) {
70
  // Result to return.
71
  $res = '';
72

    
73
  switch ($path) {
74
    case 'admin/help#cdm_dataportal':
75
      // $popup = (module_exists('advanced_help')) ? theme('advanced_help_topic', 'cdm_help', 'website-overview') : '';
76
      // var_dump($popup);
77
      $content = cdm_dataportal_file_get_content(HELP_OVERVIEW);
78
      $res = $content;
79
      break;
80

    
81
    default:
82
      $path_aux = str_replace('/', '_', $path);
83
      if (function_exists('theme_cdm_portal_' . $path_aux)) {
84
        $res = theme('cdm_dataportal_' . $path_aux, array());
85
      }
86
  }
87

    
88
  return $res;
89
}
90

    
91
/**
92
 * @todo Please document this function.
93
 * @see http://drupal.org/node/1354
94
 */
95
function cdm_dataportal_file_get_content($path) {
96

    
97
  // Modifing the html file to get the drupal paths.
98
  $content = file_get_contents($path);
99
  $content_result = str_replace("{MODULE_PATH}", file_build_uri($path), $content);
100

    
101
  /* XXXXX change made because of problems with SVN!!! XXXXX
102
   //converting from html to apt for maven documentation
103
   $apt_content = $content_result;
104
   //general modifications
105
   $apt_content = str_replace('<p>', '', $apt_content);
106
   $apt_content = str_replace('</p>', '', $apt_content);
107
   $apt_content = str_replace('<b>', '<<', $apt_content);
108
   $apt_content = str_replace('</b>', '>>', $apt_content);
109
   $apt_content = str_replace('<i>', '<', $apt_content);
110
   $apt_content = str_replace('</i>', '>', $apt_content);
111
   $apt_content = str_replace('<h4>', '', $apt_content);
112
   $apt_content = str_replace('</h4>', '', $apt_content);
113
   $apt_content = str_replace('<h3>', '', $apt_content);
114
   $apt_content = str_replace('</h3>', '', $apt_content);
115
   $apt_content = str_replace('<ul>', '', $apt_content);
116
   $apt_content = str_replace('</ul>', '', $apt_content);
117
   $apt_content = str_replace('&amp', '&', $apt_content);
118
   $apt_content = str_replace('<li>', '*', $apt_content);
119
   $apt_content = str_replace('</li>', '', $apt_content);
120
   //special modifications
121
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/build/modules">Administer&#45&#62Site buildin&#45&#62Modules</a>',
122
   '<Administer-\>Site building-\>Modules>',
123
   $apt_content);
124
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/build/themes">Administer&#45&#62Site buildin&#45&#62Themes</a>',
125
   '<Administer-\>Site building-\>Themes>',
126
   $apt_content);
127
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal">Administer&#45&#62Site Configuration&#45&#62CDM Dataportal</a>',
128
   '<Administer-\>Site Configuration-\>CDM Dataportal>',
129
   $apt_content);
130
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/general" title="General">here</a>',
131
   '<Administer-\>Site Configuration-\>CDM Dataportal>',
132
   $apt_content);
133
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/geo" title="General">Geo &amp Map settings</a>',
134
   '<Administer-\>Site Configuration-\>CDM Dataportal-\>geo & Map>',
135
   $apt_content);
136
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/layout/search">Search Layout Settings</a>',
137
   '<Administer-\>Site Configuration-\>CDM Dataportal-\>Layout-\>Search>',
138
   $apt_content);
139
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/layout/media">Media Layout Settings</a>',
140
   '<Administer-\>Site Configuration-\>CDM Dataportal-\>Layout-\>Media>',
141
   $apt_content);
142
   //
143
   //    $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/layout/media">Media Layout Settings</a>',
144
   //                             '<Administer-\>Site Configuration-\>CDM Dataportal-\>Layout-\>Media>',
145
   //                             $apt_content);
146
   //
147

    
148
   //regular expressions
149
   $apt_content = preg_replace('/<!--.*-->/', '', $apt_content);
150
   $apt_content = preg_replace('/\<a target="(.*)" href="(.*)" title="(.*)"\>(.*)\<\/a\>/', '{{{$2}$4}}', $apt_content);
151

    
152
   $apt_file = str_replace('html', 'apt', $path);
153
   $fd = fopen($apt_file, 'w');
154
   fwrite($fd, $apt_content);
155
   fclose($fd);
156
   */
157
  return $content_result;
158
}
159

    
160
/**
161
 * See hook_theme in cdm_dataportal.module.
162
 */
163
function theme_cdm_dataportal_admin_config_cdm_dataportal_general() {
164
  $res = t('<p>Help text for this page</p>');
165
  // @WA this could also link to admin/help/cdm_dataportal_cache ?
166
  // Instead of theme_more_help_link we use a custom one here, to mimic
167
  // a D5 style link.
168
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
169
    'url' =>'admin/help/cdm_dataportal')
170
  );
171
  return $res;
172
}
173

    
174
/**
175
 * @todo Please document this function.
176
 * @see http://drupal.org/node/1354
177
 */
178
function theme_cdm_dataportal_admin_config_cdm_dataportal_geo() {
179
  $res = t('<p>Help text for this page</p>');
180
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
181
    'url' =>'admin/help/cdm_dataportal')
182
  );
183
  return $res;
184
}
185

    
186
/**
187
 * @todo Please document this function.
188
 * @see http://drupal.org/node/1354
189
 */
190
function theme_cdm_dataportal_admin_config_cdm_dataportal_layout() {
191
  $res = t('<p>Help text for this page</p>');
192
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
193
    'url' =>'admin/help/cdm_dataportal')
194
  );
195
  return $res;
196
}
197

    
198
/**
199
 * @todo Please document this function.
200
 * @see http://drupal.org/node/1354
201
 */
202
function theme_cdm_dataportal_admin_config_cdm_dataportal_cachesite() {
203
  $res = t('<p>Help text for the cache site settings page</p>');
204
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
205
    'url' =>'admin/help/cdm_dataportal')
206
  );
207
  return $res;
208
}
209

    
210
/**
211
 * Custom theme to use in admin config pages.
212
 *
213
 * Use instead of theme_more_help_link to have D5 style more-help links
214
 * instead of D7 style.
215
 *
216
 * @author w.addink <w.addink@eti.uva.nl>
217
 */
218
function theme_cdm_dataportal_admin_config_more_help_link($variables) {
219
  $html = '<div class="more-help-link cdm-dataportal-settings-more-help-link">[';
220
  $html .= l(t('more help...'), $variables['url']);
221
  $html .= ']</div>';
222
  return $html;
223
}
(13-13/15)