Turkish translation for TinyMCE module
[project/tinymce.git] / tinymce.module
1 <?php
2 // $Id$
3
4 function tinymce_help($section) {
5 switch ($section) {
6 case 'admin/help#tinymce':
7 $output = '<p>'. t('The most popular WYSIWYG editor for advance content.') .'</p>';
8 $output .= t("<p><ul>"
9 ."<li>Editor mode: full, compact and simple.</li>"
10 ."</ul>"
11 ."</p>");
12 return $output;
13 case 'admin/modules#description':
14 return t('Enable WYSIWYG Editor to your site.');
15 }
16 }
17
18 function tinymce_perm() {
19 $array = array('administer tinymce', 'access tinymce');
20 $array[] = 'enable tinymce file manager';
21
22 return $array;
23 }
24
25 function tinymce_menu($may_cache) {
26
27 $items = array();
28
29 $items[] = array(
30 'path' => 'admin/settings/tinymce',
31 'title' => t('TinyMCE'),
32 'description' => t('Tinymce settings.'),
33 'callback' => 'drupal_get_form',
34 'callback arguments' => array('tinymce_admin_settings'),
35 'access' => user_access('administer tinymce'),
36 'type' => MENU_NORMAL_ITEM);
37
38 return $items;
39 }
40
41 function tinymce_admin_settings() {
42 // only administrators can access this function
43 // Generate the form - settings applying to all patterns first
44
45 $form['tinymce_settings'] = array(
46 '#type' => 'fieldset',
47 '#weight' => -20,
48 '#title' => t('Basic settings'),
49 '#collapsible' => TRUE,
50 '#collapsed' => FALSE
51 );
52
53 $form['tinymce_settings']['editor_mode'] = array(
54 '#type' => 'radios',
55 '#title' => t('Editor Mode'),
56 '#default_value' => variable_get('editor_mode', 0),
57 '#options' => array(t('Full'), t('Compact'), t('Simple')),
58 '#description' => t("FULL: enable all TinyMCE features. COMPACT: enable most used features. SIMPLE: just enable simple editor.<hr>")
59 );
60
61 $form['tinymce_settings']['editor_element'] = array(
62 '#type' => 'radios',
63 '#title' => t('Enable TinyMCE for'),
64 '#default_value' => variable_get('editor_element', 0),
65 '#options' => array(t('Edit-body only'), t('Edit-comment only'), t('Both')),
66 '#description' => t("If you want TinyMCE available for textarea of edit-body and comment then you should select <b>Both</b> option.")
67 );
68
69 $form['tinymce_settings']['editor_node_type'] = array(
70 '#type' => 'textfield',
71 '#title' => t('Enable TinyMCE for this node types'),
72 '#default_value' => variable_get('editor_node_type', 'page,story,blog'),
73 '#description' => t("Node type in case-sensitive name, i.e: page,story,data_product,blog")
74 );
75
76 return system_settings_form($form);
77 }
78
79 function tinymce_form_alter($form_id, &$form) {
80 $editor_node_type = variable_get("editor_node_type", 'page,story,blog');
81 $form_type = $form['type']['#value'];
82
83 if (!preg_match("/\b$form_type\b/i", $editor_node_type)) return;
84
85 if ($form_id == 'comment_form' || (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) && user_access('access tinymce')) {
86 $queries = array("textarea#body", "textarea#comment");
87 tinymce_add_javascript();
88 }
89 }
90
91 function tinymce_add_javascript() {
92 $editor_mode = variable_get("editor_mode", 0);
93 $editor_element = variable_get("editor_element", 0);
94
95 drupal_add_js(drupal_get_path('module', 'tinymce') . '/includes/jscripts/tiny_mce/tiny_mce.js');
96 //drupal_add_js(drupal_get_path('module', 'tinymce') . '/imce/imce_set.js');
97
98 if ($editor_mode==0) { drupal_add_js(drupal_get_path('module', 'tinymce') . '/themes/tinymce_full.js'); }
99 elseif ($editor_mode==1) { drupal_add_js(drupal_get_path('module', 'tinymce') . '/themes/tinymce_compact.js'); }
100 else { drupal_add_js(drupal_get_path('module', 'tinymce') . '/themes/tinymce_simple.js'); }
101
102 //tinyMCE.configs[i]['file_browser_callback'] = 'imceImageBrowser';
103 if ($editor_element==0) {$tinymce_elements = 'edit-body';}
104 elseif ($editor_element==1) {$tinymce_elements = 'edit-comment';}
105 else {$tinymce_elements = 'edit-body,edit-comment';}
106
107
108 drupal_add_js("
109 if ('undefined' != typeof(window.tinyMCE)) {
110 for (var i=0; i<tinyMCE.configs.length; i++) {
111 tinyMCE.configs[i]['elements'] = '$tinymce_elements';
112 }
113 }
114 "
115 , 'inline');
116 }