diff --git a/Changelog b/Changelog index dddec26..45d98c0 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,14 @@ -This file documents changes for Yod Framework release 1.3.2 and earlier. +This file documents changes for Yod Framework release 1.3.3 and earlier. + +version 1.3.3: + + - Remove methods findAll in the class Yod_Model + - Remove methods config, import, plugin, model and dbmodel in the class Yod_Model + - Remove methods config, import, plugin, model and dbmodel in the class Yod_Controller + - Fixed a bug in yod_application_autoload with namespace in PHP + - Change the default value of constant YOD_EXTPATH + - Modify the method autoload, plugin and import of class Yod_Application + - Fixed a bug in yod_init_compile_file (support zend_exception_error) version 1.3.2: diff --git a/README.md b/README.md index 3b05e92..4ceba4b 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ class HelloController extends Yod_Controller { public function indexAction() { - $this->assign('content', $this->model('Hello')->content()); + $this->assign('content', Yod::model('Hello')->content()); $this->display('/index/index'); } diff --git a/dll/php_yod-1.3.2-5.3-nts-vc9-x64-debug.dll b/dll/php_yod-1.3.2-5.3-nts-vc9-x64-debug.dll deleted file mode 100644 index e82040d..0000000 Binary files a/dll/php_yod-1.3.2-5.3-nts-vc9-x64-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-nts-vc9-x64.dll b/dll/php_yod-1.3.2-5.3-nts-vc9-x64.dll deleted file mode 100644 index 561043b..0000000 Binary files a/dll/php_yod-1.3.2-5.3-nts-vc9-x64.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-nts-vc9-x86-debug.dll b/dll/php_yod-1.3.2-5.3-nts-vc9-x86-debug.dll deleted file mode 100644 index 7e036ed..0000000 Binary files a/dll/php_yod-1.3.2-5.3-nts-vc9-x86-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-nts-vc9-x86.dll b/dll/php_yod-1.3.2-5.3-nts-vc9-x86.dll deleted file mode 100644 index 3eb6d09..0000000 Binary files a/dll/php_yod-1.3.2-5.3-nts-vc9-x86.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-vc9-x64-debug.dll b/dll/php_yod-1.3.2-5.3-vc9-x64-debug.dll deleted file mode 100644 index e5fa987..0000000 Binary files a/dll/php_yod-1.3.2-5.3-vc9-x64-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-vc9-x64.dll b/dll/php_yod-1.3.2-5.3-vc9-x64.dll deleted file mode 100644 index d4fee8d..0000000 Binary files a/dll/php_yod-1.3.2-5.3-vc9-x64.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-vc9-x86-debug.dll b/dll/php_yod-1.3.2-5.3-vc9-x86-debug.dll deleted file mode 100644 index a6f0e42..0000000 Binary files a/dll/php_yod-1.3.2-5.3-vc9-x86-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.3-vc9-x86.dll b/dll/php_yod-1.3.2-5.3-vc9-x86.dll deleted file mode 100644 index d2ed6d9..0000000 Binary files a/dll/php_yod-1.3.2-5.3-vc9-x86.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-nts-vc9-x64-debug.dll b/dll/php_yod-1.3.2-5.4-nts-vc9-x64-debug.dll deleted file mode 100644 index 46e0df2..0000000 Binary files a/dll/php_yod-1.3.2-5.4-nts-vc9-x64-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-nts-vc9-x64.dll b/dll/php_yod-1.3.2-5.4-nts-vc9-x64.dll deleted file mode 100644 index c87c630..0000000 Binary files a/dll/php_yod-1.3.2-5.4-nts-vc9-x64.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-nts-vc9-x86-debug.dll b/dll/php_yod-1.3.2-5.4-nts-vc9-x86-debug.dll deleted file mode 100644 index afc9a74..0000000 Binary files a/dll/php_yod-1.3.2-5.4-nts-vc9-x86-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-nts-vc9-x86.dll b/dll/php_yod-1.3.2-5.4-nts-vc9-x86.dll deleted file mode 100644 index 182d233..0000000 Binary files a/dll/php_yod-1.3.2-5.4-nts-vc9-x86.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-vc9-x64-debug.dll b/dll/php_yod-1.3.2-5.4-vc9-x64-debug.dll deleted file mode 100644 index a87220a..0000000 Binary files a/dll/php_yod-1.3.2-5.4-vc9-x64-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-vc9-x64.dll b/dll/php_yod-1.3.2-5.4-vc9-x64.dll deleted file mode 100644 index 00b2068..0000000 Binary files a/dll/php_yod-1.3.2-5.4-vc9-x64.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-vc9-x86-debug.dll b/dll/php_yod-1.3.2-5.4-vc9-x86-debug.dll deleted file mode 100644 index 252eae3..0000000 Binary files a/dll/php_yod-1.3.2-5.4-vc9-x86-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.4-vc9-x86.dll b/dll/php_yod-1.3.2-5.4-vc9-x86.dll deleted file mode 100644 index 840462c..0000000 Binary files a/dll/php_yod-1.3.2-5.4-vc9-x86.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-nts-vc11-x64-debug.dll b/dll/php_yod-1.3.2-5.5-nts-vc11-x64-debug.dll deleted file mode 100644 index 7dfe8f7..0000000 Binary files a/dll/php_yod-1.3.2-5.5-nts-vc11-x64-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-nts-vc11-x64.dll b/dll/php_yod-1.3.2-5.5-nts-vc11-x64.dll deleted file mode 100644 index b4153e0..0000000 Binary files a/dll/php_yod-1.3.2-5.5-nts-vc11-x64.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-nts-vc11-x86-debug.dll b/dll/php_yod-1.3.2-5.5-nts-vc11-x86-debug.dll deleted file mode 100644 index 301a707..0000000 Binary files a/dll/php_yod-1.3.2-5.5-nts-vc11-x86-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-nts-vc11-x86.dll b/dll/php_yod-1.3.2-5.5-nts-vc11-x86.dll deleted file mode 100644 index 72914d1..0000000 Binary files a/dll/php_yod-1.3.2-5.5-nts-vc11-x86.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-vc11-x64-debug.dll b/dll/php_yod-1.3.2-5.5-vc11-x64-debug.dll deleted file mode 100644 index 501d594..0000000 Binary files a/dll/php_yod-1.3.2-5.5-vc11-x64-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-vc11-x64.dll b/dll/php_yod-1.3.2-5.5-vc11-x64.dll deleted file mode 100644 index d2f3086..0000000 Binary files a/dll/php_yod-1.3.2-5.5-vc11-x64.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-vc11-x86-debug.dll b/dll/php_yod-1.3.2-5.5-vc11-x86-debug.dll deleted file mode 100644 index 3f52893..0000000 Binary files a/dll/php_yod-1.3.2-5.5-vc11-x86-debug.dll and /dev/null differ diff --git a/dll/php_yod-1.3.2-5.5-vc11-x86.dll b/dll/php_yod-1.3.2-5.5-vc11-x86.dll deleted file mode 100644 index 345e9b0..0000000 Binary files a/dll/php_yod-1.3.2-5.5-vc11-x86.dll and /dev/null differ diff --git a/dll/php_yod-1.3.3-5.3-nts-vc9-x64-debug.dll b/dll/php_yod-1.3.3-5.3-nts-vc9-x64-debug.dll new file mode 100644 index 0000000..31f84ce Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-nts-vc9-x64-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.3-nts-vc9-x64.dll b/dll/php_yod-1.3.3-5.3-nts-vc9-x64.dll new file mode 100644 index 0000000..de777cc Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-nts-vc9-x64.dll differ diff --git a/dll/php_yod-1.3.3-5.3-nts-vc9-x86-debug.dll b/dll/php_yod-1.3.3-5.3-nts-vc9-x86-debug.dll new file mode 100644 index 0000000..b94ede6 Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-nts-vc9-x86-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.3-nts-vc9-x86.dll b/dll/php_yod-1.3.3-5.3-nts-vc9-x86.dll new file mode 100644 index 0000000..e605946 Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-nts-vc9-x86.dll differ diff --git a/dll/php_yod-1.3.3-5.3-vc9-x64-debug.dll b/dll/php_yod-1.3.3-5.3-vc9-x64-debug.dll new file mode 100644 index 0000000..bff4024 Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-vc9-x64-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.3-vc9-x64.dll b/dll/php_yod-1.3.3-5.3-vc9-x64.dll new file mode 100644 index 0000000..64ca484 Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-vc9-x64.dll differ diff --git a/dll/php_yod-1.3.3-5.3-vc9-x86-debug.dll b/dll/php_yod-1.3.3-5.3-vc9-x86-debug.dll new file mode 100644 index 0000000..12d484e Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-vc9-x86-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.3-vc9-x86.dll b/dll/php_yod-1.3.3-5.3-vc9-x86.dll new file mode 100644 index 0000000..b02bee0 Binary files /dev/null and b/dll/php_yod-1.3.3-5.3-vc9-x86.dll differ diff --git a/dll/php_yod-1.3.3-5.4-nts-vc9-x64-debug.dll b/dll/php_yod-1.3.3-5.4-nts-vc9-x64-debug.dll new file mode 100644 index 0000000..2a06890 Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-nts-vc9-x64-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.4-nts-vc9-x64.dll b/dll/php_yod-1.3.3-5.4-nts-vc9-x64.dll new file mode 100644 index 0000000..7cf9926 Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-nts-vc9-x64.dll differ diff --git a/dll/php_yod-1.3.3-5.4-nts-vc9-x86-debug.dll b/dll/php_yod-1.3.3-5.4-nts-vc9-x86-debug.dll new file mode 100644 index 0000000..ee85323 Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-nts-vc9-x86-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.4-nts-vc9-x86.dll b/dll/php_yod-1.3.3-5.4-nts-vc9-x86.dll new file mode 100644 index 0000000..2be393b Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-nts-vc9-x86.dll differ diff --git a/dll/php_yod-1.3.3-5.4-vc9-x64-debug.dll b/dll/php_yod-1.3.3-5.4-vc9-x64-debug.dll new file mode 100644 index 0000000..886bfcf Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-vc9-x64-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.4-vc9-x64.dll b/dll/php_yod-1.3.3-5.4-vc9-x64.dll new file mode 100644 index 0000000..de8e66f Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-vc9-x64.dll differ diff --git a/dll/php_yod-1.3.3-5.4-vc9-x86-debug.dll b/dll/php_yod-1.3.3-5.4-vc9-x86-debug.dll new file mode 100644 index 0000000..9e3360a Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-vc9-x86-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.4-vc9-x86.dll b/dll/php_yod-1.3.3-5.4-vc9-x86.dll new file mode 100644 index 0000000..35a1787 Binary files /dev/null and b/dll/php_yod-1.3.3-5.4-vc9-x86.dll differ diff --git a/dll/php_yod-1.3.3-5.5-nts-vc11-x64-debug.dll b/dll/php_yod-1.3.3-5.5-nts-vc11-x64-debug.dll new file mode 100644 index 0000000..b0cef12 Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-nts-vc11-x64-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.5-nts-vc11-x64.dll b/dll/php_yod-1.3.3-5.5-nts-vc11-x64.dll new file mode 100644 index 0000000..d69ca6a Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-nts-vc11-x64.dll differ diff --git a/dll/php_yod-1.3.3-5.5-nts-vc11-x86-debug.dll b/dll/php_yod-1.3.3-5.5-nts-vc11-x86-debug.dll new file mode 100644 index 0000000..7d1b37a Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-nts-vc11-x86-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.5-nts-vc11-x86.dll b/dll/php_yod-1.3.3-5.5-nts-vc11-x86.dll new file mode 100644 index 0000000..ea71ba0 Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-nts-vc11-x86.dll differ diff --git a/dll/php_yod-1.3.3-5.5-vc11-x64-debug.dll b/dll/php_yod-1.3.3-5.5-vc11-x64-debug.dll new file mode 100644 index 0000000..b4575d2 Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-vc11-x64-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.5-vc11-x64.dll b/dll/php_yod-1.3.3-5.5-vc11-x64.dll new file mode 100644 index 0000000..8b92c90 Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-vc11-x64.dll differ diff --git a/dll/php_yod-1.3.3-5.5-vc11-x86-debug.dll b/dll/php_yod-1.3.3-5.5-vc11-x86-debug.dll new file mode 100644 index 0000000..12daba1 Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-vc11-x86-debug.dll differ diff --git a/dll/php_yod-1.3.3-5.5-vc11-x86.dll b/dll/php_yod-1.3.3-5.5-vc11-x86.dll new file mode 100644 index 0000000..bbb1529 Binary files /dev/null and b/dll/php_yod-1.3.3-5.5-vc11-x86.dll differ diff --git a/yod/php_yod.h b/yod/php_yod.h index 45ce83a..eb5b754 100644 --- a/yod/php_yod.h +++ b/yod/php_yod.h @@ -51,10 +51,10 @@ extern zend_module_entry yod_module_entry; #endif #if PHP_YOD_DEBUG -#define YOD_VERSION "1.3.2-dev" +#define YOD_VERSION "1.3.3-dev" #define YOD_RUNMODE 7 #else -#define YOD_VERSION "1.3.2" +#define YOD_VERSION "1.3.3" #define YOD_RUNMODE 3 #endif diff --git a/yod/tests/004.phpt b/yod/tests/004.phpt index b70b699..6c3a6e1 100644 --- a/yod/tests/004.phpt +++ b/yod/tests/004.phpt @@ -19,7 +19,6 @@ class IndexController extends Yod_Controller { public function indexAction() { - \$this->import('Tests'); Tests::yodphp(); \$this->assign(array('yodphp' => 'Yod PHP Framework', 'hello' => 'Hello World!')); \$this->display('/tests/widget'); diff --git a/yod/tests/005.phpt b/yod/tests/005.phpt index 24c4ca1..c0768da 100644 --- a/yod/tests/005.phpt +++ b/yod/tests/005.phpt @@ -20,7 +20,6 @@ class IndexAction extends Yod_Action { public function run() { - \$this->import('Tests'); Tests::yodphp(); \$this->assign(array( 'yodphp' => 'Yod PHP Framework', diff --git a/yod/tests/006.phpt b/yod/tests/006.phpt index a13b42d..10734c0 100644 --- a/yod/tests/006.phpt +++ b/yod/tests/006.phpt @@ -57,13 +57,13 @@ class IndexController extends Yod_Controller { public function indexAction() { - $tests = $this->model('Tests'); + $tests = Yod::model('Tests'); $tests->yodphp(); - $tests = $this->model('Tests'); + $tests = Yod::model('Tests'); $tests->show(); - $hello = $this->model('Hello'); + $hello = Yod::model('Hello'); $hello->show(); } } diff --git a/yod/yod.c b/yod/yod.c index 92f1ec6..e986bb2 100644 --- a/yod/yod.c +++ b/yod/yod.c @@ -24,6 +24,7 @@ #include "php_ini.h" #include "main/SAPI.h" #include "Zend/zend_interfaces.h" +#include "Zend/zend_exceptions.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" @@ -447,7 +448,7 @@ char *yod_runpath(TSRMLS_D) { /** {{{ char *yod_extpath(TSRMLS_D) */ char *yod_extpath(TSRMLS_D) { - zval extpath; + zval extpath, runpath; uint extpath_len; char *runfile; @@ -456,6 +457,10 @@ char *yod_extpath(TSRMLS_D) { convert_to_string(&extpath); YOD_G(extpath) = estrndup(Z_STRVAL(extpath), Z_STRLEN(extpath)); zval_dtor(&extpath); + } else if (zend_get_constant(ZEND_STRL("YOD_RUNPATH"), &runpath TSRMLS_CC)) { + convert_to_string(&runpath); + YOD_G(extpath) = estrndup(Z_STRVAL(runpath), Z_STRLEN(runpath)); + zval_dtor(&runpath); } else { INIT_ZVAL(extpath); runfile = yod_runfile(TSRMLS_C); @@ -573,6 +578,7 @@ int yod_include(char *filepath, zval **retval, int dtor TSRMLS_DC) { zval_ptr_dtor(EG(return_value_ptr_ptr)); } } + } zend_end_try(); YOD_RESTORE_EG_ENVIRON(); @@ -626,6 +632,10 @@ static zend_op_array *yod_init_compile_file(zend_file_handle *file_handle, int t } } + if (EG(exception)) { + zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); + } + yod_application_autorun(TSRMLS_C); return NULL; diff --git a/yod/yod_application.c b/yod/yod_application.c index de2abca..e320f1a 100644 --- a/yod/yod_application.c +++ b/yod/yod_application.c @@ -367,9 +367,10 @@ int yod_application_config(char *name, uint name_len, zval *result TSRMLS_DC) { */ int yod_application_import(char *alias, uint alias_len, char *classext, uint classext_len TSRMLS_DC) { zval **ppval; - char *classfile, *classname, *classpath; + char *classfile, *classfile1, *classfile2, *classname, *classpath; size_t classfile_len, classname_len; zend_class_entry **pce = NULL; + int depth = 0, depth1 = 0; if (!YOD_G(loading)) { yod_loading(TSRMLS_C); @@ -379,12 +380,13 @@ int yod_application_import(char *alias, uint alias_len, char *classext, uint cla return 0; } - classfile = estrndup(alias, alias_len); + classfile1 = classfile = estrndup(alias, alias_len); classfile_len = 0; while (*classfile != '\0') { if (*classfile == '.' || *classfile == '\\') { *classfile = '/'; + depth++; } classfile++; classfile_len++; @@ -393,6 +395,7 @@ int yod_application_import(char *alias, uint alias_len, char *classext, uint cla while (*classfile == '/') { classfile--; classfile_len--; + depth--; } classfile = classfile - classfile_len; @@ -400,6 +403,16 @@ int yod_application_import(char *alias, uint alias_len, char *classext, uint cla while (*classfile == '/') { classfile++; classfile_len--; + depth--; + } + + classfile2 = classfile; + while (depth1 < depth) { + if (*classfile2 == '/') { + depth1++; + } + *classfile2 = tolower(*classfile2); + classfile2++; } php_basename(classfile, classfile_len, NULL, 0, &classname, &classname_len TSRMLS_CC); @@ -413,7 +426,7 @@ int yod_application_import(char *alias, uint alias_len, char *classext, uint cla add_assoc_bool_ex(YOD_G(imports), alias, alias_len + 1, 1); zend_update_static_property(yod_application_ce, ZEND_STRL("_imports"), YOD_G(imports) TSRMLS_CC); - efree(classfile); + efree(classfile1); efree(classname); return 1; } @@ -440,7 +453,7 @@ int yod_application_import(char *alias, uint alias_len, char *classext, uint cla add_assoc_string_ex(YOD_G(imports), alias, alias_len + 1, classpath, 1); zend_update_static_property(yod_application_ce, ZEND_STRL("_imports"), YOD_G(imports) TSRMLS_CC); } - efree(classfile); + efree(classfile1); #if PHP_API_VERSION < 20100412 if (zend_lookup_class_ex(classname, classname_len, 0, &pce TSRMLS_CC) == SUCCESS) { @@ -459,9 +472,10 @@ int yod_application_import(char *alias, uint alias_len, char *classext, uint cla */ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint classext_len, zval *result TSRMLS_DC) { zval *config1, **ppval, *object = NULL; - char *aliaspath, *classfile, *classname, *classfile1, *classname1, *classpath, *loweralias; + char *aliaspath, *classfile, *classfile1, *classfile2, *classname, *classname1, *classpath, *loweralias; size_t aliaspath_len, classfile_len, classname_len; zend_class_entry **pce = NULL; + int depth = 0, depth1 = 0; if (!YOD_G(loading)) { yod_loading(TSRMLS_C); @@ -471,12 +485,13 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla return 0; } - classfile = estrndup(alias, alias_len); + classfile1 = classfile = estrndup(alias, alias_len); classfile_len = 0; while (*classfile != '\0') { if (*classfile == '.' || *classfile == '\\') { *classfile = '/'; + depth++; } classfile++; classfile_len++; @@ -485,6 +500,7 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla while (*classfile == '/') { classfile--; classfile_len--; + depth--; } classfile = classfile - classfile_len; @@ -492,6 +508,16 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla while (*classfile == '/') { classfile++; classfile_len--; + depth--; + } + + classfile2 = classfile; + while (depth1 < depth) { + if (*classfile2 == '/') { + depth1++; + } + *classfile2 = tolower(*classfile2); + classfile2++; } php_basename(classfile, classfile_len, NULL, 0, &classname, &classname_len TSRMLS_CC); @@ -501,7 +527,7 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla ZVAL_ZVAL(result, *ppval, 1, 0); } - efree(classfile); + efree(classfile1); efree(classname); return 1; } @@ -514,7 +540,7 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla if (classfile_len > 4 && strncasecmp(classfile, "yod/", 4) == 0) { if (strncasecmp(classname, "Yod_", 4)) { classname_len = spprintf(&classname1, 0, "Yod_%s", classname); - efree(classname); + efree(classfile1); classname = classname1; } if (classext_len) { @@ -523,13 +549,13 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla spprintf(&classpath, 0, "%s/plugins/%s.class.php", yod_extpath(TSRMLS_C), classfile + 4); } } else if (strncasecmp(classname, "Yod_", 4) == 0) { - classfile1 = estrndup(classfile, classfile_len - classname_len); + classfile2 = estrndup(classfile, classfile_len - classname_len); if (classext_len) { - spprintf(&classpath, 0, "%s/plugins/%s%s%s", yod_extpath(TSRMLS_C), classfile1, classname + 4, classext); + spprintf(&classpath, 0, "%s/plugins/%s%s%s", yod_extpath(TSRMLS_C), classfile2, classname + 4, classext); } else { - spprintf(&classpath, 0, "%s/plugins/%s%s.class.php", yod_extpath(TSRMLS_C), classfile1, classname + 4); + spprintf(&classpath, 0, "%s/plugins/%s%s.class.php", yod_extpath(TSRMLS_C), classfile2, classname + 4); } - efree(classfile1); + efree(classfile2); } else { if (classext_len) { spprintf(&classpath, 0, "%s/plugins/%s%s", yod_runpath(TSRMLS_C), classfile, classext); @@ -545,7 +571,7 @@ int yod_application_plugin(char *alias, uint alias_len, char *classext, uint cla } efree(classpath); } - efree(classfile); + efree(classfile1); #if PHP_API_VERSION < 20100412 if (zend_lookup_class_ex(classname, classname_len, 0, &pce TSRMLS_CC) == SUCCESS) { @@ -637,22 +663,32 @@ void yod_application_autorun(TSRMLS_D) { */ static int yod_application_autoload(char *classname, uint classname_len TSRMLS_DC) { zend_class_entry **pce = NULL; - char *classfile, *classpath; + char *classfile, *classfile1, *classfile2, *classpath; + int depth = 0, depth1 = 0; #if PHP_YOD_DEBUG yod_debugf("yod_application_autoload(%s)", classname); #endif - classfile = estrndup(classname, classname_len); + classfile1 = classfile = estrndup(classname, classname_len); /* class name with namespace in PHP 5.3 */ if (strstr(classname, "\\")) { while (*classfile != '\0') { if (*classfile == '\\') { - *classfile = '_'; + *classfile = '/'; + depth++; + } + classfile++; + } + classfile2 = classfile = classfile - classname_len; + while (depth1 < depth) { + if (*classfile == '/') { + depth1++; } + *classfile = tolower(*classfile); classfile++; } - classfile = classfile - classname_len + 1; + classfile = classfile2; } if (strncasecmp(classfile, "Yod_", 4) == 0) { /* yodphp extends class */ @@ -670,7 +706,7 @@ static int yod_application_autoload(char *classname, uint classname_len TSRMLS_D spprintf(&classpath, 0, "%s/extends/%s.class.php", yod_runpath(TSRMLS_C), classfile); } } - efree(classfile); + efree(classfile1); if (VCWD_ACCESS(classpath, F_OK) == 0) { yod_include(classpath, NULL, 1 TSRMLS_CC); diff --git a/yod/yod_controller.c b/yod/yod_controller.c index d94f940..4b2507b 100644 --- a/yod/yod_controller.c +++ b/yod/yod_controller.c @@ -54,30 +54,6 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(yod_controller_run_arginfo, 0, 0, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(yod_controller_config_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, name) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_controller_import_arginfo, 0, 0, 1) - ZEND_ARG_INFO(0, alias) - ZEND_ARG_INFO(0, classext) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_controller_plugin_arginfo, 0, 0, 1) - ZEND_ARG_INFO(0, alias) - ZEND_ARG_INFO(0, classext) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_controller_model_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, name) - ZEND_ARG_INFO(0, config) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_controller_dbmodel_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, name) - ZEND_ARG_INFO(0, config) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(yod_controller_assign_arginfo, 0, 0, 1) ZEND_ARG_INFO(0, name) ZEND_ARG_INFO(0, value) @@ -811,140 +787,6 @@ PHP_METHOD(yod_controller, run) { } /* }}} */ -/** {{{ proto protected Yod_Controller::config($name = null) -*/ -PHP_METHOD(yod_controller, config) { - char *name = NULL; - uint name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugf("yod_controller_config(%s)", name ? name : ""); -#endif - - (void)yod_application_config(name, name_len, return_value TSRMLS_CC); -} -/* }}} */ - -/** {{{ proto protected Yod_Controller::import($alias, $classext = '.class.php') -*/ -PHP_METHOD(yod_controller, import) { - char *alias = NULL, *classext = NULL; - uint alias_len = 0, classext_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &alias, &alias_len, &classext, &classext_len) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugf("yod_controller_import(%s)", alias ? alias : ""); -#endif - - if (yod_application_import(alias, alias_len, classext, classext_len TSRMLS_CC)) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -/** {{{ proto protected Yod_Controller::plugin($alias, $classext = '.class.php') -*/ -PHP_METHOD(yod_controller, plugin) { -#if PHP_YOD_DEBUG - yod_controller_t *object; -#endif - char *alias = NULL, *classext = NULL; - uint alias_len = 0, classext_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &alias, &alias_len, &classext, &classext_len) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - object = getThis(); - if (instanceof_function(Z_OBJCE_P(object), yod_widget_ce TSRMLS_CC)) { - yod_debugf("yod_widget_plugin(%s)", alias ? alias : ""); - } else if (instanceof_function(Z_OBJCE_P(object), yod_action_ce TSRMLS_CC)) { - yod_debugf("yod_action_plugin(%s)", alias ? alias : ""); - } else { - yod_debugf("yod_controller_plugin(%s)", alias ? alias : ""); - } -#endif - - yod_application_plugin(alias, alias_len, classext, classext_len, return_value TSRMLS_CC); -} -/* }}} */ - -/** {{{ proto protected Yod_Controller::model($name = '', $config = '') -*/ -PHP_METHOD(yod_controller, model) { - yod_controller_t *object; - zval *name1, *config = NULL; - char *name = NULL; - uint name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sz!", &name, &name_len, &config) == FAILURE) { - return; - } - - object = getThis(); - -#if PHP_YOD_DEBUG - yod_debugl(1 TSRMLS_CC); - if (instanceof_function(Z_OBJCE_P(object), yod_widget_ce TSRMLS_CC)) { - yod_debugf("yod_widget_model(%s)", name ? name : ""); - } else if (instanceof_function(Z_OBJCE_P(object), yod_action_ce TSRMLS_CC)) { - yod_debugf("yod_action_model(%s)", name ? name : ""); - } else { - yod_debugf("yod_controller_model(%s)", name ? name : ""); - } -#endif - - if (name_len == 0) { - name1 = zend_read_property(Z_OBJCE_P(object), object, ZEND_STRL("_name"), 1 TSRMLS_CC); - if (name && Z_TYPE_P(name1) == IS_STRING) { - name_len = Z_STRLEN_P(name1); - name = Z_STRVAL_P(name1); - } - } - - yod_model_getinstance(name, name_len, config, return_value TSRMLS_CC); -} -/* }}} */ - -/** {{{ proto protected Yod_Controller::dbmodel($name = '', $config = '') -*/ -PHP_METHOD(yod_controller, dbmodel) { -#if PHP_YOD_DEBUG - yod_controller_t *object; -#endif - zval *config = NULL; - char *name = NULL; - uint name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sz!", &name, &name_len, &config) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - object = getThis(); - yod_debugl(1 TSRMLS_CC); - if (instanceof_function(Z_OBJCE_P(object), yod_widget_ce TSRMLS_CC)) { - yod_debugf("yod_widget_dbmodel(%s)", name ? name : ""); - } else if (instanceof_function(Z_OBJCE_P(object), yod_action_ce TSRMLS_CC)) { - yod_debugf("yod_action_dbmodel(%s)", name ? name : ""); - } else { - yod_debugf("yod_controller_dbmodel(%s)", name ? name : ""); - } -#endif - - yod_dbmodel_getinstance(name, name_len, config, return_value TSRMLS_CC); -} -/* }}} */ - /** {{{ proto protected Yod_Controller::assign($name, $value = null) */ PHP_METHOD(yod_controller, assign) { @@ -1077,11 +919,6 @@ zend_function_entry yod_controller_methods[] = { PHP_ME(yod_controller, __construct, yod_controller_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(yod_controller, init, yod_controller_init_arginfo, ZEND_ACC_PROTECTED) PHP_ME(yod_controller, run, yod_controller_run_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_controller, config, yod_controller_config_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_controller, import, yod_controller_import_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_controller, plugin, yod_controller_plugin_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_controller, model, yod_controller_model_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_controller, dbmodel, yod_controller_dbmodel_arginfo, ZEND_ACC_PROTECTED) PHP_ME(yod_controller, assign, yod_controller_assign_arginfo, ZEND_ACC_PROTECTED) PHP_ME(yod_controller, render, yod_controller_render_arginfo, ZEND_ACC_PROTECTED) PHP_ME(yod_controller, display, yod_controller_display_arginfo, ZEND_ACC_PROTECTED) diff --git a/yod/yod_model.c b/yod/yod_model.c index 99e4b63..60d8364 100644 --- a/yod/yod_model.c +++ b/yod/yod_model.c @@ -86,30 +86,6 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(yod_model_lastquery_arginfo, 0, 0, 0) ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_model_config_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, name) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_model_import_arginfo, 0, 0, 1) - ZEND_ARG_INFO(0, alias) - ZEND_ARG_INFO(0, classext) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_model_plugin_arginfo, 0, 0, 1) - ZEND_ARG_INFO(0, alias) - ZEND_ARG_INFO(0, classext) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_model_model_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, name) - ZEND_ARG_INFO(0, config) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(yod_model_dbmodel_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, name) - ZEND_ARG_INFO(0, config) -ZEND_END_ARG_INFO() /* }}} */ /** {{{ int yod_model_construct(yod_model_t *object, char *name, uint name_len, zval *config TSRMLS_DC) @@ -749,107 +725,6 @@ PHP_METHOD(yod_model, lastQuery) { } /* }}} */ -/** {{{ proto public Yod_Model::config($name = null) -*/ -PHP_METHOD(yod_model, config) { - char *name = NULL; - uint name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugf("yod_model_config(%s)", name ? name : ""); -#endif - - yod_application_config(name, name_len, return_value TSRMLS_CC); -} -/* }}} */ - -/** {{{ proto public Yod_Model::import($alias, $classext = '.class.php') -*/ -PHP_METHOD(yod_model, import) { - char *alias = NULL, *classext = NULL; - uint alias_len = 0, classext_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &alias, &alias_len, &classext, &classext_len) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugf("yod_model_import(%s)", alias ? alias : ""); -#endif - - if (yod_application_import(alias, alias_len, classext, classext_len TSRMLS_CC)) { - RETURN_TRUE; - } - RETURN_FALSE; -} -/* }}} */ - -/** {{{ proto public Yod_Model::plugin($alias, $classext = '.class.php') -*/ -PHP_METHOD(yod_model, plugin) { - char *alias = NULL, *classext = NULL; - uint alias_len = 0, classext_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &alias, &alias_len, &classext, &classext_len) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugf("yod_model_plugin(%s)", alias ? alias : ""); -#endif - - yod_application_plugin(alias, alias_len, classext, classext_len, return_value TSRMLS_CC); -} -/* }}} */ - -/** {{{ proto public Yod_Model::model($name = '', $config = null) -*/ -PHP_METHOD(yod_model, model) { - zval *config = NULL; - char *name = NULL; - uint name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sz!", &name, &name_len, &config) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugl(1 TSRMLS_CC); - yod_debugf("yod_model_model(%s)", name ? name : ""); -#endif - - if (name_len == 0) { - RETURN_ZVAL(getThis(), 1, 0); - } - - yod_model_getinstance(name, name_len, config, return_value TSRMLS_CC); -} -/* }}} */ - -/** {{{ proto public Yod_Model::dbmodel($name = '', $config = null) -*/ -PHP_METHOD(yod_model, dbmodel) { - zval *config = NULL; - char *name = NULL; - uint name_len = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sz!", &name, &name_len, &config) == FAILURE) { - return; - } - -#if PHP_YOD_DEBUG - yod_debugl(1 TSRMLS_CC); - yod_debugf("yod_model_dbmodel(%s)", name ? name : ""); -#endif - - yod_dbmodel_getinstance(name, name_len, config, return_value TSRMLS_CC); -} -/* }}} */ - /** {{{ proto public Yod_Model::__destruct() */ PHP_METHOD(yod_model, __destruct) { @@ -870,13 +745,7 @@ zend_function_entry yod_model_methods[] = { PHP_ME(yod_model, update, yod_model_update_arginfo, ZEND_ACC_PUBLIC) PHP_ME(yod_model, remove, yod_model_remove_arginfo, ZEND_ACC_PUBLIC) PHP_ME(yod_model, lastQuery, yod_model_lastquery_arginfo, ZEND_ACC_PUBLIC) - PHP_ME(yod_model, config, yod_model_config_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_model, import, yod_model_import_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_model, plugin, yod_model_plugin_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_model, model, yod_model_model_arginfo, ZEND_ACC_PROTECTED) - PHP_ME(yod_model, dbmodel, yod_model_dbmodel_arginfo, ZEND_ACC_PROTECTED) PHP_ME(yod_model, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR) - PHP_MALIAS(yod_model, findAll, select, yod_model_select_arginfo, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; /* }}} */ diff --git a/yod/yodphp.php b/yod/yodphp.php index 545355e..739bc2b 100644 --- a/yod/yodphp.php +++ b/yod/yodphp.php @@ -11,7 +11,7 @@ // yodphp constant defined('YOD_RUNTIME') or define('YOD_RUNTIME', microtime(true)); -defined('YOD_VERSION') or define('YOD_VERSION', '1.3.2'); +defined('YOD_VERSION') or define('YOD_VERSION', '1.3.3'); defined('YOD_FORWARD') or define('YOD_FORWARD', 5); defined('YOD_RUNMODE') or define('YOD_RUNMODE', 3); defined('YOD_CHARSET') or define('YOD_CHARSET', 'utf-8'); @@ -790,68 +790,6 @@ protected function run() } } - /** - * config - * @access protected - * @param string $name - * @return array - */ - protected function config($name = null) - { - return Yod_Application::config($name); - } - - /** - * import - * @access protected - * @param string $alias - * @param string $classext - * @return boolean - */ - protected function import($alias, $classext = '.class.php') - { - return Yod_Application::import($alias, $classext); - } - - /** - * plugin - * @access protected - * @param string $alias - * @param string $classext - * @return mixed - */ - protected function plugin($alias, $classext = '.class.php') - { - return Yod_Application::plugin($alias, $classext); - } - - /** - * model - * @access protected - * @param string $name - * @param mixed $config - * @return Yod_Model - */ - protected function model($name = '', $config = '') - { - if (empty($name)) { - $name = $this->_name; - } - return Yod_Model::getInstance($name, $config); - } - - /** - * dbmodel - * @access protected - * @param string $name - * @param mixed $config - * @return Yod_DbModel - */ - protected function dbmodel($name = '', $config = '') - { - return Yod_DbModel::getInstance($name, $config); - } - /** * assign * @access protected @@ -1228,19 +1166,6 @@ public function select($where = null, $params = array(), $select = '*') return false; } - /** - * findAll - * @access public - * @param mixed $where - * @param array $params - * @param mixed $select - * @return mixed - */ - public function findAll($where = null, $params = array(), $select = '*') - { - return $this->select($where, $params, $select); - } - /** * count * @access public @@ -1326,68 +1251,7 @@ public function lastQuery() { return $this->_db->lastQuery(); } - - /** - * config - * @access protected - * @param void - * @return array - */ - protected function config($name = null) - { - return Yod_Application::config($name); - } - /** - * import - * @access protected - * @param string $alias - * @param string $classext - * @return boolean - */ - protected function import($alias, $classext = '.class.php') - { - return Yod_Application::import($alias, $classext); - } - - /** - * plugin - * @access protected - * @param string $alias - * @param string $classext - * @return mixed - */ - protected function plugin($alias, $classext = '.class.php') - { - return Yod_Application::plugin($alias, $classext); - } - - /** - * model - * @access protected - * @param string $name - * @param mixed $config - * @return Yod_Model - */ - protected function model($name = '', $config = '') - { - if (empty($name)) { - return $this; - } - return Yod_Model::getInstance($name, $config); - } - - /** - * dbmodel - * @access protected - * @param string $name - * @param mixed $config - * @return Yod_Model - */ - protected function dbmodel($name = '', $config = null) - { - return Yod_DbModel::getInstance($name, $config); - } } /** @@ -2579,10 +2443,10 @@ abstract class Yod_Plugin } /** - * Yod_Global + * Yod * */ -abstract class Yod_G +abstract class Yod { /**