Changeset 22083
- Timestamp:
- 2012/11/07 21:04:04 (11 years ago)
- Location:
- branches/version-2_12-dev/data/class
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_ClassAutoloader.php
r21991 r22083 72 72 $plugin_class = $class; 73 73 $plugin_classpath = $classpath; 74 74 75 $objPlugin->doAction('loadClassFileChange', array(&$plugin_class, &$plugin_classpath)); 76 75 77 // FIXME: トリッキーな処理で _Ex ファイルを無視しないようにする(無視するとユーザーカスタマイズで分かりにくい) 76 78 // SC_XXXX_Ex がロードされる場合にextendsのchainを 77 79 // SC_XXXX_Ex -> SC_XXXX から、 SC_XXXX_Ex -> $class (-> SC_XXXX) と変える。 78 80 // そうでない場合は、直接置き換えと想定して帰ってきたクラスをロードする 79 if ($plugin_class !== $class) { 81 if (is_array($plugin_class) && count($plugin_class) > 0) { 82 $arrPluginClassName = $plugin_class; 83 $arrPluginClassPath = $plugin_classpath; 84 85 foreach ($arrPluginClassName as $key => $plugin_class) { 86 $plugin_classpath = $arrPluginClassPath[$key]; 87 88 if ($is_ex) { 89 // Ex ファイルへのフックの場合のみチェイン変更する。 90 91 if ($parent_classname) { 92 $exp = "/(class[ ]+{$plugin_class}[ ]+extends +)[a-zA-Z_\-]+( *{?)/"; 93 $replace = '$1' . $parent_classname . '$2'; 94 95 $base_class_str = file_get_contents($plugin_classpath); 96 $base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str); 97 $base_class_str = preg_replace($exp, $replace, $base_class_str, 1); 98 eval($base_class_str); 99 } else { 100 include $plugin_classpath; 101 } 102 103 $parent_classname = $plugin_class; 104 } else { 105 include $plugin_classpath; 106 } 107 } 108 80 109 if ($is_ex) { 81 // Ex ファイルへのフックの場合のみチェイン変更する。 82 $exp = "/(class[ ]+{$class}[ ]+extends +)[a-zA-Z_\-]+( *{)/"; 83 $replace = '$1' . $plugin_class . '$2'; 110 $exp = "/(class[ ]+{$class}[ ]+extends +)[a-zA-Z_\-]+( *{?)/"; 111 $replace = '$1' . $parent_classname . '$2'; 84 112 $base_class_str = file_get_contents($classpath); 85 113 $base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str); 86 114 $base_class_str = preg_replace($exp, $replace, $base_class_str, 1); 87 include $plugin_classpath;88 115 eval($base_class_str); 89 116 return; 90 } else {91 include $plugin_classpath;92 117 } 93 118 } -
branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php
r22018 r22083 105 105 } 106 106 107 if ($hook_point == 'loadClassFileChange') { 108 $arrSaveArgs = $arrArgs; 109 $arrClassName = array(); 110 $arrClassPath = array(); 111 } 112 107 113 if (array_key_exists($hook_point, $this->arrRegistedPluginActions) 108 114 && is_array($this->arrRegistedPluginActions[$hook_point])) { … … 113 119 foreach ($arrFuncs as $func) { 114 120 if (!is_null($func['function'])) { 115 call_user_func_array($func['function'], $arrArgs); 121 if ($hook_point == 'loadClassFileChange') { 122 $classname = $arrSaveArgs[0]; 123 $classpath = $arrSaveArgs[1]; 124 $arrTempArgs = array(&$classname, &$classpath); 125 126 call_user_func_array($func['function'], $arrTempArgs); 127 128 if ($classname !== $arrSaveArgs[0]) { 129 $arrClassName[] = $classname; 130 $arrClassPath[] = $classpath; 131 } 132 } else { 133 call_user_func_array($func['function'], $arrArgs); 134 } 116 135 } 136 } 137 } 138 139 if ($hook_point == 'loadClassFileChange') { 140 if (count($arrClassName) > 0) { 141 $arrArgs[0] = $arrClassName; 142 $arrArgs[1] = $arrClassPath; 117 143 } 118 144 }
Note: See TracChangeset
for help on using the changeset viewer.