ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

button_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 button_markup_1_0_0
27 {
28
39 var $Settings = false;
40 var $CachedMultyFS = false;
41 var $PageJS = false;
42 var $String = false;
43 var $Utilities = false;
44
55 function __construct()
56 {
57 try
58 {
59 $Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
60 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
61 $this->PageJS = get_package( 'page::page_js' , 'last' , __FILE__ );
62 $this->String = get_package( 'string' , 'last' , __FILE__ );
63 $this->Utilities = get_package( 'utilities' , 'last' , __FILE__ );
64 }
65 catch( Exception $e )
66 {
67 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
68 }
69 }
70
89 function pre_generation( $Options )
90 {
91 try
92 {
93 $Path = "{http_host}/"._get_package_relative_path_ex( 'gui::button_markup' , 'last' );
94 $this->PageJS->add_javascript( "$Path/include/js/button_markup.js" );
95 }
96 catch( Exception $e )
97 {
98 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
99 }
100 }
101
128 function compile_component_button( &$Settings )
129 {
130 try
131 {
132 $Settings->set_undefined( 'label' , 'label' );
133 $Settings->set_undefined( 'size' , '42' );
134 $Settings->set_undefined( 'package_version' , 'last' );
135
136 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'component_button.tpl' );
137 $Code = $this->String->print_record( $Code , $Settings->get_raw_settings() );
138
139 $Path = $this->Utilities->get_package_path( $Settings );
140
141 $Icon = $Settings->get_setting( 'icon' );
142 $Code = str_replace( '{path_to_image}' , "$Path/res/images/$Icon" , $Code );
143
144 return( $Code );
145 }
146 catch( Exception $e )
147 {
148 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
149 }
150 }
151
170 private function set_default_data_for_toolbar_button( &$Settings )
171 {
172 try
173 {
174 $Settings->set_undefined( 'title' , '' );
175 $Settings->set_undefined( 'size' , 24 );
176 $Settings->set_undefined( 'permit' , 'admin' );
177 $Settings->set_undefined( 'package_version' , 'last' );
178 $Settings->set_undefined( 'page' , 'javascript:void(0);' );
179
180 $OnClick = $Settings->get_setting( 'onclick' , false );
181 if( $OnClick === false )
182 {
183 $Settings->set_setting( 'onclick' , '' );
184 }
185 else
186 {
187 $Settings->set_setting( 'onclick' , 'onclick="'.$OnClick.'" ' );
188 }
189 }
190 catch( Exception $e )
191 {
192 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
193 }
194 }
195
218 function compile_menu_button( &$Settings )
219 {
220 try
221 {
222 $this->set_default_data_for_toolbar_button( $Settings );
223
224 $Icon = $Settings->get_setting( 'icon' );
225
226 $Path = $this->Utilities->get_package_path( $Settings );
227
228 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'menu_button.tpl' );
229
230 $Code = $this->String->print_record( $Code , $Settings->get_raw_settings() );
231
232 return( str_replace( '{path_to_image}' , "$Path/res/images/$Icon" , $Code ) );
233 }
234 catch( Exception $e )
235 {
236 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
237 }
238 }
239
262 function compile_toolbar_button( &$Settings )
263 {
264 try
265 {
266 $this->set_default_data_for_toolbar_button( $Settings );
267
268 $Icon = $Settings->get_setting( 'icon' );
269
270 $Path = $this->Utilities->get_package_path( $Settings );
271
272 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'toolbar_button.tpl' );
273 $Code = $this->String->print_record( $Code , $Settings->get_raw_settings() );
274 $Code = str_replace( '{path_to_image}' , "$Path/res/images/$Icon" , $Code );
275
276 return( $Code );
277 }
278 catch( Exception $e )
279 {
280 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
281 }
282 }
283
310 private function set_toggle_button_icons( $Code , &$Settings )
311 {
312 try
313 {
314 $Path = $this->Utilities->get_package_path( $Settings );
315
316 $Value = $Settings->get_setting( 'value' , 0 );
317 $Icon = $Settings->get_setting( $Value ? 'icon' : 'icon_toggle' );
318 $IconToggle = $Settings->get_setting( $Value ? 'icon_toggle' : 'icon' );
319
320 $ToggleFunc = $Settings->get_setting( 'toggle_func' );
321
322 $Func = "ultimix.button_markup.ToggleButton( this , '$Icon' , '$IconToggle' , $ToggleFunc );";
323 $Code = str_replace(
324 array( '{path_to_image}' , '{func}' , '{icon}' , '{icon_toggle}' ) ,
325 array( "$Path/res/images/$Icon" , $Func , $Icon , $IconToggle ) , $Code
326 );
327
328 return( $Code );
329 }
330 catch( Exception $e )
331 {
332 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
333 }
334 }
335
358 function compile_toggle_button( &$Settings )
359 {
360 try
361 {
362 $this->set_default_data_for_toolbar_button( $Settings );
363
364 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'toggle_button.tpl' );
365 $Code = $this->String->print_record( $Code , $Settings->get_raw_settings() );
366
367 $Code = $this->set_toggle_button_icons( $Code , $Settings );
368
369 return( $Code );
370 }
371 catch( Exception $e )
372 {
373 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
374 }
375 }
376
377 //TODO: use run_controller_and_remove_dom_button macro anywhere
400 function compile_run_controller_and_remove_dom_button( &$Settings )
401 {
402 try
403 {
404 $this->set_default_data_for_toolbar_button( $Settings );
405
406 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'run_controller_and_remove_dom_button.tpl' );
407
408 $Code = $this->String->print_record( $Code , $Settings->get_raw_settings() );
409
410 $Path = $this->Utilities->get_package_path( $Settings );
411
412 $Code = str_replace( '{path_to_image}' , $Path."/res/images/$Icon" , $Code );
413
414 return( $Code );
415 }
416 catch( Exception $e )
417 {
418 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
419 }
420 }
421 }
422
423 ?>