--- freemind.module.old 2005-12-12 21:32:09.000000000 +0000
+++ /home/hutch/tmp/patches/freemind.module 2006-05-15 19:46:11.000000000 +0100
@@ -6,6 +6,10 @@
*/
/*
+ * this has been hacked to work with drupal v4.7.0
+ */
+
+/*
* Module to render vocabularies in freemind node format
*/
function freemind_format($fr_overview_vocab, $fr_description, $fr_taxlinks, $fr_nodes, $fr_teasers) {
@@ -70,11 +74,11 @@
$term = $tree[$i];
/* restrict to a single type if given */
$type_q = ($type ? " AND n.type = '$type'" : "");
- $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));
while ($node = db_fetch_object($result)) {
$link = l($node->title, "node/$node->nid", array ("title" => $detail, "class" => "dhtml_node"));
-// this line modified to include title and teaser
- $term_node = array2object(array ("nid" => $node->nid, "depth" => $term->depth+1, "link" => $link, "title" => $node->title, "teaser" => $node->teaser));
+// this line modified to include title
+ $term_node = (object) array ("nid" => $node->nid, "depth" => $term->depth+1, "link" => $link, "title" => $node->title, "teaser" => $node->teaser);
$part1 = array_slice($tree_node, 0, $i+1);
$part2 = array_slice($tree_node, $i+1, count($tree_node));
$part1[] = $term_node;
@@ -93,11 +97,13 @@
$desc = '';
if ($description != '') {
$desc = '';
- $output .= "\r\n";
+ $desc .= "\r\n";
$desc .= '';
- $output .= "\r\n";
- $desc .= "\r\n\r\n";
- $output .= "\r\n";
+ $desc .= "\r\n";
+ $desc .= "";
+ $desc .= "\r\n";
+ $desc .= "";
+ $desc .= "\r\n";
}
return $desc;
@@ -175,7 +182,7 @@
$desc_var = $fr_description;
$taxlinks = ($fr_taxlinks == 1);
$nodes = ($fr_nodes == 1);
- $teasers = ($fr_teasers == 1);
+ $teasers = 0;
$old_depth = -1;
$output = "";
for ($m = 0; $m < count($tree); $m++) {
@@ -231,48 +238,157 @@
if (!file_check_directory(file_create_path(variable_get('freemind_path', 'freemind')), FILE_CREATE_DIRECTORY)) {
$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.'));
}
-
- $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"));
- $output .= form_group(t("Freemind server settings"),freemind_get_cron_settings(),t("Server file and cron settings"));
- $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"));
- return $output;
+ $group1name = 'freemind_settings';
+ $form1[$group1name] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Default Freemind map settings'),
+ '#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'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ $get1 = freemind_get_settings($group1name);
+ $group2name = 'freemind_server_settings';
+ $form2[$group2name] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Freemind server settings'),
+ '#description' => t('Server file and cron settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ $get2 = freemind_get_cron_settings($group2name);
+ $group3name = 'freemind_map_settings';
+ $form3[$group3name] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Site map display settings'),
+ '#description' => t('Settings for display of the site map in Java applet or Flash viewer'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ $get3 = freemind_get_map_settings($group3name);
+ $form = array_merge_recursive($form1, $get1, $form2, $get2, $form3, $get3);
+ return $form;
}
-function freemind_get_settings() {
+function freemind_get_settings($groupname, $select="") {
$vocabularies = taxonomy_get_vocabularies();
$select[0] = "<". t("none") .">";
foreach ($vocabularies as $vocabulary) {
$select[$vocabulary->vid] = $vocabulary->name;
}
- $output = form_select(t("Omitted vocabularies"), "freemind_overview_vocab", variable_get("freemind_overview_vocab", array()), $select, t("Select vocabularies which should be omitted from listings."), "", 1);
- $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);
- $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);
- $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);
- $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);
- $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);
- $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);
- $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);
-
- return $output;
+ $form[$groupname]['freemind_overview_vocab'] = array(
+ '#type' => 'select',
+ '#title' => t('Omitted vocabularies'),
+ '#default_value' => variable_get("freemind_overview_vocab", array()),
+ '#options' => $select,
+ '#description' => t('Select vocabularies which should be omitted from listings.'),
+ '#multiple' => TRUE,
+ '#required' => FALSE,
+ );
+ $form[$groupname]['freemind_maptype'] = array(
+ '#type' => 'select',
+ '#title' => t('Type of map produced'),
+ '#default_value' => variable_get("freemind_maptype", 'display'),
+ '#options' => array('full' => 'Include vocabulary attributes', 'display' => 'Generate display only'),
+ '#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"),
+ '#multiple' => FALSE,
+ '#required' => TRUE,
+ );
+ $form[$groupname]['freemind_taxlinks'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Include taxonomy links?'),
+ '#default_value' => variable_get('freemind_taxlinks', 0),
+ '#description' => t("Check this box to have links included in the map for each taxonomy term; otherwise, only nodes will show links, if selected"),
+ '#return_value' => 1,
+ '#required' => FALSE,
+ );
+ $form[$groupname]['freemind_nodes'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Include nodes?'),
+ '#default_value' => variable_get('freemind_nodes', 0),
+ '#description' => t("Check this box to have nodes included in the map"),
+ '#return_value' => 1,
+ '#required' => FALSE,
+ );
+ $form[$groupname]['freemind_logo'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Include Logo?'),
+ '#default_value' => variable_get('freemind_logo', 0),
+ '#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"),
+ '#return_value' => 1,
+ '#required' => FALSE,
+ );
+ $form[$groupname]['freemind_server_title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Map title'),
+ '#size' => 50,
+ '#maxlength' => 80,
+ '#default_value' => variable_get("freemind_server_title", "Site Map"),
+ '#description' => t("Name for the map's central node. Note required if a logo is used instead"),
+ '#required' => TRUE,
+ );
+ return $form;
}
/*
* Format the settings for cron jobs and server files
*/
-function freemind_get_cron_settings() {
- $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);
- $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);
- $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);
- return $output;
+function freemind_get_cron_settings($groupname) {
+
+ $form[$groupname]['freemind_cron'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Produce Freemind map in cron run?'),
+ '#default_value' => variable_get('freemind_cron', 0),
+ '#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)"),
+ '#return_value' => 1,
+ '#required' => FALSE,
+ );
+ $form[$groupname]['freemind_path'] = array(
+ '#type' => 'textfield',
+ '#title' => t('File path name'),
+ '#size' => 50,
+ '#maxlength' => 80,
+ '#default_value' => variable_get("freemind_path", "freemind"),
+ '#description' => t("The path name for maps produced on the server. Should be present if cron is set to produce maps"),
+ '#required' => TRUE,
+ );
+
+ $form[$groupname]['freemind_server_file'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default server file name'),
+ '#size' => 50,
+ '#maxlength' => 80,
+ '#default_value' => variable_get("freemind_server_file", "index.mm"),
+ '#description' => t("The default file name for maps produced on the server. Should be present if cron is set to produce maps"),
+ '#required' => TRUE,
+ );
+
+ return $form;
}
/*
* Format the settings for Java applet and flash map display
*/
-function freemind_get_map_settings() {
- $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);
- $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);
- return $output;
+function freemind_get_map_settings($groupname) {
+
+ $form[$groupname]['freemind_java'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Freemind Java map'),
+ '#size' => 50,
+ '#maxlength' => 80,
+ '#default_value' => (variable_get("freemind_java", variable_get("file_directory_path",'').'/'.variable_get('freemind_path', 'freemind').'/sitemapjava.html')),
+ '#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"),
+ '#required' => FALSE,
+ );
+ $form[$groupname]['freemind_flash'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Freemind Flash map'),
+ '#size' => 50,
+ '#maxlength' => 80,
+ '#default_value' => (variable_get("freemind_flash", variable_get("file_directory_path",'').'/'.variable_get('freemind_path', 'freemind').'/sitemapflash.html')),
+ '#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"),
+ '#required' => FALSE,
+ );
+ return $form;
}
// Format an attribute node
@@ -359,15 +475,53 @@
if (!$op || $op == t('Change file')) {
$output = t("You can use this page to modify the default settings for the site map if you wish");
if (user_access('create map')) {
- $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(
+ '#type' => 'fieldset',
+ '#title' => t('Select server or download to workstation'),
+ '#description' => t('If you select the sitemap on the server, then you must provide a file name'),
+ );
+ $form['freemind_select_map']['freemind_where'] = array(
+ '#type' => 'radios',
+ '#title' => t(''),
+ '#default_value' => 'server',
+ '#options' => array(
+ "server" => t("Build site map on the server"),
+ "download" => t("Download site map to workstation")),
+ '#required' => TRUE,
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE,
+ );
}
else {
- $form = form_hidden('freemind_where','download');
+ $form['freemind_where'] = array(
+ '#type' => 'hidden',
+ '#default_value' => 'download',
+ );
}
- $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 .= form_button(t('Generate map'));
- $output .= form($form);
+ $form['default_freemind_map_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Default Freemind map settings'),
+ '#description' => t("You can modify these settings for your map"),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE,
+ );
+ $get1 = freemind_get_settings('default_freemind_map_settings', $select);
+ $form = array_merge_recursive($form, $get1);
+ $form['default_freemind_map_settings']['freemind_server_file'] = array(
+ '#type' => 'textfield',
+ '#title' => t('File name on server'),
+ '#size' => 50,
+ '#maxlength' => 80,
+ '#default_value' => variable_get("freemind_server_file", "index.mm"),
+ '#description' => "The file will be created in : ".file_create_path(variable_get('freemind_path', 'freemind')),
+ '#required' => TRUE,
+ );
+ $form['default_freemind_map_settings']['submit'] = array(
+ '#type' => 'submit',
+ "#value" => t('Generate map'),
+ );
+ $form['#method'] = 'post';
+ $output = drupal_get_form('freemind_map_settings', $form);
}
else {
// print "edit
";
@@ -392,12 +546,8 @@
else {
$output = "The new file was built ok";
}
-// }
}
print theme("page",$output);
-
-
-
}
function freemind_build($fr_overview_vocab, $fr_maptype, $fr_description, $fr_taxlinks, $fr_nodes, $fr_teasers, $fr_logo, $fr_server_title, $file_name) {