Changeset 2872
- Timestamp:
- 11/24/08 17:42:02 (6 weeks ago)
- Location:
- branches/adminhandler/htdocs/system/classes
- Files:
-
- 5 modified
-
adminhandler.php (modified) (2 diffs)
-
adminpage.php (modified) (3 diffs)
-
dashboardadminpage.php (modified) (2 diffs)
-
pluginsadminpage.php (modified) (2 diffs)
-
publishadminpage.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/adminhandler/htdocs/system/classes/adminhandler.php
r2870 r2872 90 90 if ( class_exists($admin_page) ) { 91 91 $admin_page = new $admin_page( $request_method, $this, $this->theme ); 92 $ fn = 'act_request_' . strtolower($request_method);93 $admin_page-> $fn();92 $action = isset($this->handler_vars['action']) ? $this->handler_vars['action'] : 'request'; 93 $admin_page->act( $action, $request_method ); 94 94 } 95 95 else { … … 110 110 if ( class_exists($admin_page) ) { 111 111 $admin_page = new $admin_page( $request_method, $this ); 112 $ fn = 'act_ajax_' . strtolower($request_method);113 $admin_page-> $fn( $this->handler_vars);112 $action = isset($this->handler_vars['action']) ? $this->handler_vars['action'] : 'request'; 113 $admin_page->act_ajax( $action, $request_method ); 114 114 } 115 115 else { -
branches/adminhandler/htdocs/system/classes/adminpage.php
r2870 r2872 5 5 protected $request_method; 6 6 protected $handler; 7 protected $handler_vars = array(); 7 8 protected $theme; 8 9 … … 15 16 } 16 17 18 // @todo fix allow list for new action methods. 17 19 public function __call( $method, $args ) 18 20 { 19 21 $class = get_class($this); 20 Plugins::act( "{$class}_{$ this->request_method}", $this, $args );22 Plugins::act( "{$class}_{$method}", $this, $args ); 21 23 header( 'HTTP/1.1 405 Method Not Allowed', true, 405 ); 22 24 // Build list of accepted methods and send allow header as per spec.. … … 38 40 } 39 41 42 public function act( $action, $method ) 43 { 44 $this->{"act_{$action}_{$method}"}(); 45 } 46 47 public function act_ajax( $action, $method ) 48 { 49 $this->{"act_ajax_{$action}_{$method}"}(); 50 } 51 40 52 protected function display( $template_name ) 41 53 { -
branches/adminhandler/htdocs/system/classes/dashboardadminpage.php
r2870 r2872 130 130 131 131 /** 132 * Handles ajax requests from the dashboard133 */134 public function act_ajax_post( $handler_vars )135 {136 $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) );137 $this->theme = Themes::create( 'admin', 'RawPHPEngine', $theme_dir );138 139 switch ( $handler_vars['action'] ) {140 case 'updateModules':141 $modules = array();142 foreach($_POST as $key => $module ) {143 // skip POST elements which are not module names144 if ( preg_match( '/^module\d+$/', $key ) ) {145 list( $module_id, $module_name ) = split( ':', $module, 2 );146 // remove non-sortable modules from the list147 if ( $module_id != 'nosort' ) {148 $modules[$module_id] = $module_name;149 }150 }151 }152 153 Modules::set_active( $modules );154 echo json_encode( true );155 break;156 case 'addModule':157 $id = Modules::add( $handler_vars['module_name'] );158 $this->fetch_dashboard_modules();159 $result = array(160 'message' => "Added module {$handler_vars['module_name']}.",161 'modules' => $this->theme->fetch( 'dashboard_modules' ),162 );163 echo json_encode( $result );164 break;165 case 'removeModule':166 Modules::remove( $handler_vars['moduleid'] );167 $this->fetch_dashboard_modules();168 $result = array(169 'message' => 'Removed module',170 'modules' => $this->theme->fetch( 'dashboard_modules' ),171 );172 echo json_encode( $result );173 break;174 }175 }176 177 /**178 132 * Adds a module to the user's dashboard 179 133 * @param object form FormUI object … … 187 141 return false; 188 142 } 143 144 // AJAX Methods 145 146 public function act_ajax( $action, $method ) 147 { 148 $theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) ); 149 $this->theme = Themes::create( 'admin', 'RawPHPEngine', $theme_dir ); 150 151 parent::act_ajax( $action, $method ); 152 } 153 154 public function act_ajax_updateModules_post() 155 { 156 $modules = array(); 157 foreach($_POST as $key => $module ) { 158 // skip POST elements which are not module names 159 if ( preg_match( '/^module\d+$/', $key ) ) { 160 list( $module_id, $module_name ) = split( ':', $module, 2 ); 161 // remove non-sortable modules from the list 162 if ( $module_id != 'nosort' ) { 163 $modules[$module_id] = $module_name; 164 } 165 } 166 } 167 168 Modules::set_active( $modules ); 169 echo json_encode( true ); 170 } 171 172 public function act_ajax_addModule_post() 173 { 174 $id = Modules::add( $this->handler_vars['module_name'] ); 175 $this->fetch_dashboard_modules(); 176 $result = array( 177 'message' => "Added module {$this->handler_vars['module_name']}.", 178 'modules' => $this->theme->fetch( 'dashboard_modules' ), 179 ); 180 echo json_encode( $result ); 181 } 182 183 public function act_ajax_removeModule_post() 184 { 185 Modules::remove( $this->handler_vars['moduleid'] ); 186 $this->fetch_dashboard_modules(); 187 $result = array( 188 'message' => 'Removed module', 189 'modules' => $this->theme->fetch( 'dashboard_modules' ), 190 ); 191 echo json_encode( $result ); 192 } 189 193 } -
branches/adminhandler/htdocs/system/classes/pluginsadminpage.php
r2870 r2872 3 3 class PluginsAdminPage extends AdminPage 4 4 { 5 /**5 /** 6 6 * A POST handler for the admin plugins page that simply passes those options through. 7 7 */ 8 public function post_plugins()8 public function act_request_post() 9 9 { 10 return $this-> get_plugins();10 return $this->act_request_get(); 11 11 } 12 12 13 public function get_plugins()13 public function act_request_get() 14 14 { 15 15 $all_plugins = Plugins::list_all(); … … 69 69 } 70 70 71 /** 72 * Handles plugin activation or deactivation. 73 */ 74 public function get_plugin_toggle() 75 { 76 $extract = $this->handler_vars->filter_keys('plugin_id', 'action'); 77 foreach($extract as $key => $value) { 78 $$key = $value; 79 } 80 81 $plugins = Plugins::list_all(); 82 foreach($plugins as $file) { 83 if(Plugins::id_from_file($file) == $plugin_id) { 84 switch ( strtolower($action) ) { 85 case 'activate': 86 if ( Plugins::activate_plugin($file) ) { 87 $plugins = Plugins::get_active(); 88 Session::notice( 89 _t( "Activated plugin '%s'", array($plugins[Plugins::id_from_file( $file )]->info->name) ), 90 $plugins[Plugins::id_from_file($file)]->plugin_id 91 ); 92 } 93 break; 94 case 'deactivate': 95 if ( Plugins::deactivate_plugin($file) ) { 96 $plugins = Plugins::get_active(); 97 Session::notice( 98 _t( "Deactivated plugin '%s'", array($plugins[Plugins::id_from_file( $file )]->info->name) ), 99 $plugins[Plugins::id_from_file($file)]->plugin_id 100 ); 101 } 102 break; 103 default: 104 Plugins::act( 105 'adminhandler_get_plugin_toggle_action', 106 $action, 107 $file, 108 $plugin_id, 109 $plugins 110 ); 111 break; 112 } 113 } 114 } 115 Utils::redirect( URL::get( 'admin', 'page=plugins' ) ); 116 } 117 118 /** 71 /** 119 72 * Handles plugin activation or deactivation. 120 73 */ -
branches/adminhandler/htdocs/system/classes/publishadminpage.php
r2870 r2872 101 101 } 102 102 103 public function form_publish( $post, $newpost = true)103 public function form_publish( Post $post, $newpost = true) 104 104 { 105 105 $form = new FormUI('create-content');
