| 1 |
<?php |
<?php |
| 2 |
// $Id: tables.module,v 1.11 2009/06/18 11:16:19 realityloop Exp $ |
// $Id: tables.module,v 1.12 2009/06/18 11:17:22 realityloop Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 14 |
|
|
| 15 |
function tables_help($section) { |
function tables_help($section) { |
| 16 |
switch ($section) { |
switch ($section) { |
|
case 'admin/modules#description': |
|
|
return t('Filter to allow insertion of a table'); |
|
| 17 |
case 'admin/help#tables': |
case 'admin/help#tables': |
| 18 |
return t('<p>This filter module makes it easy and safe insert tables into the text of a node. '. |
return t('<p>This filter module makes it easy and safe insert tables into the text of a node. '. |
| 19 |
'<p>A table always starts with "[table". To set a custom class for the table next put in "=class" '. |
'<p>A table always starts with "[table". To set a custom class for the table next put in "=class" '. |
| 145 |
switch ($op) { |
switch ($op) { |
| 146 |
case 'list': |
case 'list': |
| 147 |
return (array(0 => t('Tables filter'))); |
return (array(0 => t('Tables filter'))); |
|
break; |
|
| 148 |
|
|
| 149 |
case 'name': |
case 'name': |
| 150 |
return t('tables filter'); |
return t('tables filter'); |
|
break; |
|
| 151 |
|
|
| 152 |
case 'description': |
case 'description': |
| 153 |
return t('converts [table ...] macros into HTML tables.'); |
return t('converts [table ...] macros into HTML tables.'); |
|
break; |
|
| 154 |
|
|
| 155 |
case 'process': |
case 'process': |
| 156 |
$tables=_tables_prepare($text); //returns an array of $tables[0] = table macro $table[1]= table html |
$tables=_tables_prepare($text); //returns an array of $tables[0] = table macro $table[1]= table html |
| 160 |
else { |
else { |
| 161 |
return $text; |
return $text; |
| 162 |
} |
} |
|
break; |
|
| 163 |
|
|
| 164 |
case 'prepare': |
case 'prepare': |
| 165 |
return $text; |
return $text; |
|
break; |
|
|
|
|
| 166 |
} |
} |
| 167 |
} |
} |
| 168 |
|
|
| 171 |
} |
} |
| 172 |
|
|
| 173 |
function tables_menu($may_cache) { |
function tables_menu($may_cache) { |
| 174 |
|
$items = array(); |
| 175 |
|
|
| 176 |
if (!$may_cache) { |
if (!$may_cache) { |
| 177 |
if ($css = variable_get('tables_css', drupal_get_path('module','tables').'/tables.css')) { |
drupal_add_css(variable_get('tables_css', drupal_get_path('module','tables'). '/tables.css')); |
| 178 |
theme('add_style', $css); |
|
| 179 |
} |
$items[] = array( |
| 180 |
|
'path' => 'admin/settings/tables', |
| 181 |
|
'title' => t('Tables Filter'), |
| 182 |
|
'description' => t('Filter to allow insertion of a table'), |
| 183 |
|
'callback' => 'drupal_get_form', |
| 184 |
|
'callback arguments' => array('tables_admin_settings'), |
| 185 |
|
'access' => user_access('administer site configuration'), |
| 186 |
|
); |
| 187 |
} |
} |
| 188 |
return array(); |
|
| 189 |
|
return $items; |
| 190 |
} |
} |
| 191 |
|
|
| 192 |
function tables_settings() { |
function tables_admin_settings() { |
| 193 |
if (!file_check_location(variable_get('tables_css', drupal_get_path('module','tables').'/tables.css'))) { |
if (!file_check_location(variable_get('tables_css', drupal_get_path('module','tables').'/tables.css'))) { |
| 194 |
$error['tables_css'] = theme('error', t('File does not exist, or is not readable.')); |
$error['tables_css'] = theme('error', t('File does not exist, or is not readable.')); |
| 195 |
} |
} |
| 196 |
$form["tables_css"] = array('#type' => 'textfield', |
$form['tables_css'] = array( |
| 197 |
'#title' => t('Style Sheet'), |
'#type' => 'textfield', |
| 198 |
'#default_value' => variable_get('tables_css', drupal_get_path('module','tables').'/tables.css'), |
'#title' => t('Style Sheet'), |
| 199 |
'#size' => 70, |
'#default_value' => variable_get('tables_css', drupal_get_path('module','tables').'/tables.css'), |
| 200 |
'#maxlength' => 255, |
'#size' => 70, |
| 201 |
'#description' => t("Specify the relative path to your tables style sheet. The style sheet specified here will be used to style tables you insert. If you prefer to style your tables in your theme, you can leave this field blank. ". $error['tables_css']), |
'#maxlength' => 255, |
| 202 |
); |
'#description' => t('Specify the relative path to your tables style sheet. The style sheet specified here will be used to style tables you insert. If you prefer to style your tables in your theme, you can leave this field blank.'), |
| 203 |
|
); |
| 204 |
$form["tables_default_style"] = array('#type' => 'textfield', |
|
| 205 |
'#title' => t('Default style'), |
$form['tables_default_style'] = array( |
| 206 |
'#default_value' => variable_get('tables_default_style', 'tables-elegant'), |
'#type' => 'textfield', |
| 207 |
'#size' => 70, |
'#title' => t('Default style'), |
| 208 |
'#maxlength' => 255, |
'#default_value' => variable_get('tables_default_style', 'tables-elegant'), |
| 209 |
'#description' => t("Set the default style sheet to use if no style sheet is set in the specific table. "), |
'#size' => 70, |
| 210 |
); |
'#maxlength' => 255, |
| 211 |
|
'#description' => t('Set the default style sheet to use if no style sheet is set in the specific table.'), |
| 212 |
|
); |
| 213 |
|
|
| 214 |
return $form; |
return system_settings_form($form); |
| 215 |
} |
} |