Project

General

Profile

1
<?php
2
/*
3
*
4
*                       About WebsiteBaker
5
*
6
* Website Baker is a PHP-based Content Management System (CMS)
7
* designed with one goal in mind: to enable its users to produce websites
8
* with ease.
9
*
10
*                       LICENSE INFORMATION
11
*
12
* WebsiteBaker is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; either version 2
15
* of the License, or (at your option) any later version.
16
*
17
* WebsiteBaker is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
* See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
*
26
*                   WebsiteBaker Extra Information
27
*
28
*  Website Baker wrapper functions for the Javascript code editor: "EditArea"
29
*
30
*/
31
/**
32
 *
33
 * @category        framework
34
 * @package         include
35
 * @author		    Christophe Dolivet (EditArea), Christian Sommer (WB wrapper)
36
 * @author          WebsiteBaker Project
37
 * @copyright       2004-2009, Ryan Djurovich
38
 * @copyright       2009-2010, Website Baker Org. e.V.
39
 * @link			http://www.websitebaker2.org/
40
 * @license         http://www.gnu.org/licenses/gpl.html
41
 * @platform        WebsiteBaker 2.8.x
42
 * @requirements    PHP 4.3.4 and higher
43
 * @version         $Id: wb_wrapper_edit_area.php 1273 2010-01-24 08:26:18Z Luisehahne $
44
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/include/editarea/wb_wrapper_edit_area.php $
45
 * @lastmodified    $Date: 2010-01-24 09:26:18 +0100 (Sun, 24 Jan 2010) $
46
 *
47
 */
48

    
49
function loader_help()
50
{
51
?>
52
   <script type="text/javascript">
53
      var head= document.getElementsByTagName('head')[0];
54
      var script= document.createElement('script');
55
      script.type= 'text/javascript';
56
      script.src= '<?php print WB_URL; ?>/include/editarea/edit_area_full.js';
57
      head.appendChild(script);
58
   </script>
59
<?php
60

    
61
}
62

    
63
if (!function_exists('registerEditArea')) {
64
	function registerEditArea($id = 'code_area', $syntax = 'php', $syntax_selection = true
65
		, $allow_resize = 'both', $allow_toggle = true, $start_highlight = true
66
		, $min_width = 600, $min_height = 300, $toolbar = 'default')
67
	{
68

    
69
		// set default toolbar if no user defined was specified
70
		if ($toolbar == 'default') {
71
			$toolbar = 'search, fullscreen, |, undo, redo, |, select_font, syntax_selection, |, highlight, reset_highlight, |, help';
72
			$toolbar = (!$syntax_selection) ? str_replace('syntax_selection,', '', $toolbar) : $toolbar;
73
		}
74

    
75
		// check if used Website Baker backend language is supported by EditArea
76
		$language = 'en';
77
		if (defined('LANGUAGE') && file_exists(dirname(__FILE__) . '/langs/' . strtolower(LANGUAGE) . '.js')) {
78
			$language = strtolower(LANGUAGE);
79
		}
80

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

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

    
87
        loader_help();
88
		// return the Javascript code
89
		$result = <<< EOT
90
		<script type="text/javascript">
91
			editAreaLoader.init({
92
				id: 				'$id'
93
				,start_highlight:	$start_highlight
94
				,syntax:			'$syntax'
95
				,min_width:			$min_width
96
				,min_height:		$min_height
97
				,allow_resize: 		'$allow_resize'
98
				,allow_toggle: 		$allow_toggle
99
				,toolbar: 			'$toolbar'
100
				,language:			'$language'
101
			});
102
		</script>
103
EOT;
104
		return $result;	
105
	}
106
}
107

    
108
if (!function_exists('getEditAreaSyntax')) {
109
	function getEditAreaSyntax($file) 
110
	{
111
		// returns the highlight scheme for edit_area
112
		$syntax = 'php';
113
		if (is_readable($file)) {
114
			// extract file extension
115
			$file_info = pathinfo($file);
116
		
117
			switch ($file_info['extension']) {
118
				case 'htm': case 'html': case 'htt':
119
					$syntax = 'html';
120
	  				break;
121

    
122
	 			case 'css':
123
					$syntax = 'css';
124
	  				break;
125

    
126
				case 'js':
127
					$syntax = 'js';
128
					break;
129

    
130
				case 'xml':
131
					$syntax = 'xml';
132
					break;
133

    
134
	 			case 'php': case 'php3': case 'php4': case 'php5':
135
					$syntax = 'php';
136
	  				break;
137

    
138
				default:
139
					$syntax = 'php';
140
					break;
141
			}
142
		}
143
		return $syntax ;
144
	}
145
}
146

    
147
?>
(5-5/5)