/[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.3, Tue Jan 1 17:56:15 2008 UTC revision 1.4.4.4, Mon Apr 14 17:00:51 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: bbcode_wysiwyg.module,v 1.4.4.2 2007/11/16 17:59:56 jrbeeman Exp $  // $Id: bbcode_wysiwyg.module,v 1.4.4.3 2008/01/01 17:56:15 jrbeeman Exp $
3    
4  /**  /**
5   * Implementation of hook_perm().   * Implementation of hook_perm().
# Line 84  function bbcode_wysiwyg_admin_settings() Line 84  function bbcode_wysiwyg_admin_settings()
84   */   */
85  function bbcode_wysiwyg_js_settings($is_node, $element) {  function bbcode_wysiwyg_js_settings($is_node, $element) {
86    $buttons = variable_get('bbcode_wysiwyg_buttons_enabled', array());    $buttons = variable_get('bbcode_wysiwyg_buttons_enabled', array());
87    $openTags = array();    $open_tags = array();
88    foreach ($buttons as $key=>$value) {    foreach ($buttons as $key => $value) {
89      $openTags[$key] = false;      $open_tags[$key] = false;
90    }    }
91    return array(    return array(
92      'bbcode_wysiwyg' => array(      'bbcode_wysiwyg' => array(
# Line 95  function bbcode_wysiwyg_js_settings($is_ Line 95  function bbcode_wysiwyg_js_settings($is_
95        'isNode' => $is_node,        'isNode' => $is_node,
96        'attachTo' => $element,        'attachTo' => $element,
97        'buttons' => $buttons,        'buttons' => $buttons,
98        'openTags' => $openTags,        'openTags' => $open_tags,
99        'keydown_ctrl' => false,        'keydown_ctrl' => false,
100        'keydown_shift' => false,        'keydown_shift' => false,
101      ),      ),
# Line 106  function bbcode_wysiwyg_js_settings($is_ Line 106  function bbcode_wysiwyg_js_settings($is_
106  /**  /**
107   * Quick method for adding necessary bbcode javascript and css from any method   * Quick method for adding necessary bbcode javascript and css from any method
108   */   */
109  function bbcode_wysiwyg_add($is_node, $attachTo) {  function bbcode_wysiwyg_add($is_node, $attach_to) {
110    drupal_add_js(bbcode_wysiwyg_js_settings($is_node, $attachTo), 'setting');    drupal_add_js(bbcode_wysiwyg_js_settings($is_node, $attach_to), 'setting');
111    drupal_add_js(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.js');    drupal_add_js(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.js');
112    drupal_add_css(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.css');    drupal_add_css(drupal_get_path('module', 'bbcode_wysiwyg') .'/bbcode_wysiwyg.css');
113  }  }
# Line 119  function bbcode_wysiwyg_add($is_node, $a Line 119  function bbcode_wysiwyg_add($is_node, $a
119  function bbcode_wysiwyg_form_alter($form_id, &$form) {  function bbcode_wysiwyg_form_alter($form_id, &$form) {
120    $show = false;    $show = false;
121    $is_node = false;    $is_node = false;
122    $attachTo = '';    $attach_to = '';
123    $other_forms = variable_get('bbcode_wysiwyg_other_forms', array());    $other_forms = variable_get('bbcode_wysiwyg_other_forms', array());
124    $node_forms = variable_get('bbcode_wysiwyg_node_forms', array());    $node_forms = variable_get('bbcode_wysiwyg_node_forms', array());
125    
126    if ($form['#id'] == 'node-form' && $node_forms[$form['type']['#value']]) {    if ($form['#id'] == 'node-form' && $node_forms[$form['type']['#value']]) {
127      $show = true;      $show = true;
128      $is_node = true;      $is_node = true;
129      $attachTo = 'edit-body';      $attach_to = 'edit-body';
130    }    }
131    else if ($other_forms[$form_id]) {    else if ($other_forms[$form_id]) {
132      $show = true;      $show = true;
133      $attachTo = 'edit-comment';      $attach_to = 'edit-comment';
134    }    }
135    
136    if ($show && user_access('access bbcode formatting bar')) {    if ($show && user_access('access bbcode formatting bar')) {
137      bbcode_wysiwyg_add($is_node, $attachTo);      bbcode_wysiwyg_add($is_node, $attach_to);
138    }    }
139  }  }
140    
# Line 158  function bbcode_wysiwyg_link($type, $nod Line 158  function bbcode_wysiwyg_link($type, $nod
158    return $links;    return $links;
159  }  }
160    
   
 /**  
  * Provide the bbcode wysiwyg form  
  */  
 function _bbcode_wysiwyg_form($is_story) {  
   $form = array(  
     '#prefix' => '<center>',  
     '#suffix' => '</center>',  
     'quote' => array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bbquote',  
         'class' => 'bbcode_wysiwyg',  
         'onclick' => 'quoteSelection();setClicked(this.id);',  
         'value' => t('Quote'),  
         'alt' => 'Ctrl+Shift+Q',  
         'title' => 'Ctrl+Shift+Q',  
       )) .'/>',  
     ),  
     'bold' => array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bbbold',  
         'class' => 'bbcode_wysiwyg',  
         'style' => 'font-weight: bold',  
         'onclick' => "BBC('b');setClicked(this.id);",  
         'value' => t('B'),  
         'alt' => 'Ctrl+Shift+B',  
         'title' => 'Ctrl+Shift+B',  
       )) .'/>',  
     ),  
     'italic' => array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bbitalic',  
         'class' => 'bbcode_wysiwyg',  
         'style' => 'font-style: italic',  
         'onclick' => "BBC('i');setClicked(this.id);",  
         'value' => t('i'),  
         'alt' => 'Ctrl+Shift+I',  
         'title' => 'Ctrl+Shift+I',  
       )) .'/>',  
     ),  
     'link' => array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bblink',  
         'class' => 'bbcode_wysiwyg',  
         'onclick' => 'BBCurl();',  
         'value' => t('Link'),  
         'alt' => 'Ctrl+Shift+L',  
         'title' => 'Ctrl+Shift+L',  
       )) .'/>',  
     ),  
     'image' => array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bbimage',  
         'class' => 'bbcode_wysiwyg',  
         'onclick' => 'BBCimg();',  
         'value' => t('Image'),  
       )) .'/>',  
     ),  
   );  
   if ($is_story) {  
     $form['break'] = array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bbbreak',  
         'class' => 'bbcode_wysiwyg',  
         'onclick' => "PostWrite('<!--break-->');",  
         'value' => t('Break'),  
       )) .'/>',  
     );  
     $form['center'] = array(  
       '#type' => 'markup',  
       '#value' => '<input '. drupal_attributes(array(  
         'type' => 'button',  
         'id' => 'bbcenter',  
         'class' => 'bbcode_wysiwyg',  
         'onclick' => "BBC('center');setClicked(this.id);",  
         'value' => t('Center'),  
       )) .'/>',  
     );  
   }  
   return $form;  
 }  
 ?>  

Legend:
Removed from v.1.4.4.3  
changed lines
  Added in v.1.4.4.4

  ViewVC Help
Powered by ViewVC 1.1.2