| 1 |
<?php
|
| 2 |
// $Id: texy_syntaxhighlighting.module,v 1.2.6.5 2009/04/24 11:46:03 havran Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Syntaxhighlighting support for Texy! filter module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_init().
|
| 11 |
*/
|
| 12 |
function texy_syntaxhighlighting_init() {
|
| 13 |
if (variable_get('texy_syntaxhighlighting_use', FALSE)) {
|
| 14 |
// attach a stylesheet for the syntax highlighter
|
| 15 |
$css_path = variable_get('texy_syntaxhighlighting_css_path', 'fshl/styles/COHEN_style.css');
|
| 16 |
if ( !empty($css_path) ) {
|
| 17 |
$path = drupal_get_path('module', 'texy_syntaxhighlighting');
|
| 18 |
drupal_add_css($path .'/lib/'. $css_path);
|
| 19 |
}
|
| 20 |
}
|
| 21 |
}
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Implementation of hook_help().
|
| 25 |
*/
|
| 26 |
function texy_syntaxhighlighting_help($path, $arg) {
|
| 27 |
switch ($path) {
|
| 28 |
case 'admin/help#texy_syntaxhighlighting':
|
| 29 |
return '<p>'. t('Texy! Syntaxhighlighting allows you to use code syntaxhighlighting together with Texy! filter module.') .'</p>';
|
| 30 |
case 'admin/settings/texy/syntaxhighlighting':
|
| 31 |
return '<p>'. t('Below is a list of syntaxhighlighting settings for the Texy! filter module. Basic syntaxhighlighting module for <em>PHP, HTML, CSS, JS, CPP, Java, SQL</em> and <em>PY</em> languages <a href="@fshl-url">FSHL (Fast Syntax Highlighter)</a> is already installed and preconfigured, you only need enable it.', array('@fshl-url' => url('http://www.hvge.sk/scripts/fshl/'))) .'</p>';
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Implementation of hook_menu
|
| 37 |
*/
|
| 38 |
function texy_syntaxhighlighting_menu() {
|
| 39 |
$items['admin/settings/texy/syntaxhighlighting'] = array(
|
| 40 |
'title' => 'Syntaxhighlighting',
|
| 41 |
'description' => 'Customize the Texy! syntaxhighlighting settings.',
|
| 42 |
'page callback' => 'drupal_get_form',
|
| 43 |
'page arguments' => array('texy_form_syntaxhighlighting_settings'),
|
| 44 |
'access arguments' => array('administer site configuration'),
|
| 45 |
'type' => MENU_LOCAL_TASK,
|
| 46 |
'file' => 'texy_syntaxhighlighting.admin.inc',
|
| 47 |
);
|
| 48 |
|
| 49 |
return $items;
|
| 50 |
}
|
| 51 |
|
| 52 |
/**
|
| 53 |
* Implementation of hook_texy_settings()
|
| 54 |
*/
|
| 55 |
function texy_syntaxhighlighting_texy_settings(&$texy) {
|
| 56 |
}
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Implementation of hook_texy_handler()
|
| 60 |
*/
|
| 61 |
function texy_syntaxhighlighting_texy_handler(&$texy) {
|
| 62 |
// get base module path
|
| 63 |
$module_path = drupal_get_path('module', 'texy_syntaxhighlighting');
|
| 64 |
|
| 65 |
// check for use syntax highlighter
|
| 66 |
if (variable_get('texy_syntaxhighlighting_use', FALSE)) {
|
| 67 |
$syntaxhighlighter_name = variable_get('texy_syntaxhighlighting_name', 'fshl');
|
| 68 |
// check name of syntax highlighter
|
| 69 |
if ($syntaxhighlighter_name != '') {
|
| 70 |
$syntaxhighlighter = $module_path . '/lib/' . $syntaxhighlighter_name . '.php';
|
| 71 |
$syntaxhighlighter_dir = $module_path . '/lib/' . $syntaxhighlighter_name;
|
| 72 |
if (file_exists($syntaxhighlighter) && file_exists($syntaxhighlighter_dir)) {
|
| 73 |
// set user callback function for the /--- code blocks (for the syntax highlighter)
|
| 74 |
require_once $syntaxhighlighter;
|
| 75 |
$texy->addHandler('block', $syntaxhighlighter_name.'BlockHandler');
|
| 76 |
}
|
| 77 |
else {
|
| 78 |
drupal_set_message(t('Syntax highlighter <em>!syntaxhighlighter_name</em> is not ready...', array('!syntaxhighlighter_name' => $syntaxhighlighter_name)),'error');
|
| 79 |
}
|
| 80 |
}
|
| 81 |
}
|
| 82 |
}
|