{"action":"created","issue":{"url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4261","labels_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4261/labels{/name}","comments_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4261/comments","events_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4261/events","html_url":"https://github.com/bcit-ci/CodeIgniter/pull/4261","id":118320238,"number":4261,"title":"MY_Loader.php","user":{"login":"Hanchengluo","id":481968,"avatar_url":"https://avatars.githubusercontent.com/u/481968?v=3","gravatar_id":"","url":"https://api.github.com/users/Hanchengluo","html_url":"https://github.com/Hanchengluo","followers_url":"https://api.github.com/users/Hanchengluo/followers","following_url":"https://api.github.com/users/Hanchengluo/following{/other_user}","gists_url":"https://api.github.com/users/Hanchengluo/gists{/gist_id}","starred_url":"https://api.github.com/users/Hanchengluo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hanchengluo/subscriptions","organizations_url":"https://api.github.com/users/Hanchengluo/orgs","repos_url":"https://api.github.com/users/Hanchengluo/repos","events_url":"https://api.github.com/users/Hanchengluo/events{/privacy}","received_events_url":"https://api.github.com/users/Hanchengluo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-23T04:53:46Z","updated_at":"2015-11-23T04:58:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bcit-ci/CodeIgniter/pulls/4261","html_url":"https://github.com/bcit-ci/CodeIgniter/pull/4261","diff_url":"https://github.com/bcit-ci/CodeIgniter/pull/4261.diff","patch_url":"https://github.com/bcit-ci/CodeIgniter/pull/4261.patch"},"body":"<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r\n//    application/core\r\nclass MY_Loader extends CI_Loader\r\n{\r\n    protected $_my_controller_paths     = array();  \r\n    protected $_my_controllers          = array();\r\n \r\n    public function __construct()\r\n    {\r\n        parent::__construct();\r\n \t\r\n        $this->_my_controller_paths = array(APPPATH);\r\n    }\r\n \r\n    public function controller($controller, $name = '', $db_conn = FALSE)\r\n    {//echo $controller=ucfirst($controller);\r\n\t\r\n        if (is_array($controller))\r\n        {\r\n            foreach ($controller as $babe)\r\n            {\r\n                $this->controller($babe);\r\n            }\r\n            return;\r\n        }\r\n \r\n        if ($controller == '')\r\n        {\r\n            return;\r\n        }\r\n \r\n        $path = '';\r\n \r\n        // Is the controller in a sub-folder? If so, parse out the filename and path.\r\n        if (($last_slash = strrpos($controller, '/')) !== FALSE)\r\n        {\r\n            // The path is in front of the last slash\r\n            $path = substr($controller, 0, $last_slash + 1);\r\n \r\n            // And the controller name behind it\r\n            $controller = substr($controller, $last_slash + 1);\r\n        }\r\n \r\n        if ($name == '')\r\n        {\r\n            $name = $controller;\r\n        }\r\n \r\n        if (in_array($name, $this->_my_controllers, TRUE))\r\n        {\r\n            return;\r\n        }\r\n\r\n        $CI =& get_instance();\r\n        if (isset($CI->$name))\r\n        {\r\n            show_error('The controller name you are loading is the name of a resource that is already being used: '.$name);\r\n        }\r\n \r\n        $controller = strtolower($controller);\r\n  $controller=ucfirst($controller);\r\n        foreach ($this->_my_controller_paths as $mod_path)\r\n        {\r\n            if ( ! file_exists($mod_path.'controllers/'.$path.$controller.'.php'))\r\n            {\r\n                continue;\r\n            }\r\n \r\n            if ($db_conn !== FALSE AND ! class_exists('CI_DB'))\r\n            {\r\n                if ($db_conn === TRUE)\r\n                {\r\n                    $db_conn = '';\r\n                }\r\n \r\n                $CI->load->database($db_conn, FALSE, TRUE);\r\n            }\r\n \r\n            if ( ! class_exists('CI_Controller'))\r\n            {\r\n                load_class('Controller', 'core');\r\n            }\r\n \r\n            require_once($mod_path.'controllers/'.$path.$controller.'.php');\r\n \r\n            $controller = ucfirst($controller);\r\n \r\n            $CI->$name = new $controller();\r\n \r\n            $this->_my_controllers[] = $name;\r\n            return;\r\n        }\r\n \r\n        // couldn't find the controller\r\n        show_error('Unable to locate the controller you have specified: '.$controller);\r\n    }\r\n \r\n}\r\n "},"comment":{"url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/comments/158854092","html_url":"https://github.com/bcit-ci/CodeIgniter/pull/4261#issuecomment-158854092","issue_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4261","id":158854092,"user":{"login":"Hanchengluo","id":481968,"avatar_url":"https://avatars.githubusercontent.com/u/481968?v=3","gravatar_id":"","url":"https://api.github.com/users/Hanchengluo","html_url":"https://github.com/Hanchengluo","followers_url":"https://api.github.com/users/Hanchengluo/followers","following_url":"https://api.github.com/users/Hanchengluo/following{/other_user}","gists_url":"https://api.github.com/users/Hanchengluo/gists{/gist_id}","starred_url":"https://api.github.com/users/Hanchengluo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hanchengluo/subscriptions","organizations_url":"https://api.github.com/users/Hanchengluo/orgs","repos_url":"https://api.github.com/users/Hanchengluo/repos","events_url":"https://api.github.com/users/Hanchengluo/events{/privacy}","received_events_url":"https://api.github.com/users/Hanchengluo/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T04:58:37Z","updated_at":"2015-11-23T04:58:37Z","body":"/application/config/routes.php\r\n$route['\\\\w+'] = 'homepage/myroute/home';\r\n$route['[A-Za-z0-9]{0,100}/[A-Za-z0-9]{0,100}.html'] = 'homepage/myroute/r1';\r\n$route['[A-Za-z0-9]{0,100}/[A-Za-z0-9]{0,100}-[A-Za-z0-9]{0,100}.html'] = 'homepage/myroute/r1_1';\r\n\r\n/application/config/homepage/myroute.php\r\npublic function home()//homepage\r\n{\r\n $lang=$this->uri->segment(1);\r\nif ($lang)\r\n{$langid=$this->_base->get_paramone('lang','lang',$lang,'id');}\r\nelse\r\n{\r\n$lang=$this->_lang->get_lang_default();\r\n$langid=$lang['id'];\r\n$lang=$lang['lang'];\r\n};\r\nif(!$langid) die;\r\n$this->load->controller(\"homepage/Homepage\",'Mypage');\r\n$this->Mypage->index($langid);\r\n}"}}