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

Diff of /contributions/modules/bbcode_wysiwyg/bbcode_wysiwyg.module

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

revision 1.4.4.8, Tue Apr 29 04:09:59 2008 UTC revision 1.4.4.9, Tue Apr 29 06:14:11 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: bbcode_wysiwyg.module,v 1.4.4.7 2008/04/29 04:03:50 jrbeeman Exp $  // $Id: bbcode_wysiwyg.module,v 1.4.4.8 2008/04/29 04:09:59 jrbeeman Exp $
3    
4  /**  /**
5   * Implementation of hook_perm().   * Implementation of hook_perm().
# Line 83  function bbcode_wysiwyg_admin_settings() Line 83  function bbcode_wysiwyg_admin_settings()
83  /**  /**
84   * Provide javascript settings   * Provide javascript settings
85   */   */
86  function bbcode_wysiwyg_js_settings($is_node, $element) {  function bbcode_wysiwyg_js_settings($element) {
87    $buttons = variable_get('bbcode_wysiwyg_buttons_enabled', array());    $buttons_enabled = variable_get('bbcode_wysiwyg_buttons_enabled', array());
88      $buttons = array();
89      $shortcuts = array(
90        'bold' => 66,
91        'italic' => 73,
92        'quote' => 81,
93        'link' => 76,
94        'break' => 82,
95        'image' => 77,
96        'center' => 67,
97      );
98    $open_tags = array();    $open_tags = array();
99    foreach ($buttons as $key => $value) {    foreach ($buttons_enabled as $key => $value) {
100      $open_tags[$key] = FALSE;      $open_tags[$key] = FALSE;
101        if ($buttons_enabled[$key]) {
102          $buttons[$key] = $shortcuts[$key];
103        }
104    }    }
105    return array(    return array(
106      'bbcode_wysiwyg' => array(      'bbcode_wysiwyg' => array(
107        'enterLinkURL' => t('Please enter the URL to link to'),        'enterLinkURL' => t('Please enter the URL to link to'),
108        'enterImageURL' => t('Please enter the address of the image to include'),        'enterImageURL' => t('Please enter the address of the image to include'),
       'isNode' => $is_node,  
109        'attachTo' => $element,        'attachTo' => $element,
110        'buttons' => $buttons,        'buttons' => $buttons,
111        'openTags' => $open_tags,        'openTags' => $open_tags,
       'keydown_ctrl' => FALSE,  
       'keydown_shift' => FALSE,  
112      ),      ),
113    );    );
114  }  }
# Line 107  function bbcode_wysiwyg_js_settings($is_ Line 117  function bbcode_wysiwyg_js_settings($is_
117  /**  /**
118   * Quick method for adding necessary bbcode javascript and css from any method   * Quick method for adding necessary bbcode javascript and css from any method
119   */   */
120  function bbcode_wysiwyg_add($is_node, $attach_to) {  function bbcode_wysiwyg_add($attach_to) {
121    drupal_add_js(bbcode_wysiwyg_js_settings($is_node, $attach_to), 'setting');    drupal_add_js(bbcode_wysiwyg_js_settings($attach_to), 'setting');
122    drupal_add_js(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.js');    drupal_add_js(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.js');
123    drupal_add_css(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.css');    drupal_add_css(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.css');
124  }  }
# Line 119  function bbcode_wysiwyg_add($is_node, $a Line 129  function bbcode_wysiwyg_add($is_node, $a
129   */   */
130  function bbcode_wysiwyg_form_alter($form_id, &$form) {  function bbcode_wysiwyg_form_alter($form_id, &$form) {
131    $show = FALSE;    $show = FALSE;
   $is_node = FALSE;  
132    $attach_to = '';    $attach_to = '';
133    $other_forms = variable_get('bbcode_wysiwyg_other_forms', array());    $other_forms = variable_get('bbcode_wysiwyg_other_forms', array());
134    $node_forms = variable_get('bbcode_wysiwyg_node_forms', array());    $node_forms = variable_get('bbcode_wysiwyg_node_forms', array());
135    
136    if ($form['#id'] == 'node-form' && $node_forms[$form['type']['#value']]) {    if ($form['#id'] == 'node-form' && $node_forms[$form['type']['#value']]) {
137      $show = TRUE;      $show = TRUE;
     $is_node = TRUE;  
138      $attach_to = 'edit-body';      $attach_to = 'edit-body';
139    }    }
140    else if ($other_forms[$form_id]) {    else if ($other_forms[$form_id]) {
# Line 135  function bbcode_wysiwyg_form_alter($form Line 143  function bbcode_wysiwyg_form_alter($form
143    }    }
144    
145    if ($show && user_access('access bbcode formatting bar')) {    if ($show && user_access('access bbcode formatting bar')) {
146      bbcode_wysiwyg_add($is_node, $attach_to);      bbcode_wysiwyg_add($attach_to);
147    }    }
148  }  }
149    

Legend:
Removed from v.1.4.4.8  
changed lines
  Added in v.1.4.4.9

  ViewVC Help
Powered by ViewVC 1.1.2