| 1 |
<?php |
<?php |
| 2 |
// $Id: freemind.module,v 1.0.0.0 2005/09/30 02:00:18 guesclin Exp $ |
// $Id: freemind.module,v 1.1 2005/12/12 21:32:09 joelguesclin Exp $ |
| 3 |
/* |
/* |
| 4 |
* Acknowledgments: this module could not have been produced without |
* Acknowledgments: this module could not have been produced without |
| 5 |
* liberal hacking from the taxonomy_dhtml module: thanks to weitzman |
* liberal hacking from the taxonomy_dhtml module: thanks to weitzman |
| 6 |
*/ |
*/ |
| 7 |
|
|
| 8 |
/* |
/* |
| 9 |
|
* this has been hacked to work with drupal v4.7.0 |
| 10 |
|
*/ |
| 11 |
|
|
| 12 |
|
/* |
| 13 |
* Module to render vocabularies in freemind node format |
* Module to render vocabularies in freemind node format |
| 14 |
*/ |
*/ |
| 15 |
function freemind_format($fr_overview_vocab, $fr_description, $fr_taxlinks, $fr_nodes, $fr_teasers) { |
function freemind_format($fr_overview_vocab, $fr_description, $fr_taxlinks, $fr_nodes, $fr_teasers) { |
| 74 |
$term = $tree[$i]; |
$term = $tree[$i]; |
| 75 |
/* restrict to a single type if given */ |
/* restrict to a single type if given */ |
| 76 |
$type_q = ($type ? " AND n.type = '$type'" : ""); |
$type_q = ($type ? " AND n.type = '$type'" : ""); |
| 77 |
$result = db_query_range("SELECT n.nid, n.title, n.type, n.teaser, u.uid, u.name FROM {term_node} r LEFT JOIN {node} n ON r.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid WHERE n.status = '1' $type_q AND r.tid = '$term->tid' ORDER BY n.changed DESC", 0, variable_get("freemind_overview_count", 50)); |
$result = db_query_range("SELECT n.nid, n.title, n.type, u.uid, u.name FROM {term_node} r LEFT JOIN {node} n ON r.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid WHERE n.status = '1' $type_q AND r.tid = '$term->tid' ORDER BY n.changed DESC", 0, variable_get("freemind_overview_count", 50)); |
| 78 |
while ($node = db_fetch_object($result)) { |
while ($node = db_fetch_object($result)) { |
| 79 |
$link = l($node->title, "node/$node->nid", array ("title" => $detail, "class" => "dhtml_node")); |
$link = l($node->title, "node/$node->nid", array ("title" => $detail, "class" => "dhtml_node")); |
| 80 |
// this line modified to include title and teaser |
// this line modified to include title |
| 81 |
$term_node = array2object(array ("nid" => $node->nid, "depth" => $term->depth+1, "link" => $link, "title" => $node->title, "teaser" => $node->teaser)); |
$term_node = (object) array ("nid" => $node->nid, "depth" => $term->depth+1, "link" => $link, "title" => $node->title, "teaser" => $node->teaser); |
| 82 |
$part1 = array_slice($tree_node, 0, $i+1); |
$part1 = array_slice($tree_node, 0, $i+1); |
| 83 |
$part2 = array_slice($tree_node, $i+1, count($tree_node)); |
$part2 = array_slice($tree_node, $i+1, count($tree_node)); |
| 84 |
$part1[] = $term_node; |
$part1[] = $term_node; |
| 97 |
$desc = ''; |
$desc = ''; |
| 98 |
if ($description != '') { |
if ($description != '') { |
| 99 |
$desc = '<node COLOR="#999999" TEXT="desc" '.($desc_var == 'folded' ? 'FOLDED="true"' : 'FOLDED="false"' ).'><font NAME="Default" SIZE="10"/>'; |
$desc = '<node COLOR="#999999" TEXT="desc" '.($desc_var == 'folded' ? 'FOLDED="true"' : 'FOLDED="false"' ).'><font NAME="Default" SIZE="10"/>'; |
| 100 |
$output .= "\r\n"; |
$desc .= "\r\n"; |
| 101 |
$desc .= '<node COLOR="#339900" TEXT="'.freemind_strings($description).'" STYLE="bubble"><edge COLOR="#999999" WIDTH="thin" STYLE="bezier"/><font NAME="Default" SIZE="10"/>'; |
$desc .= '<node COLOR="#339900" TEXT="'.freemind_strings($description).'" STYLE="bubble"><edge COLOR="#999999" WIDTH="thin" STYLE="bezier"/><font NAME="Default" SIZE="10"/>'; |
| 102 |
$output .= "\r\n"; |
$desc .= "\r\n"; |
| 103 |
$desc .= "</node>\r\n</node>\r\n"; |
$desc .= "</node>"; |
| 104 |
$output .= "\r\n"; |
$desc .= "\r\n"; |
| 105 |
|
$desc .= "</node>"; |
| 106 |
|
$desc .= "\r\n"; |
| 107 |
} |
} |
| 108 |
return $desc; |
return $desc; |
| 109 |
|
|
| 181 |
$desc_var = $fr_description; |
$desc_var = $fr_description; |
| 182 |
$taxlinks = ($fr_taxlinks == 1); |
$taxlinks = ($fr_taxlinks == 1); |
| 183 |
$nodes = ($fr_nodes == 1); |
$nodes = ($fr_nodes == 1); |
| 184 |
$teasers = ($fr_teasers == 1); |
$teasers = 0; |
| 185 |
$old_depth = -1; |
$old_depth = -1; |
| 186 |
$output = ""; |
$output = ""; |
| 187 |
for ($m = 0; $m < count($tree); $m++) { |
for ($m = 0; $m < count($tree); $m++) { |
| 237 |
if (!file_check_directory(file_create_path(variable_get('freemind_path', 'freemind')), FILE_CREATE_DIRECTORY)) { |
if (!file_check_directory(file_create_path(variable_get('freemind_path', 'freemind')), FILE_CREATE_DIRECTORY)) { |
| 238 |
$error = theme('warning', t('The script directory does not exist, or is not writable. The freemind module will not work in cron mode until you resolve this error.')); |
$error = theme('warning', t('The script directory does not exist, or is not writable. The freemind module will not work in cron mode until you resolve this error.')); |
| 239 |
} |
} |
| 240 |
|
$group1name = 'freemind_settings'; |
| 241 |
$output .= form_group(t("Default Freemind map settings"),freemind_get_settings($select),t("If you generate the map via a cron job, then these settings will be used. If you generate the map on-line, then these are default settings which can be modified")); |
$form1[$group1name] = array( |
| 242 |
$output .= form_group(t("Freemind server settings"),freemind_get_cron_settings(),t("Server file and cron settings")); |
'#type' => 'fieldset', |
| 243 |
$output .= form_group(t("Site map display settings"),freemind_get_map_settings(),t("Settings for display of the site map in Java applet or Flash viewer")); |
'#title' => t('Default Freemind map settings'), |
| 244 |
return $output; |
'#description' => t('If you generate the map via a cron job, then these settings will be used. If you generate the map on-line, then these are default settings which can be modified'), |
| 245 |
|
'#collapsible' => TRUE, |
| 246 |
|
'#collapsed' => FALSE, |
| 247 |
|
); |
| 248 |
|
$get1 = freemind_get_settings($group1name); |
| 249 |
|
$group2name = 'freemind_server_settings'; |
| 250 |
|
$form2[$group2name] = array( |
| 251 |
|
'#type' => 'fieldset', |
| 252 |
|
'#title' => t('Freemind server settings'), |
| 253 |
|
'#description' => t('Server file and cron settings'), |
| 254 |
|
'#collapsible' => TRUE, |
| 255 |
|
'#collapsed' => FALSE, |
| 256 |
|
); |
| 257 |
|
$get2 = freemind_get_cron_settings($group2name); |
| 258 |
|
$group3name = 'freemind_map_settings'; |
| 259 |
|
$form3[$group3name] = array( |
| 260 |
|
'#type' => 'fieldset', |
| 261 |
|
'#title' => t('Site map display settings'), |
| 262 |
|
'#description' => t('Settings for display of the site map in Java applet or Flash viewer'), |
| 263 |
|
'#collapsible' => TRUE, |
| 264 |
|
'#collapsed' => FALSE, |
| 265 |
|
); |
| 266 |
|
$get3 = freemind_get_map_settings($group3name); |
| 267 |
|
$form = array_merge_recursive($form1, $get1, $form2, $get2, $form3, $get3); |
| 268 |
|
return $form; |
| 269 |
} |
} |
| 270 |
|
|
| 271 |
function freemind_get_settings() { |
function freemind_get_settings($groupname, $select="") { |
| 272 |
$vocabularies = taxonomy_get_vocabularies(); |
$vocabularies = taxonomy_get_vocabularies(); |
| 273 |
$select[0] = "<". t("none") .">"; |
$select[0] = "<". t("none") .">"; |
| 274 |
foreach ($vocabularies as $vocabulary) { |
foreach ($vocabularies as $vocabulary) { |
| 275 |
$select[$vocabulary->vid] = $vocabulary->name; |
$select[$vocabulary->vid] = $vocabulary->name; |
| 276 |
} |
} |
| 277 |
$output = form_select(t("Omitted vocabularies"), "freemind_overview_vocab", variable_get("freemind_overview_vocab", array()), $select, t("Select vocabularies which should be <b>omitted</b> from listings."), "", 1); |
$form[$groupname]['freemind_overview_vocab'] = array( |
| 278 |
$output .= form_select('Type of map produced', 'freemind_maptype', variable_get("freemind_maptype",'display'), array('full' => 'Include vocabulary attributes', 'display' => 'Generate display only'), "A 'display only' map is suitable for mapping the content of the site and is usually the most suitable choice. A 'vocabulary attributes' map is intended to allow freemind to be used, in a later version, as a graphical taxonomy manipulation tool", 0, $multiple = FALSE, $required = TRUE); |
'#type' => 'select', |
| 279 |
$output .= form_select('Description inclusion', 'freemind_description', variable_get("freemind_description",'folded'), array('none' => 'No descriptions in map', 'folded' => 'Descriptions folded by default', 'unfolded' => 'Descriptions unfolded by default'), "This choice applies to taxonomy descriptions, which may be either left out of the map, included as folded nodes or included as unfolded nodes", 0, $multiple = FALSE, $required = TRUE); |
'#title' => t('Omitted vocabularies'), |
| 280 |
$output .= form_checkbox(t("Include taxonomy links?"), "freemind_taxlinks", 1, (variable_get("freemind_taxlinks", 0 )), t("Check this box to have links included in the map for each taxonomy term; otherwise, only nodes will show links, if selected"), NULL, FALSE); |
'#default_value' => variable_get("freemind_overview_vocab", array()), |
| 281 |
$output .= form_checkbox(t("Include nodes?"), "freemind_nodes", 1, (variable_get("freemind_nodes", 0 )), t("Check this box to have nodes included in the map"), NULL, FALSE); |
'#options' => $select, |
| 282 |
$output .= form_checkbox(t("Include node teasers?"), "freemind_teasers", 1, (variable_get("freemind_teasers", 0 )), t("Check this box to have node teasers included in the map as folded descriptions"), NULL, FALSE); |
'#description' => t('Select vocabularies which should be <b>omitted</b> from listings.'), |
| 283 |
$output .= form_checkbox(t("Include Logo?"), "freemind_logo", 1, (variable_get("freemind_logo", 0 )), t("Check this box to have a logo included in the centre of the map (logo must be loaded to modules/freemind/logo.gif"), NULL, FALSE); |
'#multiple' => TRUE, |
| 284 |
$output .= form_textfield(t("Map title"), "freemind_server_title", (variable_get("freemind_server_title", "Site Map")), 50, 80, "Name for the map's central node. Note required if a logo is used instead", NULL, FALSE); |
'#required' => FALSE, |
| 285 |
|
); |
| 286 |
return $output; |
$form[$groupname]['freemind_maptype'] = array( |
| 287 |
|
'#type' => 'select', |
| 288 |
|
'#title' => t('Type of map produced'), |
| 289 |
|
'#default_value' => variable_get("freemind_maptype", 'display'), |
| 290 |
|
'#options' => array('full' => 'Include vocabulary attributes', 'display' => 'Generate display only'), |
| 291 |
|
'#description' => t("A 'display only' map is suitable for mapping the content of the site and is usually the most suitable choice. A 'vocabulary attributes' map is intended to allow freemind to be used, in a later version, as a graphical taxonomy manipulation tool"), |
| 292 |
|
'#multiple' => FALSE, |
| 293 |
|
'#required' => TRUE, |
| 294 |
|
); |
| 295 |
|
$form[$groupname]['freemind_taxlinks'] = array( |
| 296 |
|
'#type' => 'checkbox', |
| 297 |
|
'#title' => t('Include taxonomy links?'), |
| 298 |
|
'#default_value' => variable_get('freemind_taxlinks', 0), |
| 299 |
|
'#description' => t("Check this box to have links included in the map for each taxonomy term; otherwise, only nodes will show links, if selected"), |
| 300 |
|
'#return_value' => 1, |
| 301 |
|
'#required' => FALSE, |
| 302 |
|
); |
| 303 |
|
$form[$groupname]['freemind_nodes'] = array( |
| 304 |
|
'#type' => 'checkbox', |
| 305 |
|
'#title' => t('Include nodes?'), |
| 306 |
|
'#default_value' => variable_get('freemind_nodes', 0), |
| 307 |
|
'#description' => t("Check this box to have nodes included in the map"), |
| 308 |
|
'#return_value' => 1, |
| 309 |
|
'#required' => FALSE, |
| 310 |
|
); |
| 311 |
|
$form[$groupname]['freemind_logo'] = array( |
| 312 |
|
'#type' => 'checkbox', |
| 313 |
|
'#title' => t('Include Logo?'), |
| 314 |
|
'#default_value' => variable_get('freemind_logo', 0), |
| 315 |
|
'#description' => t("Check this box to have a logo included in the centre of the map (logo must be loaded to modules/freemind/logo.gif"), |
| 316 |
|
'#return_value' => 1, |
| 317 |
|
'#required' => FALSE, |
| 318 |
|
); |
| 319 |
|
$form[$groupname]['freemind_server_title'] = array( |
| 320 |
|
'#type' => 'textfield', |
| 321 |
|
'#title' => t('Map title'), |
| 322 |
|
'#size' => 50, |
| 323 |
|
'#maxlength' => 80, |
| 324 |
|
'#default_value' => variable_get("freemind_server_title", "Site Map"), |
| 325 |
|
'#description' => t("Name for the map's central node. Note required if a logo is used instead"), |
| 326 |
|
'#required' => TRUE, |
| 327 |
|
); |
| 328 |
|
return $form; |
| 329 |
} |
} |
| 330 |
|
|
| 331 |
/* |
/* |
| 332 |
* Format the settings for cron jobs and server files |
* Format the settings for cron jobs and server files |
| 333 |
*/ |
*/ |
| 334 |
function freemind_get_cron_settings() { |
function freemind_get_cron_settings($groupname) { |
| 335 |
$output = form_checkbox(t("Produce Freemind map in cron run?"), "freemind_cron", 1, (variable_get("freemind_cron", 0 )), t("Check this box to have Drupal's cron run produce the Freemind map. In this case you must make sure that the default server file name is included in the configuration (see below)"), NULL, FALSE); |
|
| 336 |
$output .= form_textfield(t("File path name"), "freemind_path", (variable_get("freemind_path", "freemind")), 50, 80, "The path name for maps produced on the server. Should be present if cron is set to produce maps", NULL, TRUE); |
$form[$groupname]['freemind_cron'] = array( |
| 337 |
$output .= form_textfield(t("Default server file name"), "freemind_server_file", (variable_get("freemind_server_file", "index.mm")), 50, 80, "The default file name for maps produced on the server. Should be present if cron is set to produce maps", NULL, TRUE); |
'#type' => 'checkbox', |
| 338 |
return $output; |
'#title' => t('Produce Freemind map in cron run?'), |
| 339 |
|
'#default_value' => variable_get('freemind_cron', 0), |
| 340 |
|
'#description' => t("Check this box to have Drupal's cron run produce the Freemind map. In this case you must make sure that the default server file name is included in the configuration (see below)"), |
| 341 |
|
'#return_value' => 1, |
| 342 |
|
'#required' => FALSE, |
| 343 |
|
); |
| 344 |
|
$form[$groupname]['freemind_path'] = array( |
| 345 |
|
'#type' => 'textfield', |
| 346 |
|
'#title' => t('File path name'), |
| 347 |
|
'#size' => 50, |
| 348 |
|
'#maxlength' => 80, |
| 349 |
|
'#default_value' => variable_get("freemind_path", "freemind"), |
| 350 |
|
'#description' => t("The path name for maps produced on the server. Should be present if cron is set to produce maps"), |
| 351 |
|
'#required' => TRUE, |
| 352 |
|
); |
| 353 |
|
|
| 354 |
|
$form[$groupname]['freemind_server_file'] = array( |
| 355 |
|
'#type' => 'textfield', |
| 356 |
|
'#title' => t('Default server file name'), |
| 357 |
|
'#size' => 50, |
| 358 |
|
'#maxlength' => 80, |
| 359 |
|
'#default_value' => variable_get("freemind_server_file", "index.mm"), |
| 360 |
|
'#description' => t("The default file name for maps produced on the server. Should be present if cron is set to produce maps"), |
| 361 |
|
'#required' => TRUE, |
| 362 |
|
); |
| 363 |
|
|
| 364 |
|
return $form; |
| 365 |
} |
} |
| 366 |
|
|
| 367 |
/* |
/* |
| 368 |
* Format the settings for Java applet and flash map display |
* Format the settings for Java applet and flash map display |
| 369 |
*/ |
*/ |
| 370 |
function freemind_get_map_settings() { |
function freemind_get_map_settings($groupname) { |
| 371 |
$output .= form_textfield(t("Freemind Java map"), "freemind_java", (variable_get("freemind_java", variable_get("file_directory_path",'').'/'.variable_get('freemind_path', 'freemind').'/sitemapjava.html')), 50, 80, "Fully qualified path to html page for displaying site maps in Java applet. This is only useful if there are users who have Java map permissions, in which case they will see the link in their navigation menu", NULL, FALSE); |
|
| 372 |
$output .= form_textfield(t("Freemind Flash map"), "freemind_flash", (variable_get("freemind_flash", variable_get("file_directory_path",'').'/'.variable_get('freemind_path', 'freemind').'/sitemapflash.html')), 50, 80, "Fully qualified path to html page for displaying site maps in Flash viewer. This is only useful if there are users who have Flash map permissions, in which case they will see the link in their navigation menu", NULL, FALSE); |
$form[$groupname]['freemind_java'] = array( |
| 373 |
return $output; |
'#type' => 'textfield', |
| 374 |
|
'#title' => t('Freemind Java map'), |
| 375 |
|
'#size' => 50, |
| 376 |
|
'#maxlength' => 80, |
| 377 |
|
'#default_value' => (variable_get("freemind_java", variable_get("file_directory_path",'').'/'.variable_get('freemind_path', 'freemind').'/sitemapjava.html')), |
| 378 |
|
'#description' => t("Fully qualified path to html page for displaying site maps in Java applet. This is only useful if there are users who have Java map permissions, in which case they will see the link in their navigation menu"), |
| 379 |
|
'#required' => FALSE, |
| 380 |
|
); |
| 381 |
|
$form[$groupname]['freemind_flash'] = array( |
| 382 |
|
'#type' => 'textfield', |
| 383 |
|
'#title' => t('Freemind Flash map'), |
| 384 |
|
'#size' => 50, |
| 385 |
|
'#maxlength' => 80, |
| 386 |
|
'#default_value' => (variable_get("freemind_flash", variable_get("file_directory_path",'').'/'.variable_get('freemind_path', 'freemind').'/sitemapflash.html')), |
| 387 |
|
'#description' => t("Fully qualified path to html page for displaying site maps in Flash viewer. This is only useful if there are users who have Flash map permissions, in which case they will see the link in their navigation menu"), |
| 388 |
|
'#required' => FALSE, |
| 389 |
|
); |
| 390 |
|
return $form; |
| 391 |
} |
} |
| 392 |
|
|
| 393 |
// Format an attribute node |
// Format an attribute node |
| 474 |
if (!$op || $op == t('Change file')) { |
if (!$op || $op == t('Change file')) { |
| 475 |
$output = t("You can use this page to modify the default settings for the site map if you wish"); |
$output = t("You can use this page to modify the default settings for the site map if you wish"); |
| 476 |
if (user_access('create map')) { |
if (user_access('create map')) { |
| 477 |
$form = form_group('Select server or download to workstation',form_radios(t(""), "freemind_where", "server", array("server" => t("Build site map on the server"), "download" => t("Download site map to workstation")), t("If you select the sitemap on the server, then you must provide a file name"), TRUE )); |
$form['freemind_select_map'] = array( |
| 478 |
|
'#type' => 'fieldset', |
| 479 |
|
'#title' => t('Select server or download to workstation'), |
| 480 |
|
'#description' => t('If you select the sitemap on the server, then you must provide a file name'), |
| 481 |
|
); |
| 482 |
|
$form['freemind_select_map']['freemind_where'] = array( |
| 483 |
|
'#type' => 'radios', |
| 484 |
|
'#title' => t(''), |
| 485 |
|
'#default_value' => 'server', |
| 486 |
|
'#options' => array( |
| 487 |
|
"server" => t("Build site map on the server"), |
| 488 |
|
"download" => t("Download site map to workstation")), |
| 489 |
|
'#required' => TRUE, |
| 490 |
|
'#collapsible' => FALSE, |
| 491 |
|
'#collapsed' => FALSE, |
| 492 |
|
); |
| 493 |
} |
} |
| 494 |
else { |
else { |
| 495 |
$form = form_hidden('freemind_where','download'); |
$form['freemind_where'] = array( |
| 496 |
|
'#type' => 'hidden', |
| 497 |
|
'#default_value' => 'download', |
| 498 |
|
); |
| 499 |
} |
} |
| 500 |
$form .= form_group(t("Default Freemind map settings"),freemind_get_settings($select). form_textfield(t("File name on server"), "freemind_server_file", (variable_get("freemind_server_file", "index.mm")), 50, 80, "The file will be created in : ".file_create_path(variable_get('freemind_path', 'freemind'), NULL, TRUE)),t("You can modify these settings for your map")); |
$form['default_freemind_map_settings'] = array( |
| 501 |
|
'#type' => 'fieldset', |
| 502 |
$form .= form_button(t('Generate map')); |
'#title' => t('Default Freemind map settings'), |
| 503 |
$output .= form($form); |
'#description' => t("You can modify these settings for your map"), |
| 504 |
|
'#collapsible' => FALSE, |
| 505 |
|
'#collapsed' => FALSE, |
| 506 |
|
); |
| 507 |
|
$get1 = freemind_get_settings('default_freemind_map_settings', $select); |
| 508 |
|
$form = array_merge_recursive($form, $get1); |
| 509 |
|
$form['default_freemind_map_settings']['freemind_server_file'] = array( |
| 510 |
|
'#type' => 'textfield', |
| 511 |
|
'#title' => t('File name on server'), |
| 512 |
|
'#size' => 50, |
| 513 |
|
'#maxlength' => 80, |
| 514 |
|
'#default_value' => variable_get("freemind_server_file", "index.mm"), |
| 515 |
|
'#description' => "The file will be created in : ".file_create_path(variable_get('freemind_path', 'freemind')), |
| 516 |
|
'#required' => TRUE, |
| 517 |
|
); |
| 518 |
|
$form['default_freemind_map_settings']['submit'] = array( |
| 519 |
|
'#type' => 'submit', |
| 520 |
|
"#value" => t('Generate map'), |
| 521 |
|
); |
| 522 |
|
$form['#method'] = 'post'; |
| 523 |
|
$output = drupal_get_form('freemind_map_settings', $form); |
| 524 |
} |
} |
| 525 |
else { |
else { |
| 526 |
// print "edit<br>"; |
// print "edit<br>"; |
| 545 |
else { |
else { |
| 546 |
$output = "The new file was built ok"; |
$output = "The new file was built ok"; |
| 547 |
} |
} |
|
// } |
|
| 548 |
} |
} |
| 549 |
print theme("page",$output); |
print theme("page",$output); |
|
|
|
|
|
|
|
|
|
| 550 |
} |
} |
| 551 |
|
|
| 552 |
function freemind_build($fr_overview_vocab, $fr_maptype, $fr_description, $fr_taxlinks, $fr_nodes, $fr_teasers, $fr_logo, $fr_server_title, $file_name) { |
function freemind_build($fr_overview_vocab, $fr_maptype, $fr_description, $fr_taxlinks, $fr_nodes, $fr_teasers, $fr_logo, $fr_server_title, $file_name) { |