'admin/settings/yui_editor', 'title' => t('YUI editor settings'), 'callback' => 'drupal_get_form', 'callback arguments' => 'yui_editor_settings_form', 'access' => user_access('administer site configuration'), 'description' => t("View/Modify YUI editor settings"), ); } // Thank you block.module :) $path = drupal_get_path_alias($_GET['q']); $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get("yui_editor_include", ''), '/')) .')$/'; $yui_include = variable_get("yui_editor_include", ""); if(preg_match($regexp, $path) or empty($yui_include)) { render_editor(); } return $items; } /** * implementation of hook_perm(). */ function yui_editor_perm() { $array = array('Access YUI editor'); return $array; } /** *The settings page. * **/ function yui_editor_settings_form() { $form['yui_editor_include'] = array('#type' => 'textarea', '#title' => t('Paths'), '#description' => t('Define where should YUI replace the body textarea, each path on a new line. You can use wildcards (*). (Leave blank for every form)'), '#default_value' => variable_get('yui_editor_include', ''), '#rows' => 5, '#cols' => 60, ); $form['yui_editor_ids'] = array('#type' => 'textarea', '#title' => t('IDs'), '#description' => t('Define which textareas do you want the editor to replace, write the ID of each textarea on a seperate line. (if empty the editor will only replace the body textarea)'), '#default_value' => variable_get('yui_editor_ids', ''), '#rows' => 5, '#cols' => 20, ); $form['yui_editor_height'] = array('#type' => 'textfield', '#title' => t('Height'), '#default_value' => variable_get('yui_editor_height', '300'), '#description' => t('The height of the editor in pixels') ); $form['yui_editor_width'] = array('#type' => 'textfield', '#title' => t('Width'), '#default_value' => variable_get('yui_editor_width', '522'), '#description' => t('The width of the editor in pixels') ); return system_settings_form($form); } /** * Add the javascript/CSS needed to render the editor * **/ function render_editor() { if (!user_access('Access YUI editor')) { return; } $yui_source = variable_get('yui_source','http://yui.yahooapis.com/2.3.0'); yui_add_css('editor', $yui_source, '/assets/dpSyntaxHighlighter.css'); //yui_add_css('editor', $yui_source, '/build/container/assets/skins/sam/container.css'); yui_add_css('editor', $yui_source, '/build/menu/assets/skins/sam/menu.css'); yui_add_css('editor', $yui_source, '/build/button/assets/skins/sam/button.css'); yui_add_css('editor', $yui_source, '/build/editor/assets/skins/sam/editor.css'); yui_add_js('editor', $yui_source, '/build/utilities/utilities.js'); yui_add_js('editor', $yui_source, '/build/container/container-min.js'); yui_add_js('editor', $yui_source, '/build/menu/menu-min.js'); yui_add_js('editor', $yui_source, '/build/button/button-beta-min.js'); yui_add_js('editor', $yui_source, '/build/editor/editor-beta-min.js'); drupal_add_js(drupal_get_path("module", "yui_editor")."/yui_editor.js"); $ids = variable_get('yui_editor_ids', ''); $textareas = array(); if (!empty($ids)) { $textareas = explode("\r\n", $ids); } else { $textareas[] = 'edit-body'; } foreach($textareas as $id) { drupal_add_js("render_editor('".$id."', ".variable_get('yui_editor_height', '300').", ".variable_get('yui_editor_width', '500').");", "inline", "footer"); } }