Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / 7.x / modules / cdm_dataportal / help.php @ 72032ea6

History | View | Annotate | Download (7.96 KB)

1 6657531f Andreas Kohlbecker
<?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
19
/**
20
 * Used in cdm_dataportal.module.
21
 */
22
function cdm_dataportal_menu_help(&$items) {
23
24
  $items['admin/help/cdm_dataportal_general'] = array(
25
    'title' => 'general',
26
    'page callback' => 'cdm_dataportal_file_get_content',
27
    'page arguments' => array(HELP_SETTINGS_GENERAL),
28
    'access callback' => 'user_is_logged_in',
29
    'type' => MENU_LOCAL_TASK,
30
  );
31
32
  $items['admin/help/cdm_dataportal_geo'] = array(
33
    'title' => 'geo',
34
    'page callback' => 'cdm_dataportal_file_get_content',
35
    'page arguments' => array(HELP_SETTINGS_GEO),
36
    'access callback' => 'user_is_logged_in',
37
    'type' => MENU_LOCAL_TASK,
38
  );
39
40
  $items['admin/help/cdm_dataportal_layout'] = array(
41
    'title' => 'layout',
42
    'page callback' => 'cdm_dataportal_file_get_content',
43
    'page arguments' => array(HELP_SETTINGS_LAYOUT),
44
    'access callback' => 'user_is_logged_in',
45
    'type' => MENU_LOCAL_TASK,
46
  );
47
48
  $items['admin/help/cdm_dataportal_cache'] = array(
49
    'title' => 'cache',
50
    'page callback' => 'cdm_dataportal_file_get_content',
51
    'page arguments' => array(HELP_SETTINGS_CACHE),
52
    'access callback' => 'user_is_logged_in',
53
    'type' => MENU_LOCAL_TASK,
54
  );
55
}
56
57
/**
58
 * Implements hook_help().
59
 */
60
function cdm_dataportal_help($path, $arg) {
61
  // Result to return.
62
  $res = '';
63
64
  switch ($path) {
65
    case 'admin/help#cdm_dataportal':
66
      // $popup = (module_exists('advanced_help')) ? theme('advanced_help_topic', 'cdm_help', 'website-overview') : '';
67
      // var_dump($popup);
68
      $content = cdm_dataportal_file_get_content(HELP_OVERVIEW);
69
      $res = $content;
70
      break;
71
72
    default:
73
      $path_aux = str_replace('/', '_', $path);
74
      if (function_exists('theme_cdm_portal_' . $path_aux)) {
75
        $res = theme('cdm_dataportal_' . $path_aux, array());
76
      }
77
  }
78
79
  return $res;
80
}
81
82
/**
83
 * @todo Please document this function.
84
 * @see http://drupal.org/node/1354
85
 */
