ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

page_markup_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_markup_utilities_1_0_0
27 {
28
39 var $CachedMultyFS = false;
40 var $Security = false;
41 var $Trace = false;
42
53 function __construct()
54 {
55 try
56 {
57 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
58 $this->Security = get_package( 'security' , 'last' , __FILE__ );
59 $this->Trace = get_package( 'trace' , 'last' , __FILE__ );
60 }
61 catch( Exception $e )
62 {
63 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
64 }
65 }
66
85 function add_meta_parameters( &$Options )
86 {
87 try
88 {
89 $PackageName = $Options->get_setting( 'package_name' );
90 $PackageVersion = $Options->get_setting( 'package_version' , 'last' );
91
92 if( $Options->get_setting( 'meta' , false ) !== false )
93 {
94 $PackagePath = _get_package_relative_path_ex( $PackageName , $PackageVersion );
95 $MetaFileName = $Options->get_setting( 'meta' );
96 $MetaSettings = $this->CachedMultyFS->file_get_contents( "$PackagePath/meta/$MetaFileName" );
97 $Options->append_settings( $MetaSettings );
98 }
99 }
100 catch( Exception $e )
101 {
102 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
103 }
104 }
105
128 private function call_controller( &$Package , &$Options )
129 {
130 try
131 {
132 if( method_exists( $Package , 'controller' ) === false )
133 {
134 throw( new Exception( 'Function "controller" was not found for class '.get_class( $Package ) ) );
135 }
136 else
137 {
138 $Class = get_class( $Package );
139 $this->Trace->add_trace_string( "{lang:running_direct_controller} for the class $Class" , COMMON );
140
141 $Package->controller( $Options );
142
143 $this->Trace->add_trace_string( "{lang:ending_direct_controller} for the class $Class" , COMMON );
144 }
145 }
146 catch( Exception $e )
147 {
148 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
149 }
150 }
151
170 function direct_controller( &$Options )
171 {
172 try
173 {
174 $this->Security->reset_s( 'direct_controller' , 1 );
175
176 $this->Trace->add_trace_string( '{lang:processing_direct_controller}' , COMMON );
177
178 $PackageName = $Options->get_setting( 'package_name' , false );
179 if( $PackageName !== false )
180 {
181 $PackageVersion = $Options->get_setting( 'package_version' , 'last' );
182 $Package = get_package( $PackageName , $PackageVersion , __FILE__ );
183
184 $this->add_meta_parameters( $Options );
185
186 $this->call_controller( $Package , $Options );
187 }
188
189 $this->Security->reset_s( 'direct_controller' , 0 );
190 }
191 catch( Exception $e )
192 {
193 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
194 }
195 }
196
223 function wrap_control_view( &$Options , $ControlView )
224 {
225 try
226 {
227 $Class = $Options->get_setting( 'wrapper_class' , false );
228 if( $Class !== false )
229 {
230 $Class = " class=\"$Class\"";
231 }
232
233 $Id = $Options->get_setting( 'wrapper_id' , false );
234 if( $Id !== false )
235 {
236 $Id = " id=\"$Id\"";
237 }
238
239 if( $Id || $Class )
240 {
241 $PlaceHolders = array( '{id}' , '{class}' , '{control_view}' );
242 $ViewWrapper = $this->CachedMultyFS->get_template( __FILE__ , 'view_wrapper.tpl' );
243 $ControlView = str_replace( $PlaceHolders , array( $Id , $Class , $ControlView ) , $ViewWrapper );
244 }
245
246 return( $ControlView );
247 }
248 catch( Exception $e )
249 {
250 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
251 }
252 }
253
276 function direct_view( &$Options )
277 {
278 try
279 {
280 $PackageName = $Options->get_setting( 'package_name' , false );
281 $PackageVersion = $Options->get_setting( 'package_version' , 'last' );
282
283 if( $PackageName !== false )
284 {
285 $Package = get_package( $PackageName , $PackageVersion , __FILE__ );
286
287 $this->add_meta_parameters( $Options );
288
289 if( method_exists( $Package , 'view' ) === false )
290 {
291 throw( new Exception( 'Function "view" was not found for class '.get_class( $Package ) ) );
292 }
293 else
294 {
295 $ControlView = $Package->view( $Options );
296 return( $this->wrap_control_view( $Options , $ControlView ) );
297 }
298 }
299 }
300 catch( Exception $e )
301 {
302 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
303 }
304 }
305 }
306
307 ?>