/[drupal]/contributions/modules/export_dxml/export_dxml.module
ViewVC logotype

Diff of /contributions/modules/export_dxml/export_dxml.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3.4.1, Tue Sep 4 00:33:20 2007 UTC revision 1.3.4.2, Mon Sep 10 05:23:15 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: export_dxml.module,v 1.3 2005/11/29 19:28:10 puregin Exp $  // $Id: export_dxml.module,v 1.3.4.1 2007/09/04 00:33:20 puregin Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 18  function export_dxml_perm() { Line 18  function export_dxml_perm() {
18  /**  /**
19   * Implementation of hook_link().   * Implementation of hook_link().
20   */   */
21  function export_dxml_link($type, $node = 0, $main = 0) {  function export_dxml_link($type, $node = 0, $teaser = FALSE) {
22    $links = array();    $links = array();
23    if ($type == 'node' && isset($node->parent)) {    if ($type == 'node' && isset($node->parent)) {
24      if (!$main) {      if (!$teaser) {
25        if (user_access('export books as dxml')) {        if (user_access('export books as dxml')) {
26          $links['book_export_dxml'] = array(          $links['book_export_dxml'] = array(
27            'title' => t('Export Drupal XML'),            'title' => t('Export Drupal XML'),
28            'href' => 'book/export/dxml/'. $node->nid,            'href' => 'book/export/dxml/'. $node->nid,
29            'attributes' => array('title' => t('Export this book page and its sub-pages as Drupal XML (suitable for re-import)'))            'attributes' => array('title' => t('Export this book page and its sub-pages as Drupal XML (suitable for re-import)')),
30              'html' => FALSE,
31            );            );
32        }        }
33      }      }
# Line 130  function book_node_visitor_dxml_pre($nod Line 131  function book_node_visitor_dxml_pre($nod
131    $output .= " author='"._get_username($node->uid)."'";    $output .= " author='"._get_username($node->uid)."'";
132    $output .= " uid='$node->uid'";    $output .= " uid='$node->uid'";
133    $output .= " created='$node->created'";    $output .= " created='$node->created'";
134      $output .= " changed='$node->changed'";
135    $output .= " status='$node->status'";    $output .= " status='$node->status'";
136    $output .= " format='$node->format'";    $output .= " format='$node->format'";
137    $output .= " sticky='$node->sticky'";    $output .= " sticky='$node->sticky'";
# Line 158  function export_dxml_help($section) { Line 160  function export_dxml_help($section) {
160    switch ($section) {    switch ($section) {
161      case 'admin/help#export_dxml':      case 'admin/help#export_dxml':
162        $output .= '<p>'. t('Users can choose to <em>export</em> 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 <em>Export Drupal XML</em> link. Note: it may be neccessary to shift-click on the link to save the results to a file on the local computer.') . '</p>';        $output .= '<p>'. t('Users can choose to <em>export</em> 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 <em>Export Drupal XML</em> link. Note: it may be neccessary to shift-click on the link to save the results to a file on the local computer.') . '</p>';
163    +      $output .= '<p>'. t('The Export DXML module allows authorized users to export the page and its subsections as Drupal XML for offline editing, for import to another book or another Drupal site, or for other post-processing,  by clicking on the <em>Export Drupal XML</em> link the module presents on each book page. Note: it may be neccessary to shift-click on the link to save the results to a file on the local computer.') . '</p>';
164        return $output;        return $output;
165      case 'admin/modules#description':      case 'admin/modules#description':
166        return t('Allows authorized users to export a book as Drupal XML.');        return t('Allows authorized users to export a book as Drupal XML.');
# Line 177  function export_dxml_menu($may_cache) { Line 180  function export_dxml_menu($may_cache) {
180    
181    if ($may_cache) {    if ($may_cache) {
182      $items[] = array(      $items[] = array(
183        'path' => 'admin/export_dxml',        'path' => 'admin/settings/export_dxml',
184        'title' => t('book export (dxml)'),        'title' => t('Book Export (dxml)'),
185        'callback' => 'export_dxml_admin',        'description' => t('Book export (dxml) settings'),
186        'type' => MENU_NORMAL_ITEM,        'access' => user_access('export books as dxml'),
187          'callback' => 'drupal_get_form',
188          'callback arguments' => array('export_dxml_admin'),
189        'weight' => 0);        'weight' => 0);
190    }    }
191    
# Line 190  function export_dxml_menu($may_cache) { Line 195  function export_dxml_menu($may_cache) {
195  /**  /**
196   * Menu callback; displays the book administration page.   * Menu callback; displays the book administration page.
197   */   */
198  function export_dxml_admin($nid = 0) {  function export_dxml_admin() {
   $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("<em>Allow PHP Export</em> has been set to $flag"));  
   }  
   
199    $output .= "<b>The following settings affect all books:</b>";    $output .= "<b>The following settings affect all books:</b>";
200    $form['flag'] = array('#type' => 'checkbox',    $form['allow_php'] =
201                          '#title' => 'Allow PHP Export',      array('#type' => 'checkbox',
202                          '#value' => variable_get('Allow PHP Export', false)            '#title' => 'Allow PHP Export',
203                          );            '#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.'),
204    $form['set_flag'] = array('#type' => 'submit',            '#default_value' => variable_get('Allow PHP Export', false),
205                              '#value' => t('Update settings'));            );
206      // Update button
207    $output .= drupal_get_form('book_admin_set_flag', $form);    $form['update']['attach'] =
208        array('#type' => 'submit',
209    return $output;            '#value' => t('Update'),
210              '#weight' => 5,
211              );
212    
213      return $form;
214    }
215    
216    function export_dxml_admin_submit($form_id, $form_values) {
217      variable_set('Allow PHP Export', $form_values['allow_php']);
218      drupal_set_message(t("<em>Allow PHP Export</em> has been set to %flag",
219                           array("%flag" => $form_values['allow_php']?'true':'false')));
220  }  }
221    
222  /**  /**
# Line 229  function export_dxml_admin($nid = 0) { Line 227  function export_dxml_admin($nid = 0) {
227   *   - string containing the name of the user, if found.   *   - string containing the name of the user, if found.
228   */   */
229  function _get_username($uid) {  function _get_username($uid) {
230      static $users = array();    static $users = array();
231      global $user_cache_stats;    global $user_cache_stats;
232    
233      $username = "";    $username = "";
234      if (is_string($users[$uid]) && $users[$uid] != '') {    if (is_string($users[$uid]) && $users[$uid] != '') {
235          $username = $users[$uid];      $username = $users[$uid];
236      }    }
237      else {    else {
238          $user = user_load(array('uid' => $uid));      $user = user_load(array('uid' => $uid));
239          $username = $user->name;      $username = $user->name;
240          $users[$uid] = $username;      $users[$uid] = $username;
241      }    }
242      return $username;    return $username;
243  }  }

Legend:
Removed from v.1.3.4.1  
changed lines
  Added in v.1.3.4.2

  ViewVC Help
Powered by ViewVC 1.1.2