--- export_dxml\export_dxml.module 2005-11-29 13:28:10.000000000 -0500 +++ export_dxml.module 2007-09-02 19:49:25.472875000 -0400 @@ -11,21 +11,23 @@ * Implementation of hook_perm(). */ function export_dxml_perm() { - return array('export books as dxml'); + return array('Export books as dxml'); } /** * Implementation of hook_link(). */ -function export_dxml_link($type, $node = 0, $main = 0) { +function export_dxml_link($type, $node = 0, $teaser = FALSE) { $links = array(); if ($type == 'node' && isset($node->parent)) { - if (!$main) { - if (user_access('export books as dxml')) { - $links[] = l(t('export Drupal XML'), - 'book/export/dxml/'. $node->nid, - array('title' => t('Export this book page and its sub-pages as Drupal XML (suitable for re-import)'))); + if (!$teaser) { + if (user_access('Export books as dxml')) { + $links['export_dxml'] = array( + 'href' => 'book/export/dxml/'. $node->nid, + 'title' => t('Export as Drupal XML'), + 'html' => FALSE, + ); } } } @@ -41,7 +43,7 @@ function export_dxml_link($type, $node = * * Note that the user must have both 'access content' permissions (checked * when the menu item for export is invoked in book.module) and - * 'export books as dxml' permissions to export a book. + * 'Export books as dxml' permissions to export a book. * * @param nid * - an integer representing the node id (nid) of the node to export @@ -52,7 +54,7 @@ function export_dxml_link($type, $node = * - the DXML representing the node and its children in the book hierarchy */ function book_export_dxml($nid, $depth) { - if (user_access('export books as dxml')) { + if (user_access('Export books as dxml')) { drupal_set_header('Content-Type: text/xml; charset=utf-8'); $xml = "\n"; $xml .= "\n"; @@ -128,6 +130,7 @@ function book_node_visitor_dxml_pre($nod $output .= " author='"._get_username($node->uid)."'"; $output .= " uid='$node->uid'"; $output .= " created='$node->created'"; + $output .= " changed='$node->changed'"; $output .= " status='$node->status'"; $output .= " format='$node->format'"; $output .= " sticky='$node->sticky'"; @@ -155,15 +158,8 @@ function book_node_visitor_dxml_post($no function export_dxml_help($section) { switch ($section) { case 'admin/help#export_dxml': - $output .= '

'. t('Users can choose to export the page and its subsections as Drupal XML for offline editing, import to another book or another Drupal site, or other post-processing, by selecting the Export Drupal XML link. Note: it may be neccessary to shift-click on the link to save the results to a file on the local computer.') . '

'; + $output .= '

'. t('The export_dxml module allows authorized users to export the page and its subsections as Drupal XML for offline editing, import to another book or another Drupal site, or other post-processing, by selecting the Export Drupal XML link. Note: it may be neccessary to shift-click on the link to save the results to a file on the local computer.') . '

'; return $output; - case 'admin/modules#description': - return t('Allows authorized users to export a book as Drupal XML.'); - case 'admin/node/export_dxml': - return t("

The export_dxml module allows authorized users to export a book as DocBook XML (for offline editing, or production of print or other electronic publication formats).") . '

'; - case 'admin/export_dxml': - return '

' . t("If the Allow PHP Export setting is enabled, then PHP code in books to be exported will be included in the output as PHP. Otherwise, the PHP will be evaluated and the resulting output will be exported.") . '

'; - } } @@ -172,51 +168,41 @@ function export_dxml_help($section) { */ function export_dxml_menu($may_cache) { $items = array(); - if ($may_cache) { $items[] = array( - 'path' => 'admin/export_dxml', - 'title' => t('book export (dxml)'), - 'callback' => 'export_dxml_admin', - 'type' => MENU_NORMAL_ITEM, - 'weight' => 0); + 'path' => 'admin/settings/export_dxml', + 'title' => t('Book export'), + 'description' => t('Book export (dxml) settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('export_dxml_admin'), + 'access' => user_access('Export books as dxml'), + ); } - return $items; } /** - * Menu callback; displays the book administration page. + * Menu callback; displays the export_dxml administration page. */ -function export_dxml_admin($nid = 0) { - $op = $_POST['op']; - $edit = $_POST['edit']; - $php_export_flag = $edit['flag']; - - if ($op == t('Update settings')) { - if ($php_export_flag) { - $flag = "true"; - variable_set('Allow PHP Export', true); - } - else { - $flag = "false"; - variable_set('Allow PHP Export', false); - } - drupal_set_message(t("Allow PHP Export has been set to $flag")); - } - - $output .= "The following settings affect all books:"; - $form['flag'] = array('#type' => 'checkbox', - '#title' => 'Allow PHP Export', - '#value' => variable_get('Allow PHP Export', false) - ); - $form['set_flag'] = array('#type' => 'submit', - '#value' => t('Update settings')); - - $output .= drupal_get_form('book_admin_set_flag', $form); - - return $output; +function export_dxml_admin() { + $form['allow_php'] = array('#type' => 'checkbox', + '#title' => t('Allow PHP Export'), + '#description' => t('If this setting is enabled, then PHP code in books to be exported will be included in the output as PHP. Otherwise, the PHP will be evaluated and the resulting output will be exported. This setting affects all books.'), + '#default_value' => variable_get('Allow PHP Export', false), + ); + +// Update Button + $form['update']['attach'] = array( + '#type' => 'submit', + '#value' => t('Update'), + '#weight' => 5, + ); + + return $form; +} +function export_dxml_admin_submit($form_id, $form_values) { + variable_set('Allow PHP Export', $form_values['allow_php']); } /**