| @@ 1069-1153 (lines=85) @@ | ||
| 1066 | * |
|
| 1067 | * modified by ci-phpunit-test |
|
| 1068 | */ |
|
| 1069 | protected function _ci_load_library($class, $params = NULL, $object_name = NULL) |
|
| 1070 | { |
|
| 1071 | // Get the class name, and while we're at it trim any slashes. |
|
| 1072 | // The directory path can be included as part of the class name, |
|
| 1073 | // but we don't want a leading slash |
|
| 1074 | $class = str_replace('.php', '', trim($class, '/')); |
|
| 1075 | ||
| 1076 | // Was the path included with the class name? |
|
| 1077 | // We look for a slash to determine this |
|
| 1078 | if (($last_slash = strrpos($class, '/')) !== FALSE) |
|
| 1079 | { |
|
| 1080 | // Extract the path |
|
| 1081 | $subdir = substr($class, 0, ++$last_slash); |
|
| 1082 | ||
| 1083 | // Get the filename from the path |
|
| 1084 | $class = substr($class, $last_slash); |
|
| 1085 | } |
|
| 1086 | else |
|
| 1087 | { |
|
| 1088 | $subdir = ''; |
|
| 1089 | } |
|
| 1090 | ||
| 1091 | $class = ucfirst($class); |
|
| 1092 | ||
| 1093 | // Replace library in ci-phpuni-test |
|
| 1094 | if (file_exists(APPPATH.'tests/_ci_phpunit_test/replacing/libraries/'.$subdir.$class.'.php')) |
|
| 1095 | { |
|
| 1096 | return $this->_ci_load_stock_library($class, $subdir, $params, $object_name); |
|
| 1097 | } |
|
| 1098 | ||
| 1099 | // Is this a stock library? There are a few special conditions if so ... |
|
| 1100 | if (file_exists(BASEPATH.'libraries/'.$subdir.$class.'.php')) |
|
| 1101 | { |
|
| 1102 | return $this->_ci_load_stock_library($class, $subdir, $params, $object_name); |
|
| 1103 | } |
|
| 1104 | ||
| 1105 | // Let's search for the requested library file and load it. |
|
| 1106 | foreach ($this->_ci_library_paths as $path) |
|
| 1107 | { |
|
| 1108 | // BASEPATH has already been checked for |
|
| 1109 | if ($path === BASEPATH) |
|
| 1110 | { |
|
| 1111 | continue; |
|
| 1112 | } |
|
| 1113 | ||
| 1114 | $filepath = $path.'libraries/'.$subdir.$class.'.php'; |
|
| 1115 | ||
| 1116 | // Safety: Was the class already loaded by a previous call? |
|
| 1117 | if (class_exists($class, FALSE)) |
|
| 1118 | { |
|
| 1119 | // Before we deem this to be a duplicate request, let's see |
|
| 1120 | // if a custom object name is being supplied. If so, we'll |
|
| 1121 | // return a new instance of the object |
|
| 1122 | if ($object_name !== NULL) |
|
| 1123 | { |
|
| 1124 | $CI =& get_instance(); |
|
| 1125 | if ( ! isset($CI->$object_name)) |
|
| 1126 | { |
|
| 1127 | return $this->_ci_init_library($class, '', $params, $object_name); |
|
| 1128 | } |
|
| 1129 | } |
|
| 1130 | ||
| 1131 | // log_message('debug', $class.' class already loaded. Second attempt ignored.'); |
|
| 1132 | // return; |
|
| 1133 | } |
|
| 1134 | // Does the file exist? No? Bummer... |
|
| 1135 | if ( ! file_exists($filepath)) |
|
| 1136 | { |
|
| 1137 | continue; |
|
| 1138 | } |
|
| 1139 | ||
| 1140 | include_once($filepath); |
|
| 1141 | return $this->_ci_init_library($class, '', $params, $object_name); |
|
| 1142 | } |
|
| 1143 | ||
| 1144 | // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? |
|
| 1145 | if ($subdir === '') |
|
| 1146 | { |
|
| 1147 | return $this->_ci_load_library($class.'/'.$class, $params, $object_name); |
|
| 1148 | } |
|
| 1149 | ||
| 1150 | // If we got this far we were unable to find the requested class. |
|
| 1151 | log_message('error', 'Unable to load the requested class: '.$class); |
|
| 1152 | show_error('Unable to load the requested class: '.$class); |
|
| 1153 | } |
|
| 1154 | ||
| 1155 | // -------------------------------------------------------------------- |
|
| 1156 | ||
| @@ 1058-1142 (lines=85) @@ | ||
| 1055 | * |
|
| 1056 | * modified by ci-phpunit-test |
|
| 1057 | */ |
|
| 1058 | protected function _ci_load_library($class, $params = NULL, $object_name = NULL) |
|
| 1059 | { |
|
| 1060 | // Get the class name, and while we're at it trim any slashes. |
|
| 1061 | // The directory path can be included as part of the class name, |
|
| 1062 | // but we don't want a leading slash |
|
| 1063 | $class = str_replace('.php', '', trim($class, '/')); |
|
| 1064 | ||
| 1065 | // Was the path included with the class name? |
|
| 1066 | // We look for a slash to determine this |
|
| 1067 | if (($last_slash = strrpos($class, '/')) !== FALSE) |
|
| 1068 | { |
|
| 1069 | // Extract the path |
|
| 1070 | $subdir = substr($class, 0, ++$last_slash); |
|
| 1071 | ||
| 1072 | // Get the filename from the path |
|
| 1073 | $class = substr($class, $last_slash); |
|
| 1074 | } |
|
| 1075 | else |
|
| 1076 | { |
|
| 1077 | $subdir = ''; |
|
| 1078 | } |
|
| 1079 | ||
| 1080 | $class = ucfirst($class); |
|
| 1081 | ||
| 1082 | // Replace library in ci-phpuni-test |
|
| 1083 | if (file_exists(APPPATH.'tests/_ci_phpunit_test/replacing/libraries/'.$subdir.$class.'.php')) |
|
| 1084 | { |
|
| 1085 | return $this->_ci_load_stock_library($class, $subdir, $params, $object_name); |
|
| 1086 | } |
|
| 1087 | ||
| 1088 | // Is this a stock library? There are a few special conditions if so ... |
|
| 1089 | if (file_exists(BASEPATH.'libraries/'.$subdir.$class.'.php')) |
|
| 1090 | { |
|
| 1091 | return $this->_ci_load_stock_library($class, $subdir, $params, $object_name); |
|
| 1092 | } |
|
| 1093 | ||
| 1094 | // Let's search for the requested library file and load it. |
|
| 1095 | foreach ($this->_ci_library_paths as $path) |
|
| 1096 | { |
|
| 1097 | // BASEPATH has already been checked for |
|
| 1098 | if ($path === BASEPATH) |
|
| 1099 | { |
|
| 1100 | continue; |
|
| 1101 | } |
|
| 1102 | ||
| 1103 | $filepath = $path.'libraries/'.$subdir.$class.'.php'; |
|
| 1104 | ||
| 1105 | // Safety: Was the class already loaded by a previous call? |
|
| 1106 | if (class_exists($class, FALSE)) |
|
| 1107 | { |
|
| 1108 | // Before we deem this to be a duplicate request, let's see |
|
| 1109 | // if a custom object name is being supplied. If so, we'll |
|
| 1110 | // return a new instance of the object |
|
| 1111 | if ($object_name !== NULL) |
|
| 1112 | { |
|
| 1113 | $CI =& get_instance(); |
|
| 1114 | if ( ! isset($CI->$object_name)) |
|
| 1115 | { |
|
| 1116 | return $this->_ci_init_library($class, '', $params, $object_name); |
|
| 1117 | } |
|
| 1118 | } |
|
| 1119 | ||
| 1120 | // log_message('debug', $class.' class already loaded. Second attempt ignored.'); |
|
| 1121 | // return; |
|
| 1122 | } |
|
| 1123 | // Does the file exist? No? Bummer... |
|
| 1124 | if ( ! file_exists($filepath)) |
|
| 1125 | { |
|
| 1126 | continue; |
|
| 1127 | } |
|
| 1128 | ||
| 1129 | include_once($filepath); |
|
| 1130 | return $this->_ci_init_library($class, '', $params, $object_name); |
|
| 1131 | } |
|
| 1132 | ||
| 1133 | // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? |
|
| 1134 | if ($subdir === '') |
|
| 1135 | { |
|
| 1136 | return $this->_ci_load_library($class.'/'.$class, $params, $object_name); |
|
| 1137 | } |
|
| 1138 | ||
| 1139 | // If we got this far we were unable to find the requested class. |
|
| 1140 | log_message('error', 'Unable to load the requested class: '.$class); |
|
| 1141 | show_error('Unable to load the requested class: '.$class); |
|
| 1142 | } |
|
| 1143 | ||
| 1144 | // -------------------------------------------------------------------- |
|
| 1145 | ||