00001 <?php
00007 namespace Habari;
00008
00014 class UserThemeHandler extends ActionHandler
00015 {
00016
00020 public function __construct()
00021 {
00022 $this->setup_theme();
00023 }
00024
00034 public function act( $action )
00035 {
00036 $this->action = $action;
00037
00038 $action_method = 'act_' . $action;
00039 $before_action_method = 'before_' . $action_method;
00040 $after_action_method = 'after_' . $action_method;
00041
00042 $this->theme->$before_action_method();
00043 try {
00044 $handled = false;
00045 $handled = Plugins::filter( 'theme_act_' . $action, $handled, $this->theme );
00046 if ( !$handled ) {
00047 $this->theme->$action_method();
00048 }
00049 }
00050 catch( Error $e ) {
00051 EventLog::log( $e->humane_error(), 'error', 'theme', 'habari', print_r( $e, 1 ) );
00052 Session::error( $e->humane_error() );
00053 if ( DEBUG ) {
00054 Utils::debug( $e );
00055 }
00056 }
00057 $this->theme->$after_action_method();
00058 }
00059
00066 protected function display( $template_name )
00067 {
00068
00069
00070
00071
00072 foreach ( $this->handler_vars as $key => $value ) {
00073 $this->theme->assign( $key, $value );
00074 }
00075 try {
00076 $this->theme->display( $template_name );
00077 }
00078 catch( Error $e ) {
00079 EventLog::log( $e->humane_error(), 'error', 'theme', 'habari', print_r( $e, 1 ) );
00080 }
00081 }
00082 }
00083
00084 ?>