Changeset 2851
- Timestamp:
- 11/24/08 01:06:07 (7 weeks ago)
- Files:
-
- 12 modified
-
makaanga/0.x/htdocs/index.php (modified) (5 diffs)
-
trunk/htdocs/system/admin/css/admin.css (modified) (1 diff)
-
trunk/htdocs/system/classes/actionhandler.php (modified) (4 diffs)
-
trunk/htdocs/system/classes/adminhandler.php (modified) (11 diffs)
-
trunk/htdocs/system/classes/controller.php (modified) (2 diffs)
-
trunk/htdocs/system/classes/formui.php (modified) (8 diffs)
-
trunk/htdocs/system/classes/hiengine.php (modified) (1 diff)
-
trunk/htdocs/system/classes/installhandler.php (modified) (19 diffs)
-
trunk/htdocs/system/classes/post.php (modified) (4 diffs)
-
trunk/htdocs/system/classes/posts.php (modified) (9 diffs)
-
trunk/htdocs/system/classes/theme.php (modified) (3 diffs)
-
trunk/htdocs/system/classes/utils.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
makaanga/0.x/htdocs/index.php
r2214 r2851 22 22 * Start the profile time 23 23 */ 24 $profile_start= microtime(true); 24 $profile_start= microtime(true); 25 25 26 26 /** … … 43 43 // as well as the ability to dynamically change HTTP headers after output has started. 44 44 ob_start(); 45 46 // Replace all of the $_GET, $_POST and $_SERVER superglobals with object 47 // representations of each. Unset $_REQUEST, which is evil. 48 // $_COOKIE must be set after sessions start 49 SuperGlobal::process_gps(); 45 50 46 51 /** … … 122 127 if ( file_exists( $config ) ) { 123 128 require_once $config; 124 129 125 130 // Set the default locale. 126 131 Locale::set( isset($locale) ? $locale : 'en-us' ); 127 132 128 133 if ( !defined( 'DEBUG' ) ) define( 'DEBUG', false ); 129 134 … … 191 196 * Include all the active plugins. 192 197 * By loading them here they'll have global scope. 193 * 198 * 194 199 * We loop through them twice so we can cache all plugin classes on the first load() call. 195 200 * This gives about 60% improvement. … … 208 213 // Start the session. 209 214 Session::init(); 215 216 // Replace the $_COOKIE superglobal with an object representation 217 SuperGlobal::process_c(); 210 218 211 219 // Initiating request handling, tell the plugins. -
trunk/htdocs/system/admin/css/admin.css
r2846 r2851 1821 1821 1822 1822 body.page-tags .container span { 1823 white-space: nowrap;1823 display: inline-block; 1824 1824 } 1825 1825 -
trunk/htdocs/system/classes/actionhandler.php
r2825 r2851 2 2 3 3 /** 4 * A base class handler for URL-based actions. All ActionHandlers must 4 * A base class handler for URL-based actions. All ActionHandlers must 5 5 * extend this class for the Controller to call their actions. 6 * 6 * 7 7 * @package Habari 8 */ 8 */ 9 9 class ActionHandler 10 10 { 11 11 /** 12 12 * Name of action to trigger 13 * 13 * 14 14 * @var string 15 15 * @see act() 16 16 */ 17 17 public $action = ''; 18 18 19 19 /** 20 20 * Internal array of handler variables (state info) 21 * 21 * 22 22 * @var array 23 23 */ … … 31 31 * 32 32 * @param string $action the action that was in the URL rule 33 */ 33 */ 34 34 public function act($action) { 35 35 $this->action = $action; 36 36 37 37 $action_method = 'act_' . $action; 38 38 $before_action_method = 'before_' . $action_method; 39 39 $after_action_method = 'after_' . $action_method; 40 40 41 41 if (method_exists($this, $action_method)) { 42 42 if (method_exists($this, $before_action_method)) { … … 46 46 * Plugin action to allow plugins to execute before a certain 47 47 * action is triggered 48 * 48 * 49 49 * @see ActionHandler::$action 50 50 * @action before_act_{$action} 51 51 */ 52 52 Plugins::act( $before_action_method, $this ); 53 53 54 54 $this->$action_method(); 55 55 56 56 /** 57 57 * Plugin action to allow plugins to execute after a certain 58 58 * action is triggered 59 * 59 * 60 60 * @see ActionHandler::$action 61 61 * @action before_act_{$action} … … 71 71 * Helper method to convert calls to $handler->my_action() 72 72 * to $handler->act('my_action'); 73 * 73 * 74 74 * @param string $function function name 75 75 * @param array $args function arguments 76 76 */ 77 77 public function __call($function, $args) { 78 $this->handler_vars = array_merge($this->handler_vars, $args);79 78 return $this->act($function); 80 79 } 81 80 82 81 /** 83 * Helper method to allow RewriteRules to send a redirect. The method will 82 * Helper method to allow RewriteRules to send a redirect. The method will 84 83 * redirect to the build_str of the RewriteRule if matched. 85 84 */ -
trunk/htdocs/system/classes/adminhandler.php
r2845 r2851 47 47 /* At this point, Controller has not created handler_vars, so we have to modify $_POST/$_GET. */ 48 48 if ( isset( $last_form_data['post'] ) ) { 49 $_POST = array_merge( $_POST,$last_form_data['post'] );49 $_POST = $_POST->merge( $last_form_data['post'] ); 50 50 $_SERVER['REQUEST_METHOD']= 'POST'; // This will trigger the proper act_admin switches. 51 51 Session::remove_error( 'expired_form_submission' ); 52 52 } 53 53 if ( isset( $last_form_data['get'] ) ) { 54 $_GET = array_merge( $_GET,$last_form_data['get'] );54 $_GET = $_GET->merge( $last_form_data['get'] ); 55 55 Session::remove_error( 'expired_form_submission' ); 56 56 // No need to change REQUEST_METHOD since GET is the default. … … 420 420 public function post_publish() 421 421 { 422 extract( $this->handler_vars );423 424 422 $form = $this->form_publish( new Post(), false ); 425 423 … … 486 484 public function get_publish( $template = 'publish') 487 485 { 488 extract( $this->handler_vars ); 486 $extract = $this->handler_vars->filter_keys('id', 'content_type'); 487 foreach($extract as $key => $value) { 488 $$key = $value; 489 } 490 489 491 if ( isset( $id ) ) { 490 492 $post = Post::get( array( 'id' => $id, 'status' => Post::status( 'any' ) ) ); … … 540 542 $form->content->tabindex = 2; 541 543 $form->content->value = $post->content; 544 $form->content->raw = true; 542 545 543 546 // Create the tags field … … 616 619 public function post_delete_post() 617 620 { 618 extract( $this->handler_vars ); 621 $extract = $this->handler_vars->filter_keys('id', 'nonce', 'timestamp', 'PasswordDigest'); 622 foreach($extract as $key => $value) { 623 $$key = $value; 624 } 625 619 626 $okay = TRUE; 620 627 if ( empty( $id ) || empty( $nonce ) || empty( $timestamp ) || empty( $PasswordDigest ) ) { … … 657 664 public function post_user() 658 665 { 659 extract( $this->handler_vars ); 666 $extract = $this->handler_vars->filter_keys('nonce', 'timestamp', 'PasswordDigest'); 667 foreach($extract as $key => $value) { 668 $$key = $value; 669 } 660 670 661 671 $wsse = Utils::WSSE( $nonce, $timestamp ); … … 671 681 $fields = array( 'user_id' => 'id', 'delete' => NULL, 'username' => 'username', 'displayname' => 'displayname', 'email' => 'email', 'imageurl' => 'imageurl', 'pass1' => NULL, 'locale_tz' => 'locale_tz', 'locale_date_format' => 'locale_date_format', 'locale_time_format' => 'locale_time_format' ); 672 682 $fields = Plugins::filter( 'adminhandler_post_user_fields', $fields ); 673 $posted_fields = array_intersect_key( $this->handler_vars, $fields);683 $posted_fields = $this->handler_vars->filter_keys( array_keys( $fields ) ); 674 684 675 685 // Editing someone else's profile? If so, load that user's profile … … 743 753 break; 744 754 default: 745 if ( isset( $ {$fields[$posted_field]} ) && ( $user->info->$fields[$posted_field] != ${$fields[$posted_field]}) ) {746 $user->info->$fields[$posted_field]= $ {$fields[$posted_field]};755 if ( isset( $this->handler_vars[$fields[$posted_field]] ) && ( $user->info->$fields[$posted_field] != $this->handler_vars[$fields[$posted_field]] ) ) { 756 $user->info->$fields[$posted_field]= $this->handler_vars[$fields[$posted_field]]; 747 757 Session::notice( _t( 'Userinfo updated!' ) ); 748 758 $update = TRUE; … … 875 885 $this->fetch_users(); 876 886 877 extract( $this->handler_vars ); 887 $extract = $this->handler_vars->filter_keys('newuser', 'delete', 'new_pass1', 'new_pass2', 'new_email', 'new_username'); 888 foreach($extract as $key => $value) { 889 $$key = $value; 890 } 878 891 879 892 if(isset($newuser)) { 880 893 $action = 'newuser'; 881 } elseif(isset($delete)) { 894 } 895 elseif(isset($delete)) { 882 896 $action = 'delete'; 883 897 } … … 936 950 public function get_plugin_toggle() 937 951 { 938 extract( $this->handler_vars ); 952 $extract = $this->handler_vars->filter_keys('plugin_id', 'action'); 953 foreach($extract as $key => $value) { 954 $$key = $value; 955 } 956 939 957 $plugins = Plugins::list_all(); 940 958 foreach($plugins as $file) { … … 1020 1038 public function get_activate_theme() 1021 1039 { 1022 extract( $this->handler_vars ); 1040 $theme_name = $this->handler_vars['theme_name']; 1041 $theme_dir = $this->handler_vars['theme_dir']; 1023 1042 if ( isset($theme_name) && isset($theme_dir) ) { 1024 1043 Themes::activate_theme( $theme_name, $theme_dir ); -
trunk/htdocs/system/classes/controller.php
r2592 r2851 119 119 $start_url = trim($start_url, '/'); 120 120 121 /* Remove the querystring from the URL */122 if ( strpos($start_url, '?') !== FALSE ) {123 list($start_url, $query_string)= explode('?', $start_url);124 }125 126 /* Return $_GET values to their proper place */127 if( !empty($query_string) ) {128 parse_str($query_string, $_GET);129 }130 131 /* Undo what magic_quotes_gpc might have wrought */132 Utils::revert_magic_quotes_gpc();133 134 121 /* Allow plugins to rewrite the stub before it's passed through the rules */ 135 122 $start_url = Plugins::filter('rewrite_request', $start_url); … … 154 141 155 142 /* Also, we musn't forget to add the GET and POST vars into the action's settings array */ 156 $controller->handler->handler_vars = array_merge($controller->handler->handler_vars, $_GET, $_POST); 143 $handler_vars = new SuperGlobal($controller->handler->handler_vars); 144 $handler_vars = $handler_vars->merge($_GET, $_POST); 145 $controller->handler->handler_vars = $handler_vars; 157 146 return true; 158 147 } -
trunk/htdocs/system/classes/formui.php
r2755 r2851 699 699 protected $properties = array(); 700 700 protected $template = null; 701 protected $raw = false; 701 702 702 703 /** … … 922 923 case 'value': 923 924 if(isset($_POST[$this->field])) { 924 return $ _POST[$this->field];925 return $this->raw ? $_POST->raw($this->field) : $_POST[$this->field]; 925 926 } 926 927 else { … … 995 996 $this->template = $value; 996 997 break; 998 case 'raw': 999 $this->raw = $value; 1000 break; 997 1001 default: 998 1002 $this->properties[$name] = $value; … … 1075 1079 $this->container->move_after( $this, $target ); 1076 1080 } 1077 1081 1078 1082 /** 1079 1083 * Remove this controls from the form … … 1182 1186 $theme = $this->get_theme($forvalidation, $this); 1183 1187 $max = Tags::max_count(); 1184 1188 1185 1189 $tag = $this->tag; 1186 1190 1187 1191 $theme->class = 'tag_'.$tag->slug; 1188 1192 $theme->id = $tag->id; … … 1190 1194 $theme->caption = $tag->tag; 1191 1195 $theme->count = $tag->count; 1192 1196 1193 1197 return $theme->fetch( 'tabcontrol_tag' ); 1194 1198 } … … 1353 1357 return $theme->fetch( $this->get_template() ); 1354 1358 } 1355 1359 1356 1360 /** 1357 1361 * Magic __get method for returning property values … … 1379 1383 return parent::__get($name); 1380 1384 } 1381 1385 1382 1386 } 1383 1387 -
trunk/htdocs/system/classes/hiengine.php
r2705 r2851 237 237 case 'url': 238 238 return '<?php URL::out( \'' . $cmd_matches[2] . '\' ); ?>'; 239 case 'session': 240 switch($cmd_matches[2]) { 241 case 'messages': 242 return '<?php if(Session::has_messages()){Session::messages_out();} ?>'; 243 case 'errors': 244 return '<?php if(Session::has_errors()){Session::messages_out();} ?>'; 245 } 239 246 } 240 247 } -
trunk/htdocs/system/classes/installhandler.php
r2820 r2851 14 14 public function act_begin_install() 15 15 { 16 // Revert magic quotes, normally Controller calls this.17 Utils::revert_magic_quotes_gpc();18 19 16 // Create a new theme to handle the display of the installer 20 17 $this->theme = Themes::create('installer', 'RawPHPEngine', HABARI_PATH . '/system/installer/'); 21 18 22 19 /** 23 20 * Set user selected Locale or default … … 119 116 // now merge in any HTTP POST values that might have been sent 120 117 // these will override the defaults and the config.php values 121 $this->handler_vars = array_merge($this->handler_vars,$_POST);118 $this->handler_vars = $this->handler_vars->merge($_POST); 122 119 123 120 // we need details for the admin user to install … … 165 162 } 166 163 167 164 168 165 169 166 // Installation complete. Secure sqlite if it was chosen as the database type to use … … 178 175 return true; 179 176 } 180 177 181 178 /* 182 179 * Helper function to grab list of plugins … … 217 214 $plugin['active']= false; 218 215 } 219 216 220 217 $plugins[$plugin_id]= $plugin; 221 218 } 222 219 223 220 return $plugins; 224 221 } 225 222 226 223 /** 227 224 * Helper function to remove code repetition … … 234 231 $this->theme->assign($key, $value); 235 232 } 236 233 237 234 $this->theme->assign('plugins', $this->get_plugins()); 238 235 239 236 $this->theme->display($template_name); 240 237 exit; … … 305 302 } 306 303 $this->theme->assign('missing_extensions', $missing_extensions); 307 304 308 305 if ( extension_loaded('pdo') ) { 309 306 /* Check for PDO drivers */ … … 333 330 } 334 331 } 335 332 336 333 /** 337 334 * $local_writable is used in the template, but never set in Habari … … 341 338 */ 342 339 $this->theme->assign( 'local_writable', true ); 343 340 344 341 return $requirements_met; 345 342 } … … 449 446 DB::begin_transaction(); 450 447 } 451 448 452 449 /* Store current DB version so we don't immediately run dbdelta. */ 453 450 Version::save_dbversion(); … … 824 821 'rewrite_base' => '#RewriteBase /', 825 822 'rewrite_rule' => 'RewriteRule . index.php [PT]', 823 'hide_habari' => 'RewriteRule ^(system/(classes|locale|schema|$)) index.php [PT]', 826 824 'close_block' => '### HABARI END', 827 825 ); … … 956 954 957 955 /** 958 * attempts to write the Files clause to the .htaccess file 956 * attempts to write the Files clause to the .htaccess file 959 957 * if the clause for this sqlite doesn't exist. 960 958 * @return bool success or failure … … 998 996 return true; 999 997 } 1000 998 1001 999 private function upgrade_db_pre ( $current_version ) { 1002 1000 1003 1001 // this is actually a stripped-down version of DatabaseConnection::upgrade() - it doesn't support files 1004 1002 1005 1003 $upgrade_functions = get_class_methods( $this ); 1006 1004 1007 1005 $upgrades = array(); 1008 1006 1009 1007 foreach ( $upgrade_functions as $fn ) { 1010 1008 1011 1009 // match all methods named "upgrade_db_pre_<rev#>" 1012 1010 if ( preg_match( '%^upgrade_db_pre_([0-9]+)$%i', $fn, $matches ) ) { 1013 1011 1014 1012 $upgrade_version = intval( $matches[1] ); 1015 1013 1016 1014 if ( $upgrade_version > $current_version ) { 1017 1015 1018 1016 $upgrades[ sprintf( '%010s_1', $upgrade_version ) ] = $fn; 1019 1020 } 1021 1022 } 1023 1024 } 1025 1017 1018 } 1019 1020 } 1021 1022 } 1023 1026 1024 // sort the upgrades by revision, ascending 1027 1025 ksort( $upgrades ); 1028 1029 1026 1027 1030 1028 foreach ( $upgrades as $upgrade ) { 1031 1029 1032 1030 $result =& call_user_func( array( $this, $upgrade ) ); 1033 1031 1034 1032 // if we failed, abort 1035 1033 if ( $result === false ) { 1036 1034 break; 1037 1035 } 1038 1039 } 1040 1041 } 1042 1036 1037 } 1038 1039 } 1040 1043 1041 private function upgrade_db_post ( $current_version ) { 1044 1042 1045 1043 // this is actually a stripped-down version of DatabaseConnection::upgrade() - it doesn't support files 1046 1044 1047 1045 $upgrade_functions = get_class_methods( $this ); 1048 1046 1049 1047 $upgrades = array(); 1050 1048 1051 1049 foreach ( $upgrade_functions as $fn ) { 1052 1050 1053 1051 // match all methods named "upgrade_db_post_<rev#>" 1054 1052 if ( preg_match( '%^upgrade_db_post_([0-9]+)$%i', $fn, $matches ) ) { 1055 1053 1056 1054<
