Module for TP supports Chinese

Source: Internet
Author: User
Tags vars
In order for the URL to support Chinese, for example, www.xxx.com/Canton/xx need to be in emptyaction to capture the canton/xxxx. However, TP tacitly recognizes that the module name does not support Chinese. Therefore, the PHP core file for the TP framework needs to be modified:
App.class.php
Revised Password:

Java code

/** * Execute application * @access public * @return void */static public function exec () {if (!preg          _match ('/^[a-za-z] (\w) *$/', module_name)) {//Security detection $module = FALSE; }else{//Create an action Controller instance $group = defined (' group_name ') && C (' App_group_m ODE ') ==0? Group_name. '              /' : ''; $module = A ($group.                              MODULE_NAME); if (Preg_match ("/[\x7f-\xff]/", module_name)) {//Chinese mode if (In_array (module_name,c (' Chinese_module_name '))) {/                  /within the specified Chinese $module = A ($group. ' Istheempty '); }else{_404 (L (' _module_not_exist_ '). ': '.                  MODULE_NAME); }}else{$module = A ($group.              MODULE_NAME);                  }} if (! $module) {if (' 4e5e5d7364f443e28fbf0d3ae744a59a ' = = module_name) { Header ("Content-type:image/png");              Exit (Base64_decode (App::logo ())); } if (Function_exists (' __hack_module ')) {///hack method defines the extension module to return the action object $modul                  E = __hack_module ();                  if (!is_object ($module)) {//No further execution is performed directly returning return;                  }}else{//Whether the empty module is defined $module = A ($group. ' Empty '); if (! $module) {_404 (L (' _module_not_exist_ '). ': '.                  MODULE_NAME); }}}//Get the current operation name to support dynamic routing $action = C (' Action_name ')?          C (' Action_name '): action_name;          $action. = C (' Action_suffix '); try{if (!preg_match ('/^[a-za-z] (\w) *$/', $action)) {//Illegal operation throw new Reflec              Tionexception ();              }//Perform the current operation $method = new Reflectionmethod ($module, $action); if ($method->ispubliC ()) {$class = new Reflectionclass ($module); Predecessor action if ($class->hasmethod (' _before_ '. $action)) {$before = $class->getmet                      Hod (' _before_ '. $action);                      if ($before->ispublic ()) {$before->invoke ($module); }}//URL parameter binding detects if (C (' Url_params_bind ') && $method->getnumb                              Erofparameters () >0) {switch ($_server[' Request_method ') {case ' POST ':                              $vars = Array_merge ($_get,$_post);                          Break                              Case ' PUT ': Parse_str (file_get_contents (' Php://input '), $vars);                          Break                      Default: $vars = $_get; } $params = $method->getparameters ();                          foreach ($params as $param) {$name = $param->getname ();                          if (Isset ($vars [$name])) {$args [] = $vars [$name];                          }elseif ($param->isdefaultvalueavailable ()) {$args [] = $param->getdefaultvalue ();                          }else{throw_exception (L (' _param_error_ '). ': '. $name);                  }} $method->invokeargs ($module, $args);                  }else{$method->invoke ($module);   }//Post action if ($class->hasmethod (' _after_ '. $action)) {$after =                      $class->getmethod (' _after_ ' $action);                      if ($after->ispublic ()) {$after->invoke ($module); }                  }              }else{//Operation method is not public throw exception throw new Reflectionexception (); }} catch (Reflectionexception $e) {////method call occurred after an exception was booted to __call method processing $method = new Reflecti              Onmethod ($module, ' __call ');          $method->invokeargs ($module, Array ($action, "));      } return; }



Add the Chinese MODULE name you need to support to the config.php chinese_module_name configuration numbers

This will support the Chinese URL parsing.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.