ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

page_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 page_markup_1_0_0
27 {
28
39 var $PageMarkupUtilities = false;
40 var $Security = false;
41
52 function __construct()
53 {
54 try
55 {
56 $this->PageMarkupUtilities = get_package(
57 'page::page_markup::page_markup_utilities' , 'last' , __FILE__
58 );
59 $this->Security = get_package( 'security' , 'last' , __FILE__ );
60 }
61 catch( Exception $e )
62 {
63 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
64 }
65 }
66
89 function compile_direct_controller( &$Settings )
90 {
91 try
92 {
93 if( $Settings->get_setting( 'need_run' , 1 ) == 1 )
94 {
95 $this->PageMarkupUtilities->direct_controller( $Settings );
96 }
97
98 return( '' );
99 }
100 catch( Exception $e )
101 {
102 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
103 }
104 }
105
128 function compile_direct_view( &$Settings )
129 {
130 try
131 {
132 $this->Security->reset_s( 'direct_view' , true );
133
134 $Settings->set_undefined( 'view' , 1 );
135
136 $Code = '';
137 if( $Settings->get_setting( 'need_run' , 1 ) == 1 )
138 {
139 $Code = $this->PageMarkupUtilities->direct_view( $Settings );
140 }
141
142 $this->Security->reset_s( 'direct_view' , false );
143
144 return( $Code );
145 }
146 catch( Exception $e )
147 {
148 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
149 }
150 }
151
174 function compile_redirect( &$Settings )
175 {
176 try
177 {
178 $NeedRedirect = intval( $Settings->get_setting( 'need_redirect' , 1 ) );
179
180 if( $NeedRedirect )
181 {
182 header( 'Location: '.$Settings->get_setting( 'page' ) );
183 exit( 0 );
184 }
185
186 return( '' );
187 }
188 catch( Exception $e )
189 {
190 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
191 }
192 }
193
220 function compile_safe( &$Settings , $Data )
221 {
222 try
223 {
224 return( $this->Security->get( $Data , 'string' ) );
225 }
226 catch( Exception $e )
227 {
228 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
229 }
230 }
231
262 function compile_common_literals( $Names , $Str , $Changed )
263 {
264 try
265 {
266 foreach( $Names as $i => $Name )
267 {
268 if( strpos( $Str , '{'.$Name.'}' ) !== false )
269 {
270 $Code = "{settings:package_name=page::page_composer;name=$Name;config_file_name=cf_site}";
271
272 $Str = str_replace( '{'.$Name.'}' , $Code , $Str );
273 $Changed = true;
274 }
275 }
276
277 return( array( $Str , $Changed ) );
278 }
279 catch( Exception $e )
280 {
281 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
282 }
283 }
284
315 function compile_front_page_literals( $Names , $Str , $Changed )
316 {
317 try
318 {
319 if( $this->Security->get_gp( 'page_name' , 'command' ) != 'index' )
320 {
321 return( array( $Str , $Changed ) );
322 }
323
324 foreach( $Names as $i => $Name )
325 {
326 if( strpos( $Str , '{'.$Name.'}' ) !== false )
327 {
328 $Code = '<h1>{settings:package_name=page::page_composer;name='.$Name.
329 ';config_file_name=cf_site}</h1>';
330
331 $Str = str_replace( '{'.$Name.'}' , $Code , $Str );
332 $Changed = true;
333 }
334 }
335
336 return( array( $Str , $Changed ) );
337 }
338 catch( Exception $e )
339 {
340 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
341 }
342 }
343
370 function compile_for_pages( $Settings , $Data )
371 {
372 try
373 {
374 $Pages = explode( ',' , $Settings->get_setting( 'pages' ) );
375
376 $PageName = $this->Security->get_gp( 'page_name' , 'command' );
377
378 if( in_array( $PageName , $Pages ) )
379 {
380 return( $Data );
381 }
382
383 return( '' );
384 }
385 catch( Exception $e )
386 {
387 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
388 }
389 }
390
417 function compile_not_for_pages( $Settings , $Data )
418 {
419 try
420 {
421 $Pages = explode( ',' , $Settings->get_setting( 'pages' ) );
422
423 $PageName = $this->Security->get_gp( 'page_name' , 'command' );
424
425 if( !in_array( $PageName , $Pages ) )
426 {
427 return( $Data );
428 }
429
430 return( '' );
431 }
432 catch( Exception $e )
433 {
434 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
435 }
436 }
437
460 private function run_meta_settings( &$MetaSettings , $Str )
461 {
462 try
463 {
464 $Settings = $MetaSettings->get_all_settings();
465 $Code = '';
466 if( $MetaSettings->get_setting( 'controller' , '0' ) != '0' )
467 {
468 $Code = "{direct_controller:$Settings}";
469 }
470 elseif( $MetaSettings->get_setting( 'view' , '0' ) != '0' )
471 {
472 $Code = "{direct_view:$Settings}";
473 }
474 elseif( $MetaSettings->get_setting( 'post_process' , '0' ) != '0' )
475 {
476 $AutoMarkup = get_package( 'page::auto_markup' , 'last' , __FILE__ );
477 $Str = $AutoMarkup->compile_string( $Str );
478 }
479 $Str = str_replace( "{meta:$Parameters}" , $Code , $Str );
480 return( $Str );
481 }
482 catch( Exception $e )
483 {
484 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
485 }
486 }
487
510 private function load_meta_settings( &$MacroSettings , &$MetaSettings )
511 {
512 try
513 {
514 $PackageName = $MacroSettings->get_setting( 'package_name' );
515 $PackageVersion = $MacroSettings->get_setting( 'package_version' , 'last' );
516
517 $MetaFile = _get_package_relative_path_ex( $PackageName , $PackageVersion );
518 $MeatFile .= '/meta/'.$MacroSettings->get_setting( 'name' );
519
520 $MetaSettings->load_file( $MetaFile );
521
522 $MetaSettings->set_setting( 'package_name' , $PackageName );
523 $MetaSettings->set_setting( 'package_version' , $PackageVersion );
524 }
525 catch( Exception $e )
526 {
527 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
528 }
529 }
530
553 function compile_meta( &$Settings )
554 {
555 try
556 {
557 $MetaSettings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
558 $this->load_meta_settings( $Settings , $MetaSettings );
559
560 $Str = $this->run_meta_settings( $MetaSettings , $Str );
561 }
562 catch( Exception $e )
563 {
564 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
565 }
566 }
567 }
568
569 ?>