Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        framework
5
 * @package         include
6
 * @author		    Christophe Dolivet (EditArea), Christian Sommer (WB wrapper)
7
 * @author          WebsiteBaker Project
8
 * @copyright       2004-2009, Ryan Djurovich
9
 * @copyright       2009-2010, Website Baker Org. e.V.
10
 * @link			http://www.websitebaker2.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.x
13
 * @requirements    PHP 4.3.4 and higher
14
 * @version         $Id: wb_wrapper_edit_area.php 1289 2010-02-10 15:13:21Z kweitzel $
15
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/trunk/wb/include/editarea/wb_wrapper_edit_area.php $
16
 * @lastmodified    $Date: 2010-02-10 16:13:21 +0100 (Wed, 10 Feb 2010) $
17
 *
18
 */
19

    
20
function loader_help()
21
{
22
?>
23
   <script type="text/javascript">
24
      var head= document.getElementsByTagName('head')[0];
25
      var script= document.createElement('script');
26
      script.type= 'text/javascript';
27
      script.src= '<?php print WB_URL; ?>/include/editarea/edit_area_full.js';
28
      head.appendChild(script);
29
   </script>
30
<?php
31

    
32
}
33

    
34
if (!function_exists('registerEditArea')) {
35
	function registerEditArea(
36
                $id = 'code_area',
37
                $syntax = 'php',
38
                $syntax_selection = true,
39
                $allow_resize = 'both',
40
                $allow_toggle = true,
41
                $start_highlight = true,
42
                $min_width = 600,
43
                $min_height = 300,
44
                $toolbar = 'default'
45
            )
46
	{
47

    
48
		// set default toolbar if no user defined was specified
49
		if ($toolbar == 'default') {
50
			$toolbar = 'search, fullscreen, |, undo, redo, |, select_font, syntax_selection, |, highlight, reset_highlight, |, help';
51
			$toolbar = (!$syntax_selection) ? str_replace('syntax_selection,', '', $toolbar) : $toolbar;
52
		}
53

    
54
		// check if used Website Baker backend language is supported by EditArea
55
		$language = 'en';
56
		if (defined('LANGUAGE') && file_exists(dirname(__FILE__) . '/langs/' . strtolower(LANGUAGE) . '.js'))
57
        {
58
			$language = strtolower(LANGUAGE);
59
		}
60

    
61
		// check if highlight syntax is supported by edit_area
62
		$syntax = in_array($syntax, array('css', 'html', 'js', 'php', 'xml')) ? $syntax : 'php';
63

    
64
		// check if resize option is supported by edit_area
65
		$allow_resize = in_array($allow_resize, array('no', 'both', 'x', 'y')) ? $allow_resize : 'no';
66

    
67
		// return the Javascript code
68
		$result = <<< EOT
69
		<script type="text/javascript">
70
			editAreaLoader.init({
71
				id: 				'$id',
72
				start_highlight:	$start_highlight,
73
				syntax:			    '$syntax',
74
				min_width:			$min_width,
75
				min_height:		    $min_height,
76
				allow_resize: 		'$allow_resize',
77
				allow_toggle: 		$allow_toggle,
78
				toolbar: 			'$toolbar',
79
				language:			'$language'
80
			});
81
		</script>
82
EOT;
83
		return $result;	
84
	}
85
}
86

    
87
if (!function_exists('getEditAreaSyntax')) {
88
	function getEditAreaSyntax($file) 
89
	{
90
		// returns the highlight scheme for edit_area
91
		$syntax = 'php';
92
		if (is_readable($file)) {
93
			// extract file extension
94
			$file_info = pathinfo($file);
95
		
96
			switch ($file_info['extension']) {
97
				case 'htm': case 'html': case 'htt':
98
					$syntax = 'html';
99
	  				break;
100

    
101
	 			case 'css':
102
					$syntax = 'css';
103
	  				break;
104

    
105
				case 'js':
106
					$syntax = 'js';
107
					break;
108

    
109
				case 'xml':
110
					$syntax = 'xml';
111
					break;
112

    
113
	 			case 'php': case 'php3': case 'php4': case 'php5':
114
					$syntax = 'php';
115
	  				break;
116

    
117
				default:
118
					$syntax = 'php';
119
					break;
120
			}
121
		}
122
		return $syntax ;
123
	}
124
}
125

    
126
?>
(5-5/5)