ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

controls_markup.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class controls_markup_1_0_0
27 {
28
39 var $CachedMultyFS = false;
40 var $Database = false;
41 var $Security = false;
42 var $String = false;
43
54 function __construct()
55 {
56 try
57 {
58 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
59 $this->Database = get_package( 'database' , 'last' , __FILE__ );
60 $this->Security = get_package( 'security' , 'last' , __FILE__ );
61 $this->String = get_package( 'string' , 'last' , __FILE__ );
62 }
63 catch( Exception $e )
64 {
65 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
66 }
67 }
68
87 private function prepare_textarea_settings( &$Settings )
88 {
89 try
90 {
91 $Settings->set_undefined( 'toolbar' , 'ultimix_full' );
92 $Settings->set_undefined( 'name' , 'editor');
93 $Settings->set_undefined( 'class' , 'width_640 height_480' );
94 }
95 catch( Exception $e )
96 {
97 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
98 }
99 }
100
127 function compile_textarea( &$Settings , $Data )
128 {
129 try
130 {
131 $Settings->set_setting( 'text' , $Data );
132
133 $this->prepare_textarea_settings( $Settings );
134
135 $SimpleEditor = $Settings->get_setting( 'simple_editor' , 0 );
136 $File = $SimpleEditor == 1 ? 'simple_editor.tpl' : 'editor.tpl';
137 $EditorTemplate = $this->CachedMultyFS->get_template( __FILE__ , $File );
138 $RawSettings = $Settings->get_raw_settings();
139
140 return( $this->String->print_record( $EditorTemplate , $RawSettings ) );
141 }
142 catch( Exception $e )
143 {
144 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
145 }
146 }
147
170 function get_select_data( &$Settings )
171 {
172 try
173 {
174 if( $Settings->get_setting( 'query' , false ) !== false )
175 {
176 $Query = $Settings->get_setting( 'query' );
177 $this->Database->query_as( DB_OBJECT );
178 $Records = $this->Database->query( $Query );
179 $Records = $this->Database->fetch_results( $Records );
180 $First = get_field_ex( $Records , 'id' );
181 $Second = get_field_ex( $Records , 'value' );
182 }
183 else
184 {
185 $First = explode( '|' , $Settings->get_setting( 'first' , false ) );
186 $Second = explode( '|' , $Settings->get_setting( 'second' , false ) );
187 }
188
189 return( array( $First , $Second ) );
190 }
191 catch( Exception $e )
192 {
193 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
194 }
195 }
196
227 private function compile_select_options( $First , $Second , $SelectedId )
228 {
229 try
230 {
231 $Code = '';
232
233 foreach( $First as $k => $v )
234 {
235 $Selected = '';
236
237 if( $SelectedId !== false && $SelectedId == $v )
238 {
239 $Selected = 'selected ';
240 }
241
242 $PlaceHolders = array( '{selected}' , '{value}' , '{title}' );
243 $Data = array( $Selected , $v , $Second[ $k ] );
244 $Code .= $this->CachedMultyFS->get_template( __FILE__ , 'select_option.tpl' );
245 $Code = str_replace( $PlaceHolders , $Data , $Code );
246 }
247
248 return( $Code );
249 }
250 catch( Exception $e )
251 {
252 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
253 }
254 }
255
278 function compile_select( &$Settings )
279 {
280 try
281 {
282 $Name = $Settings->get_setting( 'name' );
283 $Class = $Settings->get_setting( 'class' , 'width_320 flat' );
284
285 list( $First , $Second ) = $this->get_select_data( $Settings );
286
287 $SelectedId = $this->Security->get_gp(
288 $Name , 'string' , $Settings->get_setting( 'value' , false )
289 );
290
291 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'select_start.tpl' );
292 $Code = str_replace( array( '{name}' , '{class}' ) , array( $Name , $Class ) , $Code );
293
294 $Code .= $this->compile_select_options( $First , $Second , $SelectedId );
295
296 return( $Code.$this->CachedMultyFS->get_template( __FILE__ , 'select_end.tpl' ) );
297 }
298 catch( Exception $e )
299 {
300 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
301 }
302 }
303
326 function compile_year_list( &$Settings )
327 {
328 try
329 {
330 $From = $Settings->get_setting( 'from' , intval( date( 'Y' ) ) - 10 );
331 $To = $Settings->get_setting( 'to' , intval( date( 'Y' ) ) + 10 );
332 $First = array();
333 for( $i = $From ; $i <= $To ; $i++ )
334 {
335 $First [] = $i;
336 }
337 $First = implode( '|' , $First );
338
339 return( "{select:first=$First;second=$First;".$Settings->get_raw_settings()."}" );
340 }
341 catch( Exception $e )
342 {
343 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
344 }
345 }
346 }
347
348 ?>