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 1274 2010-01-24 13:55: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 14:55: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(
65
                $id = 'code_area',
66
                $syntax = 'php',
67
                $syntax_selection = true,
68
                $allow_resize = 'both',
69
                $allow_toggle = true,
70
                $start_highlight = true,
71
                $min_width = 600,
72
                $min_height = 300,
73
                $toolbar = 'default'
74
            )
75
	{
76

    
77
		// set default toolbar if no user defined was specified
78
		if ($toolbar == 'default') {
79
			$toolbar = 'search, fullscreen, |, undo, redo, |, select_font, syntax_selection, |, highlight, reset_highlight, |, help';
80
			$toolbar = (!$syntax_selection) ? str_replace('syntax_selection,', '', $toolbar) : $toolbar;
81
		}
82

    
83
		// check if used Website Baker backend language is supported by EditArea
84
		$language = 'en';
85
		if (defined('LANGUAGE') && file_exists(dirname(__FILE__) . '/langs/' . strtolower(LANGUAGE) . '.js'))
86
        {
87
			$language = strtolower(LANGUAGE);
88
		}
89

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

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

    
96
		// return the Javascript code
97
		$result = <<< EOT
98
		<script type="text/javascript">
99
			editAreaLoader.init({
100
				id: 				'$id',
101
				start_highlight:	$start_highlight,
102
				syntax:			    '$syntax',
103
				min_width:			$min_width,
104
				min_height:		    $min_height,
105
				allow_resize: 		'$allow_resize',
106
				allow_toggle: 		$allow_toggle,
107
				toolbar: 			'$toolbar',
108
				language:			'$language'
109
			});
110
		</script>
111
EOT;
112
		return $result;	
113
	}
114
}
115

    
116
if (!function_exists('getEditAreaSyntax')) {
117
	function getEditAreaSyntax($file) 
118
	{
119
		// returns the highlight scheme for edit_area
120
		$syntax = 'php';
121
		if (is_readable($file)) {
122
			// extract file extension
123
			$file_info = pathinfo($file);
124
		
125
			switch ($file_info['extension']) {
126
				case 'htm': case 'html': case 'htt':
127
					$syntax = 'html';
128
	  				break;
129

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

    
134
				case 'js':
135
					$syntax = 'js';
136
					break;
137

    
138
				case 'xml':
139
					$syntax = 'xml';
140
					break;
141

    
142
	 			case 'php': case 'php3': case 'php4': case 'php5':
143
					$syntax = 'php';
144
	  				break;
145

    
146
				default:
147
					$syntax = 'php';
148
					break;
149
			}
150
		}
151
		return $syntax ;
152
	}
153
}
154

    
155
?>
(5-5/5)