quickfw-git Mailing List for QuickFramework
Brought to you by:
ivan1986,
seriousdron
You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
(9) |
Apr
(25) |
May
(22) |
Jun
(22) |
Jul
(15) |
Aug
(16) |
Sep
(4) |
Oct
(9) |
Nov
(9) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(5) |
Feb
(3) |
Mar
(2) |
Apr
(11) |
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
From: Ivan1986 <iva...@us...> - 2011-10-12 16:59:44
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 3e55a06ffb102e9ac336ffe28414993b72c6f309 (commit) from dd7f43757f0006b78b2769383bb5cd4e654b50e6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3e55a06ffb102e9ac336ffe28414993b72c6f309 Author: Ivan Borzenkov <iva...@li...> Date: Wed Oct 12 20:59:17 2011 +0400 Папка lib перенесена в QFW diff --git a/lib/Curl.php b/QFW/lib/Curl.php similarity index 100% rename from lib/Curl.php rename to QFW/lib/Curl.php diff --git a/lib/DbSimple/Connect.php b/QFW/lib/DbSimple/Connect.php similarity index 100% rename from lib/DbSimple/Connect.php rename to QFW/lib/DbSimple/Connect.php diff --git a/lib/DbSimple/Database.php b/QFW/lib/DbSimple/Database.php similarity index 100% rename from lib/DbSimple/Database.php rename to QFW/lib/DbSimple/Database.php diff --git a/lib/DbSimple/Generic.php b/QFW/lib/DbSimple/Generic.php similarity index 100% rename from lib/DbSimple/Generic.php rename to QFW/lib/DbSimple/Generic.php diff --git a/lib/DbSimple/Ibase.php b/QFW/lib/DbSimple/Ibase.php similarity index 100% rename from lib/DbSimple/Ibase.php rename to QFW/lib/DbSimple/Ibase.php diff --git a/lib/DbSimple/Litepdo.php b/QFW/lib/DbSimple/Litepdo.php similarity index 100% rename from lib/DbSimple/Litepdo.php rename to QFW/lib/DbSimple/Litepdo.php diff --git a/lib/DbSimple/Mypdo.php b/QFW/lib/DbSimple/Mypdo.php similarity index 100% rename from lib/DbSimple/Mypdo.php rename to QFW/lib/DbSimple/Mypdo.php diff --git a/lib/DbSimple/Mysql.php b/QFW/lib/DbSimple/Mysql.php similarity index 100% rename from lib/DbSimple/Mysql.php rename to QFW/lib/DbSimple/Mysql.php diff --git a/lib/DbSimple/Postgresql.php b/QFW/lib/DbSimple/Postgresql.php similarity index 100% rename from lib/DbSimple/Postgresql.php rename to QFW/lib/DbSimple/Postgresql.php diff --git a/lib/DbSimple/Sqlite.php b/QFW/lib/DbSimple/Sqlite.php similarity index 100% rename from lib/DbSimple/Sqlite.php rename to QFW/lib/DbSimple/Sqlite.php diff --git a/lib/Debug/ErrorHook/Catcher.php b/QFW/lib/Debug/ErrorHook/Catcher.php similarity index 100% rename from lib/Debug/ErrorHook/Catcher.php rename to QFW/lib/Debug/ErrorHook/Catcher.php diff --git a/lib/Debug/ErrorHook/INotifier.php b/QFW/lib/Debug/ErrorHook/INotifier.php similarity index 100% rename from lib/Debug/ErrorHook/INotifier.php rename to QFW/lib/Debug/ErrorHook/INotifier.php diff --git a/lib/Debug/ErrorHook/JabberNotifier.php b/QFW/lib/Debug/ErrorHook/JabberNotifier.php similarity index 100% rename from lib/Debug/ErrorHook/JabberNotifier.php rename to QFW/lib/Debug/ErrorHook/JabberNotifier.php diff --git a/lib/Debug/ErrorHook/Listener.php b/QFW/lib/Debug/ErrorHook/Listener.php similarity index 100% rename from lib/Debug/ErrorHook/Listener.php rename to QFW/lib/Debug/ErrorHook/Listener.php diff --git a/lib/Debug/ErrorHook/LogNotifier.php b/QFW/lib/Debug/ErrorHook/LogNotifier.php similarity index 100% rename from lib/Debug/ErrorHook/LogNotifier.php rename to QFW/lib/Debug/ErrorHook/LogNotifier.php diff --git a/lib/Debug/ErrorHook/MailNotifier.php b/QFW/lib/Debug/ErrorHook/MailNotifier.php similarity index 100% rename from lib/Debug/ErrorHook/MailNotifier.php rename to QFW/lib/Debug/ErrorHook/MailNotifier.php diff --git a/lib/Debug/ErrorHook/RemoveDupsWrapper.php b/QFW/lib/Debug/ErrorHook/RemoveDupsWrapper.php similarity index 100% rename from lib/Debug/ErrorHook/RemoveDupsWrapper.php rename to QFW/lib/Debug/ErrorHook/RemoveDupsWrapper.php diff --git a/lib/Debug/ErrorHook/TextNotifier.php b/QFW/lib/Debug/ErrorHook/TextNotifier.php similarity index 100% rename from lib/Debug/ErrorHook/TextNotifier.php rename to QFW/lib/Debug/ErrorHook/TextNotifier.php diff --git a/lib/Debug/ErrorHook/Util.php b/QFW/lib/Debug/ErrorHook/Util.php similarity index 100% rename from lib/Debug/ErrorHook/Util.php rename to QFW/lib/Debug/ErrorHook/Util.php diff --git a/lib/Email.php b/QFW/lib/Email.php similarity index 100% rename from lib/Email.php rename to QFW/lib/Email.php diff --git a/lib/HTML/FormPersister.php b/QFW/lib/HTML/FormPersister.php similarity index 100% rename from lib/HTML/FormPersister.php rename to QFW/lib/HTML/FormPersister.php diff --git a/lib/HTML/MetaForm.php b/QFW/lib/HTML/MetaForm.php similarity index 100% rename from lib/HTML/MetaForm.php rename to QFW/lib/HTML/MetaForm.php diff --git a/lib/HTML/MetaFormAction.php b/QFW/lib/HTML/MetaFormAction.php similarity index 100% rename from lib/HTML/MetaFormAction.php rename to QFW/lib/HTML/MetaFormAction.php diff --git a/lib/HTML/SemiParser.php b/QFW/lib/HTML/SemiParser.php similarity index 100% rename from lib/HTML/SemiParser.php rename to QFW/lib/HTML/SemiParser.php diff --git a/lib/JsHttpRequest.php b/QFW/lib/JsHttpRequest.php similarity index 100% rename from lib/JsHttpRequest.php rename to QFW/lib/JsHttpRequest.php diff --git a/lib/Language.php b/QFW/lib/Language.php similarity index 100% rename from lib/Language.php rename to QFW/lib/Language.php diff --git a/lib/Lock.php b/QFW/lib/Lock.php similarity index 100% rename from lib/Lock.php rename to QFW/lib/Lock.php diff --git a/lib/Log.php b/QFW/lib/Log.php similarity index 100% rename from lib/Log.php rename to QFW/lib/Log.php diff --git a/lib/Modules/Scaffold/Display.php b/QFW/lib/Modules/Scaffold/Display.php similarity index 100% rename from lib/Modules/Scaffold/Display.php rename to QFW/lib/Modules/Scaffold/Display.php diff --git a/lib/Modules/Scaffold/Fields.php b/QFW/lib/Modules/Scaffold/Fields.php similarity index 100% rename from lib/Modules/Scaffold/Fields.php rename to QFW/lib/Modules/Scaffold/Fields.php diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/QFW/lib/Modules/Scaffold/ScaffoldController.php similarity index 100% rename from lib/Modules/Scaffold/ScaffoldController.php rename to QFW/lib/Modules/Scaffold/ScaffoldController.php diff --git a/lib/Modules/Scaffold/scaffold/edit.php b/QFW/lib/Modules/Scaffold/scaffold/edit.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/edit.php rename to QFW/lib/Modules/Scaffold/scaffold/edit.php diff --git a/lib/Modules/Scaffold/scaffold/filterForm.php b/QFW/lib/Modules/Scaffold/scaffold/filterForm.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/filterForm.php rename to QFW/lib/Modules/Scaffold/scaffold/filterForm.php diff --git a/lib/Modules/Scaffold/scaffold/index.php b/QFW/lib/Modules/Scaffold/scaffold/index.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/index.php rename to QFW/lib/Modules/Scaffold/scaffold/index.php diff --git a/lib/Modules/Scaffold/scaffold/info.php b/QFW/lib/Modules/Scaffold/scaffold/info.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/info.php rename to QFW/lib/Modules/Scaffold/scaffold/info.php diff --git a/lib/Modules/Scaffold/scaffold/multidel.php b/QFW/lib/Modules/Scaffold/scaffold/multidel.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/multidel.php rename to QFW/lib/Modules/Scaffold/scaffold/multidel.php diff --git a/lib/Modules/Scaffold/scaffold/multiedit.php b/QFW/lib/Modules/Scaffold/scaffold/multiedit.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/multiedit.php rename to QFW/lib/Modules/Scaffold/scaffold/multiedit.php diff --git a/lib/Modules/Scaffold/scaffold/parent.php b/QFW/lib/Modules/Scaffold/scaffold/parent.php similarity index 100% rename from lib/Modules/Scaffold/scaffold/parent.php rename to QFW/lib/Modules/Scaffold/scaffold/parent.php diff --git a/lib/Modules/StaticController.php b/QFW/lib/Modules/StaticController.php similarity index 100% rename from lib/Modules/StaticController.php rename to QFW/lib/Modules/StaticController.php diff --git a/lib/Modules/admin/Readme.txt b/QFW/lib/Modules/admin/Readme.txt similarity index 100% rename from lib/Modules/admin/Readme.txt rename to QFW/lib/Modules/admin/Readme.txt diff --git a/lib/Modules/admin/controllers/Controller.php b/QFW/lib/Modules/admin/controllers/Controller.php similarity index 100% rename from lib/Modules/admin/controllers/Controller.php rename to QFW/lib/Modules/admin/controllers/Controller.php diff --git a/lib/Modules/admin/controllers/IndexController.php b/QFW/lib/Modules/admin/controllers/IndexController.php similarity index 100% rename from lib/Modules/admin/controllers/IndexController.php rename to QFW/lib/Modules/admin/controllers/IndexController.php diff --git a/lib/Modules/admin/controllers/InfoController.php b/QFW/lib/Modules/admin/controllers/InfoController.php similarity index 100% rename from lib/Modules/admin/controllers/InfoController.php rename to QFW/lib/Modules/admin/controllers/InfoController.php diff --git a/lib/Modules/admin/controllers/NavController.php b/QFW/lib/Modules/admin/controllers/NavController.php similarity index 100% rename from lib/Modules/admin/controllers/NavController.php rename to QFW/lib/Modules/admin/controllers/NavController.php diff --git a/lib/Modules/admin/templates/auth.php b/QFW/lib/Modules/admin/templates/auth.php similarity index 100% rename from lib/Modules/admin/templates/auth.php rename to QFW/lib/Modules/admin/templates/auth.php diff --git a/lib/Modules/admin/templates/main.php b/QFW/lib/Modules/admin/templates/main.php similarity index 100% rename from lib/Modules/admin/templates/main.php rename to QFW/lib/Modules/admin/templates/main.php diff --git a/lib/Modules/admin/templates/memcache.php b/QFW/lib/Modules/admin/templates/memcache.php similarity index 100% rename from lib/Modules/admin/templates/memcache.php rename to QFW/lib/Modules/admin/templates/memcache.php diff --git a/lib/Modules/admin/templates/pager.php b/QFW/lib/Modules/admin/templates/pager.php similarity index 100% rename from lib/Modules/admin/templates/pager.php rename to QFW/lib/Modules/admin/templates/pager.php diff --git a/lib/Modules/admin/templates/sub/head_stripe.php b/QFW/lib/Modules/admin/templates/sub/head_stripe.php similarity index 100% rename from lib/Modules/admin/templates/sub/head_stripe.php rename to QFW/lib/Modules/admin/templates/sub/head_stripe.php diff --git a/lib/RecursiveArrayAccess.php b/QFW/lib/RecursiveArrayAccess.php similarity index 100% rename from lib/RecursiveArrayAccess.php rename to QFW/lib/RecursiveArrayAccess.php diff --git a/lib/Rss.php b/QFW/lib/Rss.php similarity index 100% rename from lib/Rss.php rename to QFW/lib/Rss.php diff --git a/lib/Sitemap.php b/QFW/lib/Sitemap.php similarity index 100% rename from lib/Sitemap.php rename to QFW/lib/Sitemap.php diff --git a/lib/Text.php b/QFW/lib/Text.php similarity index 100% rename from lib/Text.php rename to QFW/lib/Text.php diff --git a/lib/True_validation.php b/QFW/lib/True_validation.php similarity index 100% rename from lib/True_validation.php rename to QFW/lib/True_validation.php diff --git a/lib/View.php b/QFW/lib/View.php similarity index 100% rename from lib/View.php rename to QFW/lib/View.php diff --git a/lib/XMPPHP/BOSH.php b/QFW/lib/XMPPHP/BOSH.php similarity index 100% rename from lib/XMPPHP/BOSH.php rename to QFW/lib/XMPPHP/BOSH.php diff --git a/lib/XMPPHP/Exception.php b/QFW/lib/XMPPHP/Exception.php similarity index 100% rename from lib/XMPPHP/Exception.php rename to QFW/lib/XMPPHP/Exception.php diff --git a/lib/XMPPHP/Log.php b/QFW/lib/XMPPHP/Log.php similarity index 100% rename from lib/XMPPHP/Log.php rename to QFW/lib/XMPPHP/Log.php diff --git a/lib/XMPPHP/Roster.php b/QFW/lib/XMPPHP/Roster.php similarity index 100% rename from lib/XMPPHP/Roster.php rename to QFW/lib/XMPPHP/Roster.php diff --git a/lib/XMPPHP/XMLObj.php b/QFW/lib/XMPPHP/XMLObj.php similarity index 100% rename from lib/XMPPHP/XMLObj.php rename to QFW/lib/XMPPHP/XMLObj.php diff --git a/lib/XMPPHP/XMLStream.php b/QFW/lib/XMPPHP/XMLStream.php similarity index 100% rename from lib/XMPPHP/XMLStream.php rename to QFW/lib/XMPPHP/XMLStream.php diff --git a/lib/XMPPHP/XMPP.php b/QFW/lib/XMPPHP/XMPP.php similarity index 100% rename from lib/XMPPHP/XMPP.php rename to QFW/lib/XMPPHP/XMPP.php diff --git a/lib/jQuery.php b/QFW/lib/jQuery.php similarity index 100% rename from lib/jQuery.php rename to QFW/lib/jQuery.php diff --git a/lib/language/ru_RU/true_validation_lang.php b/QFW/lib/language/ru_RU/true_validation_lang.php similarity index 100% rename from lib/language/ru_RU/true_validation_lang.php rename to QFW/lib/language/ru_RU/true_validation_lang.php diff --git a/lib/utils.php b/QFW/lib/utils.php similarity index 100% rename from lib/utils.php rename to QFW/lib/utils.php diff --git a/cron/cruise.php b/cron/cruise.php index c7cc548..f984ee9 100644 --- a/cron/cruise.php +++ b/cron/cruise.php @@ -4,7 +4,7 @@ define ('APPPATH', ROOTPATH . '/application'); define ('VARPATH', ROOTPATH . '/var'); define ('QFWPATH', ROOTPATH . '/QFW'); - define ('LIBPATH', ROOTPATH . '/lib'); + define ('LIBPATH', QFWPATH . '/lib'); //Настройки по умолчанию, если нужно - измените // define ('TMPPATH', VARPATH . '/tmp'); diff --git a/cron/start.php b/cron/start.php index 48ac725..57317d4 100644 --- a/cron/start.php +++ b/cron/start.php @@ -4,7 +4,7 @@ define ('APPPATH', ROOTPATH . '/application'); define ('VARPATH', ROOTPATH . '/var'); define ('QFWPATH', ROOTPATH . '/QFW'); - define ('LIBPATH', ROOTPATH . '/lib'); + define ('LIBPATH', QFWPATH . '/lib'); //Настройки по умолчанию, если нужно - измените // define ('TMPPATH', VARPATH . '/tmp'); diff --git a/www/index.php b/www/index.php index 9562d55..b440e8e 100644 --- a/www/index.php +++ b/www/index.php @@ -4,7 +4,7 @@ define ('APPPATH', ROOTPATH . '/application'); define ('VARPATH', ROOTPATH . '/var'); define ('QFWPATH', ROOTPATH . '/QFW'); - define ('LIBPATH', ROOTPATH . '/lib'); + define ('LIBPATH', QFWPATH . '/lib'); //Настройки по умолчанию, если нужно - измените // define ('TMPPATH', VARPATH . '/tmp'); ----------------------------------------------------------------------- Summary of changes: {lib => QFW/lib}/Curl.php | 0 {lib => QFW/lib}/DbSimple/Connect.php | 0 {lib => QFW/lib}/DbSimple/Database.php | 0 {lib => QFW/lib}/DbSimple/Generic.php | 0 {lib => QFW/lib}/DbSimple/Ibase.php | 0 {lib => QFW/lib}/DbSimple/Litepdo.php | 0 {lib => QFW/lib}/DbSimple/Mypdo.php | 0 {lib => QFW/lib}/DbSimple/Mysql.php | 0 {lib => QFW/lib}/DbSimple/Postgresql.php | 0 {lib => QFW/lib}/DbSimple/Sqlite.php | 0 {lib => QFW/lib}/Debug/ErrorHook/Catcher.php | 0 {lib => QFW/lib}/Debug/ErrorHook/INotifier.php | 0 .../lib}/Debug/ErrorHook/JabberNotifier.php | 0 {lib => QFW/lib}/Debug/ErrorHook/Listener.php | 0 {lib => QFW/lib}/Debug/ErrorHook/LogNotifier.php | 0 {lib => QFW/lib}/Debug/ErrorHook/MailNotifier.php | 0 .../lib}/Debug/ErrorHook/RemoveDupsWrapper.php | 0 {lib => QFW/lib}/Debug/ErrorHook/TextNotifier.php | 0 {lib => QFW/lib}/Debug/ErrorHook/Util.php | 0 {lib => QFW/lib}/Email.php | 0 {lib => QFW/lib}/HTML/FormPersister.php | 0 {lib => QFW/lib}/HTML/MetaForm.php | 0 {lib => QFW/lib}/HTML/MetaFormAction.php | 0 {lib => QFW/lib}/HTML/SemiParser.php | 0 {lib => QFW/lib}/JsHttpRequest.php | 0 {lib => QFW/lib}/Language.php | 0 {lib => QFW/lib}/Lock.php | 0 {lib => QFW/lib}/Log.php | 0 {lib => QFW/lib}/Modules/Scaffold/Display.php | 0 {lib => QFW/lib}/Modules/Scaffold/Fields.php | 0 .../lib}/Modules/Scaffold/ScaffoldController.php | 0 .../lib}/Modules/Scaffold/scaffold/edit.php | 0 .../lib}/Modules/Scaffold/scaffold/filterForm.php | 0 .../lib}/Modules/Scaffold/scaffold/index.php | 0 .../lib}/Modules/Scaffold/scaffold/info.php | 0 .../lib}/Modules/Scaffold/scaffold/multidel.php | 0 .../lib}/Modules/Scaffold/scaffold/multiedit.php | 0 .../lib}/Modules/Scaffold/scaffold/parent.php | 0 {lib => QFW/lib}/Modules/StaticController.php | 0 {lib => QFW/lib}/Modules/admin/Readme.txt | 0 .../lib}/Modules/admin/controllers/Controller.php | 0 .../Modules/admin/controllers/IndexController.php | 0 .../Modules/admin/controllers/InfoController.php | 0 .../Modules/admin/controllers/NavController.php | 0 {lib => QFW/lib}/Modules/admin/templates/auth.php | 0 {lib => QFW/lib}/Modules/admin/templates/main.php | 0 .../lib}/Modules/admin/templates/memcache.php | 0 {lib => QFW/lib}/Modules/admin/templates/pager.php | 0 .../Modules/admin/templates/sub/head_stripe.php | 0 {lib => QFW/lib}/RecursiveArrayAccess.php | 0 {lib => QFW/lib}/Rss.php | 0 {lib => QFW/lib}/Sitemap.php | 0 {lib => QFW/lib}/Text.php | 0 {lib => QFW/lib}/True_validation.php | 0 {lib => QFW/lib}/View.php | 0 {lib => QFW/lib}/XMPPHP/BOSH.php | 0 {lib => QFW/lib}/XMPPHP/Exception.php | 0 {lib => QFW/lib}/XMPPHP/Log.php | 0 {lib => QFW/lib}/XMPPHP/Roster.php | 0 {lib => QFW/lib}/XMPPHP/XMLObj.php | 0 {lib => QFW/lib}/XMPPHP/XMLStream.php | 0 {lib => QFW/lib}/XMPPHP/XMPP.php | 0 {lib => QFW/lib}/jQuery.php | 0 .../lib}/language/ru_RU/true_validation_lang.php | 0 {lib => QFW/lib}/utils.php | 0 cron/cruise.php | 2 +- cron/start.php | 2 +- www/index.php | 2 +- 68 files changed, 3 insertions(+), 3 deletions(-) rename {lib => QFW/lib}/Curl.php (100%) rename {lib => QFW/lib}/DbSimple/Connect.php (100%) rename {lib => QFW/lib}/DbSimple/Database.php (100%) rename {lib => QFW/lib}/DbSimple/Generic.php (100%) rename {lib => QFW/lib}/DbSimple/Ibase.php (100%) rename {lib => QFW/lib}/DbSimple/Litepdo.php (100%) rename {lib => QFW/lib}/DbSimple/Mypdo.php (100%) rename {lib => QFW/lib}/DbSimple/Mysql.php (100%) rename {lib => QFW/lib}/DbSimple/Postgresql.php (100%) rename {lib => QFW/lib}/DbSimple/Sqlite.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/Catcher.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/INotifier.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/JabberNotifier.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/Listener.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/LogNotifier.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/MailNotifier.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/RemoveDupsWrapper.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/TextNotifier.php (100%) rename {lib => QFW/lib}/Debug/ErrorHook/Util.php (100%) rename {lib => QFW/lib}/Email.php (100%) rename {lib => QFW/lib}/HTML/FormPersister.php (100%) rename {lib => QFW/lib}/HTML/MetaForm.php (100%) rename {lib => QFW/lib}/HTML/MetaFormAction.php (100%) rename {lib => QFW/lib}/HTML/SemiParser.php (100%) rename {lib => QFW/lib}/JsHttpRequest.php (100%) rename {lib => QFW/lib}/Language.php (100%) rename {lib => QFW/lib}/Lock.php (100%) rename {lib => QFW/lib}/Log.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/Display.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/Fields.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/ScaffoldController.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/edit.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/filterForm.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/index.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/info.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/multidel.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/multiedit.php (100%) rename {lib => QFW/lib}/Modules/Scaffold/scaffold/parent.php (100%) rename {lib => QFW/lib}/Modules/StaticController.php (100%) rename {lib => QFW/lib}/Modules/admin/Readme.txt (100%) rename {lib => QFW/lib}/Modules/admin/controllers/Controller.php (100%) rename {lib => QFW/lib}/Modules/admin/controllers/IndexController.php (100%) rename {lib => QFW/lib}/Modules/admin/controllers/InfoController.php (100%) rename {lib => QFW/lib}/Modules/admin/controllers/NavController.php (100%) rename {lib => QFW/lib}/Modules/admin/templates/auth.php (100%) rename {lib => QFW/lib}/Modules/admin/templates/main.php (100%) rename {lib => QFW/lib}/Modules/admin/templates/memcache.php (100%) rename {lib => QFW/lib}/Modules/admin/templates/pager.php (100%) rename {lib => QFW/lib}/Modules/admin/templates/sub/head_stripe.php (100%) rename {lib => QFW/lib}/RecursiveArrayAccess.php (100%) rename {lib => QFW/lib}/Rss.php (100%) rename {lib => QFW/lib}/Sitemap.php (100%) rename {lib => QFW/lib}/Text.php (100%) rename {lib => QFW/lib}/True_validation.php (100%) rename {lib => QFW/lib}/View.php (100%) rename {lib => QFW/lib}/XMPPHP/BOSH.php (100%) rename {lib => QFW/lib}/XMPPHP/Exception.php (100%) rename {lib => QFW/lib}/XMPPHP/Log.php (100%) rename {lib => QFW/lib}/XMPPHP/Roster.php (100%) rename {lib => QFW/lib}/XMPPHP/XMLObj.php (100%) rename {lib => QFW/lib}/XMPPHP/XMLStream.php (100%) rename {lib => QFW/lib}/XMPPHP/XMPP.php (100%) rename {lib => QFW/lib}/jQuery.php (100%) rename {lib => QFW/lib}/language/ru_RU/true_validation_lang.php (100%) rename {lib => QFW/lib}/utils.php (100%) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-10-12 16:54:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via dd7f43757f0006b78b2769383bb5cd4e654b50e6 (commit) via b7ef98ab579cc23a7692fc181ccb9e901c383be9 (commit) via 38326e7a12bfcc71dcf8f6c205e8f6e6e082f882 (commit) via 777d8260cd06f839515d160b2250e90f36a88cc9 (commit) from cb04338a5bc79749ab0011875ea495010ad08a5d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit dd7f43757f0006b78b2769383bb5cd4e654b50e6 Author: Ivan Borzenkov <iva...@li...> Date: Wed Oct 12 20:52:32 2011 +0400 Более корректный поиск файлов - на fpm не работало diff --git a/QFW/QuickFW/Plugs.php b/QFW/QuickFW/Plugs.php index 84fea86..23c745d 100644 --- a/QFW/QuickFW/Plugs.php +++ b/QFW/QuickFW/Plugs.php @@ -1,6 +1,6 @@ <?php -require_once 'Helpers.php'; +require_once __DIR__.'/Helpers.php'; class QuickFW_Plugs { diff --git a/QFW/Templater/PlainView.php b/QFW/Templater/PlainView.php index c2650d2..4a7f9ca 100644 --- a/QFW/Templater/PlainView.php +++ b/QFW/Templater/PlainView.php @@ -1,6 +1,6 @@ <?php -require_once 'Templater.php'; +require_once __DIR__.'/Templater.php'; /** * Делегат отложенного вызова функции или метода diff --git a/QFW/Templater/Proxy.php b/QFW/Templater/Proxy.php index b92712e..3a9e27c 100644 --- a/QFW/Templater/Proxy.php +++ b/QFW/Templater/Proxy.php @@ -1,6 +1,6 @@ <?php -require_once 'Templater.php'; +require_once __DIR__.'/Templater.php'; class Templater_Proxy extends Templater { diff --git a/QFW/Templater/Smarty.php b/QFW/Templater/Smarty.php index 423684d..78e7bf9 100644 --- a/QFW/Templater/Smarty.php +++ b/QFW/Templater/Smarty.php @@ -1,6 +1,6 @@ <?php -require_once 'Templater.php'; +require_once __DIR__.'/Templater.php'; /** * Обертка для смарти * diff --git a/QFW/Templater/Twig.php b/QFW/Templater/Twig.php index f857609..5385371 100644 --- a/QFW/Templater/Twig.php +++ b/QFW/Templater/Twig.php @@ -1,6 +1,6 @@ <?php -require_once 'Templater.php'; +require_once __DIR__.'/Templater.php'; /** * Обертка для Twig * commit b7ef98ab579cc23a7692fc181ccb9e901c383be9 Author: Ivan Borzenkov <iva...@li...> Date: Tue Sep 27 21:53:27 2011 +0400 Класс для исключения diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 96414fe..9e7e450 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -1,6 +1,11 @@ <?php /** + * Класс исключения - не найден файлы для этого модуля + */ +class QuickFWConfigNotFileException extends Exception {} + +/** * Класс для работы с конфигом */ class QuickFW_Config implements ArrayAccess @@ -53,12 +58,8 @@ class QuickFW_Config implements ArrayAccess try { $data = self::loadFromFiles(self::files(false)); } - catch(Exception $e) - { - if ($e->getMessage() == 'Not Exist Config File') - $data = array(); - else - throw $e; + catch(QuickFWConfigNotFileException $e) { + $data = array(); } return new self($data, APPPATH.'/config'); } @@ -108,11 +109,8 @@ class QuickFW_Config implements ArrayAccess try { $this->data[$offset] = $this->load($offset); } - catch(Exception $e) - { - if ($e->getMessage() == 'Not Exist Config File') - return false; - throw $e; + catch(QuickFWConfigNotFileException $e) { + return false; } } return $this->data[$offset]; @@ -162,7 +160,7 @@ class QuickFW_Config implements ArrayAccess array_replace_recursive($data, $new) : $new; } if ($empty) - throw new Exception('Not Exist Config File', 42); + throw new QuickFWConfigNotFileException(); if (QuickFW_Cacher_SysSlot::is_use('config')) $C->save($data); return $data; commit 38326e7a12bfcc71dcf8f6c205e8f6e6e082f882 Author: Ivan Borzenkov <iva...@li...> Date: Tue Sep 27 12:59:43 2011 +0400 В конфиге баг с несуществующим файлом diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 7d81ec4..96414fe 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -37,7 +37,7 @@ class QuickFW_Config implements ArrayAccess $files[] = $prefix.'.host.'.$_SERVER['HTTP_HOST'].'.php'; return array( 'files' => $files, - 'key' => $prefix + 'key' => $prefix. (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''). (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''), ); @@ -50,7 +50,17 @@ class QuickFW_Config implements ArrayAccess */ static public function main() { - return new self(self::loadFromFiles(self::files(false)), APPPATH.'/config'); + try { + $data = self::loadFromFiles(self::files(false)); + } + catch(Exception $e) + { + if ($e->getMessage() == 'Not Exist Config File') + $data = array(); + else + throw $e; + } + return new self($data, APPPATH.'/config'); } private $data = array(); @@ -94,7 +104,17 @@ class QuickFW_Config implements ArrayAccess public function offsetGet($offset) { if ($this->dir && !isset($this->data[$offset])) - $this->data[$offset] = $this->load($offset); + { + try { + $this->data[$offset] = $this->load($offset); + } + catch(Exception $e) + { + if ($e->getMessage() == 'Not Exist Config File') + return false; + throw $e; + } + } return $this->data[$offset]; } public function offsetExists($offset) { return isset($this->data[$offset]); } @@ -125,19 +145,24 @@ class QuickFW_Config implements ArrayAccess $C = new QuickFW_Cacher_SysSlot('config_'.$info['key']); if ($data = $C->load()) return $data; - } + }; $data = array(); + $empty = true; foreach($info['files'] as $file) { - $new = array(); + $new = false; if (is_file($file)) $new = include($file); + if ($new !== false) + $empty = false; if ($new === 1 && isset($config)) $new = $config; if (!empty($new)) $data = (is_array($data) && is_array($new)) ? array_replace_recursive($data, $new) : $new; } + if ($empty) + throw new Exception('Not Exist Config File', 42); if (QuickFW_Cacher_SysSlot::is_use('config')) $C->save($data); return $data; commit 777d8260cd06f839515d160b2250e90f36a88cc9 Author: Ivan Borzenkov <iva...@li...> Date: Tue Sep 27 12:59:08 2011 +0400 Системное кеширование отключено по умолчанию diff --git a/QFW/QuickFW/Cacher/SysSlot.php b/QFW/QuickFW/Cacher/SysSlot.php index 3fdd2ea..af8cbdf 100644 --- a/QFW/QuickFW/Cacher/SysSlot.php +++ b/QFW/QuickFW/Cacher/SysSlot.php @@ -9,8 +9,8 @@ class QuickFW_Cacher_SysSlot extends Dklab_Cache_Frontend_Slot protected function _getBackend() { - //return Cache::get('Null'); - return Cache::get('Apc'); + return Cache::get('Null'); + //return Cache::get('Apc'); } public static function is_use($where=false) ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Cacher/SysSlot.php | 4 ++-- QFW/QuickFW/Config.php | 33 ++++++++++++++++++++++++++++----- QFW/QuickFW/Plugs.php | 2 +- QFW/Templater/PlainView.php | 2 +- QFW/Templater/Proxy.php | 2 +- QFW/Templater/Smarty.php | 2 +- QFW/Templater/Twig.php | 2 +- 7 files changed, 35 insertions(+), 12 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-08-21 14:14:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via cb04338a5bc79749ab0011875ea495010ad08a5d (commit) via 48660f35da4d5da6146af530ae12470229ea9041 (commit) via c3af39fb82e11ccac55559b48500b89b7127f2af (commit) via 3240b6712d4be1424dd2a2a9f2293a266225d93a (commit) via c50a824dc0c8a0997aa3c4525ea5f265e67f7775 (commit) via 1c6ed73e2eddb51bcf4a0639aba1f464baf35869 (commit) via 9276b26c2cbd4bc00926e3100a8f59f35db5bc5c (commit) via 1503f63d36680521785b13fb43d73820af7711dd (commit) from a24ffd90c66679d87c93eeedbf0b6b77c522e1f2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cb04338a5bc79749ab0011875ea495010ad08a5d Merge: a24ffd9 48660f3 Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 18:13:05 2011 +0400 Merge branch 'syscache' commit 48660f35da4d5da6146af530ae12470229ea9041 Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 18:05:22 2011 +0400 Документация по кешированию diff --git a/doc/asciidoc/cache.txt b/doc/asciidoc/cache.txt index e8d6a0b..e276f6e 100644 --- a/doc/asciidoc/cache.txt +++ b/doc/asciidoc/cache.txt @@ -1,6 +1,11 @@ Кеширование ----------- +Библиотека +~~~~~~~~~~ + +Используется link:http://dklab.ru/lib/Dklab_Cache/[Dklab_Cache] частично порезанная. (Дописать) + Бэкенды кеширующей системы ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -42,7 +47,19 @@ MemCache Memcache - использует стандартный класс Memecache Memcached - использует библиотеку libmemcached -XCache -^^^^^^ +XCache, Apc и eAccelerator +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Общие интерфейсы для хранении в кешах XCache и APC находятся в соответствующих классах, так как сейчас eAccelerator в полудохлом состоянии, то класса для него нету, но пишется он аналогично + +Null +^^^^ + +Пустой кешер, который не кеширует ничего - нужен для того чтобы был общий интерфейс со слотами. + +Системное кеширование +~~~~~~~~~~~~~~~~~~~~~ + +*Используйте этот кешер только на нагруженных проектах и с большой аккуратностью.* -Общий интерфейс для хранении в кеше XCache, аналогично можно написать для APC и eAccelerator, но пока не требовалось +Для кеширование системной информации есть слот +QuickFW_Cacher_SysSlot+ в файле +QFW/QuickFW/Cacher/SysSlot.php+ статическая функция +is_use+ определяет использовать кеширование или нет, а функция +_getBackend+ возвращает кешер. Пока не решен вопрос о привязке сюда конфига в зависимости от хоста (вполне возможно это будет какой-то костыль). Так как кешируются достаточно быстро выполняемые операции, то рекомендуется использовать только очень быстрые кеши, такие как APC или XCache, в противном случае такое кеширование может даже замедлить проект. \ No newline at end of file diff --git a/doc/asciidoc/templates.txt b/doc/asciidoc/templates.txt index e10a0fa..4467ed4 100644 --- a/doc/asciidoc/templates.txt +++ b/doc/asciidoc/templates.txt @@ -41,7 +41,7 @@ include::../../QFW/Templater/Templater.php[] Значения в глобальной области задаются через функцию +assign+, оставленную для совместимости с предыдущим вариантов и статическую функцию +set_global+. -Через __set метод задаются переменные объекта. Если использовать только объект +QFW::$view+ и не создавать дополнительные объекты шаблонизатора, то области видимости глобальных значений и значений объекта совпадают, причем значения объекта перекрывают глобальные. +Через магию +__set+ или метод +set+ задаются переменные объекта. Если использовать только объект +QFW::$view+ и не создавать дополнительные объекты шаблонизатора, то области видимости глобальных значений и значений объекта совпадают, причем значения объекта перекрывают глобальные. Локальные значения при вызове передаются вторым параметром в функцию +fetch+ и влияют только на этот вызов. Их можно использовать в каких-либо циклах. @@ -82,7 +82,7 @@ PlainPHP помомо стандартных функций PHP доступны следующие функции: -esc:: +esc():: Экранировка - сокращение от htmlspecialchars, настроенная на utf-8 block():: commit c3af39fb82e11ccac55559b48500b89b7127f2af Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 15:00:01 2011 +0400 Так все-таки быстрее diff --git a/QFW/Init.php b/QFW/Init.php index b6ccc92..30b8960 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -58,7 +58,9 @@ class QFW self::$db = new DbSimple_Connect(self::$config['database']); //Подключаем шаблонизатор - $class = 'Templater_'.ucfirst(self::$config['templater']['name']); + $tpl = ucfirst(self::$config['templater']['name']); + $class = 'Templater_'.$tpl; + require_once QFWPATH.'/Templater/'.$tpl.'.php'; self::$view = new $class(APPPATH, isset(self::$config['templater']['def_tpl']) ? self::$config['templater']['def_tpl'] : ''); diff --git a/QFW/QuickFW/Cache.php b/QFW/QuickFW/Cache.php index 098f8c0..48605a5 100644 --- a/QFW/QuickFW/Cache.php +++ b/QFW/QuickFW/Cache.php @@ -131,7 +131,7 @@ class Cache $backend = ucfirst($data['module']); } else - $backend = $name; + $backend = ucfirst($name); $cl='Cacher_'.$backend; require_once QFWPATH.'/Cacher/'.$backend.'.php'; $c=new $cl; commit 3240b6712d4be1424dd2a2a9f2293a266225d93a Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 14:42:52 2011 +0400 APC кеш diff --git a/QFW/Cacher/Xcache.php b/QFW/Cacher/Apc.php similarity index 70% copy from QFW/Cacher/Xcache.php copy to QFW/Cacher/Apc.php index 45d0ce3..28130ac 100644 --- a/QFW/Cacher/Xcache.php +++ b/QFW/Cacher/Apc.php @@ -1,15 +1,10 @@ <?php /** - * Xcache variable cache interface - * - * @package RELAX - * @author Petrenko Andrey - * @version 0.1 - * @copyright RosBusinessConsulting + * Apc variable cache interface */ -class Cacher_Xcache implements Zend_Cache_Backend_Interface +class Cacher_Apc implements Zend_Cache_Backend_Interface { public function setDirectives($directives) { @@ -25,7 +20,7 @@ class Cacher_Xcache implements Zend_Cache_Backend_Interface */ public function save($data, $id, $tags = array(), $specificLifetime = 3600) { - return xcache_set($id, $data, $specificLifetime); + return apc_store($id, $data); } /** @@ -36,7 +31,7 @@ class Cacher_Xcache implements Zend_Cache_Backend_Interface */ public function load($id, $doNotTest = false) { - return xcache_get($id); + return apc_fetch($id); } /** @@ -47,7 +42,7 @@ class Cacher_Xcache implements Zend_Cache_Backend_Interface */ public function test($id) { - return xcache_isset($id); + return apc_exists($id); } /** @@ -58,14 +53,12 @@ class Cacher_Xcache implements Zend_Cache_Backend_Interface */ public function remove($id) { - return xcache_unset($id); + return apc_delete($id); } public function clean($mode = CACHE_CLR_ALL, $tags = array()) { - + apc_clear_cache('user'); } } - -?> \ No newline at end of file diff --git a/QFW/Cacher/Xcache.php b/QFW/Cacher/Xcache.php index 45d0ce3..8b878dc 100644 --- a/QFW/Cacher/Xcache.php +++ b/QFW/Cacher/Xcache.php @@ -67,5 +67,3 @@ class Cacher_Xcache implements Zend_Cache_Backend_Interface } } - -?> \ No newline at end of file diff --git a/QFW/QuickFW/Cacher/SysSlot.php b/QFW/QuickFW/Cacher/SysSlot.php index d8329fe..3fdd2ea 100644 --- a/QFW/QuickFW/Cacher/SysSlot.php +++ b/QFW/QuickFW/Cacher/SysSlot.php @@ -10,7 +10,7 @@ class QuickFW_Cacher_SysSlot extends Dklab_Cache_Frontend_Slot protected function _getBackend() { //return Cache::get('Null'); - return Cache::get('File'); + return Cache::get('Apc'); } public static function is_use($where=false) @@ -25,4 +25,4 @@ class QuickFW_Cacher_SysSlot extends Dklab_Cache_Frontend_Slot return false; return false;*/ } -} \ No newline at end of file +} commit c50a824dc0c8a0997aa3c4525ea5f265e67f7775 Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 03:39:19 2011 +0400 Правки системного кеша diff --git a/QFW/QuickFW/Cacher/SysSlot.php b/QFW/QuickFW/Cacher/SysSlot.php index c17d592..d8329fe 100644 --- a/QFW/QuickFW/Cacher/SysSlot.php +++ b/QFW/QuickFW/Cacher/SysSlot.php @@ -15,11 +15,14 @@ class QuickFW_Cacher_SysSlot extends Dklab_Cache_Frontend_Slot public static function is_use($where=false) { + // используются 'MCA', 'autoload', 'config' return false; - if ($where == 'MCA') + /*if ($where == 'MCA') return false; if ($where == 'autoload') return false; - return false; + if ($where == 'config') + return false; + return false;*/ } } \ No newline at end of file diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 7cec713..7d81ec4 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -23,8 +23,10 @@ class QuickFW_Config implements ArrayAccess if (isset($_SERVER['HTTP_HOST'])) $files[] = APPPATH.'/host.'.$_SERVER['HTTP_HOST'].'.php'; return array( - 'prefix' => $prefix, 'files' => $files, + 'key' => $prefix. + (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''). + (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''), ); } $files = array(); @@ -34,8 +36,10 @@ class QuickFW_Config implements ArrayAccess if (isset($_SERVER['HTTP_HOST'])) $files[] = $prefix.'.host.'.$_SERVER['HTTP_HOST'].'.php'; return array( - 'prefix' => $prefix, 'files' => $files, + 'key' => $prefix + (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''). + (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''), ); } @@ -116,9 +120,9 @@ class QuickFW_Config implements ArrayAccess */ static private function loadFromFiles($info) { - if (QuickFW_Cacher_SysSlot::is_use()) + if (QuickFW_Cacher_SysSlot::is_use('config')) { - $C = new QuickFW_Cacher_SysSlot('config_'.$info['prefix']); + $C = new QuickFW_Cacher_SysSlot('config_'.$info['key']); if ($data = $C->load()) return $data; } @@ -134,7 +138,7 @@ class QuickFW_Config implements ArrayAccess $data = (is_array($data) && is_array($new)) ? array_replace_recursive($data, $new) : $new; } - if (QuickFW_Cacher_SysSlot::is_use()) + if (QuickFW_Cacher_SysSlot::is_use('config')) $C->save($data); return $data; } commit 1c6ed73e2eddb51bcf4a0639aba1f464baf35869 Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 03:29:14 2011 +0400 Слот системного кеширования и пустой кеш diff --git a/QFW/Cacher/Null.php b/QFW/Cacher/Null.php new file mode 100644 index 0000000..d617649 --- /dev/null +++ b/QFW/Cacher/Null.php @@ -0,0 +1,35 @@ +<?php + +/** + * Null cache interface + */ +class Cacher_Null implements Zend_Cache_Backend_Interface +{ + public function setDirectives($directives) + { + } + + public function save($data, $id, $tags = array(), $specificLifetime = 3600) + { + } + + public function load($id, $doNotTest = false) + { + return false; + } + + public function test($id) + { + return false; + } + + public function remove($id) + { + return true; + } + + public function clean($mode = CACHE_CLR_ALL, $tags = array()) + { + } + +} diff --git a/QFW/QuickFW/Autoload.php b/QFW/QuickFW/Autoload.php index f149012..212ae20 100644 --- a/QFW/QuickFW/Autoload.php +++ b/QFW/QuickFW/Autoload.php @@ -15,9 +15,11 @@ class Autoload { spl_autoload_register(array(__CLASS__, 'Bind')); spl_autoload_register(array(__CLASS__, 'Main')); - spl_autoload_register(array(__CLASS__, 'Dirs')); + spl_autoload_register(array(__CLASS__, 'Cached')); + //кешированный автолоад spl_autoload_register(array(__CLASS__, 'Controller')); spl_autoload_register(array(__CLASS__, 'SlotsAndTags')); + spl_autoload_register(array(__CLASS__, 'Dirs')); } /** @@ -33,6 +35,24 @@ class Autoload elseif (is_callable($function)) spl_autoload_register($function); } + + /** + * Загрузка результатов разбора из кеша + * + * @param string $class искомый класс + */ + static public function Cached($class) + { + if (!QuickFW_Cacher_SysSlot::is_use('autoload')) + return false; + $C = new QuickFW_Cacher_SysSlot(self::k($class)); + if ($data = $C->load()) + { + require $data; + return true; + } + return false; + } /** * Автолоад контроллеров (при наследовании) @@ -43,21 +63,19 @@ class Autoload { if (mb_strpos($class, 'Controller') === false) return false; - $class = strtr($class,'_','/'); + $c = strtr($class,'_','/'); //пространство имен - if ($pos = mb_strpos($class, '\\')) + if ($pos = mb_strpos($c, '\\')) { - $ns = strtolower(mb_substr($class, 0, $pos)); - $class = ucfirst(mb_substr($class, $pos+1)); + $ns = strtolower(mb_substr($c, 0, $pos)); + $c = ucfirst(mb_substr($c, $pos+1)); $Q = $ns.'\QFW'; //Проверка на саброутинг $dir = !class_exists($Q) ? $ns : QFW::$router->cModule.'/'.$ns.'/'.$Q::$router->cModule; } else $dir = QFW::$router->cModule; - $file = $dir.'/'.QuickFW_Router::CONTROLLERS_DIR.'/'.$class; - require APPPATH.'/'.$file.'.php'; - return true; + return self::incl($class, APPPATH.'/'.$dir.'/'.QuickFW_Router::CONTROLLERS_DIR.'/'.$c.'.php'); } /** @@ -94,6 +112,7 @@ class Autoload 'Hlp' => QFWPATH.'/QuickFW/Helpers.php', 'Dklab_Cache_Frontend_Slot' => QFWPATH.'/QuickFW/Cacher/Slot.php', 'Dklab_Cache_Frontend_Tag' => QFWPATH.'/QuickFW/Cacher/Tag.php', + 'QuickFW_Cacher_SysSlot' => QFWPATH.'/QuickFW/Cacher/SysSlot.php', ); if (empty(self::$classes[$class])) return false; @@ -135,15 +154,28 @@ class Autoload LIBPATH, MODPATH, ); - $class = str_replace('_', '/', $class); + $c = str_replace('_', '/', $class); foreach ($list as $dir) - if (is_file($dir.'/'.$class.'.php')) - { - require $dir.'/'.$class.'.php'; - return true; - } + if (is_file($dir.'/'.$c.'.php')) + return self::incl($class, $dir.'/'.$c.'.php'); return false; } + + static private function incl($class, $file) + { + if (QuickFW_Cacher_SysSlot::is_use('autoload')) + { + $C = new QuickFW_Cacher_SysSlot(self::k($class)); + $C->save($file); + } + require $file; + return true; + } + + static private function k($class) + { + return 'autoload_'.$class.(QFW::$router ? QFW::$router->cModule : ''); + } } diff --git a/QFW/QuickFW/Cacher/SysSlot.php b/QFW/QuickFW/Cacher/SysSlot.php new file mode 100644 index 0000000..c17d592 --- /dev/null +++ b/QFW/QuickFW/Cacher/SysSlot.php @@ -0,0 +1,25 @@ +<?php + +class QuickFW_Cacher_SysSlot extends Dklab_Cache_Frontend_Slot +{ + public function __construct($data, $time=false) + { + parent::__construct('QFW_'.$data, $time); + } + + protected function _getBackend() + { + //return Cache::get('Null'); + return Cache::get('File'); + } + + public static function is_use($where=false) + { + return false; + if ($where == 'MCA') + return false; + if ($where == 'autoload') + return false; + return false; + } +} \ No newline at end of file diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index df9741c..7cec713 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -116,10 +116,12 @@ class QuickFW_Config implements ArrayAccess */ static private function loadFromFiles($info) { - $C=Cache::get('File'); - $key = 'config_'.$info['prefix']; - if ($data = $C->load($key)) - return $data; + if (QuickFW_Cacher_SysSlot::is_use()) + { + $C = new QuickFW_Cacher_SysSlot('config_'.$info['prefix']); + if ($data = $C->load()) + return $data; + } $data = array(); foreach($info['files'] as $file) { @@ -132,7 +134,8 @@ class QuickFW_Config implements ArrayAccess $data = (is_array($data) && is_array($new)) ? array_replace_recursive($data, $new) : $new; } - $C->save($data, $key); + if (QuickFW_Cacher_SysSlot::is_use()) + $C->save($data); return $data; } diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index 8b4a037..d258505 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -453,13 +453,12 @@ class QuickFW_Router { while (isset($data[0]) AND $data[0] === '') array_shift($data); - if (!empty(QFW::$config['cache']['MCA'])) + if (QuickFW_Cacher_SysSlot::is_use('MCA')) { - $Cache = Cache::get('MCA'); $key = 'MCA_'.$this->sub.crc32(serialize($data)).$type. ($type=='Block' ? $this->curModule : $this->defM); - $cached = $Cache->load($key); - if ($cached) + $C = new QuickFW_Cacher_SysSlot($key); + if ($cached = $C->load()) { $MCA = $cached['MCA']; //устанавливаем переменные роутера @@ -595,12 +594,16 @@ class QuickFW_Router } $MCA['Path']=$MCA['Module'].'/'.$MCA['Controller'].'/'.$aname; - if (!empty(QFW::$config['cache']['MCA'])) - $Cache->save(array( - 'MCA' => $MCA, + if (QuickFW_Cacher_SysSlot::is_use('MCA')) + { + $MCA_Cache = $MCA; + unset($MCA_Cache['Class']); + $C->save(array( + 'MCA' => $MCA_Cache, 'defA' => $this->classes[$class_key]['defA'], 'a' => $this->classes[$class_key]['a'], - ), $key, array()); + )); + } return $MCA; } commit 9276b26c2cbd4bc00926e3100a8f59f35db5bc5c Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 03:27:31 2011 +0400 Автолоад у шаблонизаторов diff --git a/QFW/Init.php b/QFW/Init.php index 4783392..b6ccc92 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -43,24 +43,12 @@ class QFW private function __construct() {} /** - * Инициализация конфига - * - * <br>возвращает конфигурацию, специфичную для текущего хоста - * - * @return array конфигурация на этом хосте - */ - static public function config() - { - return QuickFW_Config::main(); - } - - /** * Инициализация основных объектов QFW * */ static public function Init() { - self::$config = self::config(); + self::$config = QuickFW_Config::main(); //выставляем заголовок с нужной кодировкой if (!empty(self::$config['host']['encoding'])) @@ -70,9 +58,7 @@ class QFW self::$db = new DbSimple_Connect(self::$config['database']); //Подключаем шаблонизатор - $templ = ucfirst(self::$config['templater']['name']); - $class = 'Templater_'.$templ; - require_once QFWPATH.'/Templater/'.$templ.'.php'; + $class = 'Templater_'.ucfirst(self::$config['templater']['name']); self::$view = new $class(APPPATH, isset(self::$config['templater']['def_tpl']) ? self::$config['templater']['def_tpl'] : ''); @@ -197,5 +183,3 @@ class QFW } QFW::Init(); - -?> diff --git a/QFW/QuickFW/Autoload.php b/QFW/QuickFW/Autoload.php index 165ab67..f149012 100644 --- a/QFW/QuickFW/Autoload.php +++ b/QFW/QuickFW/Autoload.php @@ -69,11 +69,12 @@ class Autoload */ static public function Main($class) { - if (mb_strpos($class, 'QuickFW') === false) - return false; - $class = strtr($class,'_','/'); - require QFWPATH.'/'.$class.'.php'; - return true; + if (mb_strpos($class, 'QuickFW_') === 0 || mb_strpos($class, 'Templater_') === 0 || mb_strpos($class, 'Cacher_') === 0) + { + require QFWPATH.'/'.strtr($class,'_','/').'.php'; + return true; + } + return false; } /** diff --git a/QFW/QuickFW/Cache.php b/QFW/QuickFW/Cache.php index b68c372..098f8c0 100644 --- a/QFW/QuickFW/Cache.php +++ b/QFW/QuickFW/Cache.php @@ -169,11 +169,13 @@ class Cache /** * Фабрика слотов * + * @deprecated Используйте autoload * @param string $name имя слота * @return Dklab_Cache_Frontend_Slot новый слот */ public static function slot($name) { + trigger_error('Используйте autoload', E_USER_NOTICE); require_once QFWPATH.'/QuickFW/Cacher/Slot.php'; require_once COMPATH.'/slots/'.$name.'.php'; $args = func_get_args(); @@ -185,11 +187,13 @@ class Cache /** * Фабрика тегов * + * @deprecated Используйте autoload * @param string $name имя тега * @return Dklab_Cache_Frontend_Tag новый тег */ public static function tag($name) { + trigger_error('Используйте autoload', E_USER_NOTICE); require_once QFWPATH.'/QuickFW/Cacher/Tag.php'; require_once COMPATH.'/tags/'.$name.'.php'; $args = func_get_args(); @@ -227,5 +231,3 @@ function thru($Cacher, $obj, $id, $tags=array(), $lifeTime=null) { return new Cache_Thru($Cacher, $obj, $id, $tags, $lifeTime); } - -?> commit 1503f63d36680521785b13fb43d73820af7711dd Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 01:30:16 2011 +0400 Базовое кеширование конфига diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index c1af2a7..df9741c 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -22,7 +22,10 @@ class QuickFW_Config implements ArrayAccess $files[] = APPPATH.'/serv.'.$_SERVER['SERVER_NAME'].'.php'; if (isset($_SERVER['HTTP_HOST'])) $files[] = APPPATH.'/host.'.$_SERVER['HTTP_HOST'].'.php'; - return $files; + return array( + 'prefix' => $prefix, + 'files' => $files, + ); } $files = array(); $files[] = $prefix.'.php'; @@ -30,7 +33,10 @@ class QuickFW_Config implements ArrayAccess $files[] = $prefix.'.serv.'.$_SERVER['SERVER_NAME'].'.php'; if (isset($_SERVER['HTTP_HOST'])) $files[] = $prefix.'.host.'.$_SERVER['HTTP_HOST'].'.php'; - return $files; + return array( + 'prefix' => $prefix, + 'files' => $files, + ); } /** @@ -108,10 +114,14 @@ class QuickFW_Config implements ArrayAccess * @param array $files файлы * @return array|mixed|QuickFW_Config вложенный массив */ - static private function loadFromFiles($files) + static private function loadFromFiles($info) { + $C=Cache::get('File'); + $key = 'config_'.$info['prefix']; + if ($data = $C->load($key)) + return $data; $data = array(); - foreach($files as $file) + foreach($info['files'] as $file) { $new = array(); if (is_file($file)) @@ -122,6 +132,7 @@ class QuickFW_Config implements ArrayAccess $data = (is_array($data) && is_array($new)) ? array_replace_recursive($data, $new) : $new; } + $C->save($data, $key); return $data; } ----------------------------------------------------------------------- Summary of changes: QFW/Cacher/{Xcache.php => Apc.php} | 21 ++++------- QFW/Cacher/Null.php | 35 ++++++++++++++++++ QFW/Cacher/Xcache.php | 2 - QFW/Init.php | 22 ++--------- QFW/QuickFW/Autoload.php | 71 ++++++++++++++++++++++++++---------- QFW/QuickFW/Cache.php | 8 +++-- QFW/QuickFW/Cacher/SysSlot.php | 28 ++++++++++++++ QFW/QuickFW/Config.php | 26 +++++++++++-- QFW/QuickFW/Router.php | 19 ++++++---- doc/asciidoc/cache.txt | 23 ++++++++++-- doc/asciidoc/templates.txt | 4 +- 11 files changed, 186 insertions(+), 73 deletions(-) copy QFW/Cacher/{Xcache.php => Apc.php} (70%) create mode 100644 QFW/Cacher/Null.php create mode 100644 QFW/QuickFW/Cacher/SysSlot.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-08-20 21:33:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via a24ffd90c66679d87c93eeedbf0b6b77c522e1f2 (commit) via eae7215e0e312c3d026ad3fd30b4d8d162240a18 (commit) from cecb9148cad4fbf19d4f1ae7ac4764852fabf495 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a24ffd90c66679d87c93eeedbf0b6b77c522e1f2 Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 01:29:28 2011 +0400 Фикс calling diff --git a/QFW/Templater/PlainView.php b/QFW/Templater/PlainView.php index a96ee90..c2650d2 100644 --- a/QFW/Templater/PlainView.php +++ b/QFW/Templater/PlainView.php @@ -41,7 +41,7 @@ class PlainView_Delegate * * @return bool можно вызывать */ - public function callable() + public function calling() { return $this->m !== false; } @@ -102,7 +102,7 @@ class Templater_PlainView extends Templater $data = ob_get_clean(); $caller = array_pop($this->callers); $caller instanceof PlainView_Delegate; - echo $caller->callable() ? $caller->run($data) : $data; + echo $caller->calling() ? $caller->run($data) : $data; } public function extend($tpl) commit eae7215e0e312c3d026ad3fd30b4d8d162240a18 Author: Ivan Borzenkov <iva...@li...> Date: Sun Aug 21 01:28:13 2011 +0400 Обновление dklabCache diff --git a/QFW/QuickFW/Cacher/Namespace.php b/QFW/QuickFW/Cacher/Namespace.php index a9322d1..a774f38 100644 --- a/QFW/QuickFW/Cacher/Namespace.php +++ b/QFW/QuickFW/Cacher/Namespace.php @@ -19,19 +19,28 @@ class Dklab_Cache_Backend_NamespaceWrapper implements Zend_Cache_Backend_Interfa return $this->_backend->setDirectives($directives); } - public function load($id, $doNotTest = false) - { - $id = is_array($id) ? array_map(array($this, '_mangleId'), $id) : $this->_mangleId($id); - $data = $this->_backend->load($id, $doNotTest); - - if (!is_array($id) || !is_array($data)) - return $data; - $d = array(); - $l = strlen($this->_namespace) + 1; - foreach($data as $k=>$v) - $d[substr($k, $l)] = $v; - return $d; + public function load($id, $doNotTestCacheValidity = false) + { + return $this->_backend->load($this->_mangleId($id), $doNotTestCacheValidity); } + + public function multiLoad($ids, $doNotTestCacheValidity = false) + { + if (!is_array($ids)) { + Zend_Cache::throwException('multiLoad() expects parameter 1 to be array, ' . gettype($ids) . ' given'); + } + if (method_exists($this->_backend, 'multiLoad')) { + return $this->_backend->multiLoad($this->_mangleIds($ids), $doNotTestCacheValidity); + } + // No multiLoad() method avalilable, so we have to emulate it to keep + // the interface consistent. + $result = array(); + foreach ($ids as $i => $id) { + $result[$id] = $this->load($id, $doNotTestCacheValidity); + } + return $result; + } + public function test($id) { return $this->_backend->test($this->_mangleId($id)); diff --git a/QFW/QuickFW/Cacher/Slot.php b/QFW/QuickFW/Cacher/Slot.php index c8beba0..faa83e2 100644 --- a/QFW/QuickFW/Cacher/Slot.php +++ b/QFW/QuickFW/Cacher/Slot.php @@ -110,6 +110,9 @@ abstract class Dklab_Cache_Frontend_Slot */ public function addTag(Dklab_Cache_Frontend_Tag $tag) { + if ($tag->getBackend() !== $this->_getBackend()) { + Zend_Cache::throwException("Backends for tag " . get_class($tag) . " and slot " . get_class($this) . " must be same"); + } $this->_tags[] = $tag; } diff --git a/QFW/QuickFW/Cacher/TagEmu.php b/QFW/QuickFW/Cacher/TagEmu.php index 3aaa189..1542754 100644 --- a/QFW/QuickFW/Cacher/TagEmu.php +++ b/QFW/QuickFW/Cacher/TagEmu.php @@ -1,17 +1,39 @@ <?php /** - * Dklab_Cache - сохраняем начальные копирайты, но код переписан :) + * Dklab_Cache_Backend_TagEmuWrapper: tag wrapper for any Zend_Cache backend. + * + * Implements tags. Tags are emulated via keys: unfortunately this + * increases the data read cost (the more tags are assigned to a key, + * the more read cost becomes). + * + * $Id$ */ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface { - const VERSION = "01"; + const VERSION = "1.50"; + private $_backend = null; - public function __construct(Zend_Cache_Backend_Interface $backend) {$this->_backend = $backend;} - public function setDirectives($directives) {return $this->_backend->setDirectives($directives);} - public function load($id, $doNotTest = false) {return $this->_loadOrTest($id, $doNotTest, false);} + public function __construct(Zend_Cache_Backend_Interface $backend) + { + $this->_backend = $backend; + } + + + public function setDirectives($directives) + { + return $this->_backend->setDirectives($directives); + } + + + public function load($id, $doNotTestCacheValidity = false) + { + return $this->_loadOrTest($id, $doNotTestCacheValidity, false); + } + + public function save($data, $id, $tags = array(), $specificLifetime = false) { // Save/update tags as usual infinite keys with value of tag version. @@ -33,10 +55,11 @@ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface $serialized = serialize($combined); return $this->_backend->save($serialized, $id, array(), $specificLifetime); } + - public function clean($mode = CACHE_CLR_ALL, $tags = array()) + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { - if ($mode == CACHE_CLR_TAG) { + if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_TAG) { if (is_array($tags)) { foreach ($tags as $tag) { $this->_backend->remove($this->_mangleTag($tag)); @@ -46,53 +69,100 @@ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface return $this->_backend->clean($mode, $tags); } } + + + public function test($id) + { + return $this->_loadOrTest($id, false, true); + } + + + public function remove($id) + { + return $this->_backend->remove($id); + } - public function test($id) {return $this->_loadOrTest($id, false, true);} - public function remove($id) {return $this->_backend->remove($id);} /** * Mangles the name to deny intersection of tag keys & data keys. * Mangled tag names are NOT saved in memcache $combined[0] value, * mangling is always performed on-demand (to same some space). - * + * * @param string $tag Tag name to mangle. * @return string Mangled tag name. */ - private function _mangleTag($tag) {return __CLASS__ . "_" . self::VERSION . "_" . $tag;} + private function _mangleTag($tag) + { + return __CLASS__ . "_" . self::VERSION . "_" . $tag; + } + + + /** + * The same as _mangleTag(), but mangles a list of tags. + * + * @see self::_mangleTag + * @param array $tags Tags to mangle. + * @return array List of mangled tags. + */ + private function _mangleTags($tags) + { + foreach ($tags as $i => $tag) { + $tags[$i] = $this->_mangleTag($tag); + } + return $tags; + } + /** * Common method called from load() and test(). - * + * * @param string $id * @param bool $doNotTestCacheValidity * @param bool $returnTrueIfValid If true, returns not the value contained * in the slot, but "true". * @return mixed */ - private function _loadOrTest($id, $doNotTest = false, $returnTrueIfValid = false) + private function _loadOrTest($id, $doNotTestCacheValidity = false, $returnTrueIfValid = false) { // Data is saved in form of: array(tagsWithVersionArray, anyData). - $serialized = $this->_backend->load($id, $doNotTest); + $serialized = $this->_backend->load($id, $doNotTestCacheValidity); if ($serialized === false) { return false; } $combined = unserialize($serialized); if (!is_array($combined)) { return false; - } + } // Test if all tags has the same version as when the slot was created // (i.e. still not removed and then recreated). - if (is_array($combined[0])) { - foreach ($combined[0] as $tag => $savedTagVersion) { - $actualTagVersion = $this->_backend->load($this->_mangleTag($tag)); - if ($actualTagVersion !== $savedTagVersion) { - return false; + if (is_array($combined[0]) && $combined[0]) { + if (method_exists($this->_backend, 'multiLoad')) { + // If we have multiLoad(), optimize queries into one. + $allMangledTagValues = $this->_backend->multiLoad($this->_mangleTags(array_keys($combined[0]))); + foreach ($combined[0] as $tag => $savedTagVersion) { + $actualTagVersion = @$allMangledTagValues[$this->_mangleTag($tag)]; + if ($actualTagVersion !== $savedTagVersion) { + return false; + } + } + } else { + // Check all tags versions AND STOP IF WE FOUND AN INCONSISTENT ONE. + // Note that this optimization works fine only if $this->_backend is + // references to Dklab_Cache_Backend, but NOT via Dklab_Cache_Backend + // wrappers, because such wrappers emulate multiLoad() via multiple + // load() calls. + foreach ($combined[0] as $tag => $savedTagVersion) { + $actualTagVersion = $this->_backend->load($this->_mangleTag($tag)); + if ($actualTagVersion !== $savedTagVersion) { + return false; + } } } } return $returnTrueIfValid? true : $combined[1]; } + /** * Generates a new unique identifier for tag version. * @@ -105,5 +175,3 @@ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface return md5(microtime() . getmypid() . uniqid('') . $counter); } } - -?> \ No newline at end of file ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Cacher/Namespace.php | 33 +++++++---- QFW/QuickFW/Cacher/Slot.php | 3 + QFW/QuickFW/Cacher/TagEmu.php | 112 ++++++++++++++++++++++++++++++-------- QFW/Templater/PlainView.php | 4 +- 4 files changed, 116 insertions(+), 36 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-08-09 08:36:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via cecb9148cad4fbf19d4f1ae7ac4764852fabf495 (commit) from 6dfe8794c21d2befbef4f56c99800c4a61f3a9fb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cecb9148cad4fbf19d4f1ae7ac4764852fabf495 Author: Ivan Borzenkov <iva...@li...> Date: Tue Aug 9 12:36:14 2011 +0400 Небольшой фикс view diff --git a/lib/View.php b/lib/View.php index 6264fc9..46fe374 100644 --- a/lib/View.php +++ b/lib/View.php @@ -74,6 +74,14 @@ class View extends Templater } /** + * Синоним fetch + */ + public function render($tmpl=false, $vars=array()) + { + return $this->fetch($tmpl, $vars); + } + + /** * Magically converts view object to string. * * @return string ----------------------------------------------------------------------- Summary of changes: lib/View.php | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-07-24 10:07:46
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 6dfe8794c21d2befbef4f56c99800c4a61f3a9fb (commit) via 7244fb58d5cf1c1acc4772d8c03d9c3f3feb6e87 (commit) via eeb3e008bd0de770576593a80908b559ceddc558 (commit) via df4f34df1412cc6060b14d08262069ca6d426e59 (commit) via 6a7066be3d91ed12b4e9fd51bbaf8b3cfc153d83 (commit) via 0769b685b8d16c2b67bdc8cf4d1d0a1e36e8b39c (commit) from a64d640d1933b3d598afff24fac0c2a8e8f85016 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6dfe8794c21d2befbef4f56c99800c4a61f3a9fb Merge: a64d640 7244fb5 Author: Ivan Borzenkov <iva...@li...> Date: Sun Jul 24 14:07:04 2011 +0400 Merge branch 'View' commit 7244fb58d5cf1c1acc4772d8c03d9c3f3feb6e87 Author: Ivan Borzenkov <iva...@li...> Date: Sun Jul 24 13:37:49 2011 +0400 Документация по View diff --git a/doc/asciidoc/templates.txt b/doc/asciidoc/templates.txt index 23e354c..e10a0fa 100644 --- a/doc/asciidoc/templates.txt +++ b/doc/asciidoc/templates.txt @@ -24,9 +24,26 @@ $config['templater'] = array( include::../../QFW/Templater/Templater.php[] --------------------------------------------- -Основные функции это +assign+ и +fetch+, причем вторую обязательно нужно переопредетить - она возвращает обработанный шаблон. +Класс View +~~~~~~~~~~ -На данный момент есть обертки для шаблонизаторов *Smarty* и *Twig* Проксирующий шаблонизатор и PlainPHP. +Объект класса +View+ представляет собой переменную, хранящую в себе имя шаблона и все переменные. +Для объекта переопределено преобразование в строку, конструктор и фабрика. + +Общий функционал +~~~~~~~~~~~~~~~~ + +Областей видимости переменных шаблона всего три: + +. Глобальная область видимости +. Область видимости только этого объекта +. Область видимости только этого вызова + +Значения в глобальной области задаются через функцию +assign+, оставленную для совместимости с предыдущим вариантов и статическую функцию +set_global+. + +Через __set метод задаются переменные объекта. Если использовать только объект +QFW::$view+ и не создавать дополнительные объекты шаблонизатора, то области видимости глобальных значений и значений объекта совпадают, причем значения объекта перекрывают глобальные. + +Локальные значения при вызове передаются вторым параметром в функцию +fetch+ и влияют только на этот вызов. Их можно использовать в каких-либо циклах. Smarty, Twig и остальные ~~~~~~~~~~~~~~~~~~~~~~~~ commit eeb3e008bd0de770576593a80908b559ceddc558 Author: Ivan Borzenkov <iva...@li...> Date: Thu Jul 21 22:37:18 2011 +0400 Расширение php в список прокси diff --git a/application/default.php b/application/default.php index 63c8d19..c222309 100644 --- a/application/default.php +++ b/application/default.php @@ -99,6 +99,7 @@ $config['templater']= array( 'exts' => array( 'tpl' => 'Smarty', 'html' => 'PlainView', + 'php' => 'PlainView', ), ); commit df4f34df1412cc6060b14d08262069ca6d426e59 Author: Ivan Borzenkov <iva...@li...> Date: Thu Jul 21 22:20:56 2011 +0400 Перенесены функции в общий класс diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php index 34024fd..17bc247 100644 --- a/QFW/Templater/Templater.php +++ b/QFW/Templater/Templater.php @@ -27,9 +27,23 @@ abstract class Templater $this->mainTemplate = $mainTpl; } - public function __get($name) + /** + * Возвращает значения переменных в шаблоне + * Используется для изменения массивов + * + * @param string $var имя переменной + * @return mixed значение + */ + public function &__get($key) { - return $this->getTemplateVars($name); + if (isset($this->_vars[$key])) + return $this->_vars[$key]; + + if (isset(static::$global_vars[$key])) + return static::$global_vars[$key]; + + $this->_vars[$key] = false; + return $this->_vars[$key]; } public function __set($name, $value) @@ -37,6 +51,11 @@ abstract class Templater $this->_vars[$name] = $value; } + public function __isset($name) + { + return isset($this->_vars[$name]) || isset(static::$global_vars[$name]); + } + /** * Sets a view variable. * @@ -104,12 +123,18 @@ abstract class Templater * @param string|array имя переменной или массив имен */ public function delete($spec) - { //TODO: уделание из всех + { if (is_array($spec)) foreach ($spec as $item) + { unset($this->_vars[$item]); + unset(static::$global_vars[$item]); + } else + { unset($this->_vars[$spec]); + unset(static::$global_vars[$spec]); + } } /** @@ -117,11 +142,15 @@ abstract class Templater * * @param string name of variable * @param mixed variable to assign by reference + * @param bool variable bind to global data * @return object */ - public function bind($name, & $var) + public function bind($name, & $var, $global = false) { - $this->_vars[$name] =& $var; + if ($global) + static::$global_vars[$name] =& $var; + else + $this->_vars[$name] =& $var; return $this; } @@ -141,7 +170,7 @@ abstract class Templater * @return mixed значение */ public function getTemplateVars($var = null) - { //TODO: получение из всех + { if ($var === null) return $this->_vars; elseif (isset($this->_vars[$var])) diff --git a/lib/View.php b/lib/View.php index 495b064..6264fc9 100644 --- a/lib/View.php +++ b/lib/View.php @@ -1,23 +1,18 @@ <?php /** - * Loads and displays Kohana view files. Can also handle output of some binary - * files, such as image, Javascript, and CSS files. - * - * $Id: View.php 4072 2009-03-13 17:20:38Z jheathco $ + * Класс шаблона, представляющего собой переменную, + * основан на шаблоне из Kohana * * @author Kohana Team * @copyright (c) 2007-2008 Kohana Team - * @license http://kohanaphp.com/license.html + * @author Ivan Borzenkov <iva...@li...> */ -class View extends Templater { +class View extends Templater +{ // The view file name and type protected $filename = FALSE; - // View variable storage - protected $kohana_local_data = array(); - protected static $kohana_global_data = array(); - /** * Creates a new View using the given parameters. * @@ -43,36 +38,17 @@ class View extends Templater { public function __construct($name = NULL, $data = NULL) { if (is_string($name) AND $name !== '') - { - // Set the filename $this->set_filename($name); - } - - if (is_array($data) AND ! empty($data)) - { - // Preload data using array_merge, to allow user extensions + if (is_array($data) AND !empty($data)) $this->_vars = array_merge($this->_vars, $data); - } $this->_tmplPath = QFW::$view->getScriptPath(); } - - /** - * Magic method access to test for view property - * - * @param string View property to test for - * @return boolean - */ - public function __isset($key = NULL) - { - return $this->is_set($key); - } /** * Sets the view filename. * * @chainable * @param string view filename - * @param string view file type * @return object */ public function set_filename($name) @@ -83,86 +59,6 @@ class View extends Templater { } /** - * Sets a view variable. - * - * @param string|array name of variable or an array of variables - * @param mixed value when using a named variable - * @return object - */ - public function set($name, $value = NULL) - { - if (is_array($name)) - { - foreach ($name as $key => $value) - { - $this->__set($key, $value); - } - } - else - { - $this->__set($name, $value); - } - - return $this; - } - - /** - * Checks for a property existence in the view locally or globally. Unlike the built in __isset(), - * this method can take an array of properties to test simultaneously. - * - * @param string $key property name to test for - * @param array $key array of property names to test for - * @return boolean property test result - * @return array associative array of keys and boolean test result - */ - public function is_set( $key = FALSE ) - { //TODO: посмотреть - // Setup result; - $result = FALSE; - - // If key is an array - if (is_array($key)) - { - // Set the result to an array - $result = array(); - - // Foreach key - foreach ($key as $property) - { - // Set the result to an associative array - $result[$property] = (array_key_exists($property, $this->kohana_local_data) OR array_key_exists($property, View::$kohana_global_data)) ? TRUE : FALSE; - } - } - else - { - // Otherwise just check one property - $result = (array_key_exists($key, $this->kohana_local_data) OR array_key_exists($key, View::$kohana_global_data)) ? TRUE : FALSE; - } - - // Return the result - return $result; - } - - /** - * Magically gets a view variable. - * - * @param string variable key - * @return mixed variable value if the key is found - * @return void if the key is not found - */ - public function &__get($key) - { //TODO: посмотреть - if (isset($this->kohana_local_data[$key])) - return $this->kohana_local_data[$key]; - - if (isset(View::$kohana_global_data[$key])) - return View::$kohana_global_data[$key]; - - if (isset($this->$key)) - return $this->$key; - } - - /** * Renders a view. * * @param boolean set to TRUE to echo the output instead of returning it commit 6a7066be3d91ed12b4e9fd51bbaf8b3cfc153d83 Author: Ivan Borzenkov <iva...@li...> Date: Thu Jul 21 21:48:04 2011 +0400 Правка View и добавление трех уровней переменных diff --git a/QFW/Templater/PlainView.php b/QFW/Templater/PlainView.php index 037780d..a96ee90 100644 --- a/QFW/Templater/PlainView.php +++ b/QFW/Templater/PlainView.php @@ -71,6 +71,7 @@ class Templater_PlainView extends Templater public function fetch($tmpl, $vars=array()) { + extract(static::$global_vars, EXTR_OVERWRITE); extract($this->_vars, EXTR_OVERWRITE); extract($vars, EXTR_OVERWRITE); $P=&$this->P; diff --git a/QFW/Templater/Proxy.php b/QFW/Templater/Proxy.php index 1e8a641..b92712e 100644 --- a/QFW/Templater/Proxy.php +++ b/QFW/Templater/Proxy.php @@ -21,18 +21,8 @@ class Templater_Proxy extends Templater } /** - * Assign variables to the template - * - * Allows setting a specific key to the specified value, OR passing an array - * of key => value pairs to set en masse. - * - * @see __set() - * @param string|array $spec The assignment strategy to use (key or array of key - * => value pairs) - * @param mixed $value (Optional) If assigning a named variable, use this - * as the value. - * @return void - */ + * добавляем unsyncronize + */ public function assign($spec, $value = null) { $this->unsyncronize(); @@ -40,6 +30,12 @@ class Templater_Proxy extends Templater return $this; } + public function __set($name, $value) + { + $this->unsyncronize(); + parent::__set($name, $value); + } + /** * Clear assigned variable * diff --git a/QFW/Templater/Smarty.php b/QFW/Templater/Smarty.php index 7a85aad..423684d 100644 --- a/QFW/Templater/Smarty.php +++ b/QFW/Templater/Smarty.php @@ -113,15 +113,8 @@ class Templater_Smarty extends Templater public function fetch($name, $vars=array()) { - if (!$vars) - return $this->getEngine()->fetch($name); - //если есть локальные переменные - сохраняем старые - //Smarty не поддерживает локальные переменные - $old = $this->getEngine()->get_template_vars(); - $this->getEngine()->assign($vars); + $this->getEngine()->assign($vars + $this->_vars + static::$global_vars); $data = $this->getEngine()->fetch($name); - $this->getEngine()->clear_all_assign(); - $this->getEngine()->assign($old); return $data; } diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php index a2da74b..34024fd 100644 --- a/QFW/Templater/Templater.php +++ b/QFW/Templater/Templater.php @@ -5,8 +5,9 @@ */ abstract class Templater { + protected static $global_vars = array(); /** @var array переменные, установленные в шаблоне */ - protected $_vars; + protected $_vars = array(); /** @var string путь к шаблонам */ protected $_tmplPath; @@ -33,10 +34,41 @@ abstract class Templater public function __set($name, $value) { - $this->assign($name, $value); + $this->_vars[$name] = $value; } /** + * Sets a view variable. + * + * @param string|array name of variable or an array of variables + * @param mixed value when using a named variable + * @return object + */ + public function set($name, $value = NULL) + { + if (is_array($name)) + $this->_vars = array_merge($this->_vars, $name); + else + $this->__set($name, $value); + return $this; + } + + /** + * Функция для совместимости с kohana View + * + * @static + * @param $name + * @param null $value + * @return void + */ + public static function set_global($name, $value = NULL) + { + if (is_array($name)) + static::$global_vars = array_merge(static::$global_vars, $name); + else + static::$global_vars[$name] = $value; + } + /** * Присваение значения переменной шаблона * * Allows setting a specific key to the specified value, OR passing an array @@ -48,10 +80,7 @@ abstract class Templater */ public function assign($name, $value = null) { - if (is_array($name)) - $this->_vars = array_merge($this->_vars, $name); - else - $this->_vars[$name] = $value; + self::set_global($name, $value); return $this; } @@ -63,9 +92,9 @@ abstract class Templater */ public function append($name, $value) { - if (empty($this->_vars[$name])) - $this->_vars[$name] = array(); - $this->_vars[$name][] = $value; + if (empty(static::$global_vars[$name])) + static::$global_vars[$name] = array(); + static::$global_vars[$name][] = $value; return $this; } @@ -75,7 +104,7 @@ abstract class Templater * @param string|array имя переменной или массив имен */ public function delete($spec) - { + { //TODO: уделание из всех if (is_array($spec)) foreach ($spec as $item) unset($this->_vars[$item]); @@ -84,6 +113,19 @@ abstract class Templater } /** + * Sets a bound variable by reference. + * + * @param string name of variable + * @param mixed variable to assign by reference + * @return object + */ + public function bind($name, & $var) + { + $this->_vars[$name] =& $var; + return $this; + } + + /** * Очистка всех установленных переменных * */ @@ -99,7 +141,7 @@ abstract class Templater * @return mixed значение */ public function getTemplateVars($var = null) - { + { //TODO: получение из всех if ($var === null) return $this->_vars; elseif (isset($this->_vars[$var])) diff --git a/QFW/Templater/Twig.php b/QFW/Templater/Twig.php index 619e246..f857609 100644 --- a/QFW/Templater/Twig.php +++ b/QFW/Templater/Twig.php @@ -66,7 +66,7 @@ class Templater_Twig extends Templater { $template = $this->getEngine()->loadTemplate($name); $this->assign('P', $this->P); - return $template->render($vars + $this->_vars); + return $template->render($vars + $this->_vars + static::$global_vars); } /** diff --git a/lib/View.php b/lib/View.php old mode 100755 new mode 100644 index 2b8471c..495b064 --- a/lib/View.php +++ b/lib/View.php @@ -1,20 +1,18 @@ -<?php defined('SYSPATH') OR die('No direct access allowed.'); +<?php /** * Loads and displays Kohana view files. Can also handle output of some binary * files, such as image, Javascript, and CSS files. * * $Id: View.php 4072 2009-03-13 17:20:38Z jheathco $ * - * @package Core * @author Kohana Team * @copyright (c) 2007-2008 Kohana Team * @license http://kohanaphp.com/license.html */ -class View_Core { +class View extends Templater { // The view file name and type - protected $kohana_filename = FALSE; - protected $kohana_filetype = FALSE; + protected $filename = FALSE; // View variable storage protected $kohana_local_data = array(); @@ -28,9 +26,9 @@ class View_Core { * @param string type of file: html, css, js, etc. * @return object */ - public static function factory($name = NULL, $data = NULL, $type = NULL) + public static function factory($name = NULL, $data = NULL) { - return new View($name, $data, $type); + return new View($name, $data); } /** @@ -42,21 +40,22 @@ class View_Core { * @param string type of file: html, css, js, etc. * @return void */ - public function __construct($name = NULL, $data = NULL, $type = NULL) + public function __construct($name = NULL, $data = NULL) { if (is_string($name) AND $name !== '') { // Set the filename - $this->set_filename($name, $type); + $this->set_filename($name); } if (is_array($data) AND ! empty($data)) { // Preload data using array_merge, to allow user extensions - $this->kohana_local_data = array_merge($this->kohana_local_data, $data); + $this->_vars = array_merge($this->_vars, $data); } + $this->_tmplPath = QFW::$view->getScriptPath(); } - + /** * Magic method access to test for view property * @@ -76,31 +75,10 @@ class View_Core { * @param string view file type * @return object */ - public function set_filename($name, $type = NULL) + public function set_filename($name) { - if ($type == NULL) - { - // Load the filename and set the content type - $this->kohana_filename = Kohana::find_file('views', $name, TRUE); - $this->kohana_filetype = EXT; - } - else - { - // Check if the filetype is allowed by the configuration - if ( ! in_array($type, Kohana::config('view.allowed_filetypes'))) - throw new Kohana_Exception('core.invalid_filetype', $type); - - // Load the filename and set the content type - $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); - $this->kohana_filetype = Kohana::config('mimes.'.$type); - - if ($this->kohana_filetype == NULL) - { - // Use the specified type - $this->kohana_filetype = $type; - } - } - + // Load the filename and set the content type + $this->filename = $name; return $this; } @@ -129,7 +107,7 @@ class View_Core { } /** - * Checks for a property existence in the view locally or globally. Unlike the built in __isset(), + * Checks for a property existence in the view locally or globally. Unlike the built in __isset(), * this method can take an array of properties to test simultaneously. * * @param string $key property name to test for @@ -138,7 +116,7 @@ class View_Core { * @return array associative array of keys and boolean test result */ public function is_set( $key = FALSE ) - { + { //TODO: посмотреть // Setup result; $result = FALSE; @@ -147,7 +125,7 @@ class View_Core { { // Set the result to an array $result = array(); - + // Foreach key foreach ($key as $property) { @@ -166,54 +144,6 @@ class View_Core { } /** - * Sets a bound variable by reference. - * - * @param string name of variable - * @param mixed variable to assign by reference - * @return object - */ - public function bind($name, & $var) - { - $this->kohana_local_data[$name] =& $var; - - return $this; - } - - /** - * Sets a view global variable. - * - * @param string|array name of variable or an array of variables - * @param mixed value when using a named variable - * @return void - */ - public static function set_global($name, $value = NULL) - { - if (is_array($name)) - { - foreach ($name as $key => $value) - { - View::$kohana_global_data[$key] = $value; - } - } - else - { - View::$kohana_global_data[$name] = $value; - } - } - - /** - * Magically sets a view variable. - * - * @param string variable key - * @param string variable value - * @return void - */ - public function __set($key, $value) - { - $this->kohana_local_data[$key] = $value; - } - - /** * Magically gets a view variable. * * @param string variable key @@ -221,7 +151,7 @@ class View_Core { * @return void if the key is not found */ public function &__get($key) - { + { //TODO: посмотреть if (isset($this->kohana_local_data[$key])) return $this->kohana_local_data[$key]; @@ -233,6 +163,21 @@ class View_Core { } /** + * Renders a view. + * + * @param boolean set to TRUE to echo the output instead of returning it + * @return string if print is FALSE + * @return void if print is TRUE + */ + public function fetch($tmpl=false, $vars=array()) + { + $tmpl = $tmpl ? $tmpl : $this->filename; + // Merge global and local data, local overrides global with the same name + $data = array_merge($this->_vars, $vars); + return QFW::$view->fetch($tmpl, $data); + } + + /** * Magically converts view object to string. * * @return string @@ -241,7 +186,7 @@ class View_Core { { try { - return $this->render(); + return $this->fetch('', array()); } catch (Exception $e) { @@ -249,61 +194,4 @@ class View_Core { return (string) $e; } } - - /** - * Renders a view. - * - * @param boolean set to TRUE to echo the output instead of returning it - * @param callback special renderer to pass the output through - * @return string if print is FALSE - * @return void if print is TRUE - */ - public function render($print = FALSE, $renderer = FALSE) - { - if (empty($this->kohana_filename)) - throw new Kohana_Exception('core.view_set_filename'); - - if (is_string($this->kohana_filetype)) - { - // Merge global and local data, local overrides global with the same name - $data = array_merge(View::$kohana_global_data, $this->kohana_local_data); - - // Load the view in the controller for access to $this - $output = Kohana::$instance->_kohana_load_view($this->kohana_filename, $data); - - if ($renderer !== FALSE AND is_callable($renderer, TRUE)) - { - // Pass the output through the user defined renderer - $output = call_user_func($renderer, $output); - } - - if ($print === TRUE) - { - // Display the output - echo $output; - return; - } - } - else - { - // Set the content type and size - header('Content-Type: '.$this->kohana_filetype[0]); - - if ($print === TRUE) - { - if ($file = fopen($this->kohana_filename, 'rb')) - { - // Display the output - fpassthru($file); - fclose($file); - } - return; - } - - // Fetch the file contents - $output = file_get_contents($this->kohana_filename); - } - - return $output; - } -} // End View \ No newline at end of file +} commit 0769b685b8d16c2b67bdc8cf4d1d0a1e36e8b39c Author: Ivan Borzenkov <iva...@li...> Date: Thu Jul 21 21:35:03 2011 +0400 View из Коханы diff --git a/lib/View.php b/lib/View.php new file mode 100755 index 0000000..2b8471c --- /dev/null +++ b/lib/View.php @@ -0,0 +1,309 @@ +<?php defined('SYSPATH') OR die('No direct access allowed.'); +/** + * Loads and displays Kohana view files. Can also handle output of some binary + * files, such as image, Javascript, and CSS files. + * + * $Id: View.php 4072 2009-03-13 17:20:38Z jheathco $ + * + * @package Core + * @author Kohana Team + * @copyright (c) 2007-2008 Kohana Team + * @license http://kohanaphp.com/license.html + */ +class View_Core { + + // The view file name and type + protected $kohana_filename = FALSE; + protected $kohana_filetype = FALSE; + + // View variable storage + protected $kohana_local_data = array(); + protected static $kohana_global_data = array(); + + /** + * Creates a new View using the given parameters. + * + * @param string view name + * @param array pre-load data + * @param string type of file: html, css, js, etc. + * @return object + */ + public static function factory($name = NULL, $data = NULL, $type = NULL) + { + return new View($name, $data, $type); + } + + /** + * Attempts to load a view and pre-load view data. + * + * @throws Kohana_Exception if the requested view cannot be found + * @param string view name + * @param array pre-load data + * @param string type of file: html, css, js, etc. + * @return void + */ + public function __construct($name = NULL, $data = NULL, $type = NULL) + { + if (is_string($name) AND $name !== '') + { + // Set the filename + $this->set_filename($name, $type); + } + + if (is_array($data) AND ! empty($data)) + { + // Preload data using array_merge, to allow user extensions + $this->kohana_local_data = array_merge($this->kohana_local_data, $data); + } + } + + /** + * Magic method access to test for view property + * + * @param string View property to test for + * @return boolean + */ + public function __isset($key = NULL) + { + return $this->is_set($key); + } + + /** + * Sets the view filename. + * + * @chainable + * @param string view filename + * @param string view file type + * @return object + */ + public function set_filename($name, $type = NULL) + { + if ($type == NULL) + { + // Load the filename and set the content type + $this->kohana_filename = Kohana::find_file('views', $name, TRUE); + $this->kohana_filetype = EXT; + } + else + { + // Check if the filetype is allowed by the configuration + if ( ! in_array($type, Kohana::config('view.allowed_filetypes'))) + throw new Kohana_Exception('core.invalid_filetype', $type); + + // Load the filename and set the content type + $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); + $this->kohana_filetype = Kohana::config('mimes.'.$type); + + if ($this->kohana_filetype == NULL) + { + // Use the specified type + $this->kohana_filetype = $type; + } + } + + return $this; + } + + /** + * Sets a view variable. + * + * @param string|array name of variable or an array of variables + * @param mixed value when using a named variable + * @return object + */ + public function set($name, $value = NULL) + { + if (is_array($name)) + { + foreach ($name as $key => $value) + { + $this->__set($key, $value); + } + } + else + { + $this->__set($name, $value); + } + + return $this; + } + + /** + * Checks for a property existence in the view locally or globally. Unlike the built in __isset(), + * this method can take an array of properties to test simultaneously. + * + * @param string $key property name to test for + * @param array $key array of property names to test for + * @return boolean property test result + * @return array associative array of keys and boolean test result + */ + public function is_set( $key = FALSE ) + { + // Setup result; + $result = FALSE; + + // If key is an array + if (is_array($key)) + { + // Set the result to an array + $result = array(); + + // Foreach key + foreach ($key as $property) + { + // Set the result to an associative array + $result[$property] = (array_key_exists($property, $this->kohana_local_data) OR array_key_exists($property, View::$kohana_global_data)) ? TRUE : FALSE; + } + } + else + { + // Otherwise just check one property + $result = (array_key_exists($key, $this->kohana_local_data) OR array_key_exists($key, View::$kohana_global_data)) ? TRUE : FALSE; + } + + // Return the result + return $result; + } + + /** + * Sets a bound variable by reference. + * + * @param string name of variable + * @param mixed variable to assign by reference + * @return object + */ + public function bind($name, & $var) + { + $this->kohana_local_data[$name] =& $var; + + return $this; + } + + /** + * Sets a view global variable. + * + * @param string|array name of variable or an array of variables + * @param mixed value when using a named variable + * @return void + */ + public static function set_global($name, $value = NULL) + { + if (is_array($name)) + { + foreach ($name as $key => $value) + { + View::$kohana_global_data[$key] = $value; + } + } + else + { + View::$kohana_global_data[$name] = $value; + } + } + + /** + * Magically sets a view variable. + * + * @param string variable key + * @param string variable value + * @return void + */ + public function __set($key, $value) + { + $this->kohana_local_data[$key] = $value; + } + + /** + * Magically gets a view variable. + * + * @param string variable key + * @return mixed variable value if the key is found + * @return void if the key is not found + */ + public function &__get($key) + { + if (isset($this->kohana_local_data[$key])) + return $this->kohana_local_data[$key]; + + if (isset(View::$kohana_global_data[$key])) + return View::$kohana_global_data[$key]; + + if (isset($this->$key)) + return $this->$key; + } + + /** + * Magically converts view object to string. + * + * @return string + */ + public function __toString() + { + try + { + return $this->render(); + } + catch (Exception $e) + { + // Display the exception using its internal __toString method + return (string) $e; + } + } + + /** + * Renders a view. + * + * @param boolean set to TRUE to echo the output instead of returning it + * @param callback special renderer to pass the output through + * @return string if print is FALSE + * @return void if print is TRUE + */ + public function render($print = FALSE, $renderer = FALSE) + { + if (empty($this->kohana_filename)) + throw new Kohana_Exception('core.view_set_filename'); + + if (is_string($this->kohana_filetype)) + { + // Merge global and local data, local overrides global with the same name + $data = array_merge(View::$kohana_global_data, $this->kohana_local_data); + + // Load the view in the controller for access to $this + $output = Kohana::$instance->_kohana_load_view($this->kohana_filename, $data); + + if ($renderer !== FALSE AND is_callable($renderer, TRUE)) + { + // Pass the output through the user defined renderer + $output = call_user_func($renderer, $output); + } + + if ($print === TRUE) + { + // Display the output + echo $output; + return; + } + } + else + { + // Set the content type and size + header('Content-Type: '.$this->kohana_filetype[0]); + + if ($print === TRUE) + { + if ($file = fopen($this->kohana_filename, 'rb')) + { + // Display the output + fpassthru($file); + fclose($file); + } + return; + } + + // Fetch the file contents + $output = file_get_contents($this->kohana_filename); + } + + return $output; + } +} // End View \ No newline at end of file ----------------------------------------------------------------------- Summary of changes: QFW/Templater/PlainView.php | 1 + QFW/Templater/Proxy.php | 20 ++++------ QFW/Templater/Smarty.php | 9 +---- QFW/Templater/Templater.php | 93 +++++++++++++++++++++++++++++++++++++----- QFW/Templater/Twig.php | 2 +- application/default.php | 1 + doc/asciidoc/templates.txt | 21 +++++++++- lib/View.php | 93 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 206 insertions(+), 34 deletions(-) create mode 100644 lib/View.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-06-11 21:09:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via a64d640d1933b3d598afff24fac0c2a8e8f85016 (commit) from eb086e4de63d19515064221da5a6bf55cef05d51 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a64d640d1933b3d598afff24fac0c2a8e8f85016 Author: Ivan Borzenkov <iva...@li...> Date: Sun Jun 12 01:07:56 2011 +0400 Используется array_replace_recursive diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index cd93802..c1af2a7 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -120,7 +120,7 @@ class QuickFW_Config implements ArrayAccess $new = $config; if (!empty($new)) $data = (is_array($data) && is_array($new)) ? - array_merge_replace_recursive($data, $new) : $new; + array_replace_recursive($data, $new) : $new; } return $data; } @@ -132,36 +132,3 @@ class QuickFW_Config implements ArrayAccess public function __unset($offset) { return $this->offsetUnset($offset); } } - -/** - * Merges any number of arrays of any dimensions, the later overwriting - * previous keys, unless the key is numeric, in whitch case, duplicated - * values will not be added. - * - * The arrays to be merged are passed as arguments to the function. - * - * @access public - * @return array Resulting array, once all have been merged - */ -function array_merge_replace_recursive() -{ - // Holds all the arrays passed - $params = func_get_args(); - // First array is used as the base, everything else overwrites on it - $return = array_shift($params); - // Merge all arrays on the first array - foreach ($params as $array) - foreach ($array as $key => $value) - // Numeric keyed values are added (unless already there) - if (is_numeric($key) && (!in_array($value, $return))) - if (is_array($value)) - $return[] = array_merge_replace_recursive($return[$key], $value); - else - $return[] = $value; - else // String keyed values are replaced - if (isset($return[$key]) && is_array($value) && is_array($return[$key])) - $return[$key] = array_merge_replace_recursive($return[$key], $value); - else - $return[$key] = $value; - return $return; -} ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Config.php | 35 +---------------------------------- 1 files changed, 1 insertions(+), 34 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-06-07 17:04:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via eb086e4de63d19515064221da5a6bf55cef05d51 (commit) from d57fc49c5b8d21fbcf1ee274191915ffafae5c92 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit eb086e4de63d19515064221da5a6bf55cef05d51 Author: Ivan Borzenkov <iva...@li...> Date: Tue Jun 7 17:42:51 2011 +0400 Небольшой фикс конфига diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index cf6ad72..cd93802 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -88,7 +88,7 @@ class QuickFW_Config implements ArrayAccess return $this->data[$offset]; } public function offsetExists($offset) { return isset($this->data[$offset]); } - public function offsetUnset($offset) { unset($this->data); } + public function offsetUnset($offset) { unset($this->data[$offset]); } /** * Пробуем загрузить файл из текущей директории diff --git a/lib/RecursiveArrayAccess.php b/lib/RecursiveArrayAccess.php index 0f39e41..48f4b17 100644 --- a/lib/RecursiveArrayAccess.php +++ b/lib/RecursiveArrayAccess.php @@ -32,7 +32,7 @@ class RecursiveArrayAccess implements ArrayAccess //public function offsetGet($offset) { return isset($this->data[$offset]) ? $this->data[$offset] : null; } public function offsetGet($offset) { return $this->data[$offset]; } public function offsetExists($offset) { return isset($this->data[$offset]); } - public function offsetUnset($offset) { unset($this->data); } + public function offsetUnset($offset) { unset($this->data[$offset]); } //as prop public function __get($offset) { return $this->offsetGet($offset); } ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Config.php | 2 +- lib/RecursiveArrayAccess.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-05-31 14:05:36
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via d57fc49c5b8d21fbcf1ee274191915ffafae5c92 (commit) via 0c395a446c92c2945c6d0444cf456ac2683e5f87 (commit) via f2a5c6ea0d6b780d49c26f2f48fbcbeb71aafa8b (commit) via 5113e76d94b8fc5baf37135df41a83afd59366b8 (commit) from 6707c473238aaca477c0ac9c661a5e4a0a4e66b5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d57fc49c5b8d21fbcf1ee274191915ffafae5c92 Merge: 6707c47 0c395a4 Author: Ivan Borzenkov <iva...@li...> Date: Tue May 31 18:03:12 2011 +0400 Merge branch 'newUrl' commit 0c395a446c92c2945c6d0444cf456ac2683e5f87 Author: Ivan Borzenkov <iva...@li...> Date: Tue May 31 18:02:28 2011 +0400 Документация по новому урлу diff --git a/doc/asciidoc/helpers.txt b/doc/asciidoc/helpers.txt index b21ef5b..93c79b8 100644 --- a/doc/asciidoc/helpers.txt +++ b/doc/asciidoc/helpers.txt @@ -5,7 +5,7 @@ ~~~~~~~~~~~~~ Для генерации URL существует отдельный класс +Url+ в котором есть статические методы. -Каждая функция-генератор кромя base принимает три параметра: относительный адрес, get параметы и якорь. +Каждая функция-генератор кромя base принимает произвольное количество параметров - компонентов Url и соединяет их разделителем компонентов (+/+ по умолчанию). +Url::base+:: отдает базовый Url @@ -20,6 +20,8 @@ Настройки хранятся в +QFW::$config[\'redirection']+, перечитать можно с помощью функции +Url::Init()+. +Функция возвращает объект, у которого есть функции добавляния якоря (+anchor+) и GET параметров (+get+). + Функции get/out Head ~~~~~~~~~~~~~~~~~~~~ commit f2a5c6ea0d6b780d49c26f2f48fbcbeb71aafa8b Author: Ivan Borzenkov <iva...@li...> Date: Wed May 11 16:25:26 2011 +0400 Несколько параметров в урле diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index eef339e..a82e25f 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -28,7 +28,7 @@ class Url */ public static function site($url='') { - return new static($url); + return new static(func_get_args()); } /** @@ -41,7 +41,7 @@ class Url */ public static function M($CA='') { - return new static($CA, static::$config['router']->cModule. + return new static(func_get_args(), static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR); } @@ -55,7 +55,7 @@ class Url */ public static function C($action='') { - return new static($action, static::$config['router']->cModule. + return new static(func_get_args(), static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR. static::$config['router']->cController. QuickFW_Router::PATH_SEPARATOR); @@ -71,7 +71,7 @@ class Url */ public static function A($params='') { - return new static($params, static::$config['router']->cModule. + return new static(func_get_args(), static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR. static::$config['router']->cController. QuickFW_Router::PATH_SEPARATOR. @@ -112,6 +112,8 @@ class Url $this->anchor = $url->anchor; return; } + if (is_array($url)) + $url = join(QuickFW_Router::PATH_SEPARATOR, $url); //Заменяем / на QuickFW_Router::PATH_SEPARATOR if (QuickFW_Router::PATH_SEPARATOR != '/') $url = strtr($url, '/', QuickFW_Router::PATH_SEPARATOR); commit 5113e76d94b8fc5baf37135df41a83afd59366b8 Author: Ivan Borzenkov <iva...@li...> Date: Wed May 11 14:29:15 2011 +0400 Переделано добавление get параметров и якоря diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index 5bc2d79..eef339e 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -11,7 +11,7 @@ class Url * Добавляет в начале базовый урл * * @param string|self $url url - * @return self базовый url + * @return Url базовый url */ public static function base($url='') { @@ -24,11 +24,11 @@ class Url * @param string|self $url url * @param string|array $get параметры * @param string $anchor якорь - * @return self адрес на сайте + * @return Url адрес на сайте */ - public static function site($url='', $get='', $anchor='') + public static function site($url='') { - return new static($url, $get, $anchor); + return new static($url); } /** @@ -37,11 +37,11 @@ class Url * @param string|self $CA url * @param string|array $get параметры * @param string $anchor якорь - * @return self адрес на сайте + * @return Url адрес на сайте */ - public static function M($CA='', $get='', $anchor='') + public static function M($CA='') { - return new static($CA, $get, $anchor, static::$config['router']->cModule. + return new static($CA, static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR); } @@ -51,11 +51,11 @@ class Url * @param string|self $action url * @param string|array $get параметры * @param string $anchor якорь - * @return self адрес на сайте + * @return Url адрес на сайте */ - public static function C($action='', $get='', $anchor='') + public static function C($action='') { - return new static($action, $get, $anchor, static::$config['router']->cModule. + return new static($action, static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR. static::$config['router']->cController. QuickFW_Router::PATH_SEPARATOR); @@ -67,11 +67,11 @@ class Url * @param string|self $params url * @param string|array $get параметры * @param string $anchor якорь - * @return self адрес на сайте + * @return Url адрес на сайте */ - public static function A($params='', $get='', $anchor='') + public static function A($params='') { - return new static($params, $get, $anchor, static::$config['router']->cModule. + return new static($params, static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR. static::$config['router']->cController. QuickFW_Router::PATH_SEPARATOR. @@ -103,23 +103,21 @@ class Url * @param string $anchor якорь * @param string $begin базовый урл от текущего */ - protected function __construct($url, $get='', $anchor='', $begin='') + protected function __construct($url, $begin='') { - if (is_array($get) && count($get)) - $get = http_build_query($get); if ($url instanceof self) { $this->u = $begin.$url->u; - $this->get = $url->get.($get?('&'.$get):''); - $this->anchor = $anchor ? ltrim($anchor, '#') : $url->anchor; + $this->get = $url->get; + $this->anchor = $url->anchor; return; } //Заменяем / на QuickFW_Router::PATH_SEPARATOR if (QuickFW_Router::PATH_SEPARATOR != '/') $url = strtr($url, '/', QuickFW_Router::PATH_SEPARATOR); $this->u = trim($begin.$url, QuickFW_Router::PATH_SEPARATOR); - $this->get = $get; - $this->anchor = ltrim($anchor, '#'); + $this->get = array(); + $this->anchor = ''; if (static::$config['delDef']) $this->u = static::$config['router']->delDef($this->u); } @@ -140,24 +138,53 @@ class Url */ public function __toString() { - return $this->get(); + return $this->asString(); } /** * урл для вывода, с подстановками + * (не всегда работает __toString) * * @return string урл */ - public function get() + public function asString() { return static::$config['router']->backrewriteUrl( static::$config['base'].static::$config['router']->backrewrite($this->u). ($this->u!=='' ? static::$config['ext'] : ''). - ($this->get ? '?' . $this->get : ''). + ($this->get ? ('?' . http_build_query($this->get)) : ''). ($this->anchor ? '#' . $this->anchor : '')); } /** + * Добавляет get параметр + * + * @param string|array $k ключ + * @param string|false $v значение + * @return Url + */ + public function get($k, $v=false) + { + if (is_array($k)) + $this->get = array_merge_recursive($this->get, $k); + else + $this->get[$k] = $v; + return $this; + } + + /** + * Добавляет якорь + * + * @param string $a якорь + * @return Url + */ + public function anchor($a) + { + $this->anchor = $a; + return $this; + } + + /** * Внутренний адрес - для блока * * @internal ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Url.php | 75 ++++++++++++++++++++++++++++++++-------------- doc/asciidoc/helpers.txt | 4 ++- 2 files changed, 55 insertions(+), 24 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-05-20 17:50:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 6707c473238aaca477c0ac9c661a5e4a0a4e66b5 (commit) from f0d14feea0647d3e5dd96d188a593ef54d82b047 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6707c473238aaca477c0ac9c661a5e4a0a4e66b5 Author: Ivan Borzenkov <iva...@li...> Date: Fri May 20 21:22:06 2011 +0400 Небольшой фикс конфига diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 64b8f2b..cf6ad72 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -116,9 +116,11 @@ class QuickFW_Config implements ArrayAccess $new = array(); if (is_file($file)) $new = include($file); - if ($new == 1 && isset($config)) + if ($new === 1 && isset($config)) $new = $config; - $data = array_merge_replace_recursive($data, $new); + if (!empty($new)) + $data = (is_array($data) && is_array($new)) ? + array_merge_replace_recursive($data, $new) : $new; } return $data; } ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Config.php | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-25 17:45:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, scaffold has been created at fd5fdcb2c6b50a75b6df227436a06df228305331 (commit) - Log ----------------------------------------------------------------- commit fd5fdcb2c6b50a75b6df227436a06df228305331 Author: Ivan Borzenkov <iva...@li...> Date: Tue Mar 1 15:39:35 2011 +0300 Правка phpdoc diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php index 5385bf4..3f29b5f 100644 --- a/lib/Modules/Scaffold/ScaffoldController.php +++ b/lib/Modules/Scaffold/ScaffoldController.php @@ -1031,8 +1031,8 @@ abstract class ScaffoldController extends Controller $infoClass->typeParams = $match[2]; } + /** @var Scaffold_Field $C */ $C = new $class(); - /** @var $C Scaffold_Field */ $C->init($infoClass); return $C; } commit cb736b71f6fba1eb5a3f4a7eee27143c106a14f6 Author: Ivan Borzenkov <iva...@li...> Date: Mon Feb 28 14:48:02 2011 +0300 Отделил инициализацию от конструктора diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php index b58ed6f..8fca13f 100644 --- a/lib/Modules/Scaffold/Fields.php +++ b/lib/Modules/Scaffold/Fields.php @@ -59,12 +59,16 @@ class Scaffold_Field_Info class Scaffold_Field extends Scaffold_Field_Info { + public function __construct() + { + } + /** - * Создает полноценное поле из данных о пользователе + * Инициализирует данные из таблицы * * @param Scaffold_Field_Info $info Информация о поле */ - public function __construct($info) + public function init($info) { $vars = get_class_vars('Scaffold_Field_Info'); foreach ($vars as $k=>$v) @@ -266,12 +270,10 @@ class Scaffold_Foreign extends Scaffold_Field /** @var bool Может ли быть нулевое значение */ protected $isnull; - public function __construct($info, $where = DBSIMPLE_SKIP) + public function init($info) { - if (!empty($info->typeParams)) - $where = $info->typeParams; $this->isnull = $info->foreign['null']; - parent::__construct($info); + parent::init($info); $this->lookup = QFW::$db->selectCol('SELECT ?# AS ARRAY_KEY_1, ?# FROM ?# {WHERE ?s}', $info->foreign['key'], $info->foreign['field'], $info->foreign['table'], $where); } @@ -302,9 +304,9 @@ abstract class Scaffold_UserInput extends Scaffold_Field /** @var integer До скольки обрезать */ private $trim; - public function __construct($info) + public function init($info) { - parent::__construct($info); + parent::init($info); $this->trim = isset($info->typeParams['trim']) ? $info->typeParams['trim'] : 80; } @@ -328,9 +330,9 @@ class Scaffold_Text extends Scaffold_UserInput /** @var integer Сколько колонок */ private $cols; - public function __construct($info) + public function init($info) { - parent::__construct($info); + parent::init($info); $this->rows = isset($info->typeParams['rows']) ? $info->typeParams['rows'] : 10; $this->cols = isset($info->typeParams['cols']) ? $info->typeParams['cols'] : 80; } @@ -367,13 +369,18 @@ class Scaffold_Varchar extends Scaffold_Field /** @var integer размер поля в базе */ private $size; - public function __construct($info, $size = 100) + public function __construct($size = false) { - if (!empty($info->typeParams) && is_numeric($info->typeParams)) - $size = $info->typeParams; - parent::__construct($info); $this->size = $size; } + + public function init($info) + { + parent::init($info); + if (!$this->size) + if (!empty($info->typeParams) && is_numeric($info->typeParams)) + $this->size = $info->typeParams; + } public function validator($id, $value) { @@ -397,11 +404,15 @@ class Scaffold_Enum extends Scaffold_Field /** @var array что в перечислении */ private $items; - public function __construct($info, $items) + public function __construct($items = '') { - parent::__construct($info); - $items = str_getcsv($items, ',', "'"); - $this->items = array_combine($items, $items); + $this->items = str_getcsv($items, ',', "'"); + } + + public function init($info) + { + parent::init($info); + $this->items = array_combine($info->typeParams, $this->items); } public function editor($id, $value) @@ -421,9 +432,13 @@ class Scaffold_Enum extends Scaffold_Field class Scaffold_Datetime extends Scaffold_Field { - public function __construct($info) + public function __construct() + { + } + + public function init($info) { - parent::__construct($info); + parent::init($info); if ($this->default == 'CURRENT_TIMESTAMP') $this->default = date('Y-m-d H:i:s'); } @@ -465,9 +480,9 @@ class Scaffold_File extends Scaffold_Field * * @param Scaffold_Field_Info $info Информация о поле */ - public function __construct($info) + public function init($info) { - parent::__construct($info); + parent::init($info); $this->label = false; if (empty ($info->typeParams['path'])) throw new Exception('Не указана директория для фалов', 1); @@ -556,11 +571,11 @@ class Scaffold_File extends Scaffold_Field class Scaffold_Image extends Scaffold_File { - public function __construct($info) + public function init($info) { if (empty($info->typeParams['accept'])) $info->typeParams['accept'] = 'image/*'; - parent::__construct($info); + parent::init($info); } public function display($id, $value) diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php index 02c633a..5385bf4 100644 --- a/lib/Modules/Scaffold/ScaffoldController.php +++ b/lib/Modules/Scaffold/ScaffoldController.php @@ -1013,22 +1013,28 @@ abstract class ScaffoldController extends Controller $infoClass->tableObject = &$this; $infoClass->primaryKey = $this->primaryKey; + $class = 'Scaffold_Field'; + $match = array(); if ($infoClass->type) { $class = 'Scaffold_'.ucfirst($infoClass->type); - return new $class($infoClass); } //определяем по типам и прочей известной информации - if ($infoClass->foreign) - return new Scaffold_Foreign($infoClass); + elseif ($infoClass->foreign) + $class = 'Scaffold_Foreign'; - $match = array(); - if (preg_match('#(.*?)(?:\((.+?)\)|$)#', $fieldInfo['Type'], $match)) - if (class_exists($class = 'Scaffold_'.ucfirst($match[1]))) - return new $class($infoClass, isset($match[2]) ? $match[2] : false ); + elseif (preg_match('#(.*?)(?:\((.+?)\)|$)#', $fieldInfo['Type'], $match)) + if (class_exists($cl = 'Scaffold_'.ucfirst($match[1]))) + { + $class = $cl; + $infoClass->typeParams = $match[2]; + } - return new Scaffold_Field($infoClass); + $C = new $class(); + /** @var $C Scaffold_Field */ + $C->init($infoClass); + return $C; } private function endTest() commit e6df258035a4aa7a13094740a761e127a6398042 Author: Ivan Borzenkov <iva...@li...> Date: Mon Feb 28 14:18:39 2011 +0300 notice old diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php index 3e0b38f..02c633a 100644 --- a/lib/Modules/Scaffold/ScaffoldController.php +++ b/lib/Modules/Scaffold/ScaffoldController.php @@ -488,6 +488,7 @@ abstract class ScaffoldController extends Controller //Обработка результата редактирования foreach($alldata as $id => $data) { + $old = $this->getOldVars($id); self::setCurRow($old); foreach ($data as $k=>$v) { commit 8cfa3b5fc77c3f0c31b952c3038b40eb63011e45 Author: Ivan Borzenkov <iva...@li...> Date: Mon Feb 28 13:45:26 2011 +0300 Автолоад для скафолдинга diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php index 5d978d8..b58ed6f 100644 --- a/lib/Modules/Scaffold/Fields.php +++ b/lib/Modules/Scaffold/Fields.php @@ -415,52 +415,6 @@ class Scaffold_Enum extends Scaffold_Field //Классы для других типов полей, указываемых пользователем -class Scaffold_Checkbox extends Scaffold_Field -{ - - public function display($id, $value) - { - return $value ? 'Да' : 'Нет'; - } - - public function editor($id, $value) - { - return '<input type="hidden" name="'.$this->editName($id).'" value="0" /> - <input type="checkbox" name="'.$this->editName($id).'" value="1" label="'.$this->title.'" - default="'.($value?'checked':'').'" />'; - } - - /** - * Часть условия WHERE для данного фильтра - * - * @param mixed $session сохраненное в сессии значение - * @return DbSimple_SubQuery часть запроса к базе данных - */ - public function filterWhere($session) - { - if ($session == 0) - return QFW::$db->subquery(''); - return QFW::$db->subquery('?# LIKE ?', - array($this->table=>$this->name), $session==1 ? '1' : '0'); - } - - /** - * Формирует поле ввода для фильтра - * - * @param mixed $session сохраненные в сесии данные - * @return string часть формы для фильтра - */ - public function filterForm($session) - { - return '<fieldset>'.$this->title.': - <label><input type="radio" name="filter['.$this->name.']" value=""'.($session==0 ? ' checked': '').'> любой</label> - <label><input type="radio" name="filter['.$this->name.']" value="1"'.($session==1 ? ' checked': '').'> установлен</label> - <label><input type="radio" name="filter['.$this->name.']" value="-1"'.($session==-1 ? ' checked': '').'> сброшен</label> - </fieldset>'; - } - -} - /** * Дата и время */ diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php index f10a049..3e0b38f 100644 --- a/lib/Modules/Scaffold/ScaffoldController.php +++ b/lib/Modules/Scaffold/ScaffoldController.php @@ -1037,4 +1037,22 @@ abstract class ScaffoldController extends Controller } } -?> + +/** + * Autoload для скафолда - классы полей в fields + * + * @param string $class имя класса + * @return bool загрузилось + */ +function ScaffoldAutoload($class) +{ + if (strpos($class, 'Scaffold_') === 0) + { + $class = str_replace('Scaffold_','fields/', $class); + require dirname(__FILE__).'/'.$class.'.php'; + return true; + } + return false; +} + +spl_autoload_register('ScaffoldAutoload'); diff --git a/lib/Modules/Scaffold/fields/Checkbox.php b/lib/Modules/Scaffold/fields/Checkbox.php new file mode 100644 index 0000000..f0fcb2f --- /dev/null +++ b/lib/Modules/Scaffold/fields/Checkbox.php @@ -0,0 +1,49 @@ +<?php +/** + * Поле с типом checkbox + */ +class Scaffold_Checkbox extends Scaffold_Field +{ + + public function display($id, $value) + { + return $value ? 'Да' : 'Нет'; + } + + public function editor($id, $value) + { + return '<input type="hidden" name="'.$this->editName($id).'" value="0" /> + <input type="checkbox" name="'.$this->editName($id).'" value="1" label="'.$this->title.'" + default="'.($value?'checked':'').'" />'; + } + + /** + * Часть условия WHERE для данного фильтра + * + * @param mixed $session сохраненное в сессии значение + * @return DbSimple_SubQuery часть запроса к базе данных + */ + public function filterWhere($session) + { + if ($session == 0) + return QFW::$db->subquery(''); + return QFW::$db->subquery('?# LIKE ?', + array($this->table=>$this->name), $session==1 ? '1' : '0'); + } + + /** + * Формирует поле ввода для фильтра + * + * @param mixed $session сохраненные в сесии данные + * @return string часть формы для фильтра + */ + public function filterForm($session) + { + return '<fieldset>'.$this->title.': + <label><input type="radio" name="filter['.$this->name.']" value=""'.($session==0 ? ' checked': '').'> любой</label> + <label><input type="radio" name="filter['.$this->name.']" value="1"'.($session==1 ? ' checked': '').'> установлен</label> + <label><input type="radio" name="filter['.$this->name.']" value="-1"'.($session==-1 ? ' checked': '').'> сброшен</label> + </fieldset>'; + } + +} ----------------------------------------------------------------------- hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-25 17:42:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via f0d14feea0647d3e5dd96d188a593ef54d82b047 (commit) via 7a090df53de676d5b1f2b4dfbcd8eadc89385077 (commit) via 45a102f65cb07b12572066657a7878e5ba81c4ec (commit) via a0c977fd9bd741e7cddc7e74ac6dcbb3b4d7c322 (commit) via 59c1705983d455a37d200f5535726cddb882a15f (commit) via 6f0593441282df153aa2dd58c4a1b32a5fc35905 (commit) from 855a0a63ab714a57b3952194ed791f1ea6e0adc4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f0d14feea0647d3e5dd96d188a593ef54d82b047 Merge: 855a0a6 7a090df Author: Ivan Borzenkov <iva...@li...> Date: Mon Apr 25 21:41:44 2011 +0400 Merge branch 'newConfig' commit 7a090df53de676d5b1f2b4dfbcd8eadc89385077 Author: Ivan Borzenkov <iva...@li...> Date: Mon Apr 25 19:27:23 2011 +0400 Исправлен возможный варнинг diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index bb30547..64b8f2b 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -113,6 +113,7 @@ class QuickFW_Config implements ArrayAccess $data = array(); foreach($files as $file) { + $new = array(); if (is_file($file)) $new = include($file); if ($new == 1 && isset($config)) commit 45a102f65cb07b12572066657a7878e5ba81c4ec Author: Ivan Borzenkov <iva...@li...> Date: Mon Apr 25 18:36:49 2011 +0400 Добавлен правильный мерж конфигов diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index eefe211..bb30547 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -117,7 +117,7 @@ class QuickFW_Config implements ArrayAccess $new = include($file); if ($new == 1 && isset($config)) $new = $config; - $data = array_merge_recursive($data, $new); + $data = array_merge_replace_recursive($data, $new); } return $data; } @@ -129,3 +129,36 @@ class QuickFW_Config implements ArrayAccess public function __unset($offset) { return $this->offsetUnset($offset); } } + +/** + * Merges any number of arrays of any dimensions, the later overwriting + * previous keys, unless the key is numeric, in whitch case, duplicated + * values will not be added. + * + * The arrays to be merged are passed as arguments to the function. + * + * @access public + * @return array Resulting array, once all have been merged + */ +function array_merge_replace_recursive() +{ + // Holds all the arrays passed + $params = func_get_args(); + // First array is used as the base, everything else overwrites on it + $return = array_shift($params); + // Merge all arrays on the first array + foreach ($params as $array) + foreach ($array as $key => $value) + // Numeric keyed values are added (unless already there) + if (is_numeric($key) && (!in_array($value, $return))) + if (is_array($value)) + $return[] = array_merge_replace_recursive($return[$key], $value); + else + $return[] = $value; + else // String keyed values are replaced + if (isset($return[$key]) && is_array($value) && is_array($return[$key])) + $return[$key] = array_merge_replace_recursive($return[$key], $value); + else + $return[$key] = $value; + return $return; +} diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index a73611b..5bc2d79 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -83,9 +83,9 @@ class Url */ public static function Init($base='') { - $base = $base ? $base : QFW::$config['redirection']['baseUrl']; + $base = $base ? $base : QFW::$config['redirection']['baseUrl']; $c = str_replace(__CLASS__, '', get_called_class()).'QFW'; - static::$config = $c::$config['redirection']; + static::$config = clone $c::$config['redirection']; static::$config['base'] = $base.(static::$config['useIndex'] ? 'index.php/' : ''); static::$config['ext'] = static::$config['defExt'] ? static::$config['defExt'] : (QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); diff --git a/application/host.quickfw.my.php b/application/host.quickfw.my.php new file mode 100644 index 0000000..5fc2510 --- /dev/null +++ b/application/host.quickfw.my.php @@ -0,0 +1,7 @@ +<?php + +return array( + 'host' => array( + 'lang' => 'en_US', + ), +); commit a0c977fd9bd741e7cddc7e74ac6dcbb3b4d7c322 Author: Ivan Borzenkov <iva...@li...> Date: Mon Apr 25 18:05:13 2011 +0400 Исправлена ошибка в конфиге diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 0de1e69..eefe211 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -114,9 +114,10 @@ class QuickFW_Config implements ArrayAccess foreach($files as $file) { if (is_file($file)) - $data = include($file); - if ($data == 1 && isset($config)) - $data = $config; + $new = include($file); + if ($new == 1 && isset($config)) + $new = $config; + $data = array_merge_recursive($data, $new); } return $data; } commit 59c1705983d455a37d200f5535726cddb882a15f Author: Ivan Borzenkov <iva...@li...> Date: Mon Apr 25 12:38:28 2011 +0400 Дока по кофигу diff --git a/doc/asciidoc/config.txt b/doc/asciidoc/config.txt index 6de2f13..996d4f7 100644 --- a/doc/asciidoc/config.txt +++ b/doc/asciidoc/config.txt @@ -6,7 +6,7 @@ В папаке +APPPATH/config+ могут находится произвольные файлы с расширением php, которые должны возвращать скаляр, массив или объект, реализующий интерфейс +ArrayAccess+ через оператор return или в переменной $config. При отсутствии в главном конфигурационном массиве элемента с указанным именем делается попытка подгрузить одноименный файл. -Для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) или именем сервера (+$_SERVER[\'SERVER_NAME']+) - +По умолчанию для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) или именем сервера (+$_SERVER[\'SERVER_NAME']+) - при запуске на этом хосте подгрузятся все файлы - сначало основной, а потом файлы, специфичные для сервера и хоста. .Отклонения конфигов @@ -85,3 +85,10 @@ return 'param'; ===================================================================== Параметры откланений и пути к конфигурационным файлам можно настроить в функциях +main+ и +files+ в классе +QuickFW_Config+ (+QFW/QuickFW/Config.php+). + +Настройка сервера +~~~~~~~~~~~~~~~~~ + +Переменная +SERVER_NAME+ берется из настроек сервера, а переменная +HTTP_HOST+ из заголовка запросов. +SERVER_NAME+ удобно использовать для разделения серверов (production, pre-production, testing, devel и других) а +HTTP_HOST+ для настройки параметров специфичных для алиасов например контроллер и экшен по умолчанию. +Для того чтобы все алиасы хоста имели одинаковый +SERVER_NAME+ в apache нужно установить параметр +UseCanonicalName+. +В nginx значение берется из первого имени сервера - не рекомендутся использовать там регулярное выражение, так как оно напрямую будет помещено в +SERVER_NAME+. \ No newline at end of file commit 6f0593441282df153aa2dd58c4a1b32a5fc35905 Author: Ivan Borzenkov <iva...@li...> Date: Mon Apr 25 01:57:02 2011 +0400 Настраиваемый конфиг diff --git a/QFW/Init.php b/QFW/Init.php index 3ea7dfc..4783392 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -51,15 +51,7 @@ class QFW */ static public function config() { - require QFWPATH.'/config.php'; - require APPPATH.'/default.php'; - - if (!isset($_SERVER['HTTP_HOST'])) - die('$_SERVER[\'HTTP_HOST\'] NOT SET'); - $file = APPPATH.'/'.$_SERVER['HTTP_HOST'].'.php'; - if (is_file($file)) - require ($file); - return new QuickFW_Config($config, APPPATH.'/config'); + return QuickFW_Config::main(); } /** diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 1ac1f30..0de1e69 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -5,6 +5,44 @@ */ class QuickFW_Config implements ArrayAccess { + /** + * Генерирует список файлов конфигураций + * + * @param string|false $prefix префикс + * @return array массив файлов + */ + static private function files($prefix) + { + if ($prefix === false) + { + $files = array(); + $files[] = QFWPATH.'/config.php'; + $files[] = APPPATH.'/default.php'; + if (isset($_SERVER['SERVER_NAME'])) + $files[] = APPPATH.'/serv.'.$_SERVER['SERVER_NAME'].'.php'; + if (isset($_SERVER['HTTP_HOST'])) + $files[] = APPPATH.'/host.'.$_SERVER['HTTP_HOST'].'.php'; + return $files; + } + $files = array(); + $files[] = $prefix.'.php'; + if (isset($_SERVER['SERVER_NAME'])) + $files[] = $prefix.'.serv.'.$_SERVER['SERVER_NAME'].'.php'; + if (isset($_SERVER['HTTP_HOST'])) + $files[] = $prefix.'.host.'.$_SERVER['HTTP_HOST'].'.php'; + return $files; + } + + /** + * Генерация основного конфига + * + * @return array|mixed|QuickFW_Config вложенный массив + */ + static public function main() + { + return new self(self::loadFromFiles(self::files(false)), APPPATH.'/config'); + } + private $data = array(); /** * @var string Директория конфигурации @@ -46,7 +84,7 @@ class QuickFW_Config implements ArrayAccess public function offsetGet($offset) { if ($this->dir && !isset($this->data[$offset])) - $this->data[$offset] = $this->loadFromFile($offset); + $this->data[$offset] = $this->load($offset); return $this->data[$offset]; } public function offsetExists($offset) { return isset($this->data[$offset]); } @@ -58,22 +96,29 @@ class QuickFW_Config implements ArrayAccess * @param string $name имя файла * @return array|mixed|QuickFW_Config вложенный массив */ - private function loadFromFile($name) + private function load($name) + { + $data = self::loadFromFiles(self::files($this->dir.'/'.$name)); + return is_array($data) ? new self($data, $this->dir.'/'.$name) : $data; + } + + /** + * Пробуем загрузить файл из текущей директории + * + * @param array $files файлы + * @return array|mixed|QuickFW_Config вложенный массив + */ + static private function loadFromFiles($files) { - $file = $this->dir.'/'.$name.'.php'; $data = array(); - if (is_file($file)) - $data = include($file); - if ($data == 1 && isset($config)) - $data = $config; - $hf = $this->dir.'/'.$name.'.'.$_SERVER['HTTP_HOST'].'.php'; - if (is_file($hf)) + foreach($files as $file) { - $data = include($hf); + if (is_file($file)) + $data = include($file); if ($data == 1 && isset($config)) $data = $config; } - return is_array($data) ? new self($data, $this->dir.'/'.$name) : $data; + return $data; } //as prop diff --git a/doc/asciidoc/config.txt b/doc/asciidoc/config.txt index 9dbd85c..6de2f13 100644 --- a/doc/asciidoc/config.txt +++ b/doc/asciidoc/config.txt @@ -2,12 +2,12 @@ ------------ Для чтения конфигов используется переменная +QFW::$config+. Она представляет собой класс к которому можно обращаться как к массиву. -Конфигурация может быть разбита на несколько файлов. Главный конфигурационный файл находится в папке приложения (+APPPATH+) и называется +default.php+, в нем должен быть определен массив $config +Конфигурация может быть разбита на несколько файлов. Главный конфигурационный файл находится в папке приложения (+APPPATH+) и называется +default.php+, в нем должен быть определен массив $config или возвращаться через оператор return. В папаке +APPPATH/config+ могут находится произвольные файлы с расширением php, которые должны возвращать скаляр, массив или объект, реализующий интерфейс +ArrayAccess+ через оператор return или в переменной $config. При отсутствии в главном конфигурационном массиве элемента с указанным именем делается попытка подгрузить одноименный файл. -Для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) - -при запуске на этом хосте подгрузятся оба файла - сначало основной, а потом файл, специфичный для хоста. +Для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) или именем сервера (+$_SERVER[\'SERVER_NAME']+) - +при запуске на этом хосте подгрузятся все файлы - сначало основной, а потом файлы, специфичные для сервера и хоста. .Отклонения конфигов ===================================================================== @@ -20,7 +20,7 @@ $config = array( ); --------------------------------------------- -+application/default.site.my.php+: ++application/default.host.site.my.php+: [source,php] --------------------------------------------- @@ -38,7 +38,7 @@ return array( ); --------------------------------------------- -+application/config/capcha.site.my.php+: ++application/config/capcha.serv.site.my.php+: [source,php] --------------------------------------------- @@ -83,3 +83,5 @@ return 'param'; array('file' => 'param', ) ===================================================================== + +Параметры откланений и пути к конфигурационным файлам можно настроить в функциях +main+ и +files+ в классе +QuickFW_Config+ (+QFW/QuickFW/Config.php+). ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 10 +--- QFW/QuickFW/Config.php | 106 ++++++++++++++++++++++++++++++++++----- QFW/QuickFW/Url.php | 4 +- application/host.quickfw.my.php | 7 +++ doc/asciidoc/config.txt | 19 +++++-- 5 files changed, 117 insertions(+), 29 deletions(-) create mode 100644 application/host.quickfw.my.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-21 22:59:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 855a0a63ab714a57b3952194ed791f1ea6e0adc4 (commit) from 016c73dc5aa3f4b207f81f465f646fd5282b617e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 855a0a63ab714a57b3952194ed791f1ea6e0adc4 Author: Ivan Borzenkov <iva...@li...> Date: Fri Apr 22 00:46:49 2011 +0400 Фиксы в симпле diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php index 719793a..4706069 100644 --- a/lib/DbSimple/Connect.php +++ b/lib/DbSimple/Connect.php @@ -123,8 +123,9 @@ class DbSimple_Connect $this->DbSimple = new $class($parsed); $this->errmsg = &$this->DbSimple->errmsg; $this->error = &$this->DbSimple->error; - if (isset($parsed['prefix'])) - $this->DbSimple->setIdentPrefix($parsed['prefix']); + $prefix = isset($parsed['prefix']) ? $parsed['prefix'] : ($this->_identPrefix ? $this->_identPrefix : false); + if ($prefix) + $this->DbSimple->setIdentPrefix($prefix); if ($this->_cachePrefix) $this->DbSimple->setCachePrefix($this->_cachePrefix); if ($this->_cacher) $this->DbSimple->setCacher($this->_cacher); if ($this->_logger) $this->DbSimple->setLogger($this->_logger); @@ -189,6 +190,7 @@ class DbSimple_Connect /** @var callback обработчик ошибок */ private $errorHandler = null; private $_cachePrefix = ''; + private $_identPrefix = null; private $_logger = null; private $_cacher = null; ----------------------------------------------------------------------- Summary of changes: lib/DbSimple/Connect.php | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-14 20:25:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 016c73dc5aa3f4b207f81f465f646fd5282b617e (commit) from 05d5cc1d8028fa113adc899eb739308dee395b43 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 016c73dc5aa3f4b207f81f465f646fd5282b617e Author: Ivan Borzenkov <iva...@li...> Date: Fri Apr 15 00:25:09 2011 +0400 Обновлена DbSimple diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php index 17fc5e7..719793a 100644 --- a/lib/DbSimple/Connect.php +++ b/lib/DbSimple/Connect.php @@ -42,6 +42,10 @@ class DbSimple_Connect protected $shema; /** @var array Что выставить при коннекте */ protected $init; + /** @var integer код ошибки */ + public $error = null; + /** @var string сообщение об ошибке */ + public $errmsg = null; /** * Конструктор только запоминает переданный DSN @@ -117,6 +121,8 @@ class DbSimple_Connect require_once dirname(__FILE__).'/'.$this->shema.'.php'; $class = 'DbSimple_'.$this->shema; $this->DbSimple = new $class($parsed); + $this->errmsg = &$this->DbSimple->errmsg; + $this->error = &$this->DbSimple->error; if (isset($parsed['prefix'])) $this->DbSimple->setIdentPrefix($parsed['prefix']); if ($this->_cachePrefix) $this->DbSimple->setCachePrefix($this->_cachePrefix); diff --git a/lib/DbSimple/Database.php b/lib/DbSimple/Database.php index 112b444..e205ae2 100644 --- a/lib/DbSimple/Database.php +++ b/lib/DbSimple/Database.php @@ -1302,7 +1302,7 @@ abstract class DbSimple_LastError $this->errorHandler = $handler; // In case of setting first error handler for already existed // error - call the handler now (usual after connect()). - if (!$prev && $this->error) { + if (!$prev && $this->error && $this->errorHandler) { call_user_func($this->errorHandler, $this->errmsg, $this->error); } return $prev; diff --git a/lib/DbSimple/Generic.php b/lib/DbSimple/Generic.php index 43dbe14..8cc9203 100644 --- a/lib/DbSimple/Generic.php +++ b/lib/DbSimple/Generic.php @@ -86,7 +86,7 @@ class DbSimple_Generic * Choose database driver according to DSN. Return new instance * of this driver. */ - function& connect($dsn) + function connect($dsn) { // Load database driver and create its instance. $parsed = DbSimple_Generic::parseDSN($dsn); @@ -96,24 +96,15 @@ class DbSimple_Generic } $class = 'DbSimple_'.ucfirst($parsed['scheme']); if (!class_exists($class)) { - $file = str_replace('_', '/', $class) . ".php"; - // Try to load library file from standard include_path. - if ($f = @fopen($file, "r", true)) { - fclose($f); + $file = dirname(__FILE__).'/'.ucfirst($parsed['scheme']). ".php"; + if (is_file($file)) { require_once($file); } else { - // Wrong include_path; try to load from current directory. - $base = basename($file); - $dir = dirname(__FILE__); - if (@is_file($path = "$dir/$base")) { - require_once($path); - } else { - trigger_error("Error loading database driver: no file $file in include_path; no file $base in $dir", E_USER_ERROR); - return null; - } + trigger_error("Error loading database driver: no file $file", E_USER_ERROR); + return null; } } - $object =& new $class($parsed); + $object = new $class($parsed); if (isset($parsed['ident_prefix'])) { $object->setIdentPrefix($parsed['ident_prefix']); } @@ -130,7 +121,7 @@ class DbSimple_Generic function parseDSN($dsn) { if (is_array($dsn)) return $dsn; - $parsed = @parse_url($dsn); + $parsed = parse_url($dsn); if (!$parsed) return null; $params = null; if (!empty($parsed['query'])) { diff --git a/lib/DbSimple/Ibase.php b/lib/DbSimple/Ibase.php index 8fe15a0..6fb6e66 100644 --- a/lib/DbSimple/Ibase.php +++ b/lib/DbSimple/Ibase.php @@ -77,7 +77,7 @@ class DbSimple_Ibase extends DbSimple_Database $this->trans = @ibase_trans($parameters, $this->link); } - function& _performNewBlob($blobid=null) + function _performNewBlob($blobid=null) { return new DbSimple_Ibase_Blob($this, $blobid); } ----------------------------------------------------------------------- Summary of changes: lib/DbSimple/Connect.php | 6 ++++++ lib/DbSimple/Database.php | 2 +- lib/DbSimple/Generic.php | 23 +++++++---------------- lib/DbSimple/Ibase.php | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-14 19:53:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 05d5cc1d8028fa113adc899eb739308dee395b43 (commit) via 27777b75651a10394a1729a229c7b28cd51304d8 (commit) from ccd4b3c9746fbe737107664270f7e0475f3ba3e1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 05d5cc1d8028fa113adc899eb739308dee395b43 Author: Ivan Borzenkov <iva...@li...> Date: Thu Apr 14 23:48:19 2011 +0400 Константы определяются перед автолоадом diff --git a/QFW/Init.php b/QFW/Init.php index fd55071..3ea7dfc 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -1,19 +1,18 @@ <?php -//регаем автолоад -require_once QFWPATH.'/QuickFW/Autoload.php'; -Autoload::Init(); - //определяем пути относительно известных if (!defined('TMPPATH')) define('TMPPATH', VARPATH.'/tmp'); if (!defined('LOGPATH')) define('LOGPATH', VARPATH.'/log'); if (!defined('COMPATH')) - define ('COMPATH', APPPATH . '/_common'); + define ('COMPATH', APPPATH.'/_common'); if (!defined('MODPATH')) - define ('MODPATH', COMPATH . '/models'); + define ('MODPATH', COMPATH.'/models'); +//регаем автолоад +require_once QFWPATH.'/QuickFW/Autoload.php'; +Autoload::Init(); class QFW { diff --git a/cron/cruise.php b/cron/cruise.php index ae8f4e0..c7cc548 100644 --- a/cron/cruise.php +++ b/cron/cruise.php @@ -7,9 +7,10 @@ define ('LIBPATH', ROOTPATH . '/lib'); //Настройки по умолчанию, если нужно - измените -// define ('TMPPATH', VARPATH . '/tmp'); -// define ('LOGPATH', VARPATH . '/log'); -// define ('MODPATH', APPPATH . '/_common/models'); +// define ('TMPPATH', VARPATH . '/tmp'); +// define ('LOGPATH', VARPATH . '/log'); +// define ('COMPATH', APPPATH . '/_common'); +// define ('MODPATH', COMPATH . '/models'); if (empty($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = gethostname(); diff --git a/cron/start.php b/cron/start.php index 30ea766..48ac725 100644 --- a/cron/start.php +++ b/cron/start.php @@ -7,9 +7,10 @@ define ('LIBPATH', ROOTPATH . '/lib'); //Настройки по умолчанию, если нужно - измените -// define ('TMPPATH', VARPATH . '/tmp'); -// define ('LOGPATH', VARPATH . '/log'); -// define ('MODPATH', APPPATH . '/_common/models'); +// define ('TMPPATH', VARPATH . '/tmp'); +// define ('LOGPATH', VARPATH . '/log'); +// define ('COMPATH', APPPATH . '/_common'); +// define ('MODPATH', COMPATH . '/models'); if (empty($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = gethostname(); diff --git a/www/index.php b/www/index.php index 17b6317..9562d55 100644 --- a/www/index.php +++ b/www/index.php @@ -7,11 +7,11 @@ define ('LIBPATH', ROOTPATH . '/lib'); //Настройки по умолчанию, если нужно - измените -// define ('TMPPATH', VARPATH . '/tmp'); -// define ('LOGPATH', VARPATH . '/log'); -// define ('COMPATH', APPPATH . '/_common'); -// define ('MODPATH', COMPATH . '/models'); - +// define ('TMPPATH', VARPATH . '/tmp'); +// define ('LOGPATH', VARPATH . '/log'); +// define ('COMPATH', APPPATH . '/_common'); +// define ('MODPATH', COMPATH . '/models'); + require (QFWPATH.'/Init.php'); QFW::$router->route(); commit 27777b75651a10394a1729a229c7b28cd51304d8 Author: Ivan Borzenkov <iva...@li...> Date: Thu Apr 14 23:46:51 2011 +0400 Константа COMPATH diff --git a/QFW/Init.php b/QFW/Init.php index 3520217..fd55071 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -9,8 +9,10 @@ if (!defined('TMPPATH')) define('TMPPATH', VARPATH.'/tmp'); if (!defined('LOGPATH')) define('LOGPATH', VARPATH.'/log'); +if (!defined('COMPATH')) + define ('COMPATH', APPPATH . '/_common'); if (!defined('MODPATH')) - define ('MODPATH', APPPATH . '/_common/models'); + define ('MODPATH', COMPATH . '/models'); class QFW diff --git a/QFW/QuickFW/Autoload.php b/QFW/QuickFW/Autoload.php index 5e00e05..165ab67 100644 --- a/QFW/QuickFW/Autoload.php +++ b/QFW/QuickFW/Autoload.php @@ -109,12 +109,12 @@ class Autoload { if (strpos($class, 'Slot_') === 0) { - require APPPATH.'/_common/slots/'.substr($class, 5).'.php'; + require COMPATH.'/slots/'.substr($class, 5).'.php'; return true; } if (strpos($class, 'Tag_') === 0) { - require APPPATH.'/_common/tags/'.substr($class, 4).'.php'; + require COMPATH.'/tags/'.substr($class, 4).'.php'; return true; } return false; diff --git a/QFW/QuickFW/Cache.php b/QFW/QuickFW/Cache.php index 3f66fd0..b68c372 100644 --- a/QFW/QuickFW/Cache.php +++ b/QFW/QuickFW/Cache.php @@ -175,7 +175,7 @@ class Cache public static function slot($name) { require_once QFWPATH.'/QuickFW/Cacher/Slot.php'; - require_once APPPATH.'/_common/slots/'.$name.'.php'; + require_once COMPATH.'/slots/'.$name.'.php'; $args = func_get_args(); array_shift($args); $reflectionObj = new ReflectionClass('Slot_'.$name); @@ -191,7 +191,7 @@ class Cache public static function tag($name) { require_once QFWPATH.'/QuickFW/Cacher/Tag.php'; - require_once APPPATH.'/_common/tags/'.$name.'.php'; + require_once COMPATH.'/tags/'.$name.'.php'; $args = func_get_args(); array_shift($args); $reflectionObj = new ReflectionClass('Tag_'.$name); diff --git a/application/default/controllers/CssController.php b/application/default/controllers/CssController.php index d5f0651..1770ec7 100644 --- a/application/default/controllers/CssController.php +++ b/application/default/controllers/CssController.php @@ -17,7 +17,7 @@ class CssController public function __construct() { //$this->path = DOC_ROOT.'/css'; - $this->path = APPPATH.'/_common/css'; + $this->path = COMPATH.'/css'; } /** diff --git a/application/default/controllers/JsController.php b/application/default/controllers/JsController.php index fd772dc..c381f18 100644 --- a/application/default/controllers/JsController.php +++ b/application/default/controllers/JsController.php @@ -12,7 +12,7 @@ class JsController public function __construct() { //$this->path = DOC_ROOT.'/js'; - $this->path = APPPATH.'/_common/js'; + $this->path = COMPATH.'/js'; } /** diff --git a/doc/asciidoc/directory.txt b/doc/asciidoc/directory.txt index fba5414..80a103d 100644 --- a/doc/asciidoc/directory.txt +++ b/doc/asciidoc/directory.txt @@ -9,7 +9,7 @@ <HTTP_HOST>.php;; Здесь находятся настройки, специфичные для конкретного хоста, например подключение к тестовой/локальной базе данных или proxy для корректной работы Curl _common/;; - папка для общих моделей, слотов, тегов, и прочих ресурсов всего сайта + константа +COMPATH+ - папка для общих моделей, слотов, тегов, и прочих ресурсов всего сайта *default/*;; Здесь находится основной модуль на который передается управление controllers/::: diff --git a/tests/QFWTests.php b/tests/QFWTests.php index 12e4ac4..285af45 100644 --- a/tests/QFWTests.php +++ b/tests/QFWTests.php @@ -5,7 +5,8 @@ define ('VARPATH', ROOTPATH . '/vap'); define ('QFWPATH', ROOTPATH . '/QFW'); define ('LIBPATH', ROOTPATH . '/lib'); - define ('MODPATH', APPPATH . '/_common/models'); + define ('COMPATH', APPPATH . '/_common'); + define ('MODPATH', COMPATH . '/models'); $_SERVER['HTTP_HOST'] = 'test'; diff --git a/www/index.php b/www/index.php index 797f30d..17b6317 100644 --- a/www/index.php +++ b/www/index.php @@ -9,7 +9,8 @@ //Настройки по умолчанию, если нужно - измените // define ('TMPPATH', VARPATH . '/tmp'); // define ('LOGPATH', VARPATH . '/log'); -// define ('MODPATH', APPPATH . '/_common/models'); +// define ('COMPATH', APPPATH . '/_common'); +// define ('MODPATH', COMPATH . '/models'); require (QFWPATH.'/Init.php'); ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 11 ++++++----- QFW/QuickFW/Autoload.php | 4 ++-- QFW/QuickFW/Cache.php | 4 ++-- application/default/controllers/CssController.php | 2 +- application/default/controllers/JsController.php | 2 +- cron/cruise.php | 7 ++++--- cron/start.php | 7 ++++--- doc/asciidoc/directory.txt | 2 +- tests/QFWTests.php | 3 ++- www/index.php | 9 +++++---- 10 files changed, 28 insertions(+), 23 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-12 14:45:51
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via ccd4b3c9746fbe737107664270f7e0475f3ba3e1 (commit) from 627ae4c38d52c27683a3658f5ad41f79dc121a5a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ccd4b3c9746fbe737107664270f7e0475f3ba3e1 Author: Ivan Borzenkov <iva...@li...> Date: Tue Apr 12 18:44:52 2011 +0400 Удалил дублирование кода diff --git a/lib/Sitemap.php b/lib/Sitemap.php index d2cf104..b16100a 100644 --- a/lib/Sitemap.php +++ b/lib/Sitemap.php @@ -62,12 +62,9 @@ class Sitemap //Файл был не один - генерим индекс if ($this->curFileNum) { + //если у нас еще есть урлы для записи if ($this->last_urls != 50000) - { //если у нас еще есть урлы для записи - $this->curFileNum++; - file_put_contents(($this->gzip ? 'compress.zlib://' : ''). - $this->dir.'/'.$this->name.$this->curFileNum.'.'.($this->gzip ? 'gz' : 'xml'), $this->data.$this->foot); - } + $this->nextFile(); $index= '<?xml version="1.0" encoding="UTF-8"?>'."\n". '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n"; ----------------------------------------------------------------------- Summary of changes: lib/Sitemap.php | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-06 01:50:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, subroute has been deleted was ddc51b78706a466a33e92c911020a03f3444a15e ----------------------------------------------------------------------- ddc51b78706a466a33e92c911020a03f3444a15e Затирались бэкреврайты при втором вызове урла ----------------------------------------------------------------------- hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-06 01:33:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 627ae4c38d52c27683a3658f5ad41f79dc121a5a (commit) via 1478bf0b67e0c32c1bda16e828fba1a56be3f049 (commit) from cfe9bf0889c406aff8dc978d0fdc113e5ab27b38 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 627ae4c38d52c27683a3658f5ad41f79dc121a5a Author: Ivan Borzenkov <iva...@li...> Date: Wed Apr 6 05:33:23 2011 +0400 В доке описана подгрузка по требованию diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 6276000..1ac1f30 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -46,29 +46,35 @@ class QuickFW_Config implements ArrayAccess public function offsetGet($offset) { if ($this->dir && !isset($this->data[$offset])) + $this->data[$offset] = $this->loadFromFile($offset); + return $this->data[$offset]; + } + public function offsetExists($offset) { return isset($this->data[$offset]); } + public function offsetUnset($offset) { unset($this->data); } + + /** + * Пробуем загрузить файл из текущей директории + * + * @param string $name имя файла + * @return array|mixed|QuickFW_Config вложенный массив + */ + private function loadFromFile($name) + { + $file = $this->dir.'/'.$name.'.php'; + $data = array(); + if (is_file($file)) + $data = include($file); + if ($data == 1 && isset($config)) + $data = $config; + $hf = $this->dir.'/'.$name.'.'.$_SERVER['HTTP_HOST'].'.php'; + if (is_file($hf)) { - //пробуем загрузить файл - $file = $this->dir.'/'.$offset.'.php'; - $data = array(); - if (is_file($file)) - $data = include($file); + $data = include($hf); if ($data == 1 && isset($config)) $data = $config; - $hf = $this->dir.'/'.$offset.'.'.$_SERVER['HTTP_HOST'].'.php'; - if (is_file($hf)) - { - $data = include($hf); - if ($data == 1 && isset($config)) - $data = $config; - } - $this->data[$offset] = is_object($data) ? $data : ( - is_array($data) ? new self($data, $this->dir.'/'.$offset) : - $data); } - return $this->data[$offset]; + return is_array($data) ? new self($data, $this->dir.'/'.$name) : $data; } - public function offsetExists($offset) { return isset($this->data[$offset]); } - public function offsetUnset($offset) { unset($this->data); } //as prop public function __get($offset) { return $this->offsetGet($offset); } diff --git a/doc/asciidoc/config.txt b/doc/asciidoc/config.txt index 1b816ff..9dbd85c 100644 --- a/doc/asciidoc/config.txt +++ b/doc/asciidoc/config.txt @@ -5,12 +5,11 @@ Конфигурация может быть разбита на несколько файлов. Главный конфигурационный файл находится в папке приложения (+APPPATH+) и называется +default.php+, в нем должен быть определен массив $config В папаке +APPPATH/config+ могут находится произвольные файлы с расширением php, которые должны возвращать скаляр, массив или объект, реализующий интерфейс +ArrayAccess+ через оператор return или в переменной $config. При отсутствии в главном конфигурационном массиве элемента с указанным именем делается попытка подгрузить одноименный файл. -Так-же в +APPPATH/config+ могут находиться вложенные папки, которые считаются вложенным массивом. Таким образом иерархия файлов в папке проецируется на массив. Для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) - при запуске на этом хосте подгрузятся оба файла - сначало основной, а потом файл, специфичный для хоста. -.Пример +.Отклонения конфигов ===================================================================== +application/default.php+: @@ -60,3 +59,27 @@ return array( ===================================================================== +Так-же в +APPPATH/config+ могут находиться вложенные папки, которые считаются вложенным массивом. Таким образом иерархия файлов в папке проецируется на массив, однако файлы загружаются по требованию - нельзя получить сразу все вложенные файлы и папки - часть иерархии подгружается только при обращении к файлу. + +.Загрузка по требованию +===================================================================== ++application/config/dir/file.php+: +[source,php] +--------------------------------------------- +return 'param'; +--------------------------------------------- + +[source,php] +--------------------------------------------- + echo QFW::$config->dir."\n"; + echo QFW::$config->dir->file."\n"; + echo QFW::$config->dir."\n"; +--------------------------------------------- + +Результат: + + array() + param + array('file' => 'param', ) + +===================================================================== commit 1478bf0b67e0c32c1bda16e828fba1a56be3f049 Author: Ivan Borzenkov <iva...@li...> Date: Wed Apr 6 05:11:40 2011 +0400 Правка дока конфига и возможность возвращать скаляр в файле diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php index 29c4f90..6276000 100644 --- a/QFW/QuickFW/Config.php +++ b/QFW/QuickFW/Config.php @@ -13,7 +13,9 @@ class QuickFW_Config implements ArrayAccess // necessary for deep copies public function __clone() { - foreach ($this->data as $key => $value) if ($value instanceof self) $this[$key] = clone $value; + foreach ($this->data as $key => $value) + if ($value instanceof self) + $this[$key] = clone $value; } public function __construct(array $data = array(), $dir='') { @@ -59,7 +61,9 @@ class QuickFW_Config implements ArrayAccess if ($data == 1 && isset($config)) $data = $config; } - $this->data[$offset] = is_object($data) ? $data : new self($data, $this->dir.'/'.$offset); + $this->data[$offset] = is_object($data) ? $data : ( + is_array($data) ? new self($data, $this->dir.'/'.$offset) : + $data); } return $this->data[$offset]; } diff --git a/doc/asciidoc/config.txt b/doc/asciidoc/config.txt index 8594f6f..1b816ff 100644 --- a/doc/asciidoc/config.txt +++ b/doc/asciidoc/config.txt @@ -3,11 +3,12 @@ Для чтения конфигов используется переменная +QFW::$config+. Она представляет собой класс к которому можно обращаться как к массиву. Конфигурация может быть разбита на несколько файлов. Главный конфигурационный файл находится в папке приложения (+APPPATH+) и называется +default.php+, в нем должен быть определен массив $config -В папаке +APPPATH/config+ могут находится произвольные файлы с расширением php, которые должны возвращать массив или объект, реализующий интерфейс +ArrayAccess+ через оператор return или в переменной $config. +В папаке +APPPATH/config+ могут находится произвольные файлы с расширением php, которые должны возвращать скаляр, массив или объект, реализующий интерфейс +ArrayAccess+ через оператор return или в переменной $config. При отсутствии в главном конфигурационном массиве элемента с указанным именем делается попытка подгрузить одноименный файл. +Так-же в +APPPATH/config+ могут находиться вложенные папки, которые считаются вложенным массивом. Таким образом иерархия файлов в папке проецируется на массив. Для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) - -при запуске на этом осте подгрузятся оба файла - сначало основной, а потом файл, специфичный для хоста. +при запуске на этом хосте подгрузятся оба файла - сначало основной, а потом файл, специфичный для хоста. .Пример ===================================================================== ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Config.php | 44 +++++++++++++++++++++++++++----------------- doc/asciidoc/config.txt | 30 +++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 20 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-06 00:56:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via cfe9bf0889c406aff8dc978d0fdc113e5ab27b38 (commit) from 8fedff2c3a38b5b885efefee2263bd43828709cf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cfe9bf0889c406aff8dc978d0fdc113e5ab27b38 Author: Ivan Borzenkov <iva...@li...> Date: Wed Apr 6 04:56:06 2011 +0400 Убрал извраты с переменной-функцией diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index cf1b2ad..8b4a037 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -428,10 +428,7 @@ class QuickFW_Router if (is_array($this->$type)) return preg_replace(array_keys($this->$type), array_values($this->$type), $uri); if (is_callable($this->$type)) - { - $f = $this->$type; - return $f($uri); - } + return call_user_func($this->$type, $uri); return $uri; } ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Router.php | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-06 00:51:40
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 8fedff2c3a38b5b885efefee2263bd43828709cf (commit) from d1771c436ef9b264a6a797b4fc611990fe200cdd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8fedff2c3a38b5b885efefee2263bd43828709cf Author: Ivan Borzenkov <iva...@li...> Date: Wed Apr 6 04:51:16 2011 +0400 Ненужный вызов в саброутинге diff --git a/QFW/sub.php b/QFW/sub.php index a584062..47c3ec1 100644 --- a/QFW/sub.php +++ b/QFW/sub.php @@ -13,9 +13,6 @@ class QFW extends \QFW */ static public function Init() { - //подключаем модули и библиотеки - self::modules(); - static::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); } diff --git a/application/default/test/sub.php b/application/default/test/sub.php index 5aea2db..f20b564 100644 --- a/application/default/test/sub.php +++ b/application/default/test/sub.php @@ -13,9 +13,6 @@ class QFW extends \QFW */ static public function Init() { - //подключаем модули и библиотеки - self::modules(); - static::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); } ----------------------------------------------------------------------- Summary of changes: QFW/sub.php | 3 --- application/default/test/sub.php | 3 --- 2 files changed, 0 insertions(+), 6 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-04-06 00:45:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via d1771c436ef9b264a6a797b4fc611990fe200cdd (commit) via 6db6b54eff8d6ac05222b6497b9e1e08838f35d6 (commit) via 8e0852e4d9dcdcbf7f63589de00a158b984f51e3 (commit) via a994588847722669dc3900cc09f36b9fa36a9ed8 (commit) via 824d104f79952baa5c21c6e221eb4b222b133302 (commit) via 1f333820cb135f7fcc92c478cb9b87abd05491a6 (commit) via 3e01d725a95deaf4fe497ee074888af284474fdc (commit) from 93f6097f71fe7436238251a564a3afcbe7a924e2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d1771c436ef9b264a6a797b4fc611990fe200cdd Author: Ivan Borzenkov <iva...@li...> Date: Wed Apr 6 04:42:46 2011 +0400 Настройка сессии - фикс после класса конфига diff --git a/QFW/QuickFW/Session.php b/QFW/QuickFW/Session.php index 4ce813a..aa11ee7 100644 --- a/QFW/QuickFW/Session.php +++ b/QFW/QuickFW/Session.php @@ -142,7 +142,7 @@ class QuickFW_Session */ public function __construct($sid = '') { - call_user_func_array('session_set_cookie_params', QFW::$config['session']); + call_user_func_array('session_set_cookie_params', QFW::$config['session']->toArray()); if (!empty($sid)) session_id($sid); $this->start(); commit 6db6b54eff8d6ac05222b6497b9e1e08838f35d6 Author: Ivan Borzenkov <iva...@li...> Date: Fri Mar 18 16:21:04 2011 +0300 Загрзка конфигов и помощью класса, директория с конфигами diff --git a/QFW/Init.php b/QFW/Init.php index a425821..3520217 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -58,7 +58,7 @@ class QFW $file = APPPATH.'/'.$_SERVER['HTTP_HOST'].'.php'; if (is_file($file)) require ($file); - return $config; + return new QuickFW_Config($config, APPPATH.'/config'); } /** diff --git a/QFW/QuickFW/Config.php b/QFW/QuickFW/Config.php new file mode 100644 index 0000000..29c4f90 --- /dev/null +++ b/QFW/QuickFW/Config.php @@ -0,0 +1,75 @@ +<?php + +/** + * Класс для работы с конфигом + */ +class QuickFW_Config implements ArrayAccess +{ + private $data = array(); + /** + * @var string Директория конфигурации + */ + private $dir = ''; + + // necessary for deep copies + public function __clone() { + foreach ($this->data as $key => $value) if ($value instanceof self) $this[$key] = clone $value; + } + + public function __construct(array $data = array(), $dir='') { + foreach ($data as $key => $value) $this[$key] = $value; + $this->dir = $dir; + } + + public function offsetSet($offset, $data) { + if (is_array($data)) $data = new self($data, true); + if ($offset === null) { // don't forget this! + $this->data[] = $data; + } else { + $this->data[$offset] = $data; + } + } + + public function toArray() { + $data = $this->data; + foreach ($data as $key => $value) + if ($value instanceof self) + $data[$key] = $value->toArray(); + return $data; + } + + public function __toString() { + return var_export($this->data, true); + } + + public function offsetGet($offset) { + if ($this->dir && !isset($this->data[$offset])) + { + //пробуем загрузить файл + $file = $this->dir.'/'.$offset.'.php'; + $data = array(); + if (is_file($file)) + $data = include($file); + if ($data == 1 && isset($config)) + $data = $config; + $hf = $this->dir.'/'.$offset.'.'.$_SERVER['HTTP_HOST'].'.php'; + if (is_file($hf)) + { + $data = include($hf); + if ($data == 1 && isset($config)) + $data = $config; + } + $this->data[$offset] = is_object($data) ? $data : new self($data, $this->dir.'/'.$offset); + } + return $this->data[$offset]; + } + public function offsetExists($offset) { return isset($this->data[$offset]); } + public function offsetUnset($offset) { unset($this->data); } + + //as prop + public function __get($offset) { return $this->offsetGet($offset); } + public function __set($offset, $data) { return $this->offsetSet($offset, $data); } + public function __isset($offset) { return $this->offsetExists($offset); } + public function __unset($offset) { return $this->offsetUnset($offset); } + +} diff --git a/application/config/.gitignore b/application/config/.gitignore new file mode 100644 index 0000000..07b8b66 --- /dev/null +++ b/application/config/.gitignore @@ -0,0 +1,2 @@ +# config dir +.gitignore diff --git a/doc/asciidoc/Makefile b/doc/asciidoc/Makefile index f39af5f..c430a80 100644 --- a/doc/asciidoc/Makefile +++ b/doc/asciidoc/Makefile @@ -1,6 +1,6 @@ all: pdf html -FILES = quickfw general quickstart directory mvc blocks templates cache auth autoload helpers features +FILES = quickfw general quickstart directory mvc blocks templates cache auth autoload config helpers features TEXTS = $(addsuffix .txt, $(FILES) ) pdf: quickfw.pdf diff --git a/doc/asciidoc/autoload.txt b/doc/asciidoc/autoload.txt index c28ae71..4b574b0 100644 --- a/doc/asciidoc/autoload.txt +++ b/doc/asciidoc/autoload.txt @@ -1,9 +1,7 @@ Автолоад -------- -Есть возможность опционально включить автолоад классов. - -Параметр +QFW::$config[\'QFW'][\'autoload']+ по умолчанию имеет значение +false+. +Начиная с версии 2.0 автолоад классов включен и его нельзя отключить. Имя файла совпадает с именем класса, символ +_+ заменяется на +/+. diff --git a/doc/asciidoc/config.txt b/doc/asciidoc/config.txt new file mode 100644 index 0000000..8594f6f --- /dev/null +++ b/doc/asciidoc/config.txt @@ -0,0 +1,61 @@ +Конфигурация +------------ + +Для чтения конфигов используется переменная +QFW::$config+. Она представляет собой класс к которому можно обращаться как к массиву. +Конфигурация может быть разбита на несколько файлов. Главный конфигурационный файл находится в папке приложения (+APPPATH+) и называется +default.php+, в нем должен быть определен массив $config +В папаке +APPPATH/config+ могут находится произвольные файлы с расширением php, которые должны возвращать массив или объект, реализующий интерфейс +ArrayAccess+ через оператор return или в переменной $config. +При отсутствии в главном конфигурационном массиве элемента с указанным именем делается попытка подгрузить одноименный файл. + +Для каждого конфигурационного файла можно сделать "отклонения" добавив к имени файла суффикс с именем хоста (+$_SERVER[\'HTTP_HOST']+) - +при запуске на этом осте подгрузятся оба файла - сначало основной, а потом файл, специфичный для хоста. + +.Пример +===================================================================== ++application/default.php+: + +[source,php] +--------------------------------------------- +$config = array( + 'database' => 'mysql://myuser:mypass@localhost/mybase', +); +--------------------------------------------- + ++application/default.site.my.php+: + +[source,php] +--------------------------------------------- +$config = array( + 'database' => 'mysql://root@localhost/mybase', +); +--------------------------------------------- + ++application/config/capcha.php+: + +[source,php] +--------------------------------------------- +return array( + 'key' => 'PRODKEY', +); +--------------------------------------------- + ++application/config/capcha.site.my.php+: + +[source,php] +--------------------------------------------- +return array( + 'key' => 'DEVKEY', +); +--------------------------------------------- + +Результат: + + QFW::$config->database == 'mysql://myuser:mypass@localhost/mybase' + QFW::$config->capcha->key == 'PRODKEY' + +Результат на site.my: + + QFW::$config->database == 'mysql://root@localhost/mybase' + QFW::$config->capcha->key == 'DEVKEY' + +===================================================================== + diff --git a/doc/asciidoc/directory.txt b/doc/asciidoc/directory.txt index d01b0d0..fba5414 100644 --- a/doc/asciidoc/directory.txt +++ b/doc/asciidoc/directory.txt @@ -26,6 +26,8 @@ Основной шаблон страницы по умолчанию [...]/;; директории модулей совпадающие по структуре с каталогом +default+ + config/;; + директория с конфигами - подразделы конфига *cron*:: Скрипты для запуска не через http cruise.php;; diff --git a/doc/asciidoc/quickfw.txt b/doc/asciidoc/quickfw.txt index 0fe9ffc..178dd6f 100644 --- a/doc/asciidoc/quickfw.txt +++ b/doc/asciidoc/quickfw.txt @@ -21,6 +21,8 @@ include::auth.txt[] include::autoload.txt[] +include::config.txt[] + include::helpers.txt[] include::features.txt[] commit 8e0852e4d9dcdcbf7f63589de00a158b984f51e3 Author: Ivan Borzenkov <iva...@li...> Date: Fri Mar 18 15:14:48 2011 +0300 Используем автолоад, всегда diff --git a/QFW/Init.php b/QFW/Init.php index 6a23418..a425821 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -1,5 +1,18 @@ <?php +//регаем автолоад +require_once QFWPATH.'/QuickFW/Autoload.php'; +Autoload::Init(); + +//определяем пути относительно известных +if (!defined('TMPPATH')) + define('TMPPATH', VARPATH.'/tmp'); +if (!defined('LOGPATH')) + define('LOGPATH', VARPATH.'/log'); +if (!defined('MODPATH')) + define ('MODPATH', APPPATH . '/_common/models'); + + class QFW { /** @var array Глобальный массив данных */ @@ -56,15 +69,11 @@ class QFW { self::$config = self::config(); - require_once QFWPATH.'/QuickFW/Cache.php'; - require_once QFWPATH.'/QuickFW/Plugs.php'; - //выставляем заголовок с нужной кодировкой if (!empty(self::$config['host']['encoding'])) header("Content-Type: text/html; charset=".self::$config['host']['encoding']); //Инициализируем класс базы данных - require_once LIBPATH.'/DbSimple/Connect.php'; self::$db = new DbSimple_Connect(self::$config['database']); //Подключаем шаблонизатор @@ -77,11 +86,9 @@ class QFW //подключаем модули и библиотеки self::modules(); - require_once QFWPATH.'/QuickFW/Router.php'; static::$router = new QuickFW_Router(APPPATH); //хелпер для урлов (зависит от QuickFW_Router) - require_once QFWPATH.'/QuickFW/Url.php'; Url::Init(); } @@ -96,24 +103,18 @@ class QFW foreach(self::$config['error'] as $handler) self::ErrorFromConfig($handler); - //автолоад - if (!empty(self::$config['QFW']['autoload'])) - { - require_once QFWPATH.'/QuickFW/Autoload.php'; - Autoload::Init(self::$config['QFW']['autoload']); - } + if (self::$config['QFW']['autoload']) + Autoload::Add(self::$config['QFW']['autoload']); //JsHttpRequest if (isset($_REQUEST['JsHttpRequest'])) { - require_once LIBPATH.'/JsHttpRequest.php'; self::$ajax = new JsHttpRequest(self::$config['host']['encoding']); //устанавливаем пустой главный шаблон self::$view->mainTemplate = ''; } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { - require_once LIBPATH.'/jquery.php'; self::$ajax = new jQuery(); //устанавливаем пустой главный шаблон self::$view->mainTemplate = ''; @@ -136,12 +137,12 @@ class QFW */ static private function ErrorFromConfig($handler) { - require_once LIBPATH.'/Debug/ErrorHook/Listener.php'; + //require_once LIBPATH.'/Debug/ErrorHook/Listener.php'; if (!self::$ErrorHook) self::$ErrorHook = new Debug_ErrorHook_Listener();; $name = ucfirst($handler['name']); - require_once LIBPATH.'/Debug/ErrorHook/'.$name.'Notifier.php'; + //require_once LIBPATH.'/Debug/ErrorHook/'.$name.'Notifier.php'; //пока так, потом возможно придется переделать { $class = 'Debug_ErrorHook_'.$name.'Notifier'; @@ -151,7 +152,7 @@ class QFW } if ($handler['RemoveDups']) { - require_once LIBPATH.'/Debug/ErrorHook/RemoveDupsWrapper.php'; + //require_once LIBPATH.'/Debug/ErrorHook/RemoveDupsWrapper.php'; $i = new Debug_ErrorHook_RemoveDupsWrapper($i, TMPPATH.'/errors', $handler['RemoveDups']); } @@ -192,7 +193,7 @@ class QFW */ static public function JabberFromConfig() { - require_once LIBPATH.'/XMPPHP/XMPP.php'; + //require_once LIBPATH.'/XMPPHP/XMPP.php'; return new XMPPHP_XMPP( QFW::$config['jabber']['host'], QFW::$config['jabber']['port'], QFW::$config['jabber']['user'], QFW::$config['jabber']['pass'], @@ -202,13 +203,6 @@ class QFW } -if (!defined('TMPPATH')) - define('TMPPATH', VARPATH.'/tmp'); -if (!defined('LOGPATH')) - define('LOGPATH', VARPATH.'/log'); -if (!defined('MODPATH')) - define ('MODPATH', APPPATH . '/_common/models'); - QFW::Init(); ?> diff --git a/QFW/QuickFW/Autoload.php b/QFW/QuickFW/Autoload.php index f9b5704..5e00e05 100644 --- a/QFW/QuickFW/Autoload.php +++ b/QFW/QuickFW/Autoload.php @@ -10,15 +10,27 @@ class Autoload /** * Инициализация автолоада * - * @param string|boolean $function имя дополнительной функции */ - static public function Init($function = false) + static public function Init() { spl_autoload_register(array(__CLASS__, 'Bind')); + spl_autoload_register(array(__CLASS__, 'Main')); spl_autoload_register(array(__CLASS__, 'Dirs')); spl_autoload_register(array(__CLASS__, 'Controller')); spl_autoload_register(array(__CLASS__, 'SlotsAndTags')); - if (is_callable($function)) + } + + /** + * добавление функции автолоада + * + * @param string|array $function имя дополнительной функции + */ + static public function Add($function = false) + { + if (is_array($function)) + foreach($function as $f) + self::Add($f); + elseif (is_callable($function)) spl_autoload_register($function); } @@ -49,6 +61,22 @@ class Autoload } /** + * Классы фреймворка + * + * <br>Так получилось, что эти классы находятся тут + * + * @param string $class искомый класс + */ + static public function Main($class) + { + if (mb_strpos($class, 'QuickFW') === false) + return false; + $class = strtr($class,'_','/'); + require QFWPATH.'/'.$class.'.php'; + return true; + } + + /** * Автолоад некоторых стандартных классов * * <br>Так получилось, что эти классы находятся тут @@ -60,7 +88,8 @@ class Autoload if (empty(self::$classes)) self::$classes = array( 'ScaffoldController' => LIBPATH.'/Modules/Scaffold/ScaffoldController.php', - 'QuickFW_Auth' => QFWPATH.'/QuickFW/Auth.php', + 'Url' => QFWPATH.'/QuickFW/Url.php', + 'Cache' => QFWPATH.'/QuickFW/Cache.php', 'Hlp' => QFWPATH.'/QuickFW/Helpers.php', 'Dklab_Cache_Frontend_Slot' => QFWPATH.'/QuickFW/Cacher/Slot.php', 'Dklab_Cache_Frontend_Tag' => QFWPATH.'/QuickFW/Cacher/Tag.php', diff --git a/QFW/config.php b/QFW/config.php index 7dd0e6e..708514c 100644 --- a/QFW/config.php +++ b/QFW/config.php @@ -34,7 +34,7 @@ $config['redirection']=array( $config['QFW'] = array( 'release' => false, /* статус проекта на данном хосте - отладка и всякие быстрые компиляции */ 'cacheSessions' => false, /* Хранить сессии в кеше, не использовать стандартный механизм */ - 'autoload' => true, /* включить автолоад false|true|string */ + 'autoload' => false, /* Функция для дополнительного автолоада */ 'auto404' => false, /* не перенаправлять на дефолтовый контроллер все запросы */ 'main404' => false, /* 404 страница в дизайне main */ 'addCSSXml' => false, /* addJS и addCSS выводят теги в XML */ diff --git a/application/default.php b/application/default.php index e24e60e..63c8d19 100644 --- a/application/default.php +++ b/application/default.php @@ -81,7 +81,7 @@ $config['cache'] = array( $config['QFW'] = array( 'release' => false, /* статус проекта на данном хосте - отладка и всякие быстрые компиляции */ 'cacheSessions' => false, /* Хранить сессии в кеше, не использовать стандартный механизм */ - 'autoload' => true, /* включить автолоад false|true|string */ + 'autoload' => false, /* Функция для дополнительного автолоада */ 'auto404' => false, /* не перенаправлять на дефолтовый контроллер все запросы */ 'main404' => false, /* 404 страница в дизайне main */ 'addCSSXml' => false, /* addJS и addCSS выводят теги в XML */ diff --git a/lib/jquery.php b/lib/jQuery.php similarity index 100% rename from lib/jquery.php rename to lib/jQuery.php commit a994588847722669dc3900cc09f36b9fa36a9ed8 Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 17 13:18:11 2011 +0300 Другой формат пагинатора diff --git a/application/helper/controllers/NavController.php b/application/helper/controllers/NavController.php index 7673245..fd2f44d 100644 --- a/application/helper/controllers/NavController.php +++ b/application/helper/controllers/NavController.php @@ -15,19 +15,39 @@ class NavController * @param string $name Имя шаблона пагинатора * @return string Сформированный пагинатор */ - public function pagerBlock($url='$', $all=0, $cur=1, $size=5, $name='pager') + public function pagerBlock($url='$', $all=0, $cur=1, $name='pager') { if ($all<2) return ''; QFW::$view->assign('pager',array( 'all'=>$all, 'c'=>$cur, 'url'=>$url, - 'size'=>$size, )); return QFW::$view->fetch('pager/'.$name.'.php'); } /** + * Пагинатор + * + * <br>готовый пейджинатор с несколькими шаблонами + * которому указывается урл и с какого элемента считать и сколько элементов + * + * @param string $url Шаблон урла, номер страницы заменен $ + * @param int $from с какого элемента + * @param int $items сколько элементов + * @param int $size По сколько отображать на странице + * @param string $name Имя шаблона пагинатора + * @return string + */ + public function pagerFromBlock($url='$', $from, $items=0, $size = 10, $name='pager') + { + $all = ceil($items / $size); + $cur = ceil($from / $size); + return $this->pagerBlock($url, $all, $cur, $name); + } + + + /** * Древоводное меню на вложенными списками * * @param array $items Массив элементов: diff --git a/application/helper/templates/pager/pager2.php b/application/helper/templates/pager/pager2.php index 984e3ab..0d78b02 100644 --- a/application/helper/templates/pager/pager2.php +++ b/application/helper/templates/pager/pager2.php @@ -1,9 +1,9 @@ <!-- Pageslist --> <div class="pageslist"> - <?php - $first = $pager['c'] - $pager['size']; + <?php $ps = 10; + $first = $pager['c'] - $ps; if($first<1) $first = 1; - $last = $pager['c'] + $pager['size']; + $last = $pager['c'] + $ps; if($last>$pager['all']) $last = $pager['all']; if ($first>1):?> commit 824d104f79952baa5c21c6e221eb4b222b133302 Author: Ivan Borzenkov <iva...@li...> Date: Fri Mar 11 16:16:49 2011 +0300 Правки TrueValidation diff --git a/lib/Language.php b/lib/Language.php index 1180379..6a9420a 100644 --- a/lib/Language.php +++ b/lib/Language.php @@ -116,6 +116,3 @@ class Language { } } -// END Language Class -QFW::$libs['lang'] = new Language(); -?> \ No newline at end of file diff --git a/lib/True_validation.php b/lib/True_validation.php index 4989b5d..9658b04 100644 --- a/lib/True_validation.php +++ b/lib/True_validation.php @@ -8,9 +8,8 @@ class True_Validation { var $_errors = array(); //Массив ошибок var $_error_messages = array();//Собственные сообщения об ошибках - function True_Validation() { + function __construct() { $this->init(); - require_once(LIBPATH.'/Language.php'); } function init() { @@ -19,6 +18,13 @@ class True_Validation { $this->_fields = array(); } + function set($name, $field, $rules, $data=null) { + $this->_fields[$name] = $field; + $this->_rules[$name] = $rules; + if ($data !== null) + $this->_data[$name] = $data; + } + function set_data($data = '') { if ($data == '') { return FALSE; @@ -87,7 +93,7 @@ class True_Validation { } // Load the language file containing error messages - QFW::$libs['lang']->load('true_validation'); + QFW::$libs['lang'] = new Language(); // Cycle through the rules and test for errors foreach ($this->_rules as $field => $rules) { @@ -466,6 +472,3 @@ class True_Validation { } } -// END Validation Class -QFW::$libs['true_validation'] = new True_Validation(); -?> \ No newline at end of file commit 1f333820cb135f7fcc92c478cb9b87abd05491a6 Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 10 17:46:52 2011 +0300 Для слота добавлен вызов лямда функции diff --git a/QFW/QuickFW/Cacher/Slot.php b/QFW/QuickFW/Cacher/Slot.php index 6ac8e45..c8beba0 100644 --- a/QFW/QuickFW/Cacher/Slot.php +++ b/QFW/QuickFW/Cacher/Slot.php @@ -130,6 +130,28 @@ abstract class Dklab_Cache_Frontend_Slot return new Dklab_Cache_Frontend_Slot_Thru($this, $obj); } + /** + * Call a function with transparent caching. + * Usage: + * $slot = new SomeSlot(...); + * $data = $slot->get(function() use(...){ + * ... + * }); + * // calls lamda function() with intermediate caching + * + * @param Closure $obj function + * @return mixed result + */ + public function get($function) + { + $result = $this->load(); + if ($result === false) { + $result = $function(); + $this->save($result); + } + return $result; + } + /** * Returns backend object responsible for this cache slot. commit 3e01d725a95deaf4fe497ee074888af284474fdc Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 10 17:05:26 2011 +0300 Нотайс в симпле diff --git a/lib/DbSimple/Sqlite.php b/lib/DbSimple/Sqlite.php index 99db8a6..ec79cc4 100644 --- a/lib/DbSimple/Sqlite.php +++ b/lib/DbSimple/Sqlite.php @@ -30,7 +30,7 @@ class DbSimple_Sqlite extends DbSimple_Database $err = ''; try { - $this->link = sqlite_factory($dsn['path'], 0666, &$err); + $this->link = sqlite_factory($dsn['path'], 0666, $err); } catch (Exception $e) { ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 46 ++++++-------- QFW/QuickFW/Autoload.php | 37 ++++++++++- QFW/QuickFW/Cacher/Slot.php | 22 ++++++ QFW/QuickFW/Config.php | 75 ++++++++++++++++++++++ QFW/QuickFW/Session.php | 2 +- QFW/config.php | 2 +- application/config/.gitignore | 2 + application/default.php | 2 +- application/helper/controllers/NavController.php | 24 ++++++- application/helper/templates/pager/pager2.php | 6 +- doc/asciidoc/Makefile | 2 +- doc/asciidoc/autoload.txt | 4 +- doc/asciidoc/config.txt | 61 ++++++++++++++++++ doc/asciidoc/directory.txt | 2 + doc/asciidoc/quickfw.txt | 2 + lib/DbSimple/Sqlite.php | 2 +- lib/Language.php | 3 - lib/True_validation.php | 15 +++-- lib/{jquery.php => jQuery.php} | 0 19 files changed, 257 insertions(+), 52 deletions(-) create mode 100644 QFW/QuickFW/Config.php create mode 100644 application/config/.gitignore create mode 100644 doc/asciidoc/config.txt rename lib/{jquery.php => jQuery.php} (100%) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-03-03 15:08:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via 93f6097f71fe7436238251a564a3afcbe7a924e2 (commit) via f29016c53f0c03a9a209b0dd7ff47f3b04396cdb (commit) via a0c11a5c296371ab2819e8b1556ef1c94cd6b29f (commit) via 0bf48b6d8435bbcbc030ba6dfe43aa160001090e (commit) via 7bf0a288e1b89abdbb3f78e89e84322cb65b4f34 (commit) via eda3035492dde52dc149ee684fe66d708a098148 (commit) via 9bd67ba7dbb13640c9eb73cc955bab1bb37f854c (commit) via ab24b811da9cf5909bdcd733824be57740e34515 (commit) via ddc51b78706a466a33e92c911020a03f3444a15e (commit) via 844e5d9135d0e5baad2fd2ff667c003b2f3805f5 (commit) via 3b280697d53c0e941d0e4c1fc023ff60b94b4825 (commit) via c8ca0b1275839a5868a1670479e48a9ceb399dd0 (commit) via 50750d384def8db6b9d5b703d5cbd15b278fa03f (commit) via 21a82c9f77672df4c1b869977faa25742c40150e (commit) via 8781ae85d90778b82e454c0cabe2a18c08f6bc0b (commit) via 45e8b4959e5609038d6c532f3ddf67754a25e52b (commit) via 0e4f07232acdf83e257a8a0127cfff4380a1292b (commit) via 0f487adea48a7d7b74c3efdc0b27c765520d678b (commit) via 22050b0340cc4b514164dc12ae9b0bbbc5b3967a (commit) via b218d313da1a51454d63cae0d48ed6b2c8961cb5 (commit) from bdb96f73364b68aefecf116c1cd850f953036515 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 93f6097f71fe7436238251a564a3afcbe7a924e2 Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 3 17:53:48 2011 +0300 Упрощение в хелпере diff --git a/QFW/QuickFW/Helpers.php b/QFW/QuickFW/Helpers.php index b8539a3..0c23dee 100644 --- a/QFW/QuickFW/Helpers.php +++ b/QFW/QuickFW/Helpers.php @@ -88,8 +88,7 @@ class Hlp } if ($content===true) { - $content=ob_get_contents(); - ob_end_clean(); + $content=ob_get_clean(); } $k = '<!--HEAD'.$name.'-->'; commit f29016c53f0c03a9a209b0dd7ff47f3b04396cdb Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 3 13:04:21 2011 +0300 Очепятка :) diff --git a/lib/utils.php b/lib/utils.php index cbe6f44..f03f08d 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -78,7 +78,7 @@ function checkUrl($url) '!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?:/[a-zа-я0-9.,_@%&'. '\[\]?+:=\~/"\'\(\)-]*)?(?:#[^ \'"&<>]*)?$~iu',$url,$ok)) return false; // если не правильно - выход - // если нет протокала - добавить + // если нет протокола - добавить if (strpos($url, '://') === false) $url='http://'.$url; return $url; commit a0c11a5c296371ab2819e8b1556ef1c94cd6b29f Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 3 12:44:06 2011 +0300 Немного привел в порядок функции diff --git a/lib/Text.php b/lib/Text.php index 68d8990..16e1b0d 100644 --- a/lib/Text.php +++ b/lib/Text.php @@ -33,9 +33,14 @@ class Text } /** - * Обрезка текста + * Обрезает длинные строки + * + * @param string $str Строка + * @param integer $size длина, до которой обрезать + * @param bool $word Обрезать по словам + * @return string Обрезанная строка */ - static public function my_trim($str, $size, $word=false) + static public function myTrim($str, $size, $word=false) { if (mb_strlen($str)<=$size) return $str; @@ -49,7 +54,6 @@ class Text return $str; } - /** * Печать размера файла в форматированном виде */ @@ -63,6 +67,59 @@ class Text } /** + * Вывод сообщения с разбивкой длинных слов без повреждения тегов + * + * @param string $msg собщение, в котором нужно разбить слова + * @param integer $n длина, на которой ставить пробел + * @return string сообщение со словами, не превышающими n символов + */ + static public function msg2html($msg, $n=50) + { + $marker = " <> "; + + # Сохраняем все тэги чтобы уберечь их от разбивки + preg_match_all("/(<.*?>)/si",$msg,$tags); + + # Заменяем все тэги на маркеры + $msg = preg_replace("/(<.*?>)/si", $marker, $msg); + + $msg = preg_replace('|\S{'.$n.'}|u','\0 ',$msg); + + # Восстанавливаем тэги в места которых были отмечены маркерами + for ($i=0; $i<count($tags[0]); $i++) + $msg = preg_replace("/$marker/si", $tags[1][$i], $msg, 1); + + return $msg; + } + + /** + * Преобразование URL в ссылки + */ + static public function make_urls($string) + { + $p = '/((?:(?:ht|f)tps?:\/\/|www\.)[^<\s\n]+)(?<![]\.,:;!\})<-])/msiu'; + $r = '<a href="$1">$1</a>$2'; + + $string = preg_replace($p, $r, $string); + + $p = '/ href="www\./msiu'; + $r = ' href="http://www.'; + + return preg_replace($p, $r, $string); + } + + /** + * Генерирует урл из текста - убирает / и применяет urlencode + * + * @param string $text + * @return string + */ + static public function genUrl($text) + { + return rawurlencode(str_replace(array('/', ' '), '-', $text)); + } + + /** * Формирование даты по-русски * <br>так как при выстановке локали неправильно склоняет * @@ -97,6 +154,12 @@ class Text return strtr(date($format, $time!==false ? $time : time()), $translation); } + /** + * Формирует из timestamp строку времяни + * + * @param integer $ts timestamp + * @return string строка - сколько времени назад + */ static public function date_ago($ts) { $dif = time() - $ts; diff --git a/lib/utils.php b/lib/utils.php index 46bad18..cbe6f44 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -85,63 +85,6 @@ function checkUrl($url) } /** - * Вывод сообщения с разбивкой длинных слов без повреждения тегов - * - * @param string $msg собщение, в котором нужно разбить слова - * @param integer $n длина, на которой ставить пробел - * @return string сообщение со словами, не превышающими n символов - */ -function msg2html($msg, $n=50) -{ - $marker = " <> "; - - # Сохраняем все тэги чтобы уберечь их от разбивки - preg_match_all("/(<.*?>)/si",$msg,$tags); - - # Заменяем все тэги на маркеры - $msg = preg_replace("/(<.*?>)/si", $marker, $msg); - - $msg = preg_replace('|\S{'.$n.'}|u','\0 ',$msg); - - # Восстанавливаем тэги в места которых были отмечены маркерами - for ($i=0; $i<count($tags[0]); $i++) - $msg = preg_replace("/$marker/si", $tags[1][$i], $msg, 1); - - return $msg; -} - -/** - * Преобразование URL в ссылки - */ -function make_urls($string) -{ - $p = '/((?:(?:ht|f)tps?:\/\/|www\.)[^<\s\n]+)(?<![]\.,:;!\})<-])/msiu'; - $r = '<a href="$1">$1</a>$2'; - - $string = preg_replace($p, $r, $string); - - $p = '/ href="www\./msiu'; - $r = ' href="http://www.'; - - return preg_replace($p, $r, $string); -} - -/** - * Обрезает длинные строки, не разрывая последнее слово - * - * @param string $str строка, которую нужно обрезать - * @param integer $size до скольки знаков - */ -function clearCut($str, $size) -{ - if(mb_strlen($str) <= $size) - return $str; - - $words = explode(' ', mb_substr($str, 0, $size)); - return implode(' ', array_slice($words, 0, count($words)-1)).'...'; -} - -/** * Выдает несколько неповторяющихся случайных значений */ function n_rand($min, $max, $count) @@ -295,16 +238,3 @@ function password_sailt($pass) { return md5($pass.QFW::$config['pass_sailt']); } - -/** - * Генерирует урл из текста - убирает / и применяет urlencode - * - * @param string $text - * @return string - */ -function genUrl($text) -{ - return rawurlencode(str_replace(array('/', ' '), '-', $text)); -} - -?> commit 0bf48b6d8435bbcbc030ba6dfe43aa160001090e Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 3 12:31:33 2011 +0300 Очепятка diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php index 4643d3b..a2da74b 100644 --- a/QFW/Templater/Templater.php +++ b/QFW/Templater/Templater.php @@ -18,12 +18,12 @@ abstract class Templater /** @var String Основной шаблон (путь относительно директории шаблонов) */ public $mainTemplate; - public function __construct($tmplPath, $mainTmpl) + public function __construct($tplPath, $mainTpl) { $this->_vars = array(); - $this->_tmplPath = $tmplPath; + $this->_tmplPath = $tplPath; $this->P = QuickFW_Plugs::getInstance(); - $this->mainTemplate = $mainTmpl; + $this->mainTemplate = $mainTpl; } public function __get($name) commit 7bf0a288e1b89abdbb3f78e89e84322cb65b4f34 Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 3 12:26:48 2011 +0300 Добавлены магические __get и __set в шаблонизатор diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php index 6fea9da..4643d3b 100644 --- a/QFW/Templater/Templater.php +++ b/QFW/Templater/Templater.php @@ -26,6 +26,16 @@ abstract class Templater $this->mainTemplate = $mainTmpl; } + public function __get($name) + { + return $this->getTemplateVars($name); + } + + public function __set($name, $value) + { + $this->assign($name, $value); + } + /** * Присваение значения переменной шаблона * commit eda3035492dde52dc149ee684fe66d708a098148 Author: Ivan Borzenkov <iva...@li...> Date: Thu Mar 3 12:14:57 2011 +0300 Удаление старого кода diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index c48e249..cf1b2ad 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -206,9 +206,7 @@ class QuickFW_Router { $data = array_slice($patt,1,3); $MCA = $this->loadMCA($data,'Block'); - // Если вы все еще сидите на PHP 5.2 то раскомментируйте старый вариант - $MCA['Params'] = empty($patt[4]) ? array() : - str_getcsv($patt[4],',',"'",'\\'); // $this->parseScobParams($patt[4]); + $MCA['Params'] = empty($patt[4]) ? array() : str_getcsv($patt[4],',',"'",'\\'); } else { @@ -454,20 +452,6 @@ class QuickFW_Router return array('params' => $params); } - protected function parseScobParams($par) - { -//регулярка для парсинга параметров - записана так, чтобы не было страшных экранировок -$re = <<<SREG -#\s*([^,"']+|"(?:[^"]|\\"|"")*?[^\"]"|'(?:[^']|\\'|'')*?[^\']')\s*(?:,|$)# -SREG; - $m=array(); - preg_match_all($re, $par, $m); - foreach ($m[1] as &$v) - $v = str_replace(array('""',"''",'\"',"\'"), array('"',"'",'"',"'"), - trim($v,'\'" ')); - return $m[1]; - } - protected function loadMCA(&$data, $type) { while (isset($data[0]) AND $data[0] === '') array_shift($data); diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php index f5e6059..6fea9da 100644 --- a/QFW/Templater/Templater.php +++ b/QFW/Templater/Templater.php @@ -130,9 +130,7 @@ abstract class Templater */ public function block($block) { - //TODO: убрать ненужную переменную после перехода на php 5.3 - $args = func_get_args(); - return call_user_func_array(array(&QFW::$router, 'blockRoute'), $args); + return call_user_func_array(array(&QFW::$router, 'blockRoute'), func_get_args()); } /** @@ -144,7 +142,6 @@ abstract class Templater */ public function localBlock($ns, $block) { - //TODO: убрать ненужную переменную после перехода на php 5.3 $args = func_get_args(); array_shift($args); $c = $ns.'\QFW'; diff --git a/cron/cruise.php b/cron/cruise.php index b270253..ae8f4e0 100644 --- a/cron/cruise.php +++ b/cron/cruise.php @@ -11,10 +11,8 @@ // define ('LOGPATH', VARPATH . '/log'); // define ('MODPATH', APPPATH . '/_common/models'); - //TODO: Выкинуть gethostbyaddr после перехода на PHP 5.3 if (empty($_SERVER['HTTP_HOST'])) - $_SERVER['HTTP_HOST'] = function_exists('gethostname') ? - gethostname() : gethostbyaddr('127.0.0.1'); + $_SERVER['HTTP_HOST'] = gethostname(); require (QFWPATH.'/Init.php'); diff --git a/cron/start.php b/cron/start.php index 9afe7ce..30ea766 100644 --- a/cron/start.php +++ b/cron/start.php @@ -11,10 +11,8 @@ // define ('LOGPATH', VARPATH . '/log'); // define ('MODPATH', APPPATH . '/_common/models'); - //TODO: Выкинуть gethostbyaddr после перехода на PHP 5.3 if (empty($_SERVER['HTTP_HOST'])) - $_SERVER['HTTP_HOST'] = function_exists('gethostname') ? - gethostname() : gethostbyaddr('127.0.0.1'); + $_SERVER['HTTP_HOST'] = gethostname(); require (QFWPATH.'/Init.php'); diff --git a/lib/Log52.php b/lib/Log52.php deleted file mode 100644 index c903358..0000000 --- a/lib/Log52.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php - -/** - * Класс логирования - * - * <br>Аналог класса Log в версии для PHP 5.2 - * <br>Нет поддержки функции log, только out - * <br>работает в 5.2, так как некоторые ... - * <br>обновиться не могут :) - * - * @version PHP5.2 - */ -class Log -{ - private static $l=null; - private static $messages=array(); - - /** - * Заносит запись в лог - * - * @param string $string запись - * @param string $to лог назначения - */ - public static function out(string $string, string $to='general') - { - if (isset(QFW::$config['log'][$to])) - $to = QFW::$config['log'][$to]; - if (self::$l === null) - self::$l = new Log(); - if ($to == 'error') - error_log($str); - elseif(strpos($to,'mailto:')===0) - self::$l->email($str,substr($to,7)); - elseif(strpos($to,'xmpp://')===0) - self::$l->jabber($str,substr($to,7)); - else - self::f($str, $to); - } - - /** - * Отправляет очередь сообщений - * <br>нужно в случае длительной работы и отправке в jabber - */ - public static function sendQuery() - { - if (isset(self::$messages['email'])) - { - foreach (self::$messages['email'] as $k=>$msg) - error_log(join("\n",$msg), 1, $k); - unset(self::$messages['email']); - } - if (isset(self::$messages['jabber'])) - { - if (!isset(QFW::$config['jabber'])) - error_log('Jabber не настроен '); - else - { - $J = QFW::JabberFromConfig(); - $J->connect(); - $J->processUntil('session_start',10); - $J->presence(); - foreach (self::$messages['jabber'] as $k=>$msg) - $J->message($k, join("\n",$msg)); - $J->disconnect(); - } - unset(self::$messages['jabber']); - } - } - - private function jabber($str, $to) { self::$messages['jabber'][$to][]=$str; } - private function email($str, $to) { self::$messages['email'][$to][]=$str; } - private static function f($str, $to) - { - error_log(date('Y-m-d H:i:s').': '.$str."\n", 3, LOGPATH.'/'.$to.'.log'); - } - - public function __destruct() - { - self::sendQuery(); - } - -} - -?> \ No newline at end of file commit 9bd67ba7dbb13640c9eb73cc955bab1bb37f854c Merge: ab24b81 ddc51b7 Author: Ivan Borzenkov <iva...@li...> Date: Tue Mar 1 15:41:17 2011 +0300 В основную ветку добавлен суброутинг diff --cc QFW/QuickFW/Router.php index 33de1d1,2e75205..c48e249 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@@ -510,9 -561,9 +561,10 @@@ SREG return $MCA; } } + $class = $this->sub.$class; $vars = get_class_vars($class); $acts = get_class_methods($class); + $defA = isset($vars['defA']) ? $vars['defA'] : $this->defA; //Выполняется при первом вызове и сохраняет значение вызванного MCA //Проверяем последний так как остальные уже записаны commit ab24b811da9cf5909bdcd733824be57740e34515 Author: Ivan Borzenkov <iva...@li...> Date: Mon Feb 28 15:15:19 2011 +0300 Класс для доступа к массивам как к объектам diff --git a/lib/RecursiveArrayAccess.php b/lib/RecursiveArrayAccess.php new file mode 100644 index 0000000..0f39e41 --- /dev/null +++ b/lib/RecursiveArrayAccess.php @@ -0,0 +1,43 @@ +<?php + +class RecursiveArrayAccess implements ArrayAccess +{ + private $data = array(); + + // necessary for deep copies + public function __clone() { + foreach ($this->data as $key => $value) if ($value instanceof self) $this[$key] = clone $value; + } + + public function __construct(array $data = array()) { + foreach ($data as $key => $value) $this[$key] = $value; + } + + public function offsetSet($offset, $data) { + if (is_array($data)) $data = new self($data); + if ($offset === null) { // don't forget this! + $this->data[] = $data; + } else { + $this->data[$offset] = $data; + } + } + + public function toArray() { + $data = $this->data; + foreach ($data as $key => $value) if ($value instanceof self) $data[$key] = $value->toArray(); + return $data; + } + + // as normal + //public function offsetGet($offset) { return isset($this->data[$offset]) ? $this->data[$offset] : null; } + public function offsetGet($offset) { return $this->data[$offset]; } + public function offsetExists($offset) { return isset($this->data[$offset]); } + public function offsetUnset($offset) { unset($this->data); } + + //as prop + public function __get($offset) { return $this->offsetGet($offset); } + public function __set($offset, $data) { return $this->offsetSet($offset, $data); } + public function __isset($offset) { return $this->offsetExists($offset); } + public function __unset($offset) { return $this->offsetUnset($offset); } + +} ----------------------------------------------------------------------- Summary of changes: QFW/Init.php | 2 +- QFW/QuickFW/Autoload.php | 12 ++- QFW/QuickFW/Helpers.php | 3 +- QFW/QuickFW/Router.php | 86 ++++++++++++++------ QFW/QuickFW/Url.php | 56 ++++++++----- QFW/Templater/Templater.php | 33 +++++++- QFW/sub.php | 43 ++++++++++ .../default/controllers/IndexController.php | 9 ++ .../test/default/controllers/IndexController.php | 20 +++++ .../default/test/default/templates/index.php | 5 + application/default/test/sub.php | 46 +++++++++++ cron/cruise.php | 4 +- cron/start.php | 4 +- doc/asciidoc/mvc.txt | 26 ++++++ lib/Log52.php | 84 ------------------- lib/RecursiveArrayAccess.php | 43 ++++++++++ lib/Text.php | 69 +++++++++++++++- lib/utils.php | 72 +---------------- 18 files changed, 395 insertions(+), 222 deletions(-) create mode 100644 QFW/sub.php create mode 100644 application/default/test/default/controllers/IndexController.php create mode 100644 application/default/test/default/templates/index.php create mode 100644 application/default/test/sub.php delete mode 100644 lib/Log52.php create mode 100644 lib/RecursiveArrayAccess.php hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-03-03 15:08:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The tag, 1.9 has been created at bdb96f73364b68aefecf116c1cd850f953036515 (commit) - Log ----------------------------------------------------------------- commit bdb96f73364b68aefecf116c1cd850f953036515 Author: Ivan Borzenkov <iva...@li...> Date: Fri Feb 18 15:08:19 2011 +0300 Небольшая оптимизация выбора action в loadMCA ----------------------------------------------------------------------- hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-02-18 17:18:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, master has been updated via bdb96f73364b68aefecf116c1cd850f953036515 (commit) from 31b59d46fb3ef0a120c1d9ad0fc35e65016ccc7b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bdb96f73364b68aefecf116c1cd850f953036515 Author: Ivan Borzenkov <iva...@li...> Date: Fri Feb 18 15:08:19 2011 +0300 Небольшая оптимизация выбора action в loadMCA diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index 4ad2f98..33de1d1 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -512,29 +512,29 @@ SREG; } $vars = get_class_vars($class); $acts = get_class_methods($class); + $defA = isset($vars['defA']) ? $vars['defA'] : $this->defA; //Выполняется при первом вызове и сохраняет значение вызванного MCA //Проверяем последний так как остальные уже записаны if ($this->action == '') { - $aname = isset($data[0]) ? $data[0] : - (isset($vars['defA']) ? $vars['defA'] : $this->defA); - if (!in_array(strtr($aname,'.','_').$type, $acts)) - $aname = (isset($vars['defA']) ? $vars['defA'] : $this->defA); + $aname = isset($data[0]) ? strtr($data[0],'.','_') : $defA; + if (!in_array($aname.$type, $acts)) + $aname = $defA; $this->cAction = $this->action = $aname; $this->type = $type; } $this->classes[$class_key] = array( 'i' => new $class, - 'defA' => isset($vars['defA']) ? $vars['defA'] : $this->defA, + 'defA' => $defA, 'a' => $acts, ); } $MCA['Class'] = $this->classes[$class_key]['i']; - $aname = isset($data[0]) ? $data[0] : $this->classes[$class_key]['defA']; - $MCA['Action'] = strtr($aname,'.','_'); + $aname = isset($data[0]) ? strtr($data[0],'.','_') : $this->classes[$class_key]['defA']; + $MCA['Action'] = $aname; $MCA['Type'] = $type; if (in_array($MCA['Action'].$MCA['Type'], $this->classes[$class_key]['a'])) @@ -542,7 +542,7 @@ SREG; else { $aname = $this->classes[$class_key]['defA']; - $MCA['Action'] = strtr($aname,'.','_'); + $MCA['Action'] = $aname; $MCA['Type'] = $type; if (!in_array($aname.$type,$this->classes[$class_key]['a'])) { ----------------------------------------------------------------------- Summary of changes: QFW/QuickFW/Router.php | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) hooks/post-receive -- quickfw |
From: Ivan1986 <iva...@us...> - 2011-02-17 08:42:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "quickfw". The branch, subroute has been created at ddc51b78706a466a33e92c911020a03f3444a15e (commit) - Log ----------------------------------------------------------------- commit ddc51b78706a466a33e92c911020a03f3444a15e Author: Ivan Borzenkov <iva...@li...> Date: Fri Feb 4 17:52:52 2011 +0300 Затирались бэкреврайты при втором вызове урла diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index fbba6cc..2e75205 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -422,6 +422,8 @@ class QuickFW_Router $this->backrewrite = $backrewrite; if (!$this->sub) $this->backrewriteUrl = $backrewriteUrl; + else + $this->backrewriteUrl = null; } if (empty($this->$type)) return $uri; commit 844e5d9135d0e5baad2fd2ff667c003b2f3805f5 Author: Ivan Borzenkov <iva...@li...> Date: Thu Feb 3 14:48:55 2011 +0300 Саброутинг - корректные реврайты в урлах diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index f401ec2..a73611b 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -168,6 +168,20 @@ class Url return $this->u; } + /** + * урл для саброута + * + * @internal + * @return string урл + */ + public function getBase() + { + return static::$config['router']->backrewriteUrl( + static::$config['base'].static::$config['router']->backrewrite($this->u). + QuickFW_Router::PATH_SEPARATOR + ); + } + } ?> diff --git a/QFW/sub.php b/QFW/sub.php index 111089f..a584062 100644 --- a/QFW/sub.php +++ b/QFW/sub.php @@ -33,10 +33,9 @@ class Url extends \Url { protected static $config;} function run($args, $count) { $base = join(\QuickFW_Router::PATH_SEPARATOR, \array_slice($args, 0, $count)); - $base = \Url::base(\Url::A($base)->intern()); $uri = join(\QuickFW_Router::PATH_SEPARATOR, \array_slice($args, $count)); QFW::Init(); - Url::Init($base.\QuickFW_Router::PATH_SEPARATOR); + Url::Init(\Url::A($base)->getBase()); $TS = new \TemplaterState(QFW::$view); return QFW::$router->subroute($uri, \QFW::$router->type); } commit 3b280697d53c0e941d0e4c1fc023ff60b94b4825 Author: Ivan Borzenkov <iva...@li...> Date: Thu Feb 3 13:37:49 2011 +0300 Разбор части урла на встроенных функциях без цикла diff --git a/QFW/sub.php b/QFW/sub.php index ab2a8ae..111089f 100644 --- a/QFW/sub.php +++ b/QFW/sub.php @@ -32,10 +32,9 @@ class Url extends \Url { protected static $config;} */ function run($args, $count) { - $base = \Url::base(\Url::A('')->intern()); - while($count--) - $base.= \QuickFW_Router::PATH_SEPARATOR.array_shift($args); - $uri = join(\QuickFW_Router::PATH_SEPARATOR, $args); + $base = join(\QuickFW_Router::PATH_SEPARATOR, \array_slice($args, 0, $count)); + $base = \Url::base(\Url::A($base)->intern()); + $uri = join(\QuickFW_Router::PATH_SEPARATOR, \array_slice($args, $count)); QFW::Init(); Url::Init($base.\QuickFW_Router::PATH_SEPARATOR); $TS = new \TemplaterState(QFW::$view); commit c8ca0b1275839a5868a1670479e48a9ceb399dd0 Author: Ivan Borzenkov <iva...@li...> Date: Tue Feb 1 16:12:47 2011 +0300 Автолоад - загрузка классов контроллеров из неймспейсов diff --git a/QFW/QuickFW/Autoload.php b/QFW/QuickFW/Autoload.php index 9ede401..f9b5704 100644 --- a/QFW/QuickFW/Autoload.php +++ b/QFW/QuickFW/Autoload.php @@ -35,13 +35,15 @@ class Autoload //пространство имен if ($pos = mb_strpos($class, '\\')) { - $file = - strtolower(mb_substr($class, 0, $pos)). - '/'.QuickFW_Router::CONTROLLERS_DIR.'/'. - ucfirst(mb_substr($class, $pos+1)); + $ns = strtolower(mb_substr($class, 0, $pos)); + $class = ucfirst(mb_substr($class, $pos+1)); + $Q = $ns.'\QFW'; + //Проверка на саброутинг + $dir = !class_exists($Q) ? $ns : QFW::$router->cModule.'/'.$ns.'/'.$Q::$router->cModule; } else - $file = QFW::$router->cModule.'/'.QuickFW_Router::CONTROLLERS_DIR.'/'.$class; + $dir = QFW::$router->cModule; + $file = $dir.'/'.QuickFW_Router::CONTROLLERS_DIR.'/'.$class; require APPPATH.'/'.$file.'.php'; return true; } commit 50750d384def8db6b9d5b703d5cbd15b278fa03f Author: Ivan Borzenkov <iva...@li...> Date: Tue Feb 1 10:56:23 2011 +0300 Вызов блока из саброута diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php index 1ff31ce..f5e6059 100644 --- a/QFW/Templater/Templater.php +++ b/QFW/Templater/Templater.php @@ -136,6 +136,22 @@ abstract class Templater } /** + * Вызывает выполнение блока и возвращает результат + * + * @param string $ns неймспейс из которого вызвать (должен быть инициализирован) + * @param string $block имя блока (MCA) + * @return string результат работы блока + */ + public function localBlock($ns, $block) + { + //TODO: убрать ненужную переменную после перехода на php 5.3 + $args = func_get_args(); + array_shift($args); + $c = $ns.'\QFW'; + return call_user_func_array(array($c::$router, 'blockRoute'), $args); + } + + /** * Синоним fetch */ public function render($tmpl, $vars=array()) commit 21a82c9f77672df4c1b869977faa25742c40150e Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 20:25:18 2011 +0300 Исправлена ошибка - не изменяем baseurl в конфиге diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index 771c7c2..f401ec2 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -81,12 +81,12 @@ class Url /** * Инициализация класса из конфига */ - public static function Init() + public static function Init($base='') { + $base = $base ? $base : QFW::$config['redirection']['baseUrl']; $c = str_replace(__CLASS__, '', get_called_class()).'QFW'; static::$config = $c::$config['redirection']; - static::$config['base'] = static::$config['baseUrl']. - (static::$config['useIndex'] ? 'index.php/' : ''); + static::$config['base'] = $base.(static::$config['useIndex'] ? 'index.php/' : ''); static::$config['ext'] = static::$config['defExt'] ? static::$config['defExt'] : (QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); static::$config['router'] = $c::$router; diff --git a/QFW/sub.php b/QFW/sub.php index 5aea2db..ab2a8ae 100644 --- a/QFW/sub.php +++ b/QFW/sub.php @@ -37,8 +37,7 @@ function run($args, $count) $base.= \QuickFW_Router::PATH_SEPARATOR.array_shift($args); $uri = join(\QuickFW_Router::PATH_SEPARATOR, $args); QFW::Init(); - QFW::$config['redirection']['baseUrl'] = $base.\QuickFW_Router::PATH_SEPARATOR; - Url::Init(); + Url::Init($base.\QuickFW_Router::PATH_SEPARATOR); $TS = new \TemplaterState(QFW::$view); return QFW::$router->subroute($uri, \QFW::$router->type); } commit 8781ae85d90778b82e454c0cabe2a18c08f6bc0b Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 19:12:05 2011 +0300 Дока по саброутингу diff --git a/doc/asciidoc/mvc.txt b/doc/asciidoc/mvc.txt index 5190b8a..9ff285d 100644 --- a/doc/asciidoc/mvc.txt +++ b/doc/asciidoc/mvc.txt @@ -133,3 +133,29 @@ class CronContriller ===================================================================== +Саброутинг +~~~~~~~~~~ + +Можно сделать "подприложение" и вызывать его из экшена, при этом заново произойдет разбор указанной часто uri +Для этого нужно в папке модуля создать произвольную папку и в нее скопировать файл +QFW/sub.php+ после чего помянять в нем имя неймспейса на новый. + +[source,php] +--------------------------------------------- +//... +class UserContriller +{ + //... + indexCli($id) + { + QFW::$view->assign('user', User::get($id)); + include dirname(dirname(__FILE__)).'/user/sub.php'; + return user\run(func_get_args(), 1); + } + //... +} +--------------------------------------------- + +После чего вызвать функцию +run+ из неймспейса передав ей результат +func_get_args()+ и количество параметров, которые были использованы. +Внутри папки точно так-же создаются модули с контроллерами и экшанами, модели и шаблонизатор общие. + +Работает только в PHP 5.3 \ No newline at end of file commit 45e8b4959e5609038d6c532f3ddf67754a25e52b Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 19:06:04 2011 +0300 Для суброутинга сделаны урлы diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index 6f3b46a..fbba6cc 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -416,10 +416,12 @@ class QuickFW_Router if ($this->$type === false) { $rewrite = $backrewrite = $backrewriteUrl = array(); - require_once APPPATH . '/rewrite.php'; + if (!$this->sub || is_file($this->baseDir . '/rewrite.php')) + require_once $this->baseDir . '/rewrite.php'; $this->rewrite = $rewrite; $this->backrewrite = $backrewrite; - $this->backrewriteUrl = $backrewriteUrl; + if (!$this->sub) + $this->backrewriteUrl = $backrewriteUrl; } if (empty($this->$type)) return $uri; diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index a1fa0fd..771c7c2 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -41,7 +41,7 @@ class Url */ public static function M($CA='', $get='', $anchor='') { - return new static($CA, $get, $anchor, QFW::$router->cModule. + return new static($CA, $get, $anchor, static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR); } @@ -55,9 +55,9 @@ class Url */ public static function C($action='', $get='', $anchor='') { - return new static($action, $get, $anchor, QFW::$router->cModule. + return new static($action, $get, $anchor, static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR. - QFW::$router->cController. + static::$config['router']->cController. QuickFW_Router::PATH_SEPARATOR); } @@ -71,11 +71,11 @@ class Url */ public static function A($params='', $get='', $anchor='') { - return new static($params, $get, $anchor, QFW::$router->cModule. + return new static($params, $get, $anchor, static::$config['router']->cModule. QuickFW_Router::PATH_SEPARATOR. - QFW::$router->cController. + static::$config['router']->cController. QuickFW_Router::PATH_SEPARATOR. - QFW::$router->cAction.QuickFW_Router::PATH_SEPARATOR); + static::$config['router']->cAction.QuickFW_Router::PATH_SEPARATOR); } /** @@ -83,11 +83,13 @@ class Url */ public static function Init() { - static::$config = QFW::$config['redirection']; + $c = str_replace(__CLASS__, '', get_called_class()).'QFW'; + static::$config = $c::$config['redirection']; static::$config['base'] = static::$config['baseUrl']. (static::$config['useIndex'] ? 'index.php/' : ''); static::$config['ext'] = static::$config['defExt'] ? static::$config['defExt'] : (QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); + static::$config['router'] = $c::$router; } /** @var array QFW::$config['redirection'] */ @@ -119,7 +121,7 @@ class Url $this->get = $get; $this->anchor = ltrim($anchor, '#'); if (static::$config['delDef']) - $this->u = QFW::$router->delDef($this->u); + $this->u = static::$config['router']->delDef($this->u); } /** @var string внутреннее представление адреса */ @@ -148,8 +150,8 @@ class Url */ public function get() { - return QFW::$router->backrewriteUrl( - static::$config['base'].QFW::$router->backrewrite($this->u). + return static::$config['router']->backrewriteUrl( + static::$config['base'].static::$config['router']->backrewrite($this->u). ($this->u!=='' ? static::$config['ext'] : ''). ($this->get ? '?' . $this->get : ''). ($this->anchor ? '#' . $this->anchor : '')); diff --git a/QFW/basesub.php b/QFW/basesub.php deleted file mode 100644 index 9bc2c90..0000000 --- a/QFW/basesub.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -namespace baseSub; - -class QFW extends \QFW -{ - /** @var QuickFW_Router Роутер */ - static public $router; - - private function __construct() {} - - /** - * Инициализация основных объектов QFW - * - */ - static public function Init() - { - //подключаем модули и библиотеки - self::modules(); - - static::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); - } - - /** - * Инициализирует необязательные модули - * <br>в зависимости от настроек конфигов - */ - static public function modules() - { - //TODO настройка автолоада - } - -} - -class Url extends \Url -{ - public static function Init($base) - { - static::$config = QFW::$config['redirection']; - static::$config['delDef'] = QFW::$config['redirection']['delDef']; - static::$config['baseUrl'] = static::$config['base'] = $base; - static::$config['ext'] = (\QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); - } - - /** @var array QFW::$config['redirection'] */ - protected static $config; - -} - -?> diff --git a/application/default/test/sub.php b/QFW/sub.php similarity index 84% copy from application/default/test/sub.php copy to QFW/sub.php index a876c8d..5aea2db 100644 --- a/application/default/test/sub.php +++ b/QFW/sub.php @@ -2,9 +2,7 @@ namespace test; -require_once QFWPATH.'/basesub.php'; - -class QFW extends \baseSub\QFW +class QFW extends \QFW { /** @var QuickFW_Router Роутер */ static public $router; @@ -23,7 +21,7 @@ class QFW extends \baseSub\QFW } -class Url extends \baseSub\Url {} +class Url extends \Url { protected static $config;} /** * Вызывает саброутинг @@ -39,7 +37,8 @@ function run($args, $count) $base.= \QuickFW_Router::PATH_SEPARATOR.array_shift($args); $uri = join(\QuickFW_Router::PATH_SEPARATOR, $args); QFW::Init(); - Url::Init($base.\QuickFW_Router::PATH_SEPARATOR); + QFW::$config['redirection']['baseUrl'] = $base.\QuickFW_Router::PATH_SEPARATOR; + Url::Init(); $TS = new \TemplaterState(QFW::$view); return QFW::$router->subroute($uri, \QFW::$router->type); } diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index b6f5fff..1c93ec0 100644 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -15,8 +15,6 @@ class IndexController extends QuickFW_Auth return ''; QFW::$view->assign('out', $p1); include dirname(dirname(__FILE__)).'/test/sub.php'; - $a = func_get_args(); - array_shift($a); return test\run(func_get_args(), 1); } diff --git a/application/default/test/sub.php b/application/default/test/sub.php index a876c8d..5aea2db 100644 --- a/application/default/test/sub.php +++ b/application/default/test/sub.php @@ -2,9 +2,7 @@ namespace test; -require_once QFWPATH.'/basesub.php'; - -class QFW extends \baseSub\QFW +class QFW extends \QFW { /** @var QuickFW_Router Роутер */ static public $router; @@ -23,7 +21,7 @@ class QFW extends \baseSub\QFW } -class Url extends \baseSub\Url {} +class Url extends \Url { protected static $config;} /** * Вызывает саброутинг @@ -39,7 +37,8 @@ function run($args, $count) $base.= \QuickFW_Router::PATH_SEPARATOR.array_shift($args); $uri = join(\QuickFW_Router::PATH_SEPARATOR, $args); QFW::Init(); - Url::Init($base.\QuickFW_Router::PATH_SEPARATOR); + QFW::$config['redirection']['baseUrl'] = $base.\QuickFW_Router::PATH_SEPARATOR; + Url::Init(); $TS = new \TemplaterState(QFW::$view); return QFW::$router->subroute($uri, \QFW::$router->type); } commit 0e4f07232acdf83e257a8a0127cfff4380a1292b Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 18:06:43 2011 +0300 Доработан вызов саброутинга diff --git a/QFW/basesub.php b/QFW/basesub.php index 06ffadb..9bc2c90 100644 --- a/QFW/basesub.php +++ b/QFW/basesub.php @@ -47,12 +47,4 @@ class Url extends \Url } -function run($base, $uri) -{ - QFW::Init(); - Url::Init($base.''); - $TS = new \TemplaterState(QFW::$view); - return QFW::$router->subroute($uri, \QFW::$router->type); -} - ?> diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index da49da8..b6f5fff 100644 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -17,8 +17,7 @@ class IndexController extends QuickFW_Auth include dirname(dirname(__FILE__)).'/test/sub.php'; $a = func_get_args(); array_shift($a); - $data = test\run(Url::A($p1), join('/',$a)); - return $data; + return test\run(func_get_args(), 1); } public function indexAction() diff --git a/application/default/test/sub.php b/application/default/test/sub.php index ddb7ef7..a876c8d 100644 --- a/application/default/test/sub.php +++ b/application/default/test/sub.php @@ -25,10 +25,21 @@ class QFW extends \baseSub\QFW class Url extends \baseSub\Url {} -function run($base, $uri) +/** + * Вызывает саброутинг + * + * @param array $args результат func_get_args() + * @param integer $count сколько использовано в экшене + * @return string результат + */ +function run($args, $count) { + $base = \Url::base(\Url::A('')->intern()); + while($count--) + $base.= \QuickFW_Router::PATH_SEPARATOR.array_shift($args); + $uri = join(\QuickFW_Router::PATH_SEPARATOR, $args); QFW::Init(); - Url::Init($base.''); + Url::Init($base.\QuickFW_Router::PATH_SEPARATOR); $TS = new \TemplaterState(QFW::$view); return QFW::$router->subroute($uri, \QFW::$router->type); } commit 0f487adea48a7d7b74c3efdc0b27c765520d678b Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 17:44:23 2011 +0300 Доработки саброутинга - вынесен в базовый класс diff --git a/QFW/Init.php b/QFW/Init.php index 7b2023d..0bad1ba 100644 --- a/QFW/Init.php +++ b/QFW/Init.php @@ -78,7 +78,7 @@ class QFW self::modules(); require_once QFWPATH.'/QuickFW/Router.php'; - self::$router = new QuickFW_Router(APPPATH); + static::$router = new QuickFW_Router(APPPATH); //хелпер для урлов (зависит от QuickFW_Router) require_once QFWPATH.'/QuickFW/Url.php'; diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index cba5420..6f3b46a 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -88,7 +88,14 @@ class QuickFW_Router $this->defA = QFW::$config['default']['action']; } - public function r($requestUri = null, $type='Action') + /** + * Вызов Uri для исполнения в саброутинге + * + * @param string $requestUri запрашиваемый Uri + * @param string $type тип Uri (Action|Cli|...) + * @return stinrg результат + */ + public function subroute($requestUri = null, $type='Action') { $requestUri = $this->rewrite($requestUri); $data = explode(self::PATH_SEPARATOR, $requestUri); @@ -122,7 +129,6 @@ class QuickFW_Router QFW::$view->setScriptPath($this->baseDir.'/'.$MCA['Module'].'/templates'); return $result; - } /** diff --git a/QFW/basesub.php b/QFW/basesub.php new file mode 100644 index 0000000..06ffadb --- /dev/null +++ b/QFW/basesub.php @@ -0,0 +1,58 @@ +<?php + +namespace baseSub; + +class QFW extends \QFW +{ + /** @var QuickFW_Router Роутер */ + static public $router; + + private function __construct() {} + + /** + * Инициализация основных объектов QFW + * + */ + static public function Init() + { + //подключаем модули и библиотеки + self::modules(); + + static::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); + } + + /** + * Инициализирует необязательные модули + * <br>в зависимости от настроек конфигов + */ + static public function modules() + { + //TODO настройка автолоада + } + +} + +class Url extends \Url +{ + public static function Init($base) + { + static::$config = QFW::$config['redirection']; + static::$config['delDef'] = QFW::$config['redirection']['delDef']; + static::$config['baseUrl'] = static::$config['base'] = $base; + static::$config['ext'] = (\QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); + } + + /** @var array QFW::$config['redirection'] */ + protected static $config; + +} + +function run($base, $uri) +{ + QFW::Init(); + Url::Init($base.''); + $TS = new \TemplaterState(QFW::$view); + return QFW::$router->subroute($uri, \QFW::$router->type); +} + +?> diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index 6538206..da49da8 100644 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -13,12 +13,11 @@ class IndexController extends QuickFW_Auth { if (!$p1) return ''; + QFW::$view->assign('out', $p1); include dirname(dirname(__FILE__)).'/test/sub.php'; $a = func_get_args(); array_shift($a); - echo "<br><br>".Url::A($p1)."<br><br>"; - $data = 'a'.test\run::run(Url::A($p1), join('/',$a)).'a'; - echo "<br><br>".Url::A($p1)."<br><br>"; + $data = test\run(Url::A($p1), join('/',$a)); return $data; } diff --git a/application/default/test/default/controllers/IndexController.php b/application/default/test/default/controllers/IndexController.php index 3b3a081..a6c27d0 100644 --- a/application/default/test/default/controllers/IndexController.php +++ b/application/default/test/default/controllers/IndexController.php @@ -11,6 +11,7 @@ class IndexController extends \QuickFW_Auth public function indexAction() { + QFW::$view->assign('in', 'in'); return QFW::$view->fetch('index.php'); } diff --git a/application/default/test/default/templates/index.php b/application/default/test/default/templates/index.php index 2cc11c0..5c26a0b 100644 --- a/application/default/test/default/templates/index.php +++ b/application/default/test/default/templates/index.php @@ -2,3 +2,4 @@ <?php echo Url::A('a'); ?><br> <?php echo test\Url::A('a'); ?><br> <?php echo test\Url::C('a'); ?><br> +<?php echo $out.' '.$in ?> diff --git a/application/default/test/sub.php b/application/default/test/sub.php index bb12007..ddb7ef7 100644 --- a/application/default/test/sub.php +++ b/application/default/test/sub.php @@ -2,110 +2,35 @@ namespace test; -class QFW -{ - /** @var array Глобальный массив данных */ - static public $globalData = array(); +require_once QFWPATH.'/basesub.php'; +class QFW extends \baseSub\QFW +{ /** @var QuickFW_Router Роутер */ static public $router; - /** @var array Конфигурация */ - static public $config; - - /** @var Templater_PlainView Шаблонизатор */ - static public $view; - - /** @var array Подключенные глобальные библиотеки */ - static public $libs = array(); - - /** @var DbSimple_Database|false Подключение к базе данных */ - static public $db = false; - - /** @var mixed|false Данные о пользователе */ - static public $userdata = false; - - /** @var JsHttpRequest|jQuery|false JsHttpRequest или jQuery, если был выполнени Ajax запрос */ - static public $ajax = false; - - private function __construct() {} - - /** - * Инициализация конфига - * - * <br>возвращает конфигурацию, специфичную для текущего хоста - * - * @return array конфигурация на этом хосте - */ - static public function config() - { - require QFWPATH.'/config.php'; - require APPPATH.'/default.php'; - - if (!isset($_SERVER['HTTP_HOST'])) - die('$_SERVER[\'HTTP_HOST\'] NOT SET'); - $file = APPPATH.'/'.$_SERVER['HTTP_HOST'].'.php'; - if (is_file($file)) - require ($file); - return $config; - } - /** * Инициализация основных объектов QFW * */ static public function Init() { - self::$config = \QFW::$config; - - self::$db = \QFW::$db; - - self::$view = \QFW::$view; - //подключаем модули и библиотеки self::modules(); - require_once QFWPATH.'/QuickFW/Router.php'; - self::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); - } - - /** - * Инициализирует необязательные модули - * <br>в зависимости от настроек конфигов - */ - static public function modules() - { - //TODO настройка автолоада + static::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); } } -class Url extends \Url -{ - public static function Init($base) - { - static::$config = QFW::$config['redirection']; - static::$config['delDef'] = QFW::$config['redirection']['delDef']; - static::$config['baseUrl'] = static::$config['base'] = $base; - static::$config['ext'] = (\QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); - } - - /** @var array QFW::$config['redirection'] */ - protected static $config; - -} +class Url extends \baseSub\Url {} -class run +function run($base, $uri) { - static public function run($base, $uri) - { - Url::Init($base.''); - $TS = new \TemplaterState(QFW::$view); - $data = QFW::$router->r($uri); - return $data; - } + QFW::Init(); + Url::Init($base.''); + $TS = new \TemplaterState(QFW::$view); + return QFW::$router->subroute($uri, \QFW::$router->type); } -QFW::Init(); - ?> commit 22050b0340cc4b514164dc12ae9b0bbbc5b3967a Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 17:05:10 2011 +0300 Пока LSB из php5.3 diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php index a346f19..a1fa0fd 100644 --- a/QFW/QuickFW/Url.php +++ b/QFW/QuickFW/Url.php @@ -15,7 +15,7 @@ class Url */ public static function base($url='') { - return new self('').$url; + return new static('').$url; } /** @@ -28,7 +28,7 @@ class Url */ public static function site($url='', $get='', $anchor='') { - return new self($url, $get, $anchor); + return new static($url, $get, $anchor); } /** @@ -41,7 +41,7 @@ class Url */ public static function M($CA='', $get='', $anchor='') { - return new self($CA, $get, $anchor, QFW::$router->cModule. + return new static($CA, $get, $anchor, QFW::$router->cModule. QuickFW_Router::PATH_SEPARATOR); } @@ -55,7 +55,7 @@ class Url */ public static function C($action='', $get='', $anchor='') { - return new self($action, $get, $anchor, QFW::$router->cModule. + return new static($action, $get, $anchor, QFW::$router->cModule. QuickFW_Router::PATH_SEPARATOR. QFW::$router->cController. QuickFW_Router::PATH_SEPARATOR); @@ -71,7 +71,7 @@ class Url */ public static function A($params='', $get='', $anchor='') { - return new self($params, $get, $anchor, QFW::$router->cModule. + return new static($params, $get, $anchor, QFW::$router->cModule. QuickFW_Router::PATH_SEPARATOR. QFW::$router->cController. QuickFW_Router::PATH_SEPARATOR. @@ -83,15 +83,15 @@ class Url */ public static function Init() { - self::$config = QFW::$config['redirection']; - self::$config['base'] = self::$config['baseUrl']. - (self::$config['useIndex'] ? 'index.php/' : ''); - self::$config['ext'] = self::$config['defExt'] ? self::$config['defExt'] : + static::$config = QFW::$config['redirection']; + static::$config['base'] = static::$config['baseUrl']. + (static::$config['useIndex'] ? 'index.php/' : ''); + static::$config['ext'] = static::$config['defExt'] ? static::$config['defExt'] : (QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); } /** @var array QFW::$config['redirection'] */ - private static $config; + protected static $config; /** * Конструктор класса запроса @@ -101,7 +101,7 @@ class Url * @param string $anchor якорь * @param string $begin базовый урл от текущего */ - private function __construct($url, $get='', $anchor='', $begin='') + protected function __construct($url, $get='', $anchor='', $begin='') { if (is_array($get) && count($get)) $get = http_build_query($get); @@ -118,7 +118,7 @@ class Url $this->u = trim($begin.$url, QuickFW_Router::PATH_SEPARATOR); $this->get = $get; $this->anchor = ltrim($anchor, '#'); - if (self::$config['delDef']) + if (static::$config['delDef']) $this->u = QFW::$router->delDef($this->u); } @@ -149,8 +149,8 @@ class Url public function get() { return QFW::$router->backrewriteUrl( - self::$config['base'].QFW::$router->backrewrite($this->u). - ($this->u!=='' ? self::$config['ext'] : ''). + static::$config['base'].QFW::$router->backrewrite($this->u). + ($this->u!=='' ? static::$config['ext'] : ''). ($this->get ? '?' . $this->get : ''). ($this->anchor ? '#' . $this->anchor : '')); } diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index 0fe5236..6538206 100644 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -16,7 +16,10 @@ class IndexController extends QuickFW_Auth include dirname(dirname(__FILE__)).'/test/sub.php'; $a = func_get_args(); array_shift($a); - return 'a'.test\run::run(join('/',$a)).'a'; + echo "<br><br>".Url::A($p1)."<br><br>"; + $data = 'a'.test\run::run(Url::A($p1), join('/',$a)).'a'; + echo "<br><br>".Url::A($p1)."<br><br>"; + return $data; } public function indexAction() diff --git a/application/default/test/default/controllers/IndexController.php b/application/default/test/default/controllers/IndexController.php index 9864438..3b3a081 100644 --- a/application/default/test/default/controllers/IndexController.php +++ b/application/default/test/default/controllers/IndexController.php @@ -11,7 +11,7 @@ class IndexController extends \QuickFW_Auth public function indexAction() { - return 'zzz'; + return QFW::$view->fetch('index.php'); } } diff --git a/application/default/test/default/templates/index.php b/application/default/test/default/templates/index.php index 9ab50b9..2cc11c0 100644 --- a/application/default/test/default/templates/index.php +++ b/application/default/test/default/templates/index.php @@ -1,10 +1,4 @@ -<h2>Добро пожаловать</h2> - -<ul> - <li><a href="<?php echo Url::M('doc') ?>">Документация</a> - <p><small>Для генерации нужен установленный a2x, xetex и вообще только unix - с виндой трахайтесь как хотите</small></p> - </li> - <li><a href="<?php echo Url::C('dinmenu') ?>">Динамическое меню</a> - <p><small>Пример вложенного динамического меню с помощью хелпера на CSS3</small></p> - </li> -</ul> +Проверка работы саброутинга<br> +<?php echo Url::A('a'); ?><br> +<?php echo test\Url::A('a'); ?><br> +<?php echo test\Url::C('a'); ?><br> diff --git a/application/default/test/default/templates/main.php b/application/default/test/default/templates/main.php deleted file mode 100644 index 1e4fc8e..0000000 --- a/application/default/test/default/templates/main.php +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <title><?php echo isset($title)?'QFW::'.$title:'QFW' ?></title> -</head> -<body> -<h1>QFW - <small>оно таки у вас завелось</small></h1> -<?php echo $content; ?> -</body> -</html> diff --git a/application/default/test/sub.php b/application/default/test/sub.php index b7f6b66..bb12007 100644 --- a/application/default/test/sub.php +++ b/application/default/test/sub.php @@ -60,19 +60,13 @@ class QFW self::$db = \QFW::$db; - //Подключаем шаблонизатор - $templ = ucfirst(self::$config['templater']['name']); - $class = '\Templater_'.$templ; - require_once QFWPATH.'/Templater/'.$templ.'.php'; - self::$view = new $class(dirname(__FILE__), ''); + self::$view = \QFW::$view; //подключаем модули и библиотеки self::modules(); require_once QFWPATH.'/QuickFW/Router.php'; self::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); - - Url::Init(); } /** @@ -88,14 +82,27 @@ class QFW class Url extends \Url { + public static function Init($base) + { + static::$config = QFW::$config['redirection']; + static::$config['delDef'] = QFW::$config['redirection']['delDef']; + static::$config['baseUrl'] = static::$config['base'] = $base; + static::$config['ext'] = (\QuickFW_Router::PATH_SEPARATOR == '/' ? '/' : ''); + } + + /** @var array QFW::$config['redirection'] */ + protected static $config; } class run { - static public function run($uri) + static public function run($base, $uri) { - return QFW::$router->r($uri); + Url::Init($base.''); + $TS = new \TemplaterState(QFW::$view); + $data = QFW::$router->r($uri); + return $data; } } commit b218d313da1a51454d63cae0d48ed6b2c8961cb5 Author: Ivan Borzenkov <iva...@li...> Date: Mon Jan 31 15:26:04 2011 +0300 Пока очень тестовый саброутинг diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php index 4ad2f98..cba5420 100644 --- a/QFW/QuickFW/Router.php +++ b/QFW/QuickFW/Router.php @@ -24,6 +24,9 @@ class QuickFW_Router protected $classes=array(); protected $baseDir; + + /** @var string Неймспейс для подроутинга */ + protected $sub; protected $defM,$defC,$defA; @@ -73,17 +76,55 @@ class QuickFW_Router /** @var string Uri который был вызван для исполнения после фильтрации переменных и реврайта */ public $RequestUri; - public function __construct($baseDir) + public function __construct($baseDir, $sub='') { $this->baseDir = rtrim($baseDir, '/\\'); $this->module = ''; $this->controller = ''; $this->action = ''; + $this->sub = $sub?($sub.'\\'):''; $this->defM = QFW::$config['default']['module']; $this->defC = QFW::$config['default']['controller']; $this->defA = QFW::$config['default']['action']; } + public function r($requestUri = null, $type='Action') + { + $requestUri = $this->rewrite($requestUri); + $data = explode(self::PATH_SEPARATOR, $requestUri); + //обнуляем если нас вызвали повторно + $this->module = ''; + $this->controller = ''; + $this->action = ''; + + $MCA = $this->loadMCA($data, $type); + if (isset($MCA['Error'])) + { + if (QFW::$config['QFW']['release']) + $this->show404(); + else + die("Был выполнен запрос \t\t".$requestUri."\nадрес был разобран в\t\t ". + $MCA['Path']."\n". + $MCA['Error']); + } + $params = $this->parseParams($data); + + $this->curModule = $this->cModule = $this->module = $MCA['Module']; + $this->curController = $this->cController = $this->controller = $MCA['Controller']; + $this->cAction = $this->action = $MCA['Action']; + $this->CurPath = $this->UriPath = $MCA['Path']; + $this->Uri = $MCA['Path'] . self::PATH_SEPARATOR . join(self::PATH_SEPARATOR, $data); + $this->RequestUri = $requestUri; + $this->ParentPath = null; + + $result = call_user_func_array(array($MCA['Class'], $MCA['Action'].$MCA['Type']), $params); + + QFW::$view->setScriptPath($this->baseDir.'/'.$MCA['Module'].'/templates'); + + return $result; + + } + /** * Вызов Uri для исполнения * @@ -424,7 +465,7 @@ SREG; if (!empty(QFW::$config['cache']['MCA'])) { $Cache = Cache::get('MCA'); - $key = 'MCA_'.crc32(serialize($data)).$type. + $key = 'MCA_'.$this->sub.crc32(serialize($data)).$type. ($type=='Block' ? $this->curModule : $this->defM); $cached = $Cache->load($key); if ($cached) @@ -498,18 +539,19 @@ SREG; if (!isset($this->classes[$class_key])) { require_once($fullname); - if (!class_exists($class)) + if (!class_exists($this->sub.$class)) { //Смотрим, а не в неймспейсе ли он случайно - if (class_exists($MCA['Module'].'\\'.$class)) - $class = $MCA['Module'].'\\'.$class; + if (class_exists($MCA['Module'].'\\'.$this->sub.$class)) + $class = $MCA['Module'].'\\'.$this->sub.$class; else { - $MCA['Error']="не найден класс \t\t\t".$class."\nКласс не найден, мать его за ногу"; + $MCA['Error']="не найден класс \t\t\t".$this->sub.$class."\nКласс не найден, мать его за ногу"; $MCA['Path']=$MCA['Module'].'/'.$MCA['Controller'].'/...'; return $MCA; } } + $class = $this->sub.$class; $vars = get_class_vars($class); $acts = get_class_methods($class); diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index fb994fa..0fe5236 100644 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -9,6 +9,16 @@ class IndexController extends QuickFW_Auth //echo QFW::$router->module.'.'.QFW::$router->controller.'.'.QFW::$router->action."<br>\n"; } + public function tttAction($p1='') + { + if (!$p1) + return ''; + include dirname(dirname(__FILE__)).'/test/sub.php'; + $a = func_get_args(); + array_shift($a); + return 'a'.test\run::run(join('/',$a)).'a'; + } + public function indexAction() { QFW::$view->assign('title', 'Основная страница'); diff --git a/application/default/test/default/controllers/IndexController.php b/application/default/test/default/controllers/IndexController.php new file mode 100644 index 0000000..9864438 --- /dev/null +++ b/application/default/test/default/controllers/IndexController.php @@ -0,0 +1,19 @@ +<?php +namespace test; + +require_once(QFWPATH.'/QuickFW/Auth.php'); + +class IndexController extends \QuickFW_Auth +{ + public function __construct() + { + } + + public function indexAction() + { + return 'zzz'; + } + +} + +?> \ No newline at end of file diff --git a/application/default/test/default/templates/index.php b/application/default/test/default/templates/index.php new file mode 100644 index 0000000..9ab50b9 --- /dev/null +++ b/application/default/test/default/templates/index.php @@ -0,0 +1,10 @@ +<h2>Добро пожаловать</h2> + +<ul> + <li><a href="<?php echo Url::M('doc') ?>">Документация</a> + <p><small>Для генерации нужен установленный a2x, xetex и вообще только unix - с виндой трахайтесь как хотите</small></p> + </li> + <li><a href="<?php echo Url::C('dinmenu') ?>">Динамическое меню</a> + <p><small>Пример вложенного динамического меню с помощью хелпера на CSS3</small></p> + </li> +</ul> diff --git a/application/default/test/default/templates/main.php b/application/default/test/default/templates/main.php new file mode 100644 index 0000000..1e4fc8e --- /dev/null +++ b/application/default/test/default/templates/main.php @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title><?php echo isset($title)?'QFW::'.$title:'QFW' ?></title> +</head> +<body> +<h1>QFW - <small>оно таки у вас завелось</small></h1> +<?php echo $content; ?> +</body> +</html> diff --git a/application/default/test/sub.php b/application/default/test/sub.php new file mode 100644 index 0000000..b7f6b66 --- /dev/null +++ b/application/default/test/sub.php @@ -0,0 +1,104 @@ +<?php + +namespace test; + +class QFW +{ + /** @var array Глобальный массив данных */ + static public $globalData = array(); + + /** @var QuickFW_Router Роутер */ + static public $router; + + /** @var array Конфигурация */ + static public $config; + + /** @var Templater_PlainView Шаблонизатор */ + static public $view; + + /** @var array Подключенные глобальные библиотеки */ + static public $libs = array(); + + /** @var DbSimple_Database|false Подключение к базе данных */ + static public $db = false; + + /** @var mixed|false Данные о пользователе */ + static public $userdata = false; + + /** @var JsHttpRequest|jQuery|false JsHttpRequest или jQuery, если был выполнени Ajax запрос */ + static public $ajax = false; + + private function __construct() {} + + /** + * Инициализация конфига + * + * <br>возвращает конфигурацию, специфичную для текущего хоста + * + * @return array конфигурация на этом хосте + */ + static public function config() + { + require QFWPATH.'/config.php'; + require APPPATH.'/default.php'; + + if (!isset($_SERVER['HTTP_HOST'])) + die('$_SERVER[\'HTTP_HOST\'] NOT SET'); + $file = APPPATH.'/'.$_SERVER['HTTP_HOST'].'.php'; + if (is_file($file)) + require ($file); + return $config; + } + + /** + * Инициализация основных объектов QFW + * + */ + static public function Init() + { + self::$config = \QFW::$config; + + self::$db = \QFW::$db; + + //Подключаем шаблонизатор + $templ = ucfirst(self::$config['templater']['name']); + $class = '\Templater_'.$templ; + require_once QFWPATH.'/Templater/'.$templ.'.php'; + self::$view = new $class(dirname(__FILE__), ''); + + //подключаем модули и библиотеки + self::modules(); + + require_once QFWPATH.'/QuickFW/Router.php'; + self::$router = new \QuickFW_Router(dirname(__FILE__), __NAMESPACE__); + + Url::Init(); + } + + /** + * Инициализирует необязательные модули + * <br>в зависимости от настроек конфигов + */ + static public function modules() + { + //TODO настройка автолоада + } + +} + +class Url extends \Url +{ + +} + +class run +{ + static public function run($uri) + { + return QFW::$router->r($uri); + } +} + +QFW::Init(); + +?> ----------------------------------------------------------------------- hooks/post-receive -- quickfw |