86
function cdm_dataportal_file_get_content($path) {
87
88
  // Modifing the html file to get the drupal paths.
89
  $content = file_get_contents($path);
90
  $content_result = str_replace("{MODULE_PATH}", file_build_uri($path), $content);
91
92
  /* XXXXX change made because of problems with SVN!!! XXXXX
93
   //converting from html to apt for maven documentation
94
   $apt_content = $content_result;
95
   //general modifications
96
   $apt_content = str_replace('<p>', '', $apt_content);
97
   $apt_content = str_replace('</p>', '', $apt_content);
98
   $apt_content = str_replace('<b>', '<<', $apt_content);
99
   $apt_content = str_replace('</b>', '>>', $apt_content);
100
   $apt_content = str_replace('<i>', '<', $apt_content);
101
   $apt_content = str_replace('</i>', '>', $apt_content);
102
   $apt_content = str_replace('<h4>', '', $apt_content);
103
   $apt_content = str_replace('</h4>', '', $apt_content);
104
   $apt_content = str_replace('<h3>', '', $apt_content);
105
   $apt_content = str_replace('</h3>', '', $apt_content);
106
   $apt_content = str_replace('<ul>', '', $apt_content);
107
   $apt_content = str_replace('</ul>', '', $apt_content);
108
   $apt_content = str_replace('&amp', '&', $apt_content);
109
   $apt_content = str_replace('<li>', '*', $apt_content);
110
   $apt_content = str_replace('</li>', '', $apt_content);
111
   //special modifications
112
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/build/modules">Administer&#45&#62Site buildin&#45&#62Modules</a>',
113
   '<Administer-\>Site building-\>Modules>',
114
   $apt_content);
115
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/build/themes">Administer&#45&#62Site buildin&#45&#62Themes</a>',
116
   '<Administer-\>Site building-\>Themes>',
117
   $apt_content);
118
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal">Administer&#45&#62Site Configuration&#45&#62CDM Dataportal</a>',
119
   '<Administer-\>Site Configuration-\>CDM Dataportal>',
120
   $apt_content);
121
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/general" title="General">here</a>',
122
   '<Administer-\>Site Configuration-\>CDM Dataportal>',
123
   $apt_content);
124
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/geo" title="General">Geo &amp Map settings</a>',
125
   '<Administer-\>Site Configuration-\>CDM Dataportal-\>geo & Map>',
126
   $apt_content);
127
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/layout/search">Search Layout Settings</a>',
128
   '<Administer-\>Site Configuration-\>CDM Dataportal-\>Layout-\>Search>',
129
   $apt_content);
130
   $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/layout/media">Media Layout Settings</a>',
131
   '<Administer-\>Site Configuration-\>CDM Dataportal-\>Layout-\>Media>',
132
   $apt_content);
133
   //
134
   //    $apt_content = str_replace('<a target="_blank" href="./?q=admin/settings/cdm_dataportal/layout/media">Media Layout Settings</a>',
135
   //                             '<Administer-\>Site Configuration-\>CDM Dataportal-\>Layout-\>Media>',
136
   //                             $apt_content);
137
   //
138

139
   //regular expressions
140
   $apt_content = preg_replace('/<!--.*-->/', '', $apt_content);
141
   $apt_content = preg_replace('/\<a target="(.*)" href="(.*)" title="(.*)"\>(.*)\<\/a\>/', '{{{$2}$4}}', $apt_content);
142

143
   $apt_file = str_replace('html', 'apt', $path);
144
   $fd = fopen($apt_file, 'w');
145
   fwrite($fd, $apt_content);
146
   fclose($fd);
147
   */
148
  return $content_result;
149
}
150
151
/**
152
 * See hook_theme in cdm_dataportal.module.
153
 */
154
function theme_cdm_dataportal_admin_config_cdm_dataportal_general() {
155
  $res = t('<p>Help text for this page</p>');
156
  // @WA this could also link to admin/help/cdm_dataportal_cache ?
157
  // Instead of theme_more_help_link we use a custom one here, to mimic
158
  // a D5 style link.
159
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
160
    'url' =>'admin/help/cdm_dataportal')
161
  );
162
  return $res;
163
}
164
165
/**
166
 * @todo Please document this function.
167
 * @see http://drupal.org/node/1354
168
 */
169
function theme_cdm_dataportal_admin_config_cdm_dataportal_geo() {
170
  $res = t('<p>Help text for this page</p>');
171
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
172
    'url' =>'admin/help/cdm_dataportal')
173
  );
174
  return $res;
175
}
176
177
/**
178
 * @todo Please document this function.
179
 * @see http://drupal.org/node/1354
180
 */
181
function theme_cdm_dataportal_admin_config_cdm_dataportal_layout() {
182
  $res = t('<p>Help text for this page</p>');
183
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
184
    'url' =>'admin/help/cdm_dataportal')
185
  );
186
  return $res;
187
}
188
189
/**
190
 * @todo Please document this function.
191
 * @see http://drupal.org/node/1354
192
 */
193
function theme_cdm_dataportal_admin_config_cdm_dataportal_cachesite() {
194
  $res = t('<p>Help text for the cache site settings page</p>');
195
  $res .= theme('cdm_dataportal_admin_config_more_help_link', array(
196
    'url' =>'admin/help/cdm_dataportal')
197
  );
198
  return $res;
199
}
200
201
/**
202
 * Custom theme to use in admin config pages.
203
 *
204
 * Use instead of theme_more_help_link to have D5 style more-help links
205
 * instead of D7 style.
206
 *
207
 * @author w.addink <w.addink@eti.uva.nl>
208
 */
209
function theme_cdm_dataportal_admin_config_more_help_link($variables) {
210
  $html = '<div class="more-help-link cdm-dataportal-settings-more-help-link">[';
211
  $html .= l(t('more help...'), $variables['url']);
212
  $html .= ']</div>';
213
  return $html;
214
}
Add picture from clipboard (Maximum size: 40 MB)