ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

page_composer_utilities.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_composer_utilities_1_0_0{
27
38 var $Cache = false;
39 var $CachedMultyFS = false;
40 var $PageComposer = false;
41 var $PageCSS = false;
42 var $PageJS = false;
43 var $Security = false;
44 var $String = false;
45 var $Tags = false;
46 var $TemplateManager = false;
47 var $Trace = false;
48
59 function __construct()
60 {
61 try
62 {
63 $this->Cache = get_package( 'cache' , 'last' , __FILE__ );
64 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
65 $this->PageCSS = get_package( 'page::page_css' , 'last' , __FILE__ );
66 $this->PageJS = get_package( 'page::page_js' , 'last' , __FILE__ );
67 $this->Security = get_package( 'security' , 'last' , __FILE__ );
68 $this->String = get_package( 'string' , 'last' , __FILE__ );
69 $this->Tags = get_package( 'string::tags' , 'last' , __FILE__ );
70 $this->TemplateManager = get_package( 'template_manager' , 'last' , __FILE__ );
71 $this->Trace = get_package( 'trace' , 'last' , __FILE__ );
72 }
73 catch( Exception $e )
74 {
75 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
76 }
77 }
78
97 function redirect_using_map( &$Options )
98 {
99 try
100 {
101 $PageName = $this->Security->get_gp( 'page_name' , 'command' );
102 $RedirectPage = $Options->get_setting( $PageName , false );
103 if( $RedirectPage === false )
104 {
105 $RedirectPage = $Options->get_setting( '*' , false );
106 }
107 if( $RedirectPage === false )
108 {
109 return;
110 }
111 header( "HTTP/1.1 301 Moved Permanently" );
112 if( $RedirectPage == 'self' )
113 {
114 header( "Location: $PageName.html" );
115 }
116 else
117 {
118 header( "Location: ".$this->Security->get_srv( 'REQUEST_URI' , 'string' ) );
119 }
120 exit( 0 );
121 }
122 catch( Exception $e )
123 {
124 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
125 }
126 }
127
146 function output_trace_if_necessary( &$PageComposer )
147 {
148 try
149 {
150 $AutoMarkup = get_package( 'page::auto_markup' , 'last' , __FILE__ );
151
152 if( $this->Security->get_gp( 'trace' , 'integer' , 0 ) )
153 {
154 $String = $PageComposer->Template->get_template();
155 $String = str_replace( '{trace}' , $this->Trace->compile_trace() , $String );
156 $String = $AutoMarkup->compile_string( $String );
157 $PageComposer->Template->set_template( $String );
158 }
159 elseif( $this->Security->get_gp( 'trace_only' , 'integer' , 0 ) )
160 {
161 $String = $this->Trace->compile_trace();
162 $String = $AutoMarkup->compile_string( $String );
163 print( $String );
164 exit( 0 );
165 }
166 }
167 catch( Exception $e )
168 {
169 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
170 }
171 }
172
191 function page_permit_validation( &$Options )
192 {
193 try
194 {
195 if( $Options->get_setting( 'page_permit_validation' , false ) )
196 {
197 $Permits = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
198 $PageName = $this->Security->get_g( 'page_name' , 'command' );
199
200 if( $Permits->validate_permits_ex( false , 'user' , $PageName , 'page' ) === false )
201 {
202 header( 'Location: ./no_permits.html' );
203 exit( 1 );
204 }
205 }
206 }
207 catch( Exception $e )
208 {
209 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
210 }
211 }
212
231 function get_template_for_package( $PageDescription )
232 {
233 try
234 {
235 $this->TemplateName = $PageDescription[ 'template' ];
236 $this->TemplateVersion = $PageDescription[ 'template_version' ];
237
238 return( $this->TemplateManager->get_template( $this->TemplateName , $this->TemplateVersion ) );
239 }
240 catch( Exception $e )
241 {
242 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
243 }
244 }
245
272 function translate_template_name( &$PageComposer , &$PageDescription )
273 {
274 try
275 {
276 $Default = $PageDescription[ 'template' ] == 'default';
277 $DefaultAdmin = $PageDescription[ 'template' ] == 'default_admin';
278
279 if( $Default || $DefaultAdmin )
280 {
281 $PageComposer->Template = $Default ?
282 $this->TemplateManager->get_default_template_name() :
283 $this->TemplateManager->get_default_admin_template_name();
284
285 $Data = array( $PageComposer->Template[ 'name' ] , $PageComposer->Template[ 'version' ] );
286 list( $PageDescription[ 'template' ] , $PageDescription[ 'template_version' ] ) = $Data;
287 }
288 }
289 catch( Exception $e )
290 {
291 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
292 }
293 }
294 }
295
296 ?>