From 45aceab6b58b057e82ac6bc03af9900c083de6eb Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 25 Feb 2010 00:16:53 +0200 Subject: [PATCH] Initial import of old legacy Zynapse Framework, untouched since early 2008. --- app/controllers/admin/admin_controller.php | 16 + app/controllers/application.php | 8 + app/controllers/page_controller.php | 65 + .../snippet_testing_controller.php | 11 + app/helpers/application_helper.php | 5 + .../snippet_helpers/snippets_helper.php | 5 + app/helpers/snippet_helpers/test_helper.php | 4 + app/helpers/snippet_testing_helper.php | 4 + app/models/category.php | 9 + app/models/comment.php | 10 + app/models/page.php | 41 + app/preferences/_internals.prefs.php | 31 + app/preferences/application.prefs.php | 23 + app/snippets/snippets.php | 8 + app/snippets/test_snippet.php | 16 + app/views-wap/__layouts/.emptydir | 0 app/views-wap/__snippets/.emptydir | 0 app/views/__layouts/_navpane.phtml | 3 + app/views/__layouts/application.phtml | 31 + app/views/__layouts/page.phtml | 34 + app/views/__snippets/__layouts/snippets.phtml | 1 + app/views/__snippets/test/index.phtml | 1 + app/views/_admin/admin/index.phtml | 0 app/views/_admin/admin/view.phtml | 0 app/views/page/_comment.phtml | 5 + app/views/page/_page_list_item.phtml | 9 + app/views/page/index.phtml | 16 + app/views/page/view.phtml | 28 + app/views/snippet_testing/index.phtml | 4 + config/boot.php | 103 ++ config/database.php | 40 + config/environment.php | 72 ++ config/environments/_shell.php | 14 + config/environments/development.php | 7 + config/environments/production.php | 7 + config/environments/test.php | 7 + config/routes.php | 21 + config/strings/_global.php | 18 + config/strings/english.php | 46 + db/zynapse_development.sql | 98 ++ libs/.emptydir | 0 logs/development.log | 0 logs/production.log | 0 logs/test.log | 0 public/.htaccess | 12 + public/dispatch.php | 21 + public/images/.emptydir | 0 public/javascripts/libs/jquery-1.2.1.pack.js | 11 + public/stylesheets/layout.css | 0 public/stylesheets/print.css | 0 public/stylesheets/reset.css | 30 + public/stylesheets/screen.css | 0 public/stylesheets/typography.css | 0 script/fix_permissions | 46 + script/generate | 46 + tmp/cache/.emptydir | 0 vendor/zynapse/action_controller.php | 771 +++++++++++ vendor/zynapse/action_view.php | 45 + vendor/zynapse/action_view/helpers.php | 162 +++ .../action_view/helpers/form_tag_helper.php | 229 ++++ .../action_view/helpers/javascript_helper.php | 131 ++ .../action_view/helpers/url_helper.php | 158 +++ .../action_view/helpers/views_helper.php | 59 + vendor/zynapse/active_record.php | 1139 +++++++++++++++++ vendor/zynapse/dispatcher.php | 48 + vendor/zynapse/inflections.php | 157 +++ vendor/zynapse/inflector.php | 216 ++++ vendor/zynapse/input_filter.php | 41 + vendor/zynapse/preferences.php | 257 ++++ vendor/zynapse/router.php | 148 +++ vendor/zynapse/session.php | 193 +++ vendor/zynapse/shell_script.php | 54 + .../zynapse/shell_scripts/fix_permissions.php | 115 ++ .../zynapse/shell_scripts/znap_generator.php | 202 +++ .../znap_generator/controller_generator.php | 229 ++++ .../znap_generator/error_generator.php | 164 +++ .../znap_generator/layout_generator.php | 106 ++ .../znap_generator/model_generator.php | 97 ++ .../znap_generator/snippet_generator.php | 210 +++ .../znap_generator/templates/controller.php | 7 + .../znap_generator/templates/error_404.phtml | 54 + .../znap_generator/templates/error_500.phtml | 54 + .../templates/error_default.phtml | 54 + .../templates/error_development_default.phtml | 116 ++ .../znap_generator/templates/helper.php | 4 + .../znap_generator/templates/layout.phtml | 29 + .../znap_generator/templates/model.php | 7 + .../znap_generator/templates/snippet.php | 10 + .../templates/snippet_helper.php | 4 + .../templates/snippet_view.phtml | 2 + .../znap_generator/templates/view.phtml | 2 + vendor/zynapse/snippet_controller.php | 522 ++++++++ vendor/zynapse/strings.php | 21 + vendor/zynapse/timer.php | 149 +++ vendor/zynapse/znap_error.php | 80 ++ vendor/zynapse/znap_error/default/404.phtml | 54 + vendor/zynapse/znap_error/default/500.phtml | 54 + .../zynapse/znap_error/default/default.phtml | 54 + .../znap_error/development/default.phtml | 116 ++ vendor/zynapse/zynapse.php | 374 ++++++ 100 files changed, 7685 insertions(+) create mode 100644 app/controllers/admin/admin_controller.php create mode 100644 app/controllers/application.php create mode 100644 app/controllers/page_controller.php create mode 100644 app/controllers/snippet_testing_controller.php create mode 100644 app/helpers/application_helper.php create mode 100644 app/helpers/snippet_helpers/snippets_helper.php create mode 100644 app/helpers/snippet_helpers/test_helper.php create mode 100644 app/helpers/snippet_testing_helper.php create mode 100644 app/models/category.php create mode 100644 app/models/comment.php create mode 100644 app/models/page.php create mode 100644 app/preferences/_internals.prefs.php create mode 100644 app/preferences/application.prefs.php create mode 100644 app/snippets/snippets.php create mode 100644 app/snippets/test_snippet.php create mode 100644 app/views-wap/__layouts/.emptydir create mode 100644 app/views-wap/__snippets/.emptydir create mode 100644 app/views/__layouts/_navpane.phtml create mode 100644 app/views/__layouts/application.phtml create mode 100644 app/views/__layouts/page.phtml create mode 100644 app/views/__snippets/__layouts/snippets.phtml create mode 100644 app/views/__snippets/test/index.phtml create mode 100644 app/views/_admin/admin/index.phtml create mode 100644 app/views/_admin/admin/view.phtml create mode 100644 app/views/page/_comment.phtml create mode 100644 app/views/page/_page_list_item.phtml create mode 100644 app/views/page/index.phtml create mode 100644 app/views/page/view.phtml create mode 100644 app/views/snippet_testing/index.phtml create mode 100644 config/boot.php create mode 100644 config/database.php create mode 100644 config/environment.php create mode 100644 config/environments/_shell.php create mode 100644 config/environments/development.php create mode 100644 config/environments/production.php create mode 100644 config/environments/test.php create mode 100644 config/routes.php create mode 100644 config/strings/_global.php create mode 100644 config/strings/english.php create mode 100644 db/zynapse_development.sql create mode 100644 libs/.emptydir create mode 100644 logs/development.log create mode 100644 logs/production.log create mode 100644 logs/test.log create mode 100644 public/.htaccess create mode 100644 public/dispatch.php create mode 100644 public/images/.emptydir create mode 100644 public/javascripts/libs/jquery-1.2.1.pack.js create mode 100644 public/stylesheets/layout.css create mode 100644 public/stylesheets/print.css create mode 100755 public/stylesheets/reset.css create mode 100644 public/stylesheets/screen.css create mode 100644 public/stylesheets/typography.css create mode 100755 script/fix_permissions create mode 100755 script/generate create mode 100644 tmp/cache/.emptydir create mode 100644 vendor/zynapse/action_controller.php create mode 100644 vendor/zynapse/action_view.php create mode 100644 vendor/zynapse/action_view/helpers.php create mode 100644 vendor/zynapse/action_view/helpers/form_tag_helper.php create mode 100644 vendor/zynapse/action_view/helpers/javascript_helper.php create mode 100644 vendor/zynapse/action_view/helpers/url_helper.php create mode 100644 vendor/zynapse/action_view/helpers/views_helper.php create mode 100644 vendor/zynapse/active_record.php create mode 100644 vendor/zynapse/dispatcher.php create mode 100644 vendor/zynapse/inflections.php create mode 100644 vendor/zynapse/inflector.php create mode 100644 vendor/zynapse/input_filter.php create mode 100644 vendor/zynapse/preferences.php create mode 100644 vendor/zynapse/router.php create mode 100644 vendor/zynapse/session.php create mode 100644 vendor/zynapse/shell_script.php create mode 100644 vendor/zynapse/shell_scripts/fix_permissions.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/controller_generator.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/error_generator.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/layout_generator.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/model_generator.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/snippet_generator.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/controller.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/error_404.phtml create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/error_500.phtml create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/error_default.phtml create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/error_development_default.phtml create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/helper.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/layout.phtml create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/model.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/snippet.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/snippet_helper.php create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/snippet_view.phtml create mode 100644 vendor/zynapse/shell_scripts/znap_generator/templates/view.phtml create mode 100644 vendor/zynapse/snippet_controller.php create mode 100644 vendor/zynapse/strings.php create mode 100644 vendor/zynapse/timer.php create mode 100644 vendor/zynapse/znap_error.php create mode 100644 vendor/zynapse/znap_error/default/404.phtml create mode 100644 vendor/zynapse/znap_error/default/500.phtml create mode 100644 vendor/zynapse/znap_error/default/default.phtml create mode 100644 vendor/zynapse/znap_error/development/default.phtml create mode 100644 vendor/zynapse/zynapse.php diff --git a/app/controllers/admin/admin_controller.php b/app/controllers/admin/admin_controller.php new file mode 100644 index 0000000..615e7e7 --- /dev/null +++ b/app/controllers/admin/admin_controller.php @@ -0,0 +1,16 @@ +render_layout = false; + echo ' controller called '; + } +} + +?> \ No newline at end of file diff --git a/app/controllers/application.php b/app/controllers/application.php new file mode 100644 index 0000000..6cd5a48 --- /dev/null +++ b/app/controllers/application.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/app/controllers/page_controller.php b/app/controllers/page_controller.php new file mode 100644 index 0000000..fd38eb2 --- /dev/null +++ b/app/controllers/page_controller.php @@ -0,0 +1,65 @@ +redirect_to('back'); + } + + @$_SESSION['views']++; + $this->views = $_SESSION['views']; + + // new Page object experiments + // $newpage = new Page(); + // $newpage->id = 8; + // $newpage->title = 'anything else'; + // $newpage->body = '...maybe not...'; + // $newpage->get_association('person'); + // $newpage->error_title = 'error message'; // define errors + // print_r($newpage); + // $newpage->save(); + // echo $newpage->build_update_query($newpage)."\n
"; + + // $newpage->delete_all('`id` > 11'); + + + // get page list + $page = new Page(); + $this->columns = $page->_columns; + $this->pages = $page->find_all(); + + + // App::$prefs->yay = 'hello'; + // unset(App::$prefs->yay); + // App::$prefs->save(); + // print_r(Znap::$prefs); + + // print_r($this->page); + // print_r(Page::$table_info); + // print_r($this->page->_columns); + } + + + function view () { + if ( isset($_REQUEST['id']) ) { + $page = new Page(); + $this->columns = $page->_columns; + $this->page = $page->find($_REQUEST['id']); + } + } + + + function edit () { + + } + + +} + +?> \ No newline at end of file diff --git a/app/controllers/snippet_testing_controller.php b/app/controllers/snippet_testing_controller.php new file mode 100644 index 0000000..40867c6 --- /dev/null +++ b/app/controllers/snippet_testing_controller.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/app/helpers/application_helper.php b/app/helpers/application_helper.php new file mode 100644 index 0000000..ba2e1f6 --- /dev/null +++ b/app/helpers/application_helper.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/app/helpers/snippet_helpers/snippets_helper.php b/app/helpers/snippet_helpers/snippets_helper.php new file mode 100644 index 0000000..ba2e1f6 --- /dev/null +++ b/app/helpers/snippet_helpers/snippets_helper.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/app/helpers/snippet_helpers/test_helper.php b/app/helpers/snippet_helpers/test_helper.php new file mode 100644 index 0000000..54857c8 --- /dev/null +++ b/app/helpers/snippet_helpers/test_helper.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/app/helpers/snippet_testing_helper.php b/app/helpers/snippet_testing_helper.php new file mode 100644 index 0000000..3e79189 --- /dev/null +++ b/app/helpers/snippet_testing_helper.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/app/models/category.php b/app/models/category.php new file mode 100644 index 0000000..2f1766c --- /dev/null +++ b/app/models/category.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/app/models/comment.php b/app/models/comment.php new file mode 100644 index 0000000..a19f2bc --- /dev/null +++ b/app/models/comment.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/app/models/page.php b/app/models/page.php new file mode 100644 index 0000000..270a24b --- /dev/null +++ b/app/models/page.php @@ -0,0 +1,41 @@ + array( + // 'class_name' => 'Comment', + // 'foreign_key' => 'page_id', + // 'conditions' => array('is_public' => 1), + // ), + // ); + + + // public $table_name = 'whatever'; + // public $primary_key = 'id'; + + + // public $type = 'mysql'; + // public $host = 'db.domain.com'; + // public $database = 'librarious_db'; + // public $username = 'root'; + // public $password = ''; + // public $persistent = false; + // public $table_prefix = 'znap_'; + // public $table_name = 'collection'; + + + function validate_title () { + if ( $this->title == '' ) { + $this->error_title = 'Title can not be empty.'; + } + } + +} + +?> \ No newline at end of file diff --git a/app/preferences/_internals.prefs.php b/app/preferences/_internals.prefs.php new file mode 100644 index 0000000..c77db67 --- /dev/null +++ b/app/preferences/_internals.prefs.php @@ -0,0 +1,31 @@ +js_url = "/javascripts"; + $this->js_libs_url = "/javascripts/libs"; + $this->js_libs = array( + 'jquery' => "jquery-1.2.1.pack.js", + ); + $this->js_charset = "utf-8"; + } + +} + +?> \ No newline at end of file diff --git a/app/preferences/application.prefs.php b/app/preferences/application.prefs.php new file mode 100644 index 0000000..bca3071 --- /dev/null +++ b/app/preferences/application.prefs.php @@ -0,0 +1,23 @@ +language = "english"; + } + +} + +?> \ No newline at end of file diff --git a/app/snippets/snippets.php b/app/snippets/snippets.php new file mode 100644 index 0000000..3ca5d07 --- /dev/null +++ b/app/snippets/snippets.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/app/snippets/test_snippet.php b/app/snippets/test_snippet.php new file mode 100644 index 0000000..c9e1c29 --- /dev/null +++ b/app/snippets/test_snippet.php @@ -0,0 +1,16 @@ +message = 'hello world'; + } + + function wiiee () { + $this->message = 'helppppp'; + $this->render_action = 'index'; + } + +} + +?> \ No newline at end of file diff --git a/app/views-wap/__layouts/.emptydir b/app/views-wap/__layouts/.emptydir new file mode 100644 index 0000000..e69de29 diff --git a/app/views-wap/__snippets/.emptydir b/app/views-wap/__snippets/.emptydir new file mode 100644 index 0000000..e69de29 diff --git a/app/views/__layouts/_navpane.phtml b/app/views/__layouts/_navpane.phtml new file mode 100644 index 0000000..267b232 --- /dev/null +++ b/app/views/__layouts/_navpane.phtml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/app/views/__layouts/application.phtml b/app/views/__layouts/application.phtml new file mode 100644 index 0000000..d1e648d --- /dev/null +++ b/app/views/__layouts/application.phtml @@ -0,0 +1,31 @@ + + + + + + + application + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + diff --git a/app/views/__layouts/page.phtml b/app/views/__layouts/page.phtml new file mode 100644 index 0000000..e21f9a1 --- /dev/null +++ b/app/views/__layouts/page.phtml @@ -0,0 +1,34 @@ + + + + + + + page + + + + + + + + +
+ +
+ + + + +
+
+ + + +
+
+
+ + + diff --git a/app/views/__snippets/__layouts/snippets.phtml b/app/views/__snippets/__layouts/snippets.phtml new file mode 100644 index 0000000..3f29013 --- /dev/null +++ b/app/views/__snippets/__layouts/snippets.phtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/views/__snippets/test/index.phtml b/app/views/__snippets/test/index.phtml new file mode 100644 index 0000000..a18bc82 --- /dev/null +++ b/app/views/__snippets/test/index.phtml @@ -0,0 +1 @@ + :) \ No newline at end of file diff --git a/app/views/_admin/admin/index.phtml b/app/views/_admin/admin/index.phtml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/_admin/admin/view.phtml b/app/views/_admin/admin/view.phtml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/page/_comment.phtml b/app/views/page/_comment.phtml new file mode 100644 index 0000000..fb517ed --- /dev/null +++ b/app/views/page/_comment.phtml @@ -0,0 +1,5 @@ +
+
+
    —
+
+
\ No newline at end of file diff --git a/app/views/page/_page_list_item.phtml b/app/views/page/_page_list_item.phtml new file mode 100644 index 0000000..e0c1219 --- /dev/null +++ b/app/views/page/_page_list_item.phtml @@ -0,0 +1,9 @@ + + $value): ?> + + + + + + + \ No newline at end of file diff --git a/app/views/page/index.phtml b/app/views/page/index.phtml new file mode 100644 index 0000000..8c1ce80 --- /dev/null +++ b/app/views/page/index.phtml @@ -0,0 +1,16 @@ +hello world!
+
+you've seen this page time 1) echo 's'; ?>.
reset + + + + + + $col_info): ?> + + + + +
+ + \ No newline at end of file diff --git a/app/views/page/view.phtml b/app/views/page/view.phtml new file mode 100644 index 0000000..c52eac5 --- /dev/null +++ b/app/views/page/view.phtml @@ -0,0 +1,28 @@ + + $value): if (array_key_exists($key, $columns)): ?> + :
+ +categories ): ?> + Categories: categories as $category) { + $cats[] = $category['name']; + } + echo implode(', ', $cats); + ?> + + +
+
+Comments:
+
+comments ): ?> + comments); ?> + +- No Comments -
+
+ + + +The page you're trying to view doesn't exist. + \ No newline at end of file diff --git a/app/views/snippet_testing/index.phtml b/app/views/snippet_testing/index.phtml new file mode 100644 index 0000000..3be23b2 --- /dev/null +++ b/app/views/snippet_testing/index.phtml @@ -0,0 +1,4 @@ +testing a snippet here: +
+ +
\ No newline at end of file diff --git a/config/boot.php b/config/boot.php new file mode 100644 index 0000000..55b0ec6 --- /dev/null +++ b/config/boot.php @@ -0,0 +1,103 @@ + $settings ) { + $regex = preg_quote($host, '/'); + $regex = str_replace('\*', '.*', $regex); + $http_host = (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') ? substr($_SERVER['HTTP_HOST'], 4) : $_SERVER['HTTP_HOST'] ; + if ( preg_match('/^'.$regex.'$/i', $http_host) ) { + foreach( $settings as $key => $value ) { + if ( !array_key_exists($key, $new_config) ) { + $new_config[$key] = $value; + } + } + } + } + } + return (!empty($new_config)) ? $new_config : false ; +} + + +?> \ No newline at end of file diff --git a/config/database.php b/config/database.php new file mode 100644 index 0000000..49364a9 --- /dev/null +++ b/config/database.php @@ -0,0 +1,40 @@ + array( + 'host' => 'localhost', + 'database' => 'zynapse_development', + 'username' => 'devuser', + 'password' => 'devpass', + 'persistent' => true, + 'table_prefix' => '', + ), + + // database settings for testing environment + 'test' => array( + 'use' => 'development', + ), + + // database settings for production environment + 'production' => array( + 'host' => 'localhost', + 'database' => 'database_name', + 'username' => 'user', + 'password' => 'password', + 'persistent' => true, + 'table_prefix' => '', + ), + +); + + +?> \ No newline at end of file diff --git a/config/environment.php b/config/environment.php new file mode 100644 index 0000000..bb261cd --- /dev/null +++ b/config/environment.php @@ -0,0 +1,72 @@ + array( + // + // ), + // 'wap.zynapse' => array( + // 'mode' => 'wap', + // ), + // 'admin.zynapse' => array( + // 'root' => 'admin', + // ), + // 'zynapse.org' => array( + // 'environment' => 'production', + // ), + // 'admin.zynapse.org' => array( + // 'environment' => 'production', + // 'root' => 'admin', + // ), +); + + +# set custom path to zynapse libs +$zynapse_libs = ''; + + +# Timer enabled in production environment? +# - its always enabled in development and test environments +$timer_enabled = false; + + +# enable php error logging? - recommended +$enable_logging = true; + +# enable internal error logging? - recommended +$internal_logging = true; + + +# if zynapse's root is not the root of the server, define +# the prefix path (without leading or trailing slashes). +$url_prefix = ''; + + + +?> \ No newline at end of file diff --git a/config/environments/_shell.php b/config/environments/_shell.php new file mode 100644 index 0000000..9e3087d --- /dev/null +++ b/config/environments/_shell.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/config/environments/development.php b/config/environments/development.php new file mode 100644 index 0000000..00b92e1 --- /dev/null +++ b/config/environments/development.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/config/environments/production.php b/config/environments/production.php new file mode 100644 index 0000000..3b01f05 --- /dev/null +++ b/config/environments/production.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/config/environments/test.php b/config/environments/test.php new file mode 100644 index 0000000..a47c3bc --- /dev/null +++ b/config/environments/test.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/config/routes.php b/config/routes.php new file mode 100644 index 0000000..7b9d081 --- /dev/null +++ b/config/routes.php @@ -0,0 +1,21 @@ +connect('', array(':controller'=>'page')); +$router->connect( 'page/:id([0-9]+)', array(':controller' => 'page', ':action' => 'view', 'test' => 'wiiee') ); +$router->connect( ':controller/:action/:id/:sort/:order' ); + +$router->connect( 'pages', array(':redirect_to' => '/page') ); + + +// default route +$router->connect( ':controller/:action/:id' ); + + +?> \ No newline at end of file diff --git a/config/strings/_global.php b/config/strings/_global.php new file mode 100644 index 0000000..aa6284a --- /dev/null +++ b/config/strings/_global.php @@ -0,0 +1,18 @@ + 'some awesome text', + + +); + +?> \ No newline at end of file diff --git a/config/strings/english.php b/config/strings/english.php new file mode 100644 index 0000000..d577929 --- /dev/null +++ b/config/strings/english.php @@ -0,0 +1,46 @@ + 'English', + + # short language name + '_ZNAP_LANG' => 'en', + + # language locale values + '_ZNAP_LOCALE' => array('eng', 'en_US'), + + # character encoding + '_ZNAP_ENCODING' => 'utf-8', + + + + +/* + + Custom Strings + - add your custom strings here + +*/ + + // 'my_string' => 'some awesome text', + + + +); + +?> \ No newline at end of file diff --git a/db/zynapse_development.sql b/db/zynapse_development.sql new file mode 100644 index 0000000..1780ae0 --- /dev/null +++ b/db/zynapse_development.sql @@ -0,0 +1,98 @@ +# Sequel Pro dump +# Version 254 +# http://code.google.com/p/sequel-pro +# +# Host: localhost (MySQL 5.0.67) +# Database: reznap_development +# Generation Time: 2009-01-02 19:18:43 +0200 +# ************************************************************ + +# Dump of table categories +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `categories`; + +CREATE TABLE `categories` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(64) NOT NULL, + `description` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; + +INSERT INTO `categories` (`id`,`name`,`description`) +VALUES + (1,'info',''), + (2,'stuff',''); + + + +# Dump of table categories_pages +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `categories_pages`; + +CREATE TABLE `categories_pages` ( + `id` int(11) NOT NULL auto_increment, + `category_id` int(11) NOT NULL, + `page_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `category_id` (`category_id`), + KEY `page_id` (`page_id`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; + +INSERT INTO `categories_pages` (`id`,`category_id`,`page_id`) +VALUES + (1,1,2), + (2,2,2), + (3,1,1); + + + +# Dump of table comments +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `comments`; + +CREATE TABLE `comments` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(64) NOT NULL, + `email` varchar(255) NOT NULL, + `url` varchar(255) NOT NULL, + `body` text NOT NULL, + `page_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `page_id` (`page_id`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; + +INSERT INTO `comments` (`id`,`name`,`email`,`url`,`body`,`page_id`) +VALUES + (1,'jim','','','fuck this is cool',2), + (2,'peter','ithinkicanfly@petrelli.com','','you suck! you really suck!!',2); + + + +# Dump of table pages +# ------------------------------------------------------------ + +DROP TABLE IF EXISTS `pages`; + +CREATE TABLE `pages` ( + `id` int(11) NOT NULL auto_increment, + `title` varchar(64) NOT NULL, + `body` text NOT NULL, + `created_at` int(11) default NULL, + `modified_at` int(11) default NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; + +INSERT INTO `pages` (`id`,`title`,`body`,`created_at`,`modified_at`) +VALUES + (1,'home page','wiiee, this is the HOME page, thingy... kinda... lol!',NULL,NULL), + (2,'another page :P','this is yet another page-thingy, this is cool... hehe :D :P',NULL,NULL), + (3,'my page','my page is awesome, so awesome :$',NULL,NULL), + (4,'iphone','omg omg omg omg O M G ! ! ! !',NULL,NULL), + (10,'title','body',NULL,NULL), + (11,'anything else','...maybe not...',NULL,NULL); + + + diff --git a/libs/.emptydir b/libs/.emptydir new file mode 100644 index 0000000..e69de29 diff --git a/logs/development.log b/logs/development.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/production.log b/logs/production.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/test.log b/logs/test.log new file mode 100644 index 0000000..e69de29 diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..58eaa7c --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,12 @@ + +RewriteEngine On + +RewriteRule ^.*\.svn.*$ /404 + +RewriteRule ^$ index.html [QSA] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !favicon.ico +RewriteCond %{REQUEST_FILENAME} !robots.txt +RewriteRule ^(.*)$ /dispatch.php [QSA,L] + diff --git a/public/dispatch.php b/public/dispatch.php new file mode 100644 index 0000000..acf7ff7 --- /dev/null +++ b/public/dispatch.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/public/images/.emptydir b/public/images/.emptydir new file mode 100644 index 0000000..e69de29 diff --git a/public/javascripts/libs/jquery-1.2.1.pack.js b/public/javascripts/libs/jquery-1.2.1.pack.js new file mode 100644 index 0000000..d646859 --- /dev/null +++ b/public/javascripts/libs/jquery-1.2.1.pack.js @@ -0,0 +1,11 @@ +/* + * jQuery 1.2.1 - New Wave Javascript + * + * Copyright (c) 2007 John Resig (jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $ + * $Rev: 3353 $ + */ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(G(){9(1m E!="W")H w=E;H E=18.15=G(a,b){I 6 7u E?6.5N(a,b):1u E(a,b)};9(1m $!="W")H D=$;18.$=E;H u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;E.1b=E.3A={5N:G(c,a){c=c||U;9(1m c=="1M"){H m=u.2S(c);9(m&&(m[1]||!a)){9(m[1])c=E.4D([m[1]],a);J{H b=U.3S(m[3]);9(b)9(b.22!=m[3])I E().1Y(c);J{6[0]=b;6.K=1;I 6}J c=[]}}J I 1u E(a).1Y(c)}J 9(E.1n(c))I 1u E(U)[E.1b.2d?"2d":"39"](c);I 6.6v(c.1c==1B&&c||(c.4c||c.K&&c!=18&&!c.1y&&c[0]!=W&&c[0].1y)&&E.2h(c)||[c])},4c:"1.2.1",7Y:G(){I 6.K},K:0,21:G(a){I a==W?E.2h(6):6[a]},2o:G(a){H b=E(a);b.4Y=6;I b},6v:G(a){6.K=0;1B.3A.1a.16(6,a);I 6},N:G(a,b){I E.N(6,a,b)},4I:G(a){H b=-1;6.N(G(i){9(6==a)b=i});I b},1x:G(f,d,e){H c=f;9(f.1c==3X)9(d==W)I 6.K&&E[e||"1x"](6[0],f)||W;J{c={};c[f]=d}I 6.N(G(a){L(H b 1i c)E.1x(e?6.R:6,b,E.1e(6,c[b],e,a,b))})},17:G(b,a){I 6.1x(b,a,"3C")},2g:G(e){9(1m e!="5i"&&e!=S)I 6.4n().3g(U.6F(e));H t="";E.N(e||6,G(){E.N(6.3j,G(){9(6.1y!=8)t+=6.1y!=1?6.6x:E.1b.2g([6])})});I t},5m:G(b){9(6[0])E(b,6[0].3H).6u().3d(6[0]).1X(G(){H a=6;1W(a.1w)a=a.1w;I a}).3g(6);I 6},8m:G(a){I 6.N(G(){E(6).6q().5m(a)})},8d:G(a){I 6.N(G(){E(6).5m(a)})},3g:G(){I 6.3z(1q,Q,1,G(a){6.58(a)})},6j:G(){I 6.3z(1q,Q,-1,G(a){6.3d(a,6.1w)})},6g:G(){I 6.3z(1q,P,1,G(a){6.12.3d(a,6)})},50:G(){I 6.3z(1q,P,-1,G(a){6.12.3d(a,6.2q)})},2D:G(){I 6.4Y||E([])},1Y:G(t){H b=E.1X(6,G(a){I E.1Y(t,a)});I 6.2o(/[^+>] [^+>]/.14(t)||t.1g("..")>-1?E.4V(b):b)},6u:G(e){H f=6.1X(G(){I 6.67?E(6.67)[0]:6.4R(Q)});H d=f.1Y("*").4O().N(G(){9(6[F]!=W)6[F]=S});9(e===Q)6.1Y("*").4O().N(G(i){H c=E.M(6,"2P");L(H a 1i c)L(H b 1i c[a])E.1j.1f(d[i],a,c[a][b],c[a][b].M)});I f},1E:G(t){I 6.2o(E.1n(t)&&E.2W(6,G(b,a){I t.16(b,[a])})||E.3m(t,6))},5V:G(t){I 6.2o(t.1c==3X&&E.3m(t,6,Q)||E.2W(6,G(a){I(t.1c==1B||t.4c)?E.2A(a,t)<0:a!=t}))},1f:G(t){I 6.2o(E.1R(6.21(),t.1c==3X?E(t).21():t.K!=W&&(!t.11||E.11(t,"2Y"))?t:[t]))},3t:G(a){I a?E.3m(a,6).K>0:P},7c:G(a){I 6.3t("."+a)},3i:G(b){9(b==W){9(6.K){H c=6[0];9(E.11(c,"24")){H e=c.4Z,a=[],Y=c.Y,2G=c.O=="24-2G";9(e<0)I S;L(H i=2G?e:0,33=2G?e+1:Y.K;i<33;i++){H d=Y[i];9(d.26){H b=E.V.1h&&!d.9V["1Q"].9L?d.2g:d.1Q;9(2G)I b;a.1a(b)}}I a}J I 6[0].1Q.1p(/\\r/g,"")}}J I 6.N(G(){9(b.1c==1B&&/4k|5j/.14(6.O))6.2Q=(E.2A(6.1Q,b)>=0||E.2A(6.2H,b)>=0);J 9(E.11(6,"24")){H a=b.1c==1B?b:[b];E("9h",6).N(G(){6.26=(E.2A(6.1Q,a)>=0||E.2A(6.2g,a)>=0)});9(!a.K)6.4Z=-1}J 6.1Q=b})},4o:G(a){I a==W?(6.K?6[0].3O:S):6.4n().3g(a)},6H:G(a){I 6.50(a).28()},6E:G(i){I 6.2J(i,i+1)},2J:G(){I 6.2o(1B.3A.2J.16(6,1q))},1X:G(b){I 6.2o(E.1X(6,G(a,i){I b.2O(a,i,a)}))},4O:G(){I 6.1f(6.4Y)},3z:G(f,d,g,e){H c=6.K>1,a;I 6.N(G(){9(!a){a=E.4D(f,6.3H);9(g<0)a.8U()}H b=6;9(d&&E.11(6,"1I")&&E.11(a[0],"4m"))b=6.4l("1K")[0]||6.58(U.5B("1K"));E.N(a,G(){H a=c?6.4R(Q):6;9(!5A(0,a))e.2O(b,a)})})}};G 5A(i,b){H a=E.11(b,"1J");9(a){9(b.3k)E.3G({1d:b.3k,3e:P,1V:"1J"});J E.5f(b.2g||b.6s||b.3O||"");9(b.12)b.12.3b(b)}J 9(b.1y==1)E("1J",b).N(5A);I a}E.1k=E.1b.1k=G(){H c=1q[0]||{},a=1,2c=1q.K,5e=P;9(c.1c==8o){5e=c;c=1q[1]||{}}9(2c==1){c=6;a=0}H b;L(;a<2c;a++)9((b=1q[a])!=S)L(H i 1i b){9(c==b[i])6r;9(5e&&1m b[i]==\'5i\'&&c[i])E.1k(c[i],b[i]);J 9(b[i]!=W)c[i]=b[i]}I c};H F="15"+(1u 3D()).3B(),6p=0,5c={};E.1k({8a:G(a){18.$=D;9(a)18.15=w;I E},1n:G(a){I!!a&&1m a!="1M"&&!a.11&&a.1c!=1B&&/G/i.14(a+"")},4a:G(a){I a.2V&&!a.1G||a.37&&a.3H&&!a.3H.1G},5f:G(a){a=E.36(a);9(a){9(18.6l)18.6l(a);J 9(E.V.1N)18.56(a,0);J 3w.2O(18,a)}},11:G(b,a){I b.11&&b.11.27()==a.27()},1L:{},M:G(c,d,b){c=c==18?5c:c;H a=c[F];9(!a)a=c[F]=++6p;9(d&&!E.1L[a])E.1L[a]={};9(b!=W)E.1L[a][d]=b;I d?E.1L[a][d]:a},30:G(c,b){c=c==18?5c:c;H a=c[F];9(b){9(E.1L[a]){2E E.1L[a][b];b="";L(b 1i E.1L[a])1T;9(!b)E.30(c)}}J{2a{2E c[F]}29(e){9(c.53)c.53(F)}2E E.1L[a]}},N:G(a,b,c){9(c){9(a.K==W)L(H i 1i a)b.16(a[i],c);J L(H i=0,48=a.K;i<48;i++)9(b.16(a[i],c)===P)1T}J{9(a.K==W)L(H i 1i a)b.2O(a[i],i,a[i]);J L(H i=0,48=a.K,3i=a[0];i<48&&b.2O(3i,i,3i)!==P;3i=a[++i]){}}I a},1e:G(c,b,d,e,a){9(E.1n(b))b=b.2O(c,[e]);H f=/z-?4I|7T-?7Q|1r|69|7P-?1H/i;I b&&b.1c==4W&&d=="3C"&&!f.14(a)?b+"2T":b},1o:{1f:G(b,c){E.N((c||"").2l(/\\s+/),G(i,a){9(!E.1o.3K(b.1o,a))b.1o+=(b.1o?" ":"")+a})},28:G(b,c){b.1o=c!=W?E.2W(b.1o.2l(/\\s+/),G(a){I!E.1o.3K(c,a)}).66(" "):""},3K:G(t,c){I E.2A(c,(t.1o||t).3s().2l(/\\s+/))>-1}},2k:G(e,o,f){L(H i 1i o){e.R["3r"+i]=e.R[i];e.R[i]=o[i]}f.16(e,[]);L(H i 1i o)e.R[i]=e.R["3r"+i]},17:G(e,p){9(p=="1H"||p=="2N"){H b={},42,41,d=["7J","7I","7G","7F"];E.N(d,G(){b["7C"+6]=0;b["7B"+6+"5Z"]=0});E.2k(e,b,G(){9(E(e).3t(\':3R\')){42=e.7A;41=e.7w}J{e=E(e.4R(Q)).1Y(":4k").5W("2Q").2D().17({4C:"1P",2X:"4F",19:"2Z",7o:"0",1S:"0"}).5R(e.12)[0];H a=E.17(e.12,"2X")||"3V";9(a=="3V")e.12.R.2X="7g";42=e.7e;41=e.7b;9(a=="3V")e.12.R.2X="3V";e.12.3b(e)}});I p=="1H"?42:41}I E.3C(e,p)},3C:G(h,j,i){H g,2w=[],2k=[];G 3n(a){9(!E.V.1N)I P;H b=U.3o.3Z(a,S);I!b||b.4y("3n")==""}9(j=="1r"&&E.V.1h){g=E.1x(h.R,"1r");I g==""?"1":g}9(j.1t(/4u/i))j=y;9(!i&&h.R[j])g=h.R[j];J 9(U.3o&&U.3o.3Z){9(j.1t(/4u/i))j="4u";j=j.1p(/([A-Z])/g,"-$1").2p();H d=U.3o.3Z(h,S);9(d&&!3n(h))g=d.4y(j);J{L(H a=h;a&&3n(a);a=a.12)2w.4w(a);L(a=0;a<2w.K;a++)9(3n(2w[a])){2k[a]=2w[a].R.19;2w[a].R.19="2Z"}g=j=="19"&&2k[2w.K-1]!=S?"2s":U.3o.3Z(h,S).4y(j)||"";L(a=0;a<2k.K;a++)9(2k[a]!=S)2w[a].R.19=2k[a]}9(j=="1r"&&g=="")g="1"}J 9(h.3Q){H f=j.1p(/\\-(\\w)/g,G(m,c){I c.27()});g=h.3Q[j]||h.3Q[f];9(!/^\\d+(2T)?$/i.14(g)&&/^\\d/.14(g)){H k=h.R.1S;H e=h.4v.1S;h.4v.1S=h.3Q.1S;h.R.1S=g||0;g=h.R.71+"2T";h.R.1S=k;h.4v.1S=e}}I g},4D:G(a,e){H r=[];e=e||U;E.N(a,G(i,d){9(!d)I;9(d.1c==4W)d=d.3s();9(1m d=="1M"){d=d.1p(/(<(\\w+)[^>]*?)\\/>/g,G(m,a,b){I b.1t(/^(70|6Z|6Y|9Q|4t|9N|9K|3a|9G|9E)$/i)?m:a+">"});H s=E.36(d).2p(),1s=e.5B("1s"),2x=[];H c=!s.1g("<9y")&&[1,"<24>",""]||!s.1g("<9w")&&[1,"<6T>",""]||s.1t(/^<(9u|1K|9t|9r|9p)/)&&[1,"<1I>",""]||!s.1g("<4m")&&[2,"<1I><1K>",""]||(!s.1g("<9m")||!s.1g("<9k"))&&[3,"<1I><1K><4m>",""]||!s.1g("<6Y")&&[2,"<1I><1K><6L>",""]||E.V.1h&&[1,"1s<1s>",""]||[0,"",""];1s.3O=c[1]+d+c[2];1W(c[0]--)1s=1s.5p;9(E.V.1h){9(!s.1g("<1I")&&s.1g("<1K")<0)2x=1s.1w&&1s.1w.3j;J 9(c[1]=="<1I>"&&s.1g("<1K")<0)2x=1s.3j;L(H n=2x.K-1;n>=0;--n)9(E.11(2x[n],"1K")&&!2x[n].3j.K)2x[n].12.3b(2x[n]);9(/^\\s/.14(d))1s.3d(e.6F(d.1t(/^\\s*/)[0]),1s.1w)}d=E.2h(1s.3j)}9(0===d.K&&(!E.11(d,"2Y")&&!E.11(d,"24")))I;9(d[0]==W||E.11(d,"2Y")||d.Y)r.1a(d);J r=E.1R(r,d)});I r},1x:G(c,d,a){H e=E.4a(c)?{}:E.5o;9(d=="26"&&E.V.1N)c.12.4Z;9(e[d]){9(a!=W)c[e[d]]=a;I c[e[d]]}J 9(E.V.1h&&d=="R")I E.1x(c.R,"9e",a);J 9(a==W&&E.V.1h&&E.11(c,"2Y")&&(d=="9d"||d=="9a"))I c.97(d).6x;J 9(c.37){9(a!=W){9(d=="O"&&E.11(c,"4t")&&c.12)6G"O 94 93\'t 92 91";c.90(d,a)}9(E.V.1h&&/6C|3k/.14(d)&&!E.4a(c))I c.4p(d,2);I c.4p(d)}J{9(d=="1r"&&E.V.1h){9(a!=W){c.69=1;c.1E=(c.1E||"").1p(/6O\\([^)]*\\)/,"")+(3I(a).3s()=="8S"?"":"6O(1r="+a*6A+")")}I c.1E?(3I(c.1E.1t(/1r=([^)]*)/)[1])/6A).3s():""}d=d.1p(/-([a-z])/8Q,G(z,b){I b.27()});9(a!=W)c[d]=a;I c[d]}},36:G(t){I(t||"").1p(/^\\s+|\\s+$/g,"")},2h:G(a){H r=[];9(1m a!="8P")L(H i=0,2c=a.K;i<2c;i++)r.1a(a[i]);J r=a.2J(0);I r},2A:G(b,a){L(H i=0,2c=a.K;i<2c;i++)9(a[i]==b)I i;I-1},1R:G(a,b){9(E.V.1h){L(H i=0;b[i];i++)9(b[i].1y!=8)a.1a(b[i])}J L(H i=0;b[i];i++)a.1a(b[i]);I a},4V:G(b){H r=[],2f={};2a{L(H i=0,6y=b.K;i<6y;i++){H a=E.M(b[i]);9(!2f[a]){2f[a]=Q;r.1a(b[i])}}}29(e){r=b}I r},2W:G(b,a,c){9(1m a=="1M")a=3w("P||G(a,i){I "+a+"}");H d=[];L(H i=0,4g=b.K;i<4g;i++)9(!c&&a(b[i],i)||c&&!a(b[i],i))d.1a(b[i]);I d},1X:G(c,b){9(1m b=="1M")b=3w("P||G(a){I "+b+"}");H d=[];L(H i=0,4g=c.K;i<4g;i++){H a=b(c[i],i);9(a!==S&&a!=W){9(a.1c!=1B)a=[a];d=d.8M(a)}}I d}});H v=8K.8I.2p();E.V={4s:(v.1t(/.+(?:8F|8E|8C|8B)[\\/: ]([\\d.]+)/)||[])[1],1N:/6w/.14(v),34:/34/.14(v),1h:/1h/.14(v)&&!/34/.14(v),35:/35/.14(v)&&!/(8z|6w)/.14(v)};H y=E.V.1h?"4h":"5h";E.1k({5g:!E.V.1h||U.8y=="8x",4h:E.V.1h?"4h":"5h",5o:{"L":"8w","8v":"1o","4u":y,5h:y,4h:y,3O:"3O",1o:"1o",1Q:"1Q",3c:"3c",2Q:"2Q",8u:"8t",26:"26",8s:"8r"}});E.N({1D:"a.12",8q:"15.4e(a,\'12\')",8p:"15.2I(a,2,\'2q\')",8n:"15.2I(a,2,\'4d\')",8l:"15.4e(a,\'2q\')",8k:"15.4e(a,\'4d\')",8j:"15.5d(a.12.1w,a)",8i:"15.5d(a.1w)",6q:"15.11(a,\'8h\')?a.8f||a.8e.U:15.2h(a.3j)"},G(i,n){E.1b[i]=G(a){H b=E.1X(6,n);9(a&&1m a=="1M")b=E.3m(a,b);I 6.2o(E.4V(b))}});E.N({5R:"3g",8c:"6j",3d:"6g",8b:"50",89:"6H"},G(i,n){E.1b[i]=G(){H a=1q;I 6.N(G(){L(H j=0,2c=a.K;j<2c;j++)E(a[j])[n](6)})}});E.N({5W:G(a){E.1x(6,a,"");6.53(a)},88:G(c){E.1o.1f(6,c)},87:G(c){E.1o.28(6,c)},86:G(c){E.1o[E.1o.3K(6,c)?"28":"1f"](6,c)},28:G(a){9(!a||E.1E(a,[6]).r.K){E.30(6);6.12.3b(6)}},4n:G(){E("*",6).N(G(){E.30(6)});1W(6.1w)6.3b(6.1w)}},G(i,n){E.1b[i]=G(){I 6.N(n,1q)}});E.N(["85","5Z"],G(i,a){H n=a.2p();E.1b[n]=G(h){I 6[0]==18?E.V.1N&&3y["84"+a]||E.5g&&38.33(U.2V["5a"+a],U.1G["5a"+a])||U.1G["5a"+a]:6[0]==U?38.33(U.1G["6n"+a],U.1G["6m"+a]):h==W?(6.K?E.17(6[0],n):S):6.17(n,h.1c==3X?h:h+"2T")}});H C=E.V.1N&&3x(E.V.4s)<83?"(?:[\\\\w*57-]|\\\\\\\\.)":"(?:[\\\\w\\82-\\81*57-]|\\\\\\\\.)",6k=1u 47("^>\\\\s*("+C+"+)"),6i=1u 47("^("+C+"+)(#)("+C+"+)"),6h=1u 47("^([#.]?)("+C+"*)");E.1k({55:{"":"m[2]==\'*\'||15.11(a,m[2])","#":"a.4p(\'22\')==m[2]",":":{80:"im[3]-0",2I:"m[3]-0==i",6E:"m[3]-0==i",3v:"i==0",3u:"i==r.K-1",6f:"i%2==0",6e:"i%2","3v-46":"a.12.4l(\'*\')[0]==a","3u-46":"15.2I(a.12.5p,1,\'4d\')==a","7X-46":"!15.2I(a.12.5p,2,\'4d\')",1D:"a.1w",4n:"!a.1w",7W:"(a.6s||a.7V||15(a).2g()||\'\').1g(m[3])>=0",3R:\'"1P"!=a.O&&15.17(a,"19")!="2s"&&15.17(a,"4C")!="1P"\',1P:\'"1P"==a.O||15.17(a,"19")=="2s"||15.17(a,"4C")=="1P"\',7U:"!a.3c",3c:"a.3c",2Q:"a.2Q",26:"a.26||15.1x(a,\'26\')",2g:"\'2g\'==a.O",4k:"\'4k\'==a.O",5j:"\'5j\'==a.O",54:"\'54\'==a.O",52:"\'52\'==a.O",51:"\'51\'==a.O",6d:"\'6d\'==a.O",6c:"\'6c\'==a.O",2r:\'"2r"==a.O||15.11(a,"2r")\',4t:"/4t|24|6b|2r/i.14(a.11)",3K:"15.1Y(m[3],a).K",7S:"/h\\\\d/i.14(a.11)",7R:"15.2W(15.32,G(1b){I a==1b.T;}).K"}},6a:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,1u 47("^([:.#]*)("+C+"+)")],3m:G(a,c,b){H d,2b=[];1W(a&&a!=d){d=a;H f=E.1E(a,c,b);a=f.t.1p(/^\\s*,\\s*/,"");2b=b?c=f.r:E.1R(2b,f.r)}I 2b},1Y:G(t,o){9(1m t!="1M")I[t];9(o&&!o.1y)o=S;o=o||U;H d=[o],2f=[],3u;1W(t&&3u!=t){H r=[];3u=t;t=E.36(t);H l=P;H g=6k;H m=g.2S(t);9(m){H p=m[1].27();L(H i=0;d[i];i++)L(H c=d[i].1w;c;c=c.2q)9(c.1y==1&&(p=="*"||c.11.27()==p.27()))r.1a(c);d=r;t=t.1p(g,"");9(t.1g(" ")==0)6r;l=Q}J{g=/^([>+~])\\s*(\\w*)/i;9((m=g.2S(t))!=S){r=[];H p=m[2],1R={};m=m[1];L(H j=0,31=d.K;j<31;j++){H n=m=="~"||m=="+"?d[j].2q:d[j].1w;L(;n;n=n.2q)9(n.1y==1){H h=E.M(n);9(m=="~"&&1R[h])1T;9(!p||n.11.27()==p.27()){9(m=="~")1R[h]=Q;r.1a(n)}9(m=="+")1T}}d=r;t=E.36(t.1p(g,""));l=Q}}9(t&&!l){9(!t.1g(",")){9(o==d[0])d.44();2f=E.1R(2f,d);r=d=[o];t=" "+t.68(1,t.K)}J{H k=6i;H m=k.2S(t);9(m){m=[0,m[2],m[3],m[1]]}J{k=6h;m=k.2S(t)}m[2]=m[2].1p(/\\\\/g,"");H f=d[d.K-1];9(m[1]=="#"&&f&&f.3S&&!E.4a(f)){H q=f.3S(m[2]);9((E.V.1h||E.V.34)&&q&&1m q.22=="1M"&&q.22!=m[2])q=E(\'[@22="\'+m[2]+\'"]\',f)[0];d=r=q&&(!m[3]||E.11(q,m[3]))?[q]:[]}J{L(H i=0;d[i];i++){H a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];9(a=="*"&&d[i].11.2p()=="5i")a="3a";r=E.1R(r,d[i].4l(a))}9(m[1]==".")r=E.4X(r,m[2]);9(m[1]=="#"){H e=[];L(H i=0;r[i];i++)9(r[i].4p("22")==m[2]){e=[r[i]];1T}r=e}d=r}t=t.1p(k,"")}}9(t){H b=E.1E(t,r);d=r=b.r;t=E.36(b.t)}}9(t)d=[];9(d&&o==d[0])d.44();2f=E.1R(2f,d);I 2f},4X:G(r,m,a){m=" "+m+" ";H c=[];L(H i=0;r[i];i++){H b=(" "+r[i].1o+" ").1g(m)>=0;9(!a&&b||a&&!b)c.1a(r[i])}I c},1E:G(t,r,h){H d;1W(t&&t!=d){d=t;H p=E.6a,m;L(H i=0;p[i];i++){m=p[i].2S(t);9(m){t=t.7O(m[0].K);m[2]=m[2].1p(/\\\\/g,"");1T}}9(!m)1T;9(m[1]==":"&&m[2]=="5V")r=E.1E(m[3],r,Q).r;J 9(m[1]==".")r=E.4X(r,m[2],h);J 9(m[1]=="["){H g=[],O=m[3];L(H i=0,31=r.K;i<31;i++){H a=r[i],z=a[E.5o[m[2]]||m[2]];9(z==S||/6C|3k|26/.14(m[2]))z=E.1x(a,m[2])||\'\';9((O==""&&!!z||O=="="&&z==m[5]||O=="!="&&z!=m[5]||O=="^="&&z&&!z.1g(m[5])||O=="$="&&z.68(z.K-m[5].K)==m[5]||(O=="*="||O=="~=")&&z.1g(m[5])>=0)^h)g.1a(a)}r=g}J 9(m[1]==":"&&m[2]=="2I-46"){H e={},g=[],14=/(\\d*)n\\+?(\\d*)/.2S(m[3]=="6f"&&"2n"||m[3]=="6e"&&"2n+1"||!/\\D/.14(m[3])&&"n+"+m[3]||m[3]),3v=(14[1]||1)-0,d=14[2]-0;L(H i=0,31=r.K;i<31;i++){H j=r[i],12=j.12,22=E.M(12);9(!e[22]){H c=1;L(H n=12.1w;n;n=n.2q)9(n.1y==1)n.4U=c++;e[22]=Q}H b=P;9(3v==1){9(d==0||j.4U==d)b=Q}J 9((j.4U+d)%3v==0)b=Q;9(b^h)g.1a(j)}r=g}J{H f=E.55[m[1]];9(1m f!="1M")f=E.55[m[1]][m[2]];f=3w("P||G(a,i){I "+f+"}");r=E.2W(r,f,h)}}I{r:r,t:t}},4e:G(b,c){H d=[];H a=b[c];1W(a&&a!=U){9(a.1y==1)d.1a(a);a=a[c]}I d},2I:G(a,e,c,b){e=e||1;H d=0;L(;a;a=a[c])9(a.1y==1&&++d==e)1T;I a},5d:G(n,a){H r=[];L(;n;n=n.2q){9(n.1y==1&&(!a||n!=a))r.1a(n)}I r}});E.1j={1f:G(g,e,c,h){9(E.V.1h&&g.4j!=W)g=18;9(!c.2u)c.2u=6.2u++;9(h!=W){H d=c;c=G(){I d.16(6,1q)};c.M=h;c.2u=d.2u}H i=e.2l(".");e=i[0];c.O=i[1];H b=E.M(g,"2P")||E.M(g,"2P",{});H f=E.M(g,"2t",G(){H a;9(1m E=="W"||E.1j.4T)I a;a=E.1j.2t.16(g,1q);I a});H j=b[e];9(!j){j=b[e]={};9(g.4S)g.4S(e,f,P);J g.7N("43"+e,f)}j[c.2u]=c;6.1Z[e]=Q},2u:1,1Z:{},28:G(d,c,b){H e=E.M(d,"2P"),2L,4I;9(1m c=="1M"){H a=c.2l(".");c=a[0]}9(e){9(c&&c.O){b=c.4Q;c=c.O}9(!c){L(c 1i e)6.28(d,c)}J 9(e[c]){9(b)2E e[c][b.2u];J L(b 1i e[c])9(!a[1]||e[c][b].O==a[1])2E e[c][b];L(2L 1i e[c])1T;9(!2L){9(d.4P)d.4P(c,E.M(d,"2t"),P);J d.7M("43"+c,E.M(d,"2t"));2L=S;2E e[c]}}L(2L 1i e)1T;9(!2L){E.30(d,"2P");E.30(d,"2t")}}},1F:G(d,b,e,c,f){b=E.2h(b||[]);9(!e){9(6.1Z[d])E("*").1f([18,U]).1F(d,b)}J{H a,2L,1b=E.1n(e[d]||S),4N=!b[0]||!b[0].2M;9(4N)b.4w(6.4M({O:d,2m:e}));b[0].O=d;9(E.1n(E.M(e,"2t")))a=E.M(e,"2t").16(e,b);9(!1b&&e["43"+d]&&e["43"+d].16(e,b)===P)a=P;9(4N)b.44();9(f&&f.16(e,b)===P)a=P;9(1b&&c!==P&&a!==P&&!(E.11(e,\'a\')&&d=="4L")){6.4T=Q;e[d]()}6.4T=P}I a},2t:G(d){H a;d=E.1j.4M(d||18.1j||{});H b=d.O.2l(".");d.O=b[0];H c=E.M(6,"2P")&&E.M(6,"2P")[d.O],3q=1B.3A.2J.2O(1q,1);3q.4w(d);L(H j 1i c){3q[0].4Q=c[j];3q[0].M=c[j].M;9(!b[1]||c[j].O==b[1]){H e=c[j].16(6,3q);9(a!==P)a=e;9(e===P){d.2M();d.3p()}}}9(E.V.1h)d.2m=d.2M=d.3p=d.4Q=d.M=S;I a},4M:G(c){H a=c;c=E.1k({},a);c.2M=G(){9(a.2M)a.2M();a.7L=P};c.3p=G(){9(a.3p)a.3p();a.7K=Q};9(!c.2m&&c.65)c.2m=c.65;9(E.V.1N&&c.2m.1y==3)c.2m=a.2m.12;9(!c.4K&&c.4J)c.4K=c.4J==c.2m?c.7H:c.4J;9(c.64==S&&c.63!=S){H e=U.2V,b=U.1G;c.64=c.63+(e&&e.2R||b.2R||0);c.7E=c.7D+(e&&e.2B||b.2B||0)}9(!c.3Y&&(c.61||c.60))c.3Y=c.61||c.60;9(!c.5F&&c.5D)c.5F=c.5D;9(!c.3Y&&c.2r)c.3Y=(c.2r&1?1:(c.2r&2?3:(c.2r&4?2:0)));I c}};E.1b.1k({3W:G(c,a,b){I c=="5Y"?6.2G(c,a,b):6.N(G(){E.1j.1f(6,c,b||a,b&&a)})},2G:G(d,b,c){I 6.N(G(){E.1j.1f(6,d,G(a){E(6).5X(a);I(c||b).16(6,1q)},c&&b)})},5X:G(a,b){I 6.N(G(){E.1j.28(6,a,b)})},1F:G(c,a,b){I 6.N(G(){E.1j.1F(c,a,6,Q,b)})},7x:G(c,a,b){9(6[0])I E.1j.1F(c,a,6[0],P,b)},25:G(){H a=1q;I 6.4L(G(e){6.4H=0==6.4H?1:0;e.2M();I a[6.4H].16(6,[e])||P})},7v:G(f,g){G 4G(e){H p=e.4K;1W(p&&p!=6)2a{p=p.12}29(e){p=6};9(p==6)I P;I(e.O=="4x"?f:g).16(6,[e])}I 6.4x(4G).5U(4G)},2d:G(f){5T();9(E.3T)f.16(U,[E]);J E.3l.1a(G(){I f.16(6,[E])});I 6}});E.1k({3T:P,3l:[],2d:G(){9(!E.3T){E.3T=Q;9(E.3l){E.N(E.3l,G(){6.16(U)});E.3l=S}9(E.V.35||E.V.34)U.4P("5S",E.2d,P);9(!18.7t.K)E(18).39(G(){E("#4E").28()})}}});E.N(("7s,7r,39,7q,6n,5Y,4L,7p,"+"7n,7m,7l,4x,5U,7k,24,"+"51,7j,7i,7h,3U").2l(","),G(i,o){E.1b[o]=G(f){I f?6.3W(o,f):6.1F(o)}});H x=P;G 5T(){9(x)I;x=Q;9(E.V.35||E.V.34)U.4S("5S",E.2d,P);J 9(E.V.1h){U.7f("<7d"+"7y 22=4E 7z=Q "+"3k=//:><\\/1J>");H a=U.3S("4E");9(a)a.62=G(){9(6.2C!="1l")I;E.2d()};a=S}J 9(E.V.1N)E.4B=4j(G(){9(U.2C=="5Q"||U.2C=="1l"){4A(E.4B);E.4B=S;E.2d()}},10);E.1j.1f(18,"39",E.2d)}E.1b.1k({39:G(g,d,c){9(E.1n(g))I 6.3W("39",g);H e=g.1g(" ");9(e>=0){H i=g.2J(e,g.K);g=g.2J(0,e)}c=c||G(){};H f="4z";9(d)9(E.1n(d)){c=d;d=S}J{d=E.3a(d);f="5P"}H h=6;E.3G({1d:g,O:f,M:d,1l:G(a,b){9(b=="1C"||b=="5O")h.4o(i?E("<1s/>").3g(a.40.1p(/<1J(.|\\s)*?\\/1J>/g,"")).1Y(i):a.40);56(G(){h.N(c,[a.40,b,a])},13)}});I 6},7a:G(){I E.3a(6.5M())},5M:G(){I 6.1X(G(){I E.11(6,"2Y")?E.2h(6.79):6}).1E(G(){I 6.2H&&!6.3c&&(6.2Q||/24|6b/i.14(6.11)||/2g|1P|52/i.14(6.O))}).1X(G(i,c){H b=E(6).3i();I b==S?S:b.1c==1B?E.1X(b,G(a,i){I{2H:c.2H,1Q:a}}):{2H:c.2H,1Q:b}}).21()}});E.N("5L,5K,6t,5J,5I,5H".2l(","),G(i,o){E.1b[o]=G(f){I 6.3W(o,f)}});H B=(1u 3D).3B();E.1k({21:G(d,b,a,c){9(E.1n(b)){a=b;b=S}I E.3G({O:"4z",1d:d,M:b,1C:a,1V:c})},78:G(b,a){I E.21(b,S,a,"1J")},77:G(c,b,a){I E.21(c,b,a,"45")},76:G(d,b,a,c){9(E.1n(b)){a=b;b={}}I E.3G({O:"5P",1d:d,M:b,1C:a,1V:c})},75:G(a){E.1k(E.59,a)},59:{1Z:Q,O:"4z",2z:0,5G:"74/x-73-2Y-72",6o:Q,3e:Q,M:S},49:{},3G:G(s){H f,2y=/=(\\?|%3F)/g,1v,M;s=E.1k(Q,s,E.1k(Q,{},E.59,s));9(s.M&&s.6o&&1m s.M!="1M")s.M=E.3a(s.M);9(s.1V=="4b"){9(s.O.2p()=="21"){9(!s.1d.1t(2y))s.1d+=(s.1d.1t(/\\?/)?"&":"?")+(s.4b||"5E")+"=?"}J 9(!s.M||!s.M.1t(2y))s.M=(s.M?s.M+"&":"")+(s.4b||"5E")+"=?";s.1V="45"}9(s.1V=="45"&&(s.M&&s.M.1t(2y)||s.1d.1t(2y))){f="4b"+B++;9(s.M)s.M=s.M.1p(2y,"="+f);s.1d=s.1d.1p(2y,"="+f);s.1V="1J";18[f]=G(a){M=a;1C();1l();18[f]=W;2a{2E 18[f]}29(e){}}}9(s.1V=="1J"&&s.1L==S)s.1L=P;9(s.1L===P&&s.O.2p()=="21")s.1d+=(s.1d.1t(/\\?/)?"&":"?")+"57="+(1u 3D()).3B();9(s.M&&s.O.2p()=="21"){s.1d+=(s.1d.1t(/\\?/)?"&":"?")+s.M;s.M=S}9(s.1Z&&!E.5b++)E.1j.1F("5L");9(!s.1d.1g("8g")&&s.1V=="1J"){H h=U.4l("9U")[0];H g=U.5B("1J");g.3k=s.1d;9(!f&&(s.1C||s.1l)){H j=P;g.9R=g.62=G(){9(!j&&(!6.2C||6.2C=="5Q"||6.2C=="1l")){j=Q;1C();1l();h.3b(g)}}}h.58(g);I}H k=P;H i=18.6X?1u 6X("9P.9O"):1u 6W();i.9M(s.O,s.1d,s.3e);9(s.M)i.5C("9J-9I",s.5G);9(s.5y)i.5C("9H-5x-9F",E.49[s.1d]||"9D, 9C 9B 9A 5v:5v:5v 9z");i.5C("X-9x-9v","6W");9(s.6U)s.6U(i);9(s.1Z)E.1j.1F("5H",[i,s]);H c=G(a){9(!k&&i&&(i.2C==4||a=="2z")){k=Q;9(d){4A(d);d=S}1v=a=="2z"&&"2z"||!E.6S(i)&&"3U"||s.5y&&E.6R(i,s.1d)&&"5O"||"1C";9(1v=="1C"){2a{M=E.6Q(i,s.1V)}29(e){1v="5k"}}9(1v=="1C"){H b;2a{b=i.5s("6P-5x")}29(e){}9(s.5y&&b)E.49[s.1d]=b;9(!f)1C()}J E.5r(s,i,1v);1l();9(s.3e)i=S}};9(s.3e){H d=4j(c,13);9(s.2z>0)56(G(){9(i){i.9q();9(!k)c("2z")}},s.2z)}2a{i.9o(s.M)}29(e){E.5r(s,i,S,e)}9(!s.3e)c();I i;G 1C(){9(s.1C)s.1C(M,1v);9(s.1Z)E.1j.1F("5I",[i,s])}G 1l(){9(s.1l)s.1l(i,1v);9(s.1Z)E.1j.1F("6t",[i,s]);9(s.1Z&&!--E.5b)E.1j.1F("5K")}},5r:G(s,a,b,e){9(s.3U)s.3U(a,b,e);9(s.1Z)E.1j.1F("5J",[a,s,e])},5b:0,6S:G(r){2a{I!r.1v&&9n.9l=="54:"||(r.1v>=6N&&r.1v<9j)||r.1v==6M||E.V.1N&&r.1v==W}29(e){}I P},6R:G(a,c){2a{H b=a.5s("6P-5x");I a.1v==6M||b==E.49[c]||E.V.1N&&a.1v==W}29(e){}I P},6Q:G(r,b){H c=r.5s("9i-O");H d=b=="6K"||!b&&c&&c.1g("6K")>=0;H a=d?r.9g:r.40;9(d&&a.2V.37=="5k")6G"5k";9(b=="1J")E.5f(a);9(b=="45")a=3w("("+a+")");I a},3a:G(a){H s=[];9(a.1c==1B||a.4c)E.N(a,G(){s.1a(3f(6.2H)+"="+3f(6.1Q))});J L(H j 1i a)9(a[j]&&a[j].1c==1B)E.N(a[j],G(){s.1a(3f(j)+"="+3f(6))});J s.1a(3f(j)+"="+3f(a[j]));I s.66("&").1p(/%20/g,"+")}});E.1b.1k({1A:G(b,a){I b?6.1U({1H:"1A",2N:"1A",1r:"1A"},b,a):6.1E(":1P").N(G(){6.R.19=6.3h?6.3h:"";9(E.17(6,"19")=="2s")6.R.19="2Z"}).2D()},1z:G(b,a){I b?6.1U({1H:"1z",2N:"1z",1r:"1z"},b,a):6.1E(":3R").N(G(){6.3h=6.3h||E.17(6,"19");9(6.3h=="2s")6.3h="2Z";6.R.19="2s"}).2D()},6J:E.1b.25,25:G(a,b){I E.1n(a)&&E.1n(b)?6.6J(a,b):a?6.1U({1H:"25",2N:"25",1r:"25"},a,b):6.N(G(){E(6)[E(6).3t(":1P")?"1A":"1z"]()})},9c:G(b,a){I 6.1U({1H:"1A"},b,a)},9b:G(b,a){I 6.1U({1H:"1z"},b,a)},99:G(b,a){I 6.1U({1H:"25"},b,a)},98:G(b,a){I 6.1U({1r:"1A"},b,a)},96:G(b,a){I 6.1U({1r:"1z"},b,a)},95:G(c,a,b){I 6.1U({1r:a},c,b)},1U:G(k,i,h,g){H j=E.6D(i,h,g);I 6[j.3L===P?"N":"3L"](G(){j=E.1k({},j);H f=E(6).3t(":1P"),3y=6;L(H p 1i k){9(k[p]=="1z"&&f||k[p]=="1A"&&!f)I E.1n(j.1l)&&j.1l.16(6);9(p=="1H"||p=="2N"){j.19=E.17(6,"19");j.2U=6.R.2U}}9(j.2U!=S)6.R.2U="1P";j.3M=E.1k({},k);E.N(k,G(c,a){H e=1u E.2j(3y,j,c);9(/25|1A|1z/.14(a))e[a=="25"?f?"1A":"1z":a](k);J{H b=a.3s().1t(/^([+-]=)?([\\d+-.]+)(.*)$/),1O=e.2b(Q)||0;9(b){H d=3I(b[2]),2i=b[3]||"2T";9(2i!="2T"){3y.R[c]=(d||1)+2i;1O=((d||1)/e.2b(Q))*1O;3y.R[c]=1O+2i}9(b[1])d=((b[1]=="-="?-1:1)*d)+1O;e.3N(1O,d,2i)}J e.3N(1O,a,"")}});I Q})},3L:G(a,b){9(E.1n(a)){b=a;a="2j"}9(!a||(1m a=="1M"&&!b))I A(6[0],a);I 6.N(G(){9(b.1c==1B)A(6,a,b);J{A(6,a).1a(b);9(A(6,a).K==1)b.16(6)}})},9f:G(){H a=E.32;I 6.N(G(){L(H i=0;i-8O?r:3I(E.17(6.T,6.1e))||0},3N:G(c,b,e){6.5u=(1u 3D()).3B();6.1O=c;6.2D=b;6.2i=e||6.2i||"2T";6.2v=6.1O;6.4q=6.4i=0;6.4r();H f=6;G t(){I f.2F()}t.T=6.T;E.32.1a(t);9(E.32.K==1){H d=4j(G(){H a=E.32;L(H i=0;i6.Y.2e+6.5u){6.2v=6.2D;6.4q=6.4i=1;6.4r();6.Y.3M[6.1e]=Q;H a=Q;L(H i 1i 6.Y.3M)9(6.Y.3M[i]!==Q)a=P;9(a){9(6.Y.19!=S){6.T.R.2U=6.Y.2U;6.T.R.19=6.Y.19;9(E.17(6.T,"19")=="2s")6.T.R.19="2Z"}9(6.Y.1z)6.T.R.19="2s";9(6.Y.1z||6.Y.1A)L(H p 1i 6.Y.3M)E.1x(6.T.R,p,6.Y.3P[p])}9(a&&E.1n(6.Y.1l))6.Y.1l.16(6.T);I P}J{H n=t-6.5u;6.4i=n/6.Y.2e;6.4q=E.3J[6.Y.3J||(E.3J.5q?"5q":"6B")](6.4i,n,0,1,6.Y.2e);6.2v=6.1O+((6.2D-6.1O)*6.4q);6.4r()}I Q}};E.2j.2F={2R:G(a){a.T.2R=a.2v},2B:G(a){a.T.2B=a.2v},1r:G(a){E.1x(a.T.R,"1r",a.2v)},6z:G(a){a.T.R[a.1e]=a.2v+a.2i}};E.1b.6m=G(){H c=0,3E=0,T=6[0],5t;9(T)8L(E.V){H b=E.17(T,"2X")=="4F",1D=T.12,23=T.23,2K=T.3H,4f=1N&&3x(4s)<8J;9(T.6V){5w=T.6V();1f(5w.1S+38.33(2K.2V.2R,2K.1G.2R),5w.3E+38.33(2K.2V.2B,2K.1G.2B));9(1h){H d=E("4o").17("8H");d=(d=="8G"||E.5g&&3x(4s)>=7)&&2||d;1f(-d,-d)}}J{1f(T.5l,T.5z);1W(23){1f(23.5l,23.5z);9(35&&/^t[d|h]$/i.14(1D.37)||!4f)d(23);9(4f&&!b&&E.17(23,"2X")=="4F")b=Q;23=23.23}1W(1D.37&&!/^1G|4o$/i.14(1D.37)){9(!/^8D|1I-9S.*$/i.14(E.17(1D,"19")))1f(-1D.2R,-1D.2B);9(35&&E.17(1D,"2U")!="3R")d(1D);1D=1D.12}9(4f&&b)1f(-2K.1G.5l,-2K.1G.5z)}5t={3E:3E,1S:c}}I 5t;G d(a){1f(E.17(a,"9T"),E.17(a,"8A"))}G 1f(l,t){c+=3x(l)||0;3E+=3x(t)||0}}})();',62,616,'||||||this|||if|||||||||||||||||||||||||||||||||function|var|return|else|length|for|data|each|type|false|true|style|null|elem|document|browser|undefined||options|||nodeName|parentNode||test|jQuery|apply|css|window|display|push|fn|constructor|url|prop|add|indexOf|msie|in|event|extend|complete|typeof|isFunction|className|replace|arguments|opacity|div|match|new|status|firstChild|attr|nodeType|hide|show|Array|success|parent|filter|trigger|body|height|table|script|tbody|cache|string|safari|start|hidden|value|merge|left|break|animate|dataType|while|map|find|global||get|id|offsetParent|select|toggle|selected|toUpperCase|remove|catch|try|cur|al|ready|duration|done|text|makeArray|unit|fx|swap|split|target||pushStack|toLowerCase|nextSibling|button|none|handle|guid|now|stack|tb|jsre|timeout|inArray|scrollTop|readyState|end|delete|step|one|name|nth|slice|doc|ret|preventDefault|width|call|events|checked|scrollLeft|exec|px|overflow|documentElement|grep|position|form|block|removeData|rl|timers|max|opera|mozilla|trim|tagName|Math|load|param|removeChild|disabled|insertBefore|async|encodeURIComponent|append|oldblock|val|childNodes|src|readyList|multiFilter|color|defaultView|stopPropagation|args|old|toString|is|last|first|eval|parseInt|self|domManip|prototype|getTime|curCSS|Date|top||ajax|ownerDocument|parseFloat|easing|has|queue|curAnim|custom|innerHTML|orig|currentStyle|visible|getElementById|isReady|error|static|bind|String|which|getComputedStyle|responseText|oWidth|oHeight|on|shift|json|child|RegExp|ol|lastModified|isXMLDoc|jsonp|jquery|previousSibling|dir|safari2|el|styleFloat|state|setInterval|radio|getElementsByTagName|tr|empty|html|getAttribute|pos|update|version|input|float|runtimeStyle|unshift|mouseover|getPropertyValue|GET|clearInterval|safariTimer|visibility|clean|__ie_init|absolute|handleHover|lastToggle|index|fromElement|relatedTarget|click|fix|evt|andSelf|removeEventListener|handler|cloneNode|addEventListener|triggered|nodeIndex|unique|Number|classFilter|prevObject|selectedIndex|after|submit|password|removeAttribute|file|expr|setTimeout|_|appendChild|ajaxSettings|client|active|win|sibling|deep|globalEval|boxModel|cssFloat|object|checkbox|parsererror|offsetLeft|wrapAll|dequeue|props|lastChild|swing|handleError|getResponseHeader|results|startTime|00|box|Modified|ifModified|offsetTop|evalScript|createElement|setRequestHeader|ctrlKey|callback|metaKey|contentType|ajaxSend|ajaxSuccess|ajaxError|ajaxStop|ajaxStart|serializeArray|init|notmodified|POST|loaded|appendTo|DOMContentLoaded|bindReady|mouseout|not|removeAttr|unbind|unload|Width|keyCode|charCode|onreadystatechange|clientX|pageX|srcElement|join|outerHTML|substr|zoom|parse|textarea|reset|image|odd|even|before|quickClass|quickID|prepend|quickChild|execScript|offset|scroll|processData|uuid|contents|continue|textContent|ajaxComplete|clone|setArray|webkit|nodeValue|fl|_default|100|linear|href|speed|eq|createTextNode|throw|replaceWith|splice|_toggle|xml|colgroup|304|200|alpha|Last|httpData|httpNotModified|httpSuccess|fieldset|beforeSend|getBoundingClientRect|XMLHttpRequest|ActiveXObject|col|br|abbr|pixelLeft|urlencoded|www|application|ajaxSetup|post|getJSON|getScript|elements|serialize|clientWidth|hasClass|scr|clientHeight|write|relative|keyup|keypress|keydown|change|mousemove|mouseup|mousedown|right|dblclick|resize|focus|blur|frames|instanceof|hover|offsetWidth|triggerHandler|ipt|defer|offsetHeight|border|padding|clientY|pageY|Left|Right|toElement|Bottom|Top|cancelBubble|returnValue|detachEvent|attachEvent|substring|line|weight|animated|header|font|enabled|innerText|contains|only|size|gt|lt|uFFFF|u0128|417|inner|Height|toggleClass|removeClass|addClass|replaceAll|noConflict|insertAfter|prependTo|wrap|contentWindow|contentDocument|http|iframe|children|siblings|prevAll|nextAll|wrapInner|prev|Boolean|next|parents|maxLength|maxlength|readOnly|readonly|class|htmlFor|CSS1Compat|compatMode|compatible|borderTopWidth|ie|ra|inline|it|rv|medium|borderWidth|userAgent|522|navigator|with|concat|1px|10000|array|ig|PI|NaN|400|reverse|fast|600|slow|Function|Object|setAttribute|changed|be|can|property|fadeTo|fadeOut|getAttributeNode|fadeIn|slideToggle|method|slideUp|slideDown|action|cssText|stop|responseXML|option|content|300|th|protocol|td|location|send|cap|abort|colg|cos|tfoot|thead|With|leg|Requested|opt|GMT|1970|Jan|01|Thu|area|Since|hr|If|Type|Content|meta|specified|open|link|XMLHTTP|Microsoft|img|onload|row|borderLeftWidth|head|attributes'.split('|'),0,{})) \ No newline at end of file diff --git a/public/stylesheets/layout.css b/public/stylesheets/layout.css new file mode 100644 index 0000000..e69de29 diff --git a/public/stylesheets/print.css b/public/stylesheets/print.css new file mode 100644 index 0000000..e69de29 diff --git a/public/stylesheets/reset.css b/public/stylesheets/reset.css new file mode 100755 index 0000000..6210872 --- /dev/null +++ b/public/stylesheets/reset.css @@ -0,0 +1,30 @@ +body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { + margin:0; + padding:0; +} +table { + border-collapse:collapse; + border-spacing:0; +} +fieldset,img { + border:0; +} +address,caption,cite,code,dfn,em,strong,th,var { + font-style:normal; + font-weight:normal; +} +ol,ul { + list-style:none; +} +caption,th { + text-align:left; +} +h1,h2,h3,h4,h5,h6 { + font-size:100%; + font-weight:normal; +} +q:before,q:after { + content:''; +} +abbr,acronym { border:0; +} \ No newline at end of file diff --git a/public/stylesheets/screen.css b/public/stylesheets/screen.css new file mode 100644 index 0000000..e69de29 diff --git a/public/stylesheets/typography.css b/public/stylesheets/typography.css new file mode 100644 index 0000000..e69de29 diff --git a/script/fix_permissions b/script/fix_permissions new file mode 100755 index 0000000..2b948e9 --- /dev/null +++ b/script/fix_permissions @@ -0,0 +1,46 @@ +#! /usr/bin/php +run(); + +?> \ No newline at end of file diff --git a/script/generate b/script/generate new file mode 100755 index 0000000..670306c --- /dev/null +++ b/script/generate @@ -0,0 +1,46 @@ +#! /usr/bin/php +run(); + +?> \ No newline at end of file diff --git a/tmp/cache/.emptydir b/tmp/cache/.emptydir new file mode 100644 index 0000000..e69de29 diff --git a/vendor/zynapse/action_controller.php b/vendor/zynapse/action_controller.php new file mode 100644 index 0000000..1084758 --- /dev/null +++ b/vendor/zynapse/action_controller.php @@ -0,0 +1,771 @@ +add_before_filter($value); + // } elseif ( $key == 'after_filter' ) { + // $this->add_after_filter($value); + // } elseif ( $key == 'helper' ) { + // $this->add_helper($value); + // } elseif ( $key == 'render_text' ) { + // $this->render_text($value); + // } elseif ( $key == 'redirect_to' ) { + // $this->redirect_to($value); + // } else { + // $this->$key = $value; + // } + // } + + //TODO permanently remove __call() function or not + // ------------------------------------------------- + // function __call ($method, $params) { + // if ( method_exists($this, $method) ) { + // return call_user_func(array($this, $method), $params); + // } else { + // if ( $method == 'before_filter' ) { + // return call_user_func(array($this, 'add_before_filter'), $params); + // } elseif ( $method == 'after_filter' ) { + // return call_user_func(array($this, 'add_after_filter'), $params); + // } elseif ( $method == 'helper' ) { + // return call_user_func(array($this, 'add_helper'), $params); + // } + // } + // } + + + function init_filters () { + // check if any filters are pre-defined + if ( isset($this->before_filter) ) { + $this->add_before_filter($this->before_filter); + unset($this->before_filter); + } + if ( isset($this->after_filter) ) { + $this->add_after_filter($this->after_filter); + unset($this->after_filter); + } + if ( isset($this->helper) ) { + $this->add_helper($this->helper); + unset($this->helper); + } + } + + + + function load_router() { + $this->router_loaded = false; + $router = new Router(); + + // load defined routes + require(Znap::$config_path."/routes.php"); + + $this->router = $router; + if ( is_object($this->router) ) { + $this->router_loaded = true; + } + } + + + function parse_request () { + if ( !$this->router_loaded ) { + $this->load_router(); + } + + $url_path = $this->router->get_url_path(); + $this->url_path = ( !empty($url_path) ) ? explode('/', $url_path) : array() ; + $this->requested_path = $url_path; + + if ( $this->router->routes_count > 0 ) { + $this->controllers_path = Znap::$controllers_path; + $this->helpers_path = $this->helpers_base_path = Znap::$helpers_path; + $this->application_controller_file = $this->controllers_path.'/application.php'; + $this->application_helper_file = $this->helpers_path.'/application_helper.php'; + $this->layouts_path = $this->layouts_base_path = Znap::$layouts_path; + $this->views_path = Znap::$views_path; + + $route = $this->router->find_route($url_path); + + if ( is_array($route) ) { + $this->check_paths(); + $this->current_route = &$this->router->current_route; + + $route_paths = explode('/', $route['path']); + $route_params = ( is_array($route['params']) ) ? $route['params'] : array() ; + $path_params = array(); + + // find path components + foreach( $route_paths as $key => $value ) { + if ( substr($value, 0, 1) == ':' && strlen($value) >= 2 ) { + $path_params[$value] = $key; + } + } + + // redirect_to? + if ( array_key_exists(':redirect_to', $route_params) && $route_params[':redirect_to'] != '' ) { + $this->redirect_to($route_params[':redirect_to']); + } + + // controller + if ( array_key_exists(':controller', $route_params) && $route_params[':controller'] != '' ) { + $this->controller = strtolower($route['params'][':controller']); + } elseif ( array_key_exists(':controller', $path_params) && @$this->url_path[$path_params[':controller']] != '' ) { + $this->controller = strtolower($this->url_path[$path_params[':controller']]); + } + + // action + if ( array_key_exists(':action', $route_params) && $route_params[':action'] != '' ) { + $this->action = strtolower($route['params'][':action']); + } elseif ( array_key_exists(':action', $path_params) && @$this->url_path[$path_params[':action']] != '' ) { + $this->action = strtolower($this->url_path[$path_params[':action']]); + } + + // id + if ( array_key_exists(':id', $route_params) && $route_params[':id'] != '' ) { + $id = strtolower($route['params'][':id']); + } elseif ( array_key_exists(':id', $path_params) && @$this->url_path[$path_params[':id']] != '' ) { + $id = strtolower($this->url_path[$path_params[':id']]); + } + if ( isset($id) && preg_match('/^[0-9]+$/i', $id) ) { + $this->id = $id; + $_REQUEST['id'] = $this->id; + $this->action_params['id'] = $this->id; + } + + // store route params so they can be accessed from methods + $this->route_params = &$route_params; + + + // additional paths + if ( !empty($path_params) ) { + foreach( $path_params as $key => $value ) { + if ( $key != ':controller' && $key != ':action' && $key != ':id' ) { + if ( array_key_exists($value, $this->url_path) && $this->url_path[$value] != '' ) { + $var = substr($key, 1); + $_REQUEST[$var] = $this->url_path[$value]; + $this->action_params[$var] = $this->url_path[$value]; + } + } + } + } + + // set the final stuff + $this->controller_file = $this->controllers_path.'/'.$this->controller.'_controller.php'; + $this->helper_file = $this->helpers_path.'/'.$this->controller.'_helper.php'; + $this->controller_class = Inflector::camelize($this->controller).'Controller'; + $this->views_path .= '/'.$this->controller; + } + } + + if ( is_file($this->controller_file) ) { + $this->loaded = true; + return true; + } else { + $this->loaded = false; + return false; + } + } + + + function process_route () { + if ( !$this->loaded ) { + if ( !$this->parse_request() ) { + $this->raise('Controller "'.$this->controller.'" not found...', '...nor were any matching routes found.', 404); + } + } + + // include application controller + if ( is_file($this->application_controller_file) ) { + include_once($this->application_controller_file); + } + + + // include current controller + include_once($this->controller_file); + if ( class_exists($this->controller_class, false) ) { + // create child controller object + $class = $this->controller_class; + $this->controller_object = new $class(); + + if ( is_object($this->controller_object) ) { + // set initial properties of child controller object + $this->controller_object->init_filters(); + $this->controller_object->controller = $this->controller; + $this->controller_object->action = $this->action; + $this->controller_object->id = $this->id; + $this->controller_object->controllers_path = &$this->controllers_path; + $this->controller_object->helpers_path = &$this->helpers_path; + $this->controller_object->helpers_base_path = &$this->helpers_base_path; + $this->controller_object->views_path = $this->views_path; + $this->controller_object->layouts_path = &$this->layouts_path; + $this->controller_object->layouts_base_path = &$this->layouts_base_path; + $this->controller_object->route_params = &$this->route_params; + $this->controller_object->requested_path = &$this->requested_path; + $this->controller_object->current_route = &$this->current_route; + + // set static Znap properties + Znap::$current_controller_object = &$this->controller_object; + Znap::$current_controller_class_name = $this->controller_class; + Znap::$current_controller_name = $this->controller; + Znap::$current_controller_path = $this->controllers_path; + Znap::$current_action_name = $this->action; + Znap::$current_route = &$this->current_route; + + + // include main application helper file + if ( is_file($this->application_helper_file) ) { + include_once($this->application_helper_file); + } + + // load language specific strings + // - defaults to english if Znap::$settings['language'] + // is not defined by before filters + Znap::load_strings(); + + // include controller specific preferences + if ( isset($this->controller_object->has_prefs) && Znap::$prefs->read($this->controller, true) ) { + $this->controller_object->prefs = &Znap::$prefs->{$this->controller}; + } + + // execute before_filters, display an error page if any filter method returns false + if ( ($before_filters_result = $this->controller_object->execute_before_filters()) === true ) { + + // supress output for capture + ob_start(); + + // include controller specific helper file + if ( is_file($this->helper_file) ) { + include_once($this->helper_file); + } + + // call default action/method if none is defined + if ( $this->action === null ) { + $this->action = $this->default_action; + } + + // execute main method + if ( $this->valid_action($this->action) ) { + $action = $this->action; + $this->controller_object->$action($this->action_params); + } elseif ( is_file($this->views_path.'/'.$this->action.'.'.Znap::$views_extension) ) { + $action = $this->action; + } else { + $this->raise('Action "'.$this->action.'" not found.', null, 404); + } + + $this->controller_object->execute_after_filters(); + $this->controller_object->action_called = true; + + // include any additionaly defined helpers + if ( count($this->controller_object->helpers) ) { + foreach( $this->controller_object->helpers as $helper ) { + if ( is_file($this->helpers_base_path.'/'.$helper.'_helper.php') ) { + include_once($this->helpers_base_path.'/'.$helper.'_helper.php'); + } + } + } + + // if true Session::flash() messages will be displayed till this is set to false on a page load. + Znap::$keep_flash = $this->keep_flash; + + // check if $redirect_to was set and redirect accordingly if so + if ( isset($this->controller_object->redirect_to) && $this->controller_object->redirect_to != '' ) { + $this->redirect_to($this->controller_object->redirect_to); + } + + // if render_text is defined as a string, render it instead of layout & view files + if ( isset($this->controller_object->render_text) && $this->controller_object->render_text != '' ) { + $this->render_text($this->controller_object->render_text); + } + + // if render_action is defined, use it as the render action, if it is false, don't render action view file + if ( isset($this->controller_object->render_action) ) { + $action = $this->controller_object->render_action; + } + + // render view file + if ( $action !== false && !$this->controller_object->render_action($action) ) { + $this->raise('No "'.$action.'" view file found.', null, 500); + } + + // grab captured output + $this->controller_object->content_for_layout = ob_get_contents(); + ob_end_clean(); + + // render or not to render layout (that is the question) + if ( $this->controller_object->render_layout !== false && ($layout_file = $this->controller_object->determine_layout()) ) { + if ( Timer::$started ) ob_start(); + if ( !$this->controller_object->render_file($layout_file) ) { + echo $this->controller_object->content_for_layout; + } + if ( Timer::$started ) ob_end_flush(); + } else { + echo $this->controller_object->content_for_layout; + } + } else { + $this->raise('The "'.$before_filters_result.'" before filter failed.', null, 500); + } + } else { + $this->raise('Failed to initiate controller object "'.$this->controller.'".', null, 500); + } + } else { + $this->raise('Controller class "'.$this->controller_class.'" not found.', null, 500); + } + } + + + function process_exception ( $object ) { + + // load language specific strings which can be used in error files + Znap::load_strings(); + + $this->error = $object; + $this->message = $object->getMessage(); + $this->details = $object->getDetails(); + $this->code = $object->getCode(); + $this->trace = $object->getTrace(); + + if ( $this->code != 0 ) { + header('Status: '.$this->code); + } + + $ZNAP_ENV = ( Znap::$use_development_errors ) ? 'development' : ZNAP_ENV ; + + $paths = array( + Znap::$errors_path.'/'.$ZNAP_ENV, + Znap::$errors_default_path, + ZNAP_LIB_ROOT.'/znap_error/'.$ZNAP_ENV, + ZNAP_LIB_ROOT.'/znap_error/default', + ); + + foreach( $paths as $path ) { + if ( is_file($path.'/'.$this->code.'.'.Znap::$views_extension) ) { + $view_file = $path.'/'.$this->code.'.'.Znap::$views_extension; + break; + } elseif ( is_file($path.'/default.'.Znap::$views_extension) ) { + $view_file = $path.'/default.'.Znap::$views_extension; + break; + } + } + + $this->render_file($view_file); + } + + + function valid_action ($action) { + if ( $action !== null && substr($action, 0, 1) != Znap::$protected_method_prefix ) { + + // get all methods + $all_methods = get_class_methods($this->controller_object); + + // get inherited methods + $inherited_methods = array_merge( + get_class_methods(__CLASS__), + $this->controller_object->before_filters, + $this->controller_object->after_filters + ); + + if ( class_exists('ApplicationController', false) ) { + $inherited_methods = array_merge($inherited_methods, get_class_methods('ApplicationController')); + } + + // validate action + $valid_actions = array_diff($all_methods, $inherited_methods); + if ( in_array($action, $valid_actions) ) { + return true; + } + } + return false; + + } + + + + function execute_filters ($filters) { + if ( count($this->$filters) ) { + foreach( $this->$filters as $filter ) { + if ( method_exists($this, $filter) ) { + if ( $this->$filter() === false ) { + return $filter; + } + } + } + } + return true; + } + + function execute_before_filters () { + return $this->execute_filters('before_filters'); + } + + function execute_after_filters () { + return $this->execute_filters('after_filters'); + } + + + function add_items_to_list ($filter, $list) { + if ( is_string($filter) && !empty($filter) ) { + if ( strpos($filter, ',') !== false ) { + $filter = explode(',', $filter); + foreach( $filter as $key => $value ) { + if ( !in_array($value, $this->$list) ) { + $this->{$list}[] = trim($value); + } + } + } else { + $this->{$list}[] = $filter; + } + } elseif ( is_array($filter) ) { + if ( count($this->$list) ) { + $this->$list = array_unique(array_merge($this->$list, $filter)); + } else { + $this->$list = $filter; + } + } + } + + function before_filter ($filter) { + $this->add_items_to_list($filter, 'before_filters'); + } + + function add_before_filter ($filter) { + $this->add_items_to_list($filter, 'before_filters'); + } + + function after_filter ($filter) { + $this->add_items_to_list($filter, 'after_filters'); + } + + function add_after_filter ($filter) { + $this->add_items_to_list($filter, 'after_filters'); + } + + + function add_helper ($helper) { + $this->add_items_to_list($helper, 'helpers'); + } + + + + function check_paths () { + if ( is_array($this->url_path) ) { + $controllers_path = $this->controllers_path; + $extra_path = array(); + $new_path = array(); + foreach( $this->url_path as $key => $path ) { + if ( is_dir($controllers_path.'/'.$path) ) { + $extra_path[] = $path; + $controllers_path .= '/'.$path; + } else { + $new_path[] = $path; + } + } + if ( !empty($extra_path) ) { + $extra_path = implode('/', $extra_path); + $this->added_path = $extra_path; + Znap::$added_path = $this->added_path; + $this->controllers_path .= '/'.$extra_path; + $this->helpers_path .= '/'.$extra_path; + $this->layouts_path .= '/'.$extra_path; + $this->views_path .= '/_'.$extra_path; + } + if ( !empty($new_path) ) { + $this->url_path = $new_path; + } + } + } + + + + function render ($options = array(), $locals = array(), $return_as_string = false) { + if ( $this->render_performed && !$this->action_called ) { + return true; + } + if ( $return_as_string ) { + ob_start(); + } + + if ( is_string($options) ) { + $this->render_file($options, $locals, true); + } elseif ( is_array($options) ) { + $options['locals'] = ( $options['locals'] ) ? $option['locals'] : array() ; + $options['use_full_path'] = ( !$options['use_full_path'] ) ? true : $options['use_full_path'] ; + if ( $options['text'] ) { + $this->render_text($options['text']); + } elseif ( $options['action'] ) { + $this->render_action($optins['action'], $options); + } elseif ( $options['file'] ) { + $this->render_file($options['file'], array_merge($options['locals'], $locals), $options['use_full_path']); + } + } + + if ( $return_as_string ) { + $result = ob_get_contents(); + ob_end_clean(); + return $result; + } + + } + + + function render_text ($text, $options = array()) { + if ( isset($options['layout']) && $options['layout'] != '' ) { + $locals['content_for_layout'] = &$text; + $layout = $this->determine_layout(); + $this->render_file($layout, $locals); + } else { + echo $text; + } + exit; + } + + + function render_action ($action, $layout = null) { + if ( $this->render_performed ) { + return true; + } + + if ( $layout != null ) { + $this->layout = $layout; + } + + if ( !empty($this->view_file) ) { + $len = strlen('.'.Znap::$views_extension); + if ( substr($this->view_file, -$len) != '.'.Znap::$views_extension ) { + $this->view_file .= '.'.Znap::$views_extension; + } + if ( strstr($this->view_file, '/') && is_file(Znap::$views_path.'/'.$this->view_file) ) { + $this->view_file = Znap::$views_path.'/'.$this->view_file; + } elseif ( is_file($this->views_path.'/'.$this->view_file) ) { + $this->view_file = $this->views_path.'/'.$this->view_file; + } + } else { + $this->view_file = $this->views_path.'/'.$action.'.'.Znap::$views_extension; + } + + $this->render_performed = true; + + return $this->render_file($this->view_file); + } + + + function render_file ($file, $collection = null, $locals = array(), $use_simple_name = false) { + + if ( $use_simple_name ) { + $file = $this->views_path.'/'.$file.'.'.Znap::$views_extension; + } + + if ( is_file($file) ) { + if ( is_object($this) ) { + foreach( $this as $tmp_key => $tmp_value ) { + ${$tmp_key} = &$this->$tmp_key; + } + unset($tmp_key, $tmp_value); + } + if ( $this->content_for_layout !== null ) { + $content_for_layout = &$this->content_for_layout; + } + if ( count($locals) ) { + foreach( $locals as $tmp_key => $tmp_value ) { + ${$tmp_key} = &$locals[$tmp_key]; + } + unset($tmp_key, $tmp_value); + } + + unset($use_full_path, $locals); + + $this->currently_rendering_file = $file; + + if ( empty($collection) ) { + include($file); + } elseif ( is_array($collection) ) { + $var_name = basename($file, '.phtml'); + if ( $var_name{0} == '_' ) { + $var_name = substr($var_name, 1); + } + ${$var_name.'_collection'} = &$collection; + $eval = "foreach( \${$var_name}_collection as \${$var_name}_key => \${$var_name} ):\n?>"; + $eval .= file_get_contents($file); + $eval .= "\n"; + eval($eval); + } + + return true; + } + return false; + } + + + function render_partial ($partial, $collection = null, $locals = array()) { + + // set file name + if ( strstr($partial, '/') ) { + $file = '_'.substr(strrchr($partial, '/'), 1).'.'.Znap::$views_extension; + $path = substr($partial, 0, strrpos($partial, '/')); + $file_name = $path.'/'.$file; + } else { + $path = ''; + $file_name = $file = '_'.$partial.'.'.Znap::$views_extension; + } + + // determine file path + if ( strstr($file_name, '/') && is_file(Znap::$views_path.'/'.$file_name) ) { + $file_name = Znap::$views_path.'/'.$file_name; + } elseif ( is_file(dirname($this->currently_rendering_file).'/'.$file_name) ) { + $file_name = dirname($this->currently_rendering_file).'/'.$file_name; + } elseif ( is_file($this->views_path.'/'.$file_name) ) { + $file_name = $this->views_path.'/'.$file_name; + } elseif ( is_file($this->layouts_path.'/'.$file_name) ) { + $file_name = $this->layouts_path.'/'.$file_name; + } elseif ( $this->layouts_path != $this->layouts_base_path && is_file($this->layouts_base_path.'/'.$file_name) ) { + $file_name = $this->layouts_base_path.'/'.$file_name; + } else { + return false; + } + + // continue if partial file exists + if ( is_file($file_name) ) { + return $this->render_file($file_name, $collection, $locals); + } + } + + + + function determine_layout ($full_path = true) { + // if controller defines and sets $layout to NULL, don't use a layout + if ( isset($this->layout) && is_null($this->layout) ) { + return null; + } + + // if _determine_layout() is defined in controller, call it to get layout name + if ( method_exists($this, Znap::$protected_method_prefix.'determine_layout') ) { + $determine_layout_method = Znap::$protected_method_prefix.'determine_layout'; + $layout = $this->$determine_layout_method(); + } else { + $layout = ( isset($this->layout) && $this->layout != '' ) ? $this->layout : $this->controller ; + } + + // defaults + $layouts_base_path = Znap::$layouts_path; + $default_layout_file = $layouts_base_path.'/application.'.Znap::$views_extension; + + if ( !$full_path && $layout ) { + $layout_file = $layout; + } elseif ( strstr($layout, '/') && is_file($layouts_base_path.'/'.$layout.'.'.Znap::$views_extension) ) { + $layout_file = $layouts_base_path.'/'.$layout.'.'.Znap::$views_extension; + } elseif ( is_file($this->layouts_path.'/'.$layout.'.'.Znap::$views_extension) ) { + $layout_file = $this->layouts_path.'/'.$layout.'.'.Znap::$views_extension; + } elseif ( is_file($layouts_base_path.'/'.$layout.'.'.Znap::$views_extension) ) { + $layout_file = $layouts_base_path.'/'.$layout.'.'.Znap::$views_extension; + } else { + $layout_file = $default_layout_file; + } + + return $layout_file; + } + + + + function redirect_to ( $options = null ) { + if ( $options == 'back' ) { + $url = $_SERVER['HTTP_REFERER']; + } else { + $url = url_for($options); + } + + if ( headers_sent() ) { + echo ''; + } else { + header('Location: '.$url); + } + exit; + } + + function raise ($message, $details, $code) { + throw new ActionControllerError($message, $details, $code); + } + + +} + + +?> \ No newline at end of file diff --git a/vendor/zynapse/action_view.php b/vendor/zynapse/action_view.php new file mode 100644 index 0000000..55d9c9e --- /dev/null +++ b/vendor/zynapse/action_view.php @@ -0,0 +1,45 @@ + \ No newline at end of file diff --git a/vendor/zynapse/action_view/helpers.php b/vendor/zynapse/action_view/helpers.php new file mode 100644 index 0000000..0a8e054 --- /dev/null +++ b/vendor/zynapse/action_view/helpers.php @@ -0,0 +1,162 @@ +object_name = $captured[1]; + $this->attribute_name = $captured[2]; + } else { + $this->object_name = $name; + } + + $property = &$this->object_name; + $attribute = &$this->attribute_name; + + if ( $auto_fill !== false && array_key_exists($property, $_REQUEST) ) { + if ( $attribute !== null && array_key_exists($attribute, $_REQUEST[$property]) ) { + $this->value = &$_REQUEST[$property][$attribute]; + } else { + $this->value = &$_REQUEST[$property]; + } + } elseif ( $auto_fill !== false && property_exists(Znap::$current_controller_object, $property) ) { + $object = &Znap::$current_controller_object; + if ( $attribute !== null ) { + if ( is_object($object->$property) && property_exists($object->$property, $attribute) ) { + $this->value = &$object->$property->$attribute; + } elseif ( is_array($object->$property) && array_key_exists($attribute, $object->$property) ) { + $this->value = &$object->$property[$attribute]; + } + } else { + $this->value = &$object->$property; + } + } elseif ( $value !== null ) { + $this->value = $value; + } + } elseif ( $value !== null ) { + $this->value = $value; + } + } + + function tag ($name, $properties = null, $open = true) { + $html = '<'.$name; + if ( ($options = $this->tag_properties($properties)) != '' ) { + $html .= ' '.$options; + } + $html .= ($open) ? '>' : ' />' ; + return $html; + } + + function content_tag ($name, $content = '', $properties = null) { + if ( !empty($properties['strip_slashes']) ) { + $content = stripslashes($content); + unset($properties['strip_slashes']); + } + return $this->tag($name, $properties).$content.''; + } + + function tag_properties ($properties = null) { + if ( is_array($properties) && count($properties) ) { + $html = array(); + foreach( $properties as $key => $value ) { + $html[] = $key.'="'.@htmlspecialchars($value, ENT_COMPAT).'"'; + } + // sort($html); //TODO decide if tag properties should be sorted or not + return implode(' ', $html); + } else { + return ''; + } + } + + function cdata_section ($content) { + return ''; + } + + + +} + + + +/* + + root scope functions + +*/ + +function tag () { + $helper = new Helpers(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'tag'), $args); +} + +function content_tag () { + $helper = new Helpers(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'content_tag'), $args); +} + +function tag_properties () { + $helper = new Helpers(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'tag_properties'), $args); +} + +function cdata_section () { + $helper = new Helpers(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'cdata_section'), $args); +} + + + + + + + + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/action_view/helpers/form_tag_helper.php b/vendor/zynapse/action_view/helpers/form_tag_helper.php new file mode 100644 index 0000000..a6670d4 --- /dev/null +++ b/vendor/zynapse/action_view/helpers/form_tag_helper.php @@ -0,0 +1,229 @@ + $name, 'id' => $name), $properties); + } + $properties = array_merge(array('method' => 'post'), $properties); + + if ( array_key_exists('multipart', $properties) && $properties['multipart'] != false) { + $properties['enctype'] = 'multipart/form-data'; + unset($properties['multipart']); + } + + $properties['action'] = $url; + return $this->tag('form', $properties); + } + + function hidden_field ($name = '', $value = null, $properties = array()) { + $this->initiate($name, $value); + + $base_properties = array( + 'type' => 'hidden', + 'name' => $name, + 'id' => $name, + 'value' => @htmlspecialchars($this->value), + ); + return $this->tag('input', array_merge($properties, $base_properties), false); + } + + function text_field ($name = '', $value = null, $properties = array()) { + $this->initiate($name, $value); + + $base_properties = array( + 'type' => 'text', + 'name' => $name, + 'id' => $name, + 'value' => @htmlspecialchars($this->value), + ); + return $this->tag('input', array_merge($properties, $base_properties), false); + } + + + function password_field ($name = '', $auto_fill = false, $properties = array()) { + $this->initiate($name, null, $auto_fill); + + $base_properties = array( + 'type' => 'password', + 'name' => $name, + 'id' => $name, + 'value' => ($auto_fill === false ? '' : @htmlspecialchars($this->value)), + ); + return $this->tag('input', array_merge($properties, $base_properties), false); + } + + function file_field ($name = '', $auto_fill = false, $properties = array()) { + $this->initiate($name, null, $auto_fill); + + $base_properties = array( + 'type' => 'file', + 'name' => $name, + 'id' => $name, + 'value' => ($auto_fill === false ? '' : @htmlspecialchars($this->value)), + ); + return $this->tag('input', array_merge($properties, $base_properties), false); + } + + function textarea ($name = '', $value = null, $properties = array()) { + $this->initiate($name, $value); + + $base_properties = array( + 'name' => $name, + 'id' => $name, + ); + + return $this->content_tag('textarea', @htmlspecialchars($this->value), array_merge($properties, $base_properties)); + } + + + function select_tag ($name, $options = array(), $properties = array(), $selected = null) { + $this->initiate($name, $selected); + + if ( $options == null ) $options = array(); + if ( $properties == null ) $properties = array(); + + $base_properties = array( + 'name' => $name, + 'id' => $name, + ); + + if ( array_key_exists('prefix', $properties) ) { + $prefix = $properties['prefix']; + unset($properties['prefix']); + } elseif ( array_key_exists('blank_prefix', $properties) ) { + $prefix = ' '; + unset($properties['blank_prefix']); + } + + $content = "\n".$this->option_tags($options, (isset($prefix)) ? $prefix : null )."\n"; + return $this->content_tag('select', $content, array_merge($properties, $base_properties)); + } + + + function option_tags ( $options, $prefix = null ) { + $html = array(); + if ( $prefix != null ) { + $html[] = $this->option_tag('', $prefix); + } + foreach( $options as $key => $value ) { + $html[] = $this->option_tag($key, $value, ($this->value == $key) ? true : false ); + } + return (count($html)) ? implode("\n", $html) : ''; + } + + + function option_tag ($value, $title, $selected = false) { + $properties['value'] = $value; + if ( $selected ) { + $properties['selected'] = 'selected'; + } + return $this->content_tag('option', $title, $properties); + } + + +} + + + +/* + + root scope functions + +*/ + + +function form_tag () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'form_tag'), $args); +} + +function hidden_field () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'hidden_field'), $args); +} + +function text_field () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'text_field'), $args); +} + +function file_field () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'file_field'), $args); + +} + +function password_field () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'password_field'), $args); +} + +function textarea () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'textarea'), $args); +} + +function select_tag () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'select_tag'), $args); +} + +function option_tags () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'option_tags'), $args); +} + +function option_tag () { + $helper = new FormTagHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'option_tag'), $args); +} + + + + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/action_view/helpers/javascript_helper.php b/vendor/zynapse/action_view/helpers/javascript_helper.php new file mode 100644 index 0000000..68c7d5f --- /dev/null +++ b/vendor/zynapse/action_view/helpers/javascript_helper.php @@ -0,0 +1,131 @@ +js_url = Znap::$url_prefix.App::$_internals->js_url; + $this->libs_url = Znap::$url_prefix.App::$_internals->js_libs_url; + $this->default_charset = (!empty(App::$_internals->js_charset)) ? App::$_internals->js_charset : 'utf-8' ; + if ( count(App::$_internals->js_libs) > 0 ) { + $this->libs = App::$_internals->js_libs; + } + } + + + + function script_lib ($library) { + if ( !empty($this->libs[$library]) ) { + $library = $this->libs[$library]; + } + if ( substr($library, -3) !== '.js' ) { + $library .= '.js'; + } + echo $this->script_tag($this->libs_url.'/'.$library, null, true); + } + + function script_src ($file) { + if ( substr($file, -3) !== '.js' ) { + $file .= '.js'; + } + echo $this->script_tag($this->js_url.'/'.$file, null, true); + } + + function script_tag ($src = null, $charset = null, $close = false) { + $properties = array( + 'src' => $src, + 'type' => 'text/javascript', + 'charset' => ($charset != null) ? $charset : $this->default_charset, + ); + $return = $this->tag('script', $properties); + if ( $close ) { + $return .= ''; + } + return $return; + } + + function script_content_tag ($src = null, $content = null, $charset = null) { + return $this->script_tag($src, $charset).$content.''; + } + + +} + + + +/* + + root scope functions + +*/ + + +function script_lib () { + $helper = new JavascriptHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'script_lib'), $args); +} + +function script_src () { + $helper = new JavascriptHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'script_src'), $args); +} + +function script_tag () { + $helper = new JavascriptHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'script_tag'), $args); +} + +function script_content_tag () { + $helper = new JavascriptHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'script_content_tag'), $args); +} + + + + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/action_view/helpers/url_helper.php b/vendor/zynapse/action_view/helpers/url_helper.php new file mode 100644 index 0000000..2469f07 --- /dev/null +++ b/vendor/zynapse/action_view/helpers/url_helper.php @@ -0,0 +1,158 @@ +convert_confirm_property_to_javascript($properties); + + if ( is_string($link_to) ) { + $url = $link_to; + } elseif ( is_array($link_to) ) { + $url = $this->url_for($link_to); + } + + $properties['href'] = $url; + if ( $name == null || $name == false ) { + $name = $link_to; + } + + return $this->content_tag('a', $name, $properties); + } + + function convert_confirm_property_to_javascript ($properties) { + if ( array_key_exists('confirm', $properties) ) { + $properties['onclick'] = 'return confirm(\''.addslashes($properties['confirm']).'\');'; + unset($properties['confirm']); + } + return $properties; + } + + + function url_for ($options = array()) { + if ( is_string($options) ) { + return $options; + } elseif ( is_array($options) ) { + + // host + $url = $_SERVER['HTTP_HOST']; + if ( substr($url, -1) == '/' ) { + $url = substr($url, 0, -1); + } + + // port + if ( $_SERVER['SERVER_PORT'] == 80 ) { + $url = 'http://'.$url; + } elseif ( $_SERVER['SERVER_PORT'] == 443 ) { + $url = 'https://'.$url; + } elseif (!empty($_SERVER['SERVER_PORT'])) { + $url = 'http://'.$url.':'.$_SERVER['SERVER_PORT']; + } + + // prefix + if ( Znap::$url_prefix != null ) { + $url = (Znap::$url_prefix{0} != '/') ? '/'.Znap::$url_prefix : Znap::$url_prefix ; + } + + $paths = array(); + + // controller + if ( array_key_exists(':controller', $options) && $options[':controller'] != '' ) { + $paths[] = $options[':controller']; + } + + // action + if ( count($paths) && array_key_exists(':action', $options) ) { + $paths[] = $options[':action']; + } + + // id + if ( count($paths) > 1 && array_key_exists(':id', $options) ) { + if ( is_object($options[':id']) && isset($options[':id']->id) ) { + $paths[] = $options[':id']->id; + } elseif ( !is_object($options[':id']) ) { + $paths[] = $options[':id']; + } + } + + $extra_params = array(); + if ( count($options) ) { + foreach( $options as $key => $value ) { + if ( !strpos($key, ':') ) { + $extra_params[$key] = $value; + } + } + } + + if ( substr($url, -1) != '/' ) { + $url .= '/'; + } + + return $url . implode('/', $paths) . (count($extra_params)) ? '?'.http_build_query($extra_params) : null ; + } + } + + +} + + + +/* + + root scope functions + +*/ + +function link_to () { + $helper = new UrlHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'link_to'), $args); +} + +function url_for () { + $helper = new UrlHelper(); + $args = func_get_args(); + return call_user_func_array(array($helper, 'url_for'), $args); +} + + + + + + + + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/action_view/helpers/views_helper.php b/vendor/zynapse/action_view/helpers/views_helper.php new file mode 100644 index 0000000..2e23581 --- /dev/null +++ b/vendor/zynapse/action_view/helpers/views_helper.php @@ -0,0 +1,59 @@ + \ No newline at end of file diff --git a/vendor/zynapse/active_record.php b/vendor/zynapse/active_record.php new file mode 100644 index 0000000..1f7e495 --- /dev/null +++ b/vendor/zynapse/active_record.php @@ -0,0 +1,1139 @@ + 'mysql', // not used in current version + 'host' => null, + 'database' => null, + 'username' => null, + 'password' => null, + 'persistent' => null, + 'table_prefix' => null, + ), + $_settings_id, + + $_columns = null, + + $_sub_class_config_values = array( + 'table_name', + 'primary_key', + 'counter_cache', //TODO impliment counter_cache + ), + $_table_name, + $_primary_key, + $_counter_cache, + + $_class_name, + + $_created_at_column = 'created_at', + $_modified_at_column = 'modified_at', + + $_any_find_returns_array = false, + $_find_returns_array = false, + $_find_all_returns_array = true, + + // table associations + $_associations = array(), + $_association_types = array( + 'has_one', + 'has_many', + 'belongs_to', + 'has_and_belongs_to_many', + ), + + $_auto_save_associations = true, + $_save_associations = array(); + + +/* + + Core Init functions + - the heart + +*/ + + function __construct ($attributes = null, $options = array()) { + if ( empty($options['child_object']) ) { + + // parse settings + $this->parse_settings( (isset($options['settings'])) ? $options['settings'] : null ); + + // start or reuse connection + $this->establish_connection(); + + // set table name + $this->_class_name = get_class($this); + if ( $this->_table_name === null ) { + $this->_table_name = $this->_settings['table_prefix'].Inflector::tableize($this->_class_name); + } + + // set primary key + if ( $this->_primary_key === null ) { + $this->_primary_key = 'id'; + } + + $this->_settings_id = md5(implode('', $this->_settings).$this->_table_name); + self::$object_settings[$this->_settings_id] = &$this->_settings; + + // table info + self::$table_info[$this->_connection_id][$this->_table_name] = &$this->_columns; + + } else { + if ( isset($options['new_record']) ) $this->_new_record = $options['new_record']; + } + $this->update_attributes($attributes); + $this->set_associations(); + } + + function __get ($key) { + if ( $key == '_columns' && !is_array($this->_columns) ) { + $this->set_column_info(); + return $this->_columns; + } elseif ( !property_exists($this, $key) && array_key_exists($key, $this->_associations) ) { + return $this->$key = $this->get_association($key); + } else { + return $this->$key; + } + } + + function __set ($key, $value) { + if ( $key == 'error' ) { + $this->add_error($value); + } elseif ( strlen($key) > 6 && substr($key, 0, 6) == 'error_' ) { + $this->add_error($value, substr($key, 6)); + } else { + $this->$key = $value; + } + } + + + function parse_settings ($input_settings) { + if ( array_key_exists(ZNAP_ENV, self::$settings) ) { + + if ( !is_array($input_settings) ) { + if ( + array_key_exists('use', self::$settings[ZNAP_ENV]) + && array_key_exists(self::$settings[ZNAP_ENV]['use'], self::$settings) + ) { + $settings = self::$settings[self::$settings[ZNAP_ENV]['use']]; + } else { + $settings = self::$settings[ZNAP_ENV]; + } + foreach( $this->_settings as $key => $value ) { + if ( property_exists($this, $key) ) { + $this->_settings[$key] = &$this->$key; + unset($this->$key); + $this->_unset_in_child[] = $key; + } elseif ( isset($settings[$key]) ) { + $this->_settings[$key] = $settings[$key]; + } + } + } else { + foreach( $this->_settings as $key => $value ) { + if ( isset($input_settings[$key]) ) { + $this->_settings[$key] = $input_settings[$key]; + } elseif ( property_exists($this, $key) ) { + $this->_settings[$key] = &$this->$key; + unset($this->$key); + $this->_unset_in_child[] = $key; + } + } + } + + foreach( $this->_sub_class_config_values as $key => $value ) { + if ( property_exists($this, $value) ) { + $this->{'_'.$value} = &$this->$value; + unset($this->$value); + $this->_unset_in_child[] = $key; + } + } + } + } + + function establish_connection () { + $settings = &$this->_settings; + if ( isset($settings['host']) && isset($settings['database']) ) { + + $this->_connection_id = $settings['username'].':'.$settings['password'].'@'.$settings['host']; + if ( $settings['persistent'] ) { + $this->_connection_id .= '?persist'; + } + + if ( !array_key_exists($this->_connection_id, self::$db) ) { + + $connect_function = ( !empty($settings['persistent']) ) ? 'mysql_pconnect' : 'mysql_connect' ; + if ( !($this->_db = @$connect_function($settings['host'], $settings['username'], $settings['password'])) ) { + $this->raise('Could not connect to database server.', mysql_error(), 500); + } + if ( !@mysql_select_db($settings['database']) ) { + $this->raise('Could not select database.', 'There was an error selecting database "'.$settings['database'].'".', 500); + } + + self::$db[$this->_connection_id] = &$this->_db; + + } else { + $this->_db = &self::$db[$this->_connection_id]; + } + } else { + $this->raise('Invalid ActiveRecord configuration', null, 500); + } + } + + + + +/* + + Main Public Functions + - main functions for accessing and manipulating data + +*/ + + + /* + Find / Fetch Functions + */ + + function find ($conditions = null, $options = array(), $return_as_array = null) { + $options['limit'] = 1; + $sql = $this->build_find_query($conditions, $options); + $result = $this->query($sql); + if ( $row = mysql_fetch_assoc($result) ) { + if ( $return_as_array === true || ($this->_any_find_returns_array || $this->_find_returns_array) ) { + return $row; + } else { + return $this->create_child_object($row); + } + } + return false; + } + + function find_all ($conditions = null, $options = array(), $return_as_array = null) { + $sql = $this->build_find_query($conditions, $options); + + $result = $this->query($sql); + if ( mysql_num_rows($result) > 0 ) { + $return = array(); + while ($row = mysql_fetch_assoc($result)) { + if ( $return_as_array === true || ($this->_any_find_returns_array || $this->_find_all_returns_array) ) { + $return[] = $row; + } else { + $return[] = $this->create_child_object($row); + } + } + if ( !empty($return) ) { + return $return; + } + } + + return false; + } + + + /* + Save / Insert Functions + */ + + function save ($attributes = array(), $dont_validate = false) { + $this->update_attributes($attributes); + + if ( $dont_validate || $this->valid() ) { + return $this->add_or_update_record(); + } + return false; + } + + function save_without_validation ($attributes = null) { + return $this->save($attributes, true); + } + + function insert ($input = null) { + $sql = $this->build_insert_query($input); + + if ( $sql !== false ) { + return $this->query($sql); + } + return false; + } + + + /* + Delete / Remove Functions + */ + + function delete ($conditions = null, $options = array()) { + $options['limit'] = 1; + return $this->delete_all($conditions, $options); + } + + function delete_all ($conditions = null, $options = array()) { + if ( $conditions == null || $conditions == '' ) { + return null; + } + $sql = $this->build_delete_query($conditions, $options); + return $this->query($sql); + } + + + /* + Count - count table rows + */ + function count ($conditions = null, $options = '') { + $query = 'SELECT '; + if ( is_array($options) ) { + if ( !empty($options['select']) ) $query .= $options['select'].', '; + $query .= 'COUNT(*) FROM `'.$this->_table_name.'`'; + if ( !empty($conditions) ) $query .= $this->build_query_conditions($conditions); + if ( !empty($options['group_by']) ) $query .= ' GROUP BY '.$options['group_by']; + $query .= ';'; + } else { + $query .= 'COUNT(*) FROM `'.$this->_table_name.'`'; + if ( !empty($conditions) ) { + $query .= $this->build_query_conditions($conditions); + } + $query .= ';'; + } + if ( $result = $this->query($query) ) { + $count = mysql_fetch_assoc($result); + return $count['COUNT(*)']; + } + return null; + } + + + /* + Query - send SQL query string + */ + function query ($query = null) { + if ( $query !== null && $query !== false) { + $result = mysql_query($query, $this->_db); + if ( ZNAP_ENV == 'development' ){ + self::$query_log[] = $query; + $this->sql_log($query); + } + return $result; + } + return false; + } + + + /* + Table Operations - use with caution + */ + + // Optimize table + function optimize ($no_write_to_binlog = false) { + $bin = ( $no_write_to_binlog ) ? 'NO_WRITE_TO_BINLOG ' : ''; + return $this->query('OPTIMIZE '.$bin.'TABLE '.$this->_table_name); + } + + // WARNING!!! THIS WILL REMOVE ALL RECORDS IN THE TABLE!! + function truncate ($are_you_sure = false) { + if ( $are_you_sure ) { + return $this->query('TRUNCATE TABLE '.$this->_table_name); + } + } + + + + +/* + + Add/Update Records + - internal functions used by save() + +*/ + + function add_or_update_record () { + $this->before_save(); + if ( $this->_new_record ) { + $this->before_create(); + $result = $this->add_record(); + $this->after_create(); + } else { + $this->before_update(); + $result = $this->update_record(); + $this->after_update(); + } + $this->after_save(); + return $result; + } + + function add_record () { + $sql = $this->build_insert_query(); + $result = ( $sql !== false ) ? $this->query($sql) : false; + $this->save_associations(); + return $result; + } + + function update_record ( $value='' ) { + $sql = $this->build_update_query(); + $result = ( $sql !== false ) ? $this->query($sql) : 1 ; + $this->save_associations(); + return $result; + } + + function update_attributes ($attributes = null) { + if ( is_array($attributes) ) { + foreach( $attributes as $field => $value ) { + if ( array_key_exists($field, $this->_associations) && $this->_auto_save_associations ) { + $this->_save_associations[$field] = $value; + } else { + if ( !$this->_new_record && $this->_track_modifications && !array_key_exists($field, $this) ) { + $this->_init_value_hashes[$field] = md5($value); + } + $this->$field = $value; + } + } + } + } + + + + +/* + + Build X Query functions + - build the actual SQL query strings from input data + +*/ + + function build_find_query ($conditions = null, $options = array()) { + + $select = ( isset($options['select']) && $options['select'] != '' ) ? $options['select'] : '*' ; + $query = 'SELECT '.$select.' FROM `'.$this->_table_name.'`'; + + if ( array_key_exists('joins', $options) ) { + if ( !empty($options['joins']) ) { + $query .= ' '.$options['joins']; + } + unset($options['joins']); + } + $query .= $this->build_query_conditions($conditions); + $query .= $this->build_query_options($options); + + return $query.';'; + } + + function build_delete_query ($conditions = null, $options = array()) { + + $query = 'DELETE FROM `'.$this->_table_name.'`'; + + $query .= $this->build_query_conditions($conditions, $options); + $query .= $this->build_query_options($options); + + return $query.';'; + } + + function build_insert_query ($input = null) { + + if ( $input === null ) { + $input = &$this; + } + + // initial var setup & input checking + if ( is_object($input) || (is_array($input) && count($input)) ) { + if ( $this->_columns === null ) { + $this->set_column_info(); + } + if ( !is_array(current($input)) && !is_object(current($input)) ) { + $input = array($input); + } + } else { + return false; + } + + // start building the query + $query = 'INSERT INTO `'.$this->_table_name.'` ( '; + + // field/column definition + $columns = array_keys($this->_columns); + //FIXME Enable a way to set a custom primary key when saving a row + # // if ( $columns[0] == $this->_primary_key ) unset($columns[0]); + # $query .= '`'.implode('` , `', $columns).'` )'; + if ( $columns[0] == $this->_primary_key ) unset($columns[0]); + $query .= '`'.$this->_primary_key.'`, `'.implode('` , `', $columns).'` )'; + + $query .= ' VALUES '; + $value_sets = array(); + foreach( $input as $current ) { + $values = array(); + foreach( $columns as $column ) { + if ( + $column == $this->_created_at_column + && ( (is_array($current) && !isset($current[$column])) || (is_object($current) && !isset($current->$column)) ) + ) { + $values[] = $this->set_time_column($column); + } elseif ( is_array($current) && isset($current[$column]) && $current[$column] !== null ) { + $values[] = $this->sql_quote($current[$column]); + } elseif ( is_object($current) && isset($current->$column) && $current->$column !== null ) { + $values[] = $this->sql_quote($current->$column); + } else { + $values[] = ( $this->_columns[$column]['Null'] == 'YES' ) ? 'NULL' : "''" ; + } + } + //FIXME Enable a way to set a custom primary key when saving a row + # $value_sets[] = "( ".implode(" , ", $values)." )"; + $value_sets[] = "( NULL, ".implode(" , ", $values)." )"; + } + $query .= implode(', ', $value_sets).';'; + + return $query; + } + + function build_update_query ($input = null) { + + if ( $input === null ) { + $input = &$this; + } + + if ( $this->_columns === null ) { + $this->set_column_info(); + } + $columns = array_keys($this->_columns); + if ( $columns[0] == $this->_primary_key ) unset($columns[0]); + + if ( is_object($input) ) { + + if ( isset($input->{$this->_primary_key}) && $input->{$this->_primary_key} !='' ) { + $id = $input->{$this->_primary_key}; + } else { + return false; + } + + $values = array(); + foreach( $columns as $key ) { + if ( + $key != $this->_primary_key && isset($input->$key) && isset($input->_columns[$key]) + && (isset($input->_init_value_hashes[$key]) && $input->_init_value_hashes[$key] != md5($input->$key)) + ) { + if ( $key == $this->_modified_at_column ) { + $values[] = $this->set_time_column($key); + } elseif ( $input->$key !== null && $input->$key != '' ) { + $values[] = '`'.$key."` = ".$this->sql_quote($input->$key); + } else { + $empty_value = ( $this->_columns[$key]['Null'] == 'YES' ) ? 'NULL' : "''"; + $values[] = '`'.$key."` = ".$empty_value; + } + } + } + + } elseif ( is_array($input) ) { + + if ( isset($input[$this->_primary_key]) && $input[$this->_primary_key] !='' ) { + $id = $input[$this->_primary_key]; + } else { + return false; + } + + $values = array(); + foreach( $columns as $key ) { + if ( $key != $this->_primary_key && array_key_exists($key, $input) && isset($this->_columns[$key]) ) { + if ( $input[$key] !== null ) { + $values[] = '`'.$key."` = ".$this->sql_quote($input[$key]); + } else { + $values[] = '`'.$key."` = " . ( $this->_columns[$key]['Null'] == 'YES' ) ? 'NULL' : "''" ; + } + } + } + } + + if ( count($values) ) { + return 'UPDATE `'.$this->_table_name.'` SET '.implode(', ', $values).' WHERE `'.$this->_primary_key."` = '".$id."' LIMIT 1;"; + } else { + return false; + } + } + + + /* + Build Helpers - help the build functions with repeatative tasks + */ + + function build_query_conditions ($conditions, $options = array()) { + if ( $conditions !== null && $conditions !== '' ) { + if ( is_string($conditions) || is_int($conditions) || is_float($conditions) ) { + if ( preg_match('/^[0-9]+$/', trim($conditions)) ) { + return ' WHERE `'.$this->_primary_key."` = '".$conditions."'"; + } else { + return ' WHERE '.$conditions; + } + } elseif ( is_array($conditions) && !empty($conditions) ) { + $cond = array(); + foreach( $conditions as $key => $value ) { + if ( !preg_match('/^[0-9]+$/', $key) && !is_array($value) ) { + $cond[] = '`'.$key."` = '".$value."'"; + } elseif ( !is_array($value) && preg_match('/^[0-9]+$/', $value) ) { + $cond[] = '`'.$this->_primary_key."` = '".$value."'"; + } elseif(is_array($value)) { + $cond[] = '`'.$key."` IN (".implode(",",$this->sql_quote($value)).")"; + } else { + $cond[] = $this->sql_quote($value); + } + } + $operator = ( !empty($options['operator']) ) ? $options['operator'] : 'AND' ; + return ' WHERE '.implode(' '.$operator.' ', $cond); + } + } + return ''; + } + + function build_query_options ($options) { + if ( $options !== null && $options !== '' ) { + if ( is_string($options) ) { + return ' '.$options; + } elseif ( is_array($options) && count($options) ) { + + $query = ''; + $query_end = ' '; + if ( !empty($options['group_by']) ){ + $query .= ' GROUP BY '.$options['group_by']; + unset($options['group_by']); + } + + if ( isset($options['order_by']) && $options['order_by'] != '' ) { + $order_by = trim($options['order_by']); + $order = ''; + if ( preg_match('/^(.*)\s(ASC|DESC)$/i', $order_by, $capture) ) { + $order = ' '.$capture[2]; + $order_by = trim($capture[1]); + } + unset($options['order_by']); + if ( $order_by != 'RAND()' && strpos($order_by, '`') === false ) $order_by = '`'.$order_by.'`'; + $query .= ' ORDER BY '.$order_by.$order; + } + if ( (isset($options['limit']) && $options['limit'] != '') && (isset($options['offset']) && $options['offset'] != '') ) { + $query_end .= 'LIMIT '.$options['limit'].' OFFSET '.$options['offset']; + unset($options['limit'], $options['offset']); + } + + foreach( $options as $key => $value ) { + if ($key != 'operator' && $key != 'select' && $value != '') { + $query .= ' '.strtoupper($key).' '.$value; + } + } + return $query.$query_end; + } + } + return ''; + } + + + + +/* + + Table Associations + - handle table associations + +*/ + + function set_associations () { + foreach( $this->_association_types as $type ) { + if ( !empty($this->$type) ) { + if ( is_string($this->$type) ) { + if ( strpos($this->$type, ',') === false ) { + $this->set_association($this->$type, $type); + } else { + $associations = explode(',', $this->$type); + foreach( $associations as $association ) { + $this->set_association($association, $type); + } + } + } elseif ( is_array($this->$type) ) { + foreach( $this->$type as $name => $options ) { + $this->set_association($name, $type, $options); + } + } + unset($this->$type); + } + } + } + + function set_association ($name, $type, $options = null) { + $name = trim($name); + if ( $type == 'has_one' || $type == 'belongs_to' ) { + $name = Inflector::singularize($name); + } + $this->_associations[$name] = array('type' => $type); + if ( is_array($options) ) { + $this->_associations[$name] = array_merge($this->_associations[$name], $options); + } + } + + function get_association ($key) { + if ( array_key_exists($key, $this->_associations) && !empty($this->{$this->_primary_key}) && !empty($this->_table_name) ) { + $assoc = $this->_associations[$key]; + $class_name = ( !empty($assoc['class_name']) ) ? $assoc['class_name'] : Inflector::camelize($key) ; + if ( $assoc['type'] == 'has_many' || $assoc['type'] == 'has_and_belongs_to_many' ) { + $class_name = Inflector::singularize($class_name); + } + if ( class_exists($class_name, true) ) { + + $object = new $class_name(); + + $foreign_key = $this->find_foreign_key( + $key, + $this->_associations, + $this->_table_name, + $object->_table_name + ); + + if ( $assoc['type'] != 'has_and_belongs_to_many' ) { + if ( $assoc['type'] == 'belongs_to' ) { + $conditions = '`'.$this->_primary_key.'` = '.$this->$foreign_key; + } else { + $conditions = '`'.$foreign_key.'` = '.$this->{$this->_primary_key}; + } + if ( !empty($assoc['conditions']) ) { + $conditions .= ' AND '.$assoc['conditions']; + } + $options = array(); + if ( !empty($assoc['joins']) ) { + $options['joins'] = $assoc['joins']; + } + if ( !empty($assoc['select']) ) { + $options['select'] = $assoc['select']; + } + } + + //FIXME return array or object code here is weird and confusing + $return_array = null; + if ( !empty($assoc['return_array']) ) { + $return_array = true; + } elseif ( !empty($assoc['return_object']) ) { + $return_array = false; + } + + if ( $assoc['type'] == 'has_one' || $assoc['type'] == 'belongs_to' ) { + $result = $object->find($conditions, $options, $return_array); + } elseif ( $assoc['type'] == 'has_many' ) { + $result = $object->find_all($conditions, $options, $return_array); + } elseif ( $assoc['type'] == 'has_and_belongs_to_many' ) { + $join_table = array($this->_table_name, $object->_table_name); + sort($join_table); + $join_table = $join_table[0].'_'.$join_table[1]; + $table_key = Inflector::singularize($this->_table_name).'_id'; + $object_key = Inflector::singularize($object->_table_name).'_id'; + $conditions = '`'.$join_table.'`.`'.$table_key.'` = '.$this->{$this->_primary_key}; + $joins = 'LEFT JOIN '.$join_table.' ON `'.$object->_table_name.'`.`'.$object->_primary_key.'` = `'.$join_table.'`.`'.$object_key.'`'; + $result = $object->find_all($conditions, array('joins' => $joins)); + } + if ( (is_array($result) && count($result) > 0 ) || is_object($result) ) { + return $result; + } + } + } + return false; + } + + function find_foreign_key ($key, $this_assoc, $this_table, $foreign_table) { + if ( !empty($this_assoc[$key]['foreign_key']) ) { + return $this_assoc[$key]['foreign_key']; + } elseif ( $this_assoc[$key]['type'] == 'belongs_to' ) { + return Inflector::singularize($foreign_table).'_id'; + } else { + return Inflector::singularize($this_table).'_id'; + } + } + + function save_associations () { + if ( count($this->_save_associations) && $this->_auto_save_associations ) { + foreach( $this->_save_associations as $field => $item ) { + + if ( !empty($this->_associations[$field]['Type']) ) { + $type = $this->_associations[$field]['Type']; + if ( $type != 'has_and_belongs_to_many' ) { + if ( is_object($item) ) { + $this->save_association($item, $type); + } elseif ( is_array($item) ) { + if ( is_array(current($item)) && is_array(end($item)) ) { + $class_name = ( !empty($this->_associations[$field]['class_name']) ) + ? $this->_associations[$field]['class_name'] : Inflector::camelize($field) ; + if ( class_exists($class_name) ) { + $object = new $class_name(); + $object->insert($array); + } + } else { + foreach( $item as $sub_item ) { + if ( is_object($sub_item) ) $this->save_association($sub_item, $type); + } + } + } + } else { // if type is "has_and_belongs_to_many" + //TODO write habtm association saving code + } + } + + } // endforeach + } + } + + function save_association ($object, $type) { + if ( is_object($object) && get_parent_class($object) == __CLASS__ ) { + if ( $type == 'has_many' || $type == 'has_one' ) { + $key = Inflector::singularize($this->_table_name).'_id'; + $object->$key = $this->{$this->_primary_key}; + } + $object->save(); + } + } + + + +/* + + Error related functions + - add errors if invalid input attempted + +*/ + + function add_error ($message = 'UNKNOWN', $field = null) { + if ( !is_null($field) ) { + $this->_errors[$field] = $message; + } else { + $this->_errors[] = $message; + } + } + + + + +/* + + Internal Functions + - not really intended for public use, if you get what i mean ;) :P + +*/ + + function sql_quote ($input, $field = null) { + if ( is_array($input) ) { + $return = array(); + foreach( $input as $key => $value ) { + $return[$key] = $this->sql_quote($value, $field); + } + return $return; + } + if ( $field !== null ) { + $field = $this->get_field_type($field); + } + if ( ($field == 'integer' || $field == 'decimal') && preg_match('/^[0-9\-\.]+$/', $input) ) { + return $input; + } else { + return "'".addslashes($input)."'"; + } + } + + function get_field_type ($field) { + if ( $this->_columns === null ) { + $this->set_column_info(); + } + if ( isset($this->_columns[$field]['Type']) && $this->_columns[$field]['Type'] != '' ) { + $type = strtolower($this->_columns[$field]['Type']); + if ( strstr($type, '(') !== false ) { + $type = substr($type, 0, strpos($type, '(')); + } + switch ( $type ) { + case 'tinyint': + case 'smallint': + case 'mediumint': + case 'int': + case 'bigint': + $type = 'integer'; + break; + + case 'float': + case 'double': + $type = 'decimal'; + break; + + default: + $type = 'string'; + } + return $type; + } + return false; + } + + function set_time_column ($column) { + // determine column type + if ( strstr($this->_columns[$column]['Type'], '(') !== false ) { + $type = substr($this->_columns[$column]['Type'], 0, strpos($this->_columns[$column]['Type'], '(')); + } else { + $type = $this->_columns[$column]['Type']; + } + + // format and resturn string + if ( $type == 'int' ) { + return time(); + } elseif ( $type == 'date' ) { + return date('Y-m-d'); + } elseif ( $type == 'datetime' ) { + return date('Y-m-d H:i:s'); + } elseif ( $type == 'timestamp' ) { + return date('YmdHis'); + } elseif ( $type == 'time' ) { + return date('H:i:s'); + } else { + return time(); + } + } + + function set_column_info () { + if ( self::$table_info[$this->_connection_id][$this->_table_name] === null ) { + $sql = 'SHOW COLUMNS FROM `'.$this->_table_name.'`;'; + $result = $this->query($sql); + if ( mysql_num_rows($result) > 0 ) { + while ($row = mysql_fetch_assoc($result)) { + $this->_columns[$row['Field']] = $row; + } + if ( count($this->_columns) ) { + foreach( $this->_columns as $column ) { + $this->_columns[$column['Field']]['HumanName'] = Inflector::humanize($column['Field']); + } + return true; + } + } + } else { + $this->_columns = &self::$table_info[$this->_connection_id][$this->_table_name]; + return true; + } + return false; + } + + function create_child_object ($attributes = array()) { + $class_name = $this->_class_name; + $object = new $class_name($attributes, array('child_object' => true, 'new_record' => false)); + //FIXME figure out a way to properly unset object vars since a php bug currently prevents it + foreach( $this->_unset_in_child as $key => $value ) { + unset($object->$key); + } + $object->_settings = &$this->_settings; + $object->_connection_id = &$this->_connection_id; + $object->_is_child_object = true; + $object->_db = &self::$db[$this->_connection_id]; + $object->_columns = &self::$table_info[$this->_connection_id][$this->_table_name]; + $object->_class_name = &$this->_class_name; + $object->_table_name = &$this->_table_name; + $object->_primary_key = &$this->_primary_key; + foreach( $this->_sub_class_config_values as $key => $value ) { + if ( property_exists($this, '_'.$value) ) { + $object->{'_'.$value} = $this->{'_'.$value}; + } + } + return $object; + } + + function raise ($message, $details, $code) { + throw new ActiveRecordError($message, $details, $code); + } + + +/* + + Validation + - validate new data before saving to database + +*/ + + function valid () { + // make sure errors are empty + // $this->_errors = array(); + + if( $this->_new_record ) { + $this->before_validation(); + $this->before_validation_on_create(); + $this->validate(); + $this->validate_model_attributes(); + $this->after_validation(); + $this->validate_on_save(); + $this->validate_on_create(); + $this->after_validation_on_create(); + } else { + $this->before_validation(); + $this->before_validation_on_update(); + $this->validate(); + $this->validate_model_attributes(); + $this->after_validation(); + $this->validate_on_save(); + $this->validate_on_update(); + $this->after_validation_on_update(); + } + + // if validation functions generated errors, flash them + if ( count($this->_errors) ) { + $this->flash_errors(); + return false; + } + return true; + } + + function validate_model_attributes () { + if ( $this->_columns === null ) { + $this->set_column_info(); + } + $valid = true; + foreach( $this->_columns as $column => $column_info ) { + if ( method_exists($this, 'validate_'.$column) ) { + $method = 'validate_'.$column; + $result = $this->$method(); + + if ( $result !== null ) { + $error = $result; + } + + if ( isset($error) ) { + if ( $error === false ) { + $error = str_replace('%column%', $column, Znap::$strings['_ZNAP_AR_ERROR_ITEM_UKNOWN']); + } + $this->add_error($error, $column); + $valid = false; + } + } + unset($error); + } + return $valid; + } + + function flash_errors ($errors = array()) { + if ( count($errors) == 0 ) { + $errors = &$this->_errors; + } + $list = ''; + foreach( $errors as $key => $value ) { + $list .= str_replace('%error%', $value, Znap::$strings['_ZNAP_AR_ERROR_ITEM_HTML']); + } + $body = str_replace('%errors%', $list, Znap::$strings['_ZNAP_AR_ERROR_BODY_HTML']); + Session::flash('error', str_replace('%title%', Znap::$strings['_ZNAP_AR_ERROR_TITLE'], $body)); + $this->_errors = array(); + } + + function sql_log($query = null, $logfile = null){ + $message = ''; + if ( ZNAP_INTERNAL_LOGGING ) { + $stamp = date("[j-M-Y G:i:s] "); + $logfile = Znap::$log_path.'/'.ZNAP_ENV.'_sql.log'; + $message = "/*\n".$stamp."\n*/\n\n".$query."\n\n"; + if ( !(file_put_contents($logfile, $message, FILE_APPEND)) ){ + $details = $logfile . ' cannot be opened.'; + Znap::$current_controller_object->raise('Cannot open the '.ZNAP_ENV.' logfile.', $details, 500 ); + } + } + } + + + + +/* + + Redeclareable functions + - redeclare any of the functions below for custom validation and checking + +*/ + + /* + before/after save, create and update + */ + function before_save () {} + + function before_create () {} + + function after_create () {} + + function before_update () {} + + function after_update () {} + + function after_save () {} + + + /* + global validate before/after validation, on create and on update + */ + function validate () {} + + function validate_on_save () {} + + function validate_on_create () {} + + function validate_on_update () {} + + function before_validation () {} + + function before_validation_on_create () {} + + function after_validation_on_create () {} + + function before_validation_on_update () {} + + function after_validation_on_update () {} + + function after_validation () {} + + + + + + + + + + + + + + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/dispatcher.php b/vendor/zynapse/dispatcher.php new file mode 100644 index 0000000..4435660 --- /dev/null +++ b/vendor/zynapse/dispatcher.php @@ -0,0 +1,48 @@ +process_route(); + } catch (Exception $e) { + Znap::$action_controller->process_exception($e); + } + } + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/inflections.php b/vendor/zynapse/inflections.php new file mode 100644 index 0000000..22aa860 --- /dev/null +++ b/vendor/zynapse/inflections.php @@ -0,0 +1,157 @@ + $rule, "replacement" => $replacement)); + } + + # Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression. + # The replacement should always be a string that may include references to the matched data from the rule. + function singular($rule, $replacement) { + array_unshift(self::$singulars, array("rule" => $rule, "replacement" => $replacement)); + } + + # Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used + # for strings, not regular expressions. You simply pass the irregular in singular and plural form. + # + # Examples: + # Inflections::irregular('octopus', 'octopi') + # Inflections::irregular('person', 'people') + function irregular($singular, $plural) { + self::plural('/('.preg_quote(substr($singular,0,1)).')'.preg_quote(substr($singular,1)).'$/i', '\1'.preg_quote(substr($plural,1))); + self::singular('/('.preg_quote(substr($plural,0,1)).')'.preg_quote(substr($plural,1)).'$/i', '\1'.preg_quote(substr($singular,1))); + } + + # Add uncountable words that shouldn't be attempted inflected. + # + # Examples: + # Inflections::uncountable("money") + # Inflections::uncountable("money", "information") + # Inflections::uncountable(array("money", "information", "rice")) + function uncountable() { + $args = func_get_args(); + if(is_array($args[0])) { + $args = $args[0]; + } + foreach($args as $word) { + self::$uncountables[] = $word; + } + } + + # Clears the loaded inflections within a given scope (functionault is :all). Give the scope as a symbol of the inflection type, + # the options are: "plurals", "singulars", "uncountables" + # + # Examples: + # Inflections::clear("all") + # Inflections::clear("plurals") + function clear($scope = "all") { + if($scope == "all") { + self::$plurals = self::$singulars = self::$uncountables = array(); + } else { + self::$$scope = array(); + } + } + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/inflector.php b/vendor/zynapse/inflector.php new file mode 100644 index 0000000..a3256cc --- /dev/null +++ b/vendor/zynapse/inflector.php @@ -0,0 +1,216 @@ += 11 && $test <= 13) { + $number = "{$number}th"; + } else { + switch((intval($number) % 10)) { + case 1: + $number = "{$number}st"; + break; + case 2: + $number = "{$number}nd"; + break; + case 3: + $number = "{$number}rd"; + break; + default: + $number = "{$number}th"; + } + } + return $number; + } + +} + + +?> \ No newline at end of file diff --git a/vendor/zynapse/input_filter.php b/vendor/zynapse/input_filter.php new file mode 100644 index 0000000..6a48df1 --- /dev/null +++ b/vendor/zynapse/input_filter.php @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/vendor/zynapse/preferences.php b/vendor/zynapse/preferences.php new file mode 100644 index 0000000..ff270d1 --- /dev/null +++ b/vendor/zynapse/preferences.php @@ -0,0 +1,257 @@ +__pref_paths = $pref_paths; + } elseif ( is_string($pref_paths) ) { + $this->__pref_paths = array($pref_paths); + } + } + } + + + function __get ($property) { + if ( isset($this->$property) ) { + return $this->$property; + } elseif ($this->read($property)) { + return $this->$property; + } else { + return null; + } + } + + + function read ($pref, $force_create = false, $create_path = null) { + if ( !isset($this->$pref) && count($this->__pref_paths) > 0 ) { + $valid_path = false; + for ( $i=0; $i < count($this->__pref_paths); $i++ ) { + if ( is_file($this->__pref_paths[$i].'/'.$pref.'.prefs.php') ) { + $valid_path = $this->__pref_paths[$i]; + break; + } + } + if ( $valid_path !== false ) { + include_once($valid_path.'/'.$pref.'.prefs.php'); + $class = $pref.'_preferences'; + if ( class_exists($class) ) { + self::$__current_pref_file = $valid_path.'/'.$pref.'.prefs.php'; + $this->$pref = new $class(); + self::$__current_pref_file = null; + if ( is_object($this->$pref) ) { + return true; + } + } + } elseif ( $force_create ) { + $object = new PreferenceContainer(); + if ( $create_path == null ) { + $create_path = $this->__pref_paths[0]; + } + if ( $object->save($pref, $create_path) ) { + $this->read($pref); + return true; + } else { + return false; + } + } + } + return false; + } + + +} + +class PreferenceContainer { + + + private $__file = null; + + + function __construct ($__file = null) { + if ( PreferenceCollection::$__current_pref_file !== null ) { + $this->__file = PreferenceCollection::$__current_pref_file; + } + } + + + function save ($pref = null, $save_path = null, $data = null) { + + // use $this for data if none is specified + if ( $data == null ) { + $data = &$this; + } + + // get class and preference name + if ( empty($pref) ) { + $class = get_class($this); + $pref = substr($class, 0, -12); + } else { + $class = $pref.'_preferences'; + } + + // start building output + $output = " $value ) { + if ( $key != '__file' ) { + $output .= "\tpublic \$".$key.";\n"; + } + } + + $output .= "\t\n"; + $output .= "\tfunction __construct () {\n"; + $output .= "\t\tparent::__construct();\n"; + $output .= "\t\t\n"; + + foreach( $data as $key => $value ) { + if ( $key != '__file' ) { + $output .= $this->output_var('this->'.$key, $value, 2); + } + } + + $output .= "\t}\n"; + $output .= "\t\n"; + $output .= "}\n"; + $output .= "\n"; + $output .= "?>"; + + // determine output filename + if ( $save_path == null ) { + if ( !empty($this->__file) ) { + $file = $this->__file; + } + } elseif ( is_dir($save_path) ) { + $file = $save_path.'/'.$pref.'.prefs.php'; + } + + // output data to file + if ( !empty($file) ) { + if ( !is_file($file) ) { + $creating = true; + } + if ( file_put_contents($file, $output) ) { + if ( isset($creating) ) { + chmod($file, 0666); + } + return true; + } + } + + return false; + } + + function output_var ($var, $value = '', $indent = 0) { + $output = $this->output_indent($indent); + $output .= '$'.$var.' = '.$this->output_value($value, $indent).";\n"; + return $output; + } + + function output_value ($value = '', $indent = 0) { + $output = ''; + if ( is_null($value) ) { + $output .= 'null'; + } elseif ( is_bool($value) ) { + $output .= ($value) ? 'true' : 'false' ; + } elseif ( is_int($value) || is_float($value) ) { + $output .= $value; + } elseif ( is_string($value) ) { + $output .= $this->output_string($value); + } elseif ( is_array($value) ) { + $output .= $this->output_array($value, ($indent + 1)); + } elseif ( is_object($value) ) { + $output .= 'unserialize('.$this->output_string(serialize($value)).')'; + } + return $output; + } + + function output_array ($array, $indent = 1) { + $output = "array(\n"; + foreach( $array as $key => $value ) { + $output .= $this->output_array_item($key, $value, $indent); + } + for ( $i=0; $i < ($indent - 1); $i++ ) { + $output .= "\t"; + } + return $output.')'; + } + + function output_array_item ($key, $value = '', $indent = 0, $register_objects = false) { + $output = $this->output_indent($indent); + $output .= "'".$key."' => "; + $output .= $this->output_value($value, $indent).",\n"; + return $output; + } + + function output_string ($string) { + $string = str_replace("\"", "\\\"", $string); + $string = str_replace("\'", "\\\'", $string); + $string = str_replace("\0", "\\0", $string); + $string = str_replace("\n", "\\n", $string); + $string = str_replace("\r", "\\r", $string); + $string = str_replace("\t", "\\t", $string); + return '"'.$string.'"'; + } + + function output_indent ($indent) { + $output = ''; + for ( $i=0; $i < $indent; $i++ ) { + $output .= "\t"; + } + return $output; + } + + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/router.php b/vendor/zynapse/router.php new file mode 100644 index 0000000..a3c8c1d --- /dev/null +++ b/vendor/zynapse/router.php @@ -0,0 +1,148 @@ +selected_route; + } + + function connect ( $url, $params = null ) { + if ( !is_array($params) ) $params = null; + $this->routes[] = array( + 'path' => $url, + 'params' => $params, + ); + $this->routes_count++; + } + + function find_route ($url = null) { + if ( $this->url === null ) $this->url = $this->get_url_path(); + if ( $this->routes_count == 0 ) $this->connect($this->default_route_path); + foreach( $this->routes as $key => $route ) { + $regex = $this->build_regex_path($route['path']); + if ( $regex['regex'] != '' ) { + $route['path'] = $regex['path']; + } + $regex = $regex['regex']; + if ( $url == '' && $regex == '' ) { + $selected_route = $route; + break; + } elseif ( $regex != '' && preg_match('/^'.$regex.'$/i', $url) ) { + $selected_route = $route; + break; + } elseif ( $route['path'] == $this->default_route_path ) { + $selected_route = $route; + break; + } + } + if ( isset($selected_route) ) { + $this->selected_route = $selected_route; + return $selected_route; + } else { + $this->selected_route = null; + return false; + } + } + + + function build_regex_path ($path) { + if ( is_array($path) ) { + return $path; + } else { + $path = explode('/', $path); + $regex = array(); + $new_path = array(); + $regex_foot = ''; + if ( count($path) ) { + foreach( $path as $element ) { + $elm_foot = ''; + if ( strlen($element) > 0 && substr($element, -1, 1) == '?' ) { + $elm_foot = '(?:'; + $regex_foot .= '|$)'; + $element = substr($element, 0, strlen($element)-1); + } + if ( preg_match('/^(:[a-z0-9_\-]+)\((.*)\)$/i', $element, $capture) ) { + $regex[] = '(?:'.$capture[2].')'.$elm_foot; + $new_path[] = $capture[1]; + } elseif ( preg_match('/^:[a-z0-9_\-]+$/i', $element) ) { + $regex[] = '(?:[a-z0-9_\-]+?)'.$elm_foot; + $new_path[] = $element; + } elseif ( preg_match('/^[a-z0-9_\-]+$/i', $element) ) { + $regex[] = $element.$elm_foot; + $new_path[] = $element; + } elseif ( Znap::$allow_dangerous_url_paths ) { + $regex[] = $element.$elm_foot; + $new_path[] = $element; + } + } + } + $regex = implode('\/', $regex).$regex_foot; + $new_path = implode('/', $new_path); + return array('regex' => $regex, 'path' => $new_path); + } + } + + function get_url_path ($prefix = null) { + if ( isset($_SERVER['REDIRECT_URL']) && !stristr($_SERVER['REDIRECT_URL'], 'dispatch.php') ) { + $url = $_SERVER['REDIRECT_URL']; + } elseif ( isset($_SERVER['REQUEST_URI']) ) { + if ( !strstr($_SERVER['REQUEST_URI'], '?') ) { + $url = $_SERVER['REQUEST_URI']; + } else { + $url = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); + } + } + if ( isset($url) ) { + $url = trim($url, '/'); + if ( !is_null(Znap::$url_prefix) && substr($url, 0, strlen(Znap::$url_prefix)) == Znap::$url_prefix ) { + $url = ltrim(substr($url, strlen(Znap::$url_prefix)), '/'); + } + return $url; + } + return false; + } + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/session.php b/vendor/zynapse/session.php new file mode 100644 index 0000000..ae4ab0b --- /dev/null +++ b/vendor/zynapse/session.php @@ -0,0 +1,193 @@ + 0 && (!isset($_SESSION[self::$key]['user_agent']) || $_SESSION[self::$key]['user_agent'] != self::$user_agent) ) { + $valid = false; + } + if ( self::$session_security > 1 ) { + if ( !self::is_aol_host() && (!isset($_SESSION[self::$key]['ip']) || $_SESSION[self::$key]['ip'] != self::$ip) ) { + $valid = false; + } + } + if ( !$valid ) { + $_SESSION = array(); + self::validate(); + } + } else { + $_SESSION[self::$key] = array( + 'user_agent' => self::$user_agent, + 'ip' => self::$ip, + ); + } + } + + function is_aol_host () { + if ( stristr(self::$user_agent, 'AOL') || preg_match('/proxy\.aol\.com$/i', gethostbyaddr(self::$ip)) ) { + return true; + } + return false; + } + + function var_setup () { + self::$session_name = defined('ZNAP_SESSION_NAME') ? ZNAP_SESSION_NAME : self::ZNAP_SESSION_NAME ; + self::$session_lifetime = defined('ZNAP_SESSION_LIFETIME') ? ZNAP_SESSION_LIFETIME : self::ZNAP_SESSION_LIFETIME ; + self::$session_maxlifetime = defined('ZNAP_SESSION_MAXLIFETIME') ? ZNAP_SESSION_MAXLIFETIME : self::ZNAP_SESSION_MAXLIFETIME ; + self::$session_use_only_cookies = defined('ZNAP_SESSION_USE_ONLY_COOKIES') ? ZNAP_SESSION_USE_ONLY_COOKIES : self::ZNAP_SESSION_USE_ONLY_COOKIES ; + self::$session_gc_probability = defined('ZNAP_SESSION_GC_PROBABILITY') ? ZNAP_SESSION_GC_PROBABILITY : self::ZNAP_SESSION_GC_PROBABILITY ; + self::$session_gc_divisor = defined('ZNAP_SESSION_GC_DIVISOR') ? ZNAP_SESSION_GC_DIVISOR : self::ZNAP_SESSION_GC_DIVISOR ; + self::$session_cache_limiter = defined('ZNAP_SESSION_CACHE_LIMITER') ? ZNAP_SESSION_CACHE_LIMITER : self::ZNAP_SESSION_CACHE_LIMITER ; + self::$session_security = defined('ZNAP_SESSION_SECURITY') ? ZNAP_SESSION_SECURITY : self::ZNAP_SESSION_SECURITY ; + } + + function ini_setup () { + ini_set('session.name', self::$session_name); + ini_set('session.cookie_lifetime', self::$session_lifetime); + ini_set('session.gc_maxlifetime', self::$session_maxlifetime); + ini_set('session.use_only_cookies', self::$session_use_only_cookies); + ini_set('session.gc_probability', self::$session_gc_probability); + ini_set('session.gc_divisor', self::$session_gc_divisor); + ini_set('session.cache_limiter', self::$session_cache_limiter); + } + + + + function flash ($key, $value = null) { + if ( $value !== null ) { + $_SESSION['flash'][$key] = $value; + } else { + $value = $_SESSION['flash'][$key]; + if ( !Znap::$keep_flash ) unset($_SESSION['flash'][$key]); + return $value; + } + } + + function isset_flash ($key) { + if ( isset($_SESSION['flash'][$key]) ) { + return true; + } + return false; + } + + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_script.php b/vendor/zynapse/shell_script.php new file mode 100644 index 0000000..f97c733 --- /dev/null +++ b/vendor/zynapse/shell_script.php @@ -0,0 +1,54 @@ +command = array_shift($_SERVER['argv']); + $this->script = basename($this->command); + $this->argv = $_SERVER['argv']; + } + + } + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/fix_permissions.php b/vendor/zynapse/shell_scripts/fix_permissions.php new file mode 100644 index 0000000..b72fdb7 --- /dev/null +++ b/vendor/zynapse/shell_scripts/fix_permissions.php @@ -0,0 +1,115 @@ +check($item) ) { + if ( $this->change($item) ) { + $this->echo_changed($item); + } else { + $this->echo_change_error($item); + } + } else { + $this->echo_ok($item); + } + } + + } + + function check ($item) { + if ( is_file($item) && substr(sprintf('%o', fileperms($item)), -4) == '0666' ) { + return true; + } elseif ( is_dir($item) && substr(sprintf('%o', fileperms($item)), -4) == '0777' ) { + return true; + } + return false; + } + + function change ($item) { + if ( is_file($item) ) { + $this->chmod($item, '0666'); + } elseif ( is_dir($item) ) { + $this->chmod($item, '0777'); + } + clearstatcache(); + return $this->check($item); + } + + function chmod ($item, $mode) { + exec(Znap::$chmod_cmd.' '.$mode.' "'.$item.'"'); + } + + function echo_changed ($item, $mode = null) { + if ( $mode == null ) { + if ( is_file($item) ) { + $mode = '0666'; + } elseif ( is_dir($item) ) { + $mode = '0777'; + $item .= '/'; + } + } + echo ' '.str_replace(ZNAP_ROOT.'/', '', $item).' changed to '.$mode.".\n"; + } + + function echo_change_error ($item, $mode = null) { + echo ' '.str_replace(ZNAP_ROOT.'/', '', $item).' is '.substr(sprintf('%o', fileperms($item)), -4)." and could not be changed to 0666.\n"; + } + + function echo_ok ($item, $mode = null) { + if ( $mode == null ) { + if ( is_file($item) ) { + $mode = '0666'; + } elseif ( is_dir($item) ) { + $mode = '0777'; + $item .= '/'; + } + } + echo ' '.str_replace(ZNAP_ROOT.'/', '', $item).' is '.$mode.".\n"; + } + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator.php b/vendor/zynapse/shell_scripts/znap_generator.php new file mode 100644 index 0000000..0ecd0cb --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator.php @@ -0,0 +1,202 @@ +get_args() ) { + $this->templates_path = Znap::$shell_scripts_path.'/znap_generator/templates'; + $this->generator_file = Znap::$shell_scripts_path.'/znap_generator/'.$this->type.'_generator.php'; + $this->generator_class = Inflector::camelize($this->type).'Generator'; + + if ( is_file($this->generator_file) ) { + require_once($this->generator_file); + if ( class_exists($this->generator_class) ) { + $class = $this->generator_class; + $this->generator_object = new $class(); + if ( is_object($this->generator_object) ) { + $this->generator_object->type = $this->type; + $this->generator_object->templates_path = $this->templates_path; + if ( !is_null($this->name) ) { + $this->generator_object->name = $this->name; + $this->generator_object->args = $this->args; + return $this->generator_object->generate(); + } else { + $this->generator_object->help(); + } + } else { + echo "\nERROR: Failed to initiate generator object.\n\n"; + } + } else { + echo "\nERROR: Invalid generate type.\n\n"; + } + } else { + echo "\nERROR: Invalid generate type.\n\n"; + } + } else { + $this->generator_help(); + } + } + + + function get_args () { + if ( !empty($this->argv[0]) ) { + $this->args = $this->argv; + $this->type = array_shift($this->args); + if ( isset($this->args[0]) && $this->args[0] != '' ) { + $this->name = $this->args[0]; + } + return true; + } + return false; + } + + + function generator_help () { + $generators = glob(Znap::$shell_scripts_path.'/znap_generator/*_generator.php'); + + echo "\n"; + echo "Usage:\n"; + echo "---------------------------------\n"; + + if ( ($count = count($generators)) > 0 ) { + for ( $i=0; $i < $count; $i++ ) { + include_once($generators[$i]); + $filename = basename($generators[$i]); + $name = substr($filename, 0, strrpos($filename, '_')); + call_user_func(array(Inflector::camelize($name).'Generator', 'help_summary')); + if ( $i < $count - 1 ) { + echo "\n"; + } + } + } + + echo "---------------------------------\n"; + echo "\n"; + } + + + function echo_create ($item) { + echo "\tcreate ".str_replace(ZNAP_ROOT.'/', '', $item)."\n"; + } + + function echo_exists ($item) { + echo "\texists ".str_replace(ZNAP_ROOT.'/', '', $item)."\n"; + } + + function echo_create_error ($item, $type = null) { + echo 'ERROR: Could not create'; + if ( $type !== null && is_string($type) ) { + echo ' '.$type.' file'; + } + echo ': '.str_replace(ZNAP_ROOT.'/', '', $item)."\n"; + } + + function echo_template_error ($item, $type = null) { + echo 'ERROR: '; + if ( $type !== null && is_string($type) ) { + echo ucfirst($type).' template'; + } else { + echo 'Template'; + } + echo ' file does not exist: '.str_replace(ZNAP_ROOT.'/', '', $item)."\n"; + } + + function validate_path($path) { + if ( is_dir($path) ) { + $this->echo_exists($path.'/'); + } elseif ( $this->dir_exists($path) ) { + $this->echo_create($path.'/'); + } else { + $this->echo_create_error($path.'/'); + return false; + } + return true; + } + + function dir_exists ($path) { + if ( !is_dir($path) ) { + if ( strstr($path, '/') ) { + $path_array = explode('/', $path); + } else { + $path_array = array($path); + } + $current_dir = $path_array[0]; + unset($path_array[0]); + foreach( $path_array as $dir ) { + $current_dir .= '/'.$dir; + if ( $current_dir != '' && !is_dir($current_dir) ) { + exec(Znap::$mkdir_cmd.' "'.$current_dir.'"'); + } + } + if ( !is_dir($path) ) { + return false; + } + } + return true; + } + + +} + + + + + + + + + + + + + + + + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/controller_generator.php b/vendor/zynapse/shell_scripts/znap_generator/controller_generator.php new file mode 100644 index 0000000..9f71934 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/controller_generator.php @@ -0,0 +1,229 @@ +name) ) { + echo "ERROR: Invalid snippet name given.\n"; + exit; + } + + if ( strstr($this->name, '/') ) { + $this->extra_path = substr($this->name, 0, strripos($this->name, '/')); + $this->name = Inflector::underscore(substr(strrchr($this->name, '/'), 1)); + $this->views_path = '/_'.$this->extra_path.'/'.$this->name; + $this->controller_path = '/'.$this->extra_path; + $this->helper_path = '/'.$this->extra_path; + } else { + $this->name = Inflector::underscore($this->name); + $this->views_path = '/'.$this->name; + } + + $this->name = Inflector::singularize($this->name); + $this->class_name = Inflector::camelize($this->name); + + // get method/view arguments + if ( isset($this->args[1]) ) { + for ( $i=1; $i < count($this->args); $i++ ) { + $this->methods[$i] = $this->args[$i]; + } + } + + // find all "views*" paths + $this->find_view_paths(); + + // validate that target controller path exists, or attempt to create if it doesn't + if ( !$this->validate_path(Znap::$controllers_path.$this->controller_path) ) { + return false; + } + + // validate that target helper path exists, or attempt to create if it doesn't + if ( !$this->validate_path(Znap::$helpers_path.$this->helper_path) ) { + return false; + } + + // validate that target view paths exists, or attempt to create if it doesn't + foreach( $this->view_root_paths as $key => $path ) { + if ( !$this->validate_path($path.$this->views_path) ) { + return false; + } + } + + $this->create_controller(); + $this->create_helper(); + $this->create_views(); + return true; + } + + + function create_controller () { + $controller_template = $this->templates_path.'/controller.php'; + $controller_file = Znap::$controllers_path.$this->controller_path.'/'.$this->name.'_controller.php'; + + if ( !is_file($controller_file) ) { + if ( is_file($controller_template) ) { + // controller + $controller = file_get_contents($controller_template); + $controller = str_replace('[class_name]', $this->class_name, $controller); + if ( count($this->methods) ) { + $methods = array(); + foreach( $this->methods as $method ) { + $methods[] = "\tfunction ".$method." () {\n\t\t\n\t}\n"; + } + $controller = str_replace('[class_methods]', "\t\n".implode("\n", $methods), $controller); + } else { + $controller = str_replace('[class_methods]', "\t", $controller); + } + if ( file_put_contents($controller_file, $controller) ) { + $this->echo_create($controller_file); + } else { + $this->echo_create_error($controller_file, 'controller'); + exit; + } + } else { + $this->echo_template_error($controller_template, 'controller'); + exit; + } + } else { + $this->echo_exists($controller_file); + } + } + + function create_helper () { + $helper_template = $this->templates_path.'/helper.php'; + $helper_file = Znap::$helpers_path.$this->helper_path.'/'.$this->name.'_helper.php'; + + if ( !is_file($helper_file) ) { + if ( is_file($helper_template) ) { + $helper = file_get_contents($helper_template); + $helper = str_replace('[class_name]', $this->class_name, $helper); + if ( file_put_contents($helper_file, $helper) ) { + $this->echo_create($helper_file); + } else { + $this->echo_create_error($helper_file, 'helper'); + } + } else { + $this->echo_template_error($helper_template, 'helper'); + } + } else { + $this->echo_exists($helper_file); + } + + } + + function create_views () { + $view_template = $this->templates_path.'/view.phtml'; + + if ( is_file($view_template) ) { + foreach( $this->view_root_paths as $path ) { + foreach( $this->methods as $view ) { + $view_file = $path.$this->views_path.'/'.$view.'.'.Znap::$views_extension; + if ( !is_file($view_file) ) { + $view_data = file_get_contents($view_template); + $view_data = str_replace('[class_name]', $this->class_name, $view_data); + $view_data = str_replace('[view]', $view, $view_data); + $view_data = str_replace('[controller]', $this->name, $view_data); + $view_data = str_replace('[view_file]', str_replace(Znap::$app_path.'/', '', $view_file), $view_data); + if ( file_put_contents($view_file, $view_data) ) { + $this->echo_create($view_file); + } else { + $this->echo_create_error($view_file, 'view'); + } + } else { + $this->echo_exists($view_file); + } + } + } + } else { + $this->echo_template_error($view_template, 'view'); + } + } + + + function find_view_paths () { + $this->view_root_paths = glob(Znap::$app_path.'/views*'); + } + + + function help_summary () { + echo "Generate Controller:\n"; + echo " ./script/generate controller controller_name [view1 view2 ...]\n"; + echo " for more controller info: ./script/generate controller\n"; + } + + function help () { + echo "\n"; + echo "Usage: ./script/generate controller ControllerName [view1 view2 ...]\n"; + echo "\n"; + echo "Description:\n"; + echo "\tThe controller generator creates functions for a new controller and\n"; + echo "\tits views.\n"; + echo "\n"; + echo "\tThe generator takes a controller name and a list of views as arguments.\n"; + echo "\tThe controller name may be given in CamelCase or under_score and should\n"; + echo "\tnot be suffixed with 'Controller'. To create a controller within a\n"; + echo "\tmodule, specify the controller name as 'folder/controller'.\n"; + echo "\tThe generator creates a controller class in app/controllers with view\n"; + echo "\ttemplates in app/views/controller_name.\n"; + echo "\n"; + echo "Example:\n"; + echo "\t./script/generate controller CreditCard open debit credit close\n"; + echo "\n"; + echo "\tCredit card controller with URLs like /credit_card/debit.\n"; + echo "\t\tController: app/controllers/credit_card_controller.php\n"; + echo "\t\tViews: app/views/credit_card/debit.phtml [...]\n"; + echo "\t\tHelper: app/helpers/credit_card_helper.php\n"; + echo "\n"; + echo "Module/Folders Example:\n"; + echo "\t./script/generate controller admin/credit_card suspend late_fee\n"; + echo "\n"; + echo "\tCredit card admin controller with URLs /admin/credit_card/suspend.\n"; + echo "\t\tController: app/controllers/admin/credit_card_controller.php\n"; + echo "\t\tViews: app/views/_admin/credit_card/suspend.phtml [...]\n"; + echo "\t\tHelper: app/helpers/credit_card_helper.php\n"; + echo "\n"; + } +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/error_generator.php b/vendor/zynapse/shell_scripts/znap_generator/error_generator.php new file mode 100644 index 0000000..780b6a7 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/error_generator.php @@ -0,0 +1,164 @@ +name) ) { + $this->error_code = &$this->name; + } else { + $this->echo_error_code(); + exit; + } + + if ( isset($this->args[1]) && $this->args[1] != '' ) { + if ( preg_match('/^(?:development|test|production)$/i', $this->args[1]) ) { + $this->environment = $this->args[1]; + $this->errors_path = str_replace(Znap::$views_path.'/', '', Znap::$errors_path).'/'.$this->environment; + } else { + $this->echo_error_env(); + exit; + } + } else { + $this->errors_path = str_replace(Znap::$views_path.'/', '', Znap::$errors_default_path); + } + + $template_file = $this->determine_template(); + + $view_paths = glob(Znap::$app_path.'/views*'); + + foreach( $view_paths as $path ) { + if ( $this->validate_path($path.'/'.$this->errors_path) ) { + $error_file = $path.'/'.$this->errors_path.'/'.$this->error_code.'.'.Znap::$views_extension; + $template_data = file_get_contents($template_file); + if ( file_put_contents($error_file, $template_data) ) { + $this->echo_create($error_file); + } else { + $this->echo_create_error($error_file, 'error'); + exit; + } + } else { + $this->echo_create_error($path.'/'.$this->errors_path); + } + } + return true; + } + + + function determine_template () { + if ( $this->environment != null && is_file($this->templates_path.'/error_'.$this->environment.'_'.$this->error_code.'.'.Znap::$views_extension) ) { + return $this->templates_path.'/error_'.$this->environment.'_'.$this->error_code.'.'.Znap::$views_extension; + } elseif ( $this->environment != null && is_file($this->templates_path.'/error_'.$this->environment.'_default.'.Znap::$views_extension) ) { + return $this->templates_path.'/error_'.$this->environment.'_default.'.Znap::$views_extension; + } elseif ( is_file($this->templates_path.'/error_'.$this->error_code.'.'.Znap::$views_extension) ) { + return $this->templates_path.'/error_'.$this->error_code.'.'.Znap::$views_extension; + } elseif ( is_file($this->templates_path.'/error_default.'.Znap::$views_extension) ) { + return $this->templates_path.'/error_default.'.Znap::$views_extension; + } else { + echo "ERROR: No suitable generate template file found.\n"; + exit; + } + } + + + function echo_error_code () { + echo "\n"; + echo "ERROR: Invalid error code given.\n"; + echo "Valid error codes are numbers 0 through 999 and \"default\".\n"; + echo "\n"; + } + + function echo_error_env () { + echo "\n"; + echo "ERROR: Invalid environment specified.\n"; + echo "Valid environment values are:\n"; + echo "\t- development\n"; + echo "\t- test\n"; + echo "\t- production\n"; + echo "\n"; + } + + + function help_summary () { + echo "Generate Error Template:\n"; + echo " ./script/generate error error_code [environment]\n"; + echo " for more layout info: ./script/generate error\n"; + } + + function help () { + echo "\n"; + echo "Usage: ./script/generate error error_code [environment]\n"; + echo "\n"; + echo "Description:\n"; + echo "\tGenerate error templates used for \"404 Page Not Found\" errors and\n"; + echo "\tmore.\n"; + echo "\n"; + echo "\tSpecifying an error code is required. Valid error code values are\n"; + echo "\tany of the standard HTTP errors, like 404 for example. Also\n"; + echo "\t\"default\" can be used as the error code to generate the default\n"; + echo "\terror template used when there is no template for the reported\n"; + echo "\terror code.\n"; + echo "\n"; + echo "\tEnvironment can also be specified, but is not required. If an\n"; + echo "\tenvironment is not specified, default will be used and the\n"; + echo "\tresulting error template will apply for all environments if there\n"; + echo "\tis no error template file for the current error code and\n"; + echo "\tenvironment.\n"; + echo "\n"; + echo "\tValid environment values are \"development\", \"test\", and\n"; + echo "\t\"production\".\n"; + echo "\n"; + echo "Examples:\n"; + echo "\t./script/generate error 404\n"; + echo "\tThis will create a 404 error layout for any environment:\n"; + echo "\t\tError Template: app/views/__errors/default/404.phtml\n"; + echo "\n"; + echo "\t./script/generate error 404 production\n"; + echo "\tThis will create a 404 error layout for the production environment:\n"; + echo "\t\tError Template: app/views/__errors/production/404.phtml\n"; + echo "\n"; + } + +} + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/layout_generator.php b/vendor/zynapse/shell_scripts/znap_generator/layout_generator.php new file mode 100644 index 0000000..8c8ac36 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/layout_generator.php @@ -0,0 +1,106 @@ +templates_path.'/layout.phtml'; + + if ( is_file($layout_template) ) { + + $this->name = Inflector::singularize($this->name); + $this->class_name = Inflector::camelize($this->name); + + if ( stristr($this->name, '_') ) { + $layout_filename = strtolower($this->name).'.'.Znap::$views_extension; + } else { + $layout_filename = Inflector::underscore($this->name).'.'.Znap::$views_extension; + } + + $view_paths = glob(Znap::$app_path.'/views*'); + + foreach( $view_paths as $path ) { + $layout_file = $path.'/__layouts/'.$layout_filename; + if ( !is_file($layout_file) ) { + $layout_data = file_get_contents($layout_template); + $layout_data = str_replace('[layout]', $this->name, $layout_data); + if ( file_put_contents($layout_file, $layout_data) ) { + $this->echo_create($layout_file); + } else { + $this->echo_create_error($layout_file, 'layout'); + exit; + } + } else { + $this->echo_exists($layout_file); + } + } + } else { + $this->echo_template_error($layout_template, 'layout'); + exit; + } + return true; + } + + function help_summary () { + echo "Generate Layout for specific Controller:\n"; + echo " ./script/generate layout controller_name\n"; + echo " for more layout info: ./script/generate layout\n"; + } + + function help () { + echo "\n"; + echo "Usage: ./script/generate layout controller_name\n"; + echo "\n"; + echo "Description:\n"; + echo "\tThe layout generator creates layout files for existing controllers.\n"; + echo "\tThe generator takes a controller name as its argument.\n"; + echo "\tController name may be given in CamelCase or under_score and should\n"; + echo "\tnot be suffixed with 'Controller'. The generator creates a layout\n"; + echo "\tfile in app/views/__layouts.\n"; + echo "\n"; + echo "Example:\n"; + echo "\t./script/generate layout Account\n"; + echo "\tThis will create an Account layout:\n"; + echo "\t\tLayout: app/views/__layout/account.phtml\n"; + echo "\n"; + } + +} + + + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/model_generator.php b/vendor/zynapse/shell_scripts/znap_generator/model_generator.php new file mode 100644 index 0000000..1ccbfa4 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/model_generator.php @@ -0,0 +1,97 @@ +name = Inflector::singularize($this->name); + $this->class_name = Inflector::camelize($this->name); + + $model_template = $this->templates_path.'/model.php'; + + if ( stristr($this->name, '_') ) { + $model_file = Znap::$models_path.'/'.strtolower($this->name).'.php'; + } else { + $model_file = Znap::$models_path.'/'.Inflector::underscore($this->name).'.php'; + } + + if ( !is_file($model_file) ) { + if ( is_file($model_template) ) { + $model_data = file_get_contents($model_template); + $model_data = str_replace('[class_name]', $this->class_name, $model_data); + if ( file_put_contents($model_file, $model_data) ) { + $this->echo_create($model_file); + } else { + $this->echo_create_error($model_file, 'model'); + } + } else { + $this->echo_template_error($model_template, 'model'); + exit; + } + } else { + $this->echo_exists($model_file); + } + return true; + } + + function help_summary () { + echo "Generate Model:\n"; + echo " ./script/generate model ModelName\n"; + echo " for more model info: ./script/generate model\n"; + } + + function help () { + echo "\n"; + echo "Usage: ./script/generate model ModelName\n"; + echo "\n"; + echo "Description:\n"; + echo "\tThe model generator creates functions for a new model.\n"; + echo "\tThe generator takes a model name as its argument. The model name\n"; + echo "\tmay be given in CamelCase or under_score and should not be suffixed\n"; + echo "\twith 'Model'. The generator creates a model class in app/models.\n"; + echo "\n"; + echo "Example:\n"; + echo "\t./script/generate model Account\n"; + echo "\tThis will create an Account model:\n"; + echo "\t\tModel: app/models/account.php\n"; + echo "\n"; + } + +} + + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/snippet_generator.php b/vendor/zynapse/shell_scripts/znap_generator/snippet_generator.php new file mode 100644 index 0000000..2c27be0 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/snippet_generator.php @@ -0,0 +1,210 @@ +name) ) { + echo "ERROR: Invalid snippet name given.\n"; + exit; + } + + $this->name = Inflector::underscore($this->name); + $this->views_path = '__snippets/'.$this->name; + + $this->name = Inflector::singularize($this->name); + $this->class_name = Inflector::camelize($this->name); + + // get method/view arguments + if ( isset($this->args[1]) ) { + for ( $i=1; $i < count($this->args); $i++ ) { + $this->methods[$i] = $this->args[$i]; + } + } + + // find all "views*" paths + $this->find_view_paths(); + + // validate that target snippet path exists, or attempt to create if it doesn't + if ( !$this->validate_path(Znap::$snippets_path) ) { + return false; + } + + // validate that target helper path exists, or attempt to create if it doesn't + if ( !$this->validate_path(Znap::$snippet_helpers_path) ) { + return false; + } + + // validate that target view paths exists, or attempt to create if it doesn't + foreach( $this->view_root_paths as $key => $path ) { + if ( !$this->validate_path($path.'/'.$this->views_path) ) { + return false; + } + } + + $this->create_snippet(); + $this->create_helper(); + $this->create_views(); + return true; + } + + + function create_snippet () { + $controller_template = $this->templates_path.'/snippet.php'; + $controller_file = Znap::$snippets_path.'/'.$this->name.'_snippet.php'; + + if ( !is_file($controller_file) ) { + if ( is_file($controller_template) ) { + // controller + $controller = file_get_contents($controller_template); + $controller = str_replace('[class_name]', $this->class_name, $controller); + if ( count($this->methods) ) { + $methods = array(); + foreach( $this->methods as $method ) { + $methods[] = "\tfunction ".$method." () {\n\t\t\n\t}\n"; + } + $controller = str_replace('[class_methods]', "\t\n".implode("\n", $methods), $controller); + } else { + $controller = str_replace('[class_methods]', "\t", $controller); + } + if ( file_put_contents($controller_file, $controller) ) { + $this->echo_create($controller_file); + } else { + $this->echo_create_error($controller_file, 'controller'); + exit; + } + } else { + $this->echo_template_error($controller_template, 'controller'); + exit; + } + } else { + $this->echo_exists($controller_file); + } + } + + function create_helper () { + $helper_template = $this->templates_path.'/snippet_helper.php'; + $helper_file = Znap::$snippet_helpers_path.'/'.$this->name.'_helper.php'; + + if ( !is_file($helper_file) ) { + if ( is_file($helper_template) ) { + $helper = file_get_contents($helper_template); + $helper = str_replace('[class_name]', $this->class_name, $helper); + if ( file_put_contents($helper_file, $helper) ) { + $this->echo_create($helper_file); + } else { + $this->echo_create_error($helper_file, 'helper'); + } + } else { + $this->echo_template_error($helper_template, 'helper'); + } + } else { + $this->echo_exists($helper_file); + } + + } + + function create_views () { + $view_template = $this->templates_path.'/snippet_view.phtml'; + + if ( is_file($view_template) ) { + foreach( $this->view_root_paths as $path ) { + foreach( $this->methods as $view ) { + $view_file = $path.'/'.$this->views_path.'/'.$view.'.'.Znap::$views_extension; + if ( !is_file($view_file) ) { + $view_data = file_get_contents($view_template); + $view_data = str_replace('[class_name]', $this->class_name, $view_data); + $view_data = str_replace('[view]', $view, $view_data); + $view_data = str_replace('[controller]', $this->name, $view_data); + $view_data = str_replace('[view_file]', str_replace(Znap::$app_path.'/', '', $view_file), $view_data); + if ( file_put_contents($view_file, $view_data) ) { + $this->echo_create($view_file); + } else { + $this->echo_create_error($view_file, 'view'); + } + } else { + $this->echo_exists($view_file); + } + } + } + } else { + $this->echo_template_error($view_template, 'view'); + } + } + + + function find_view_paths () { + $this->view_root_paths = glob(Znap::$app_path.'/views*'); + } + + + function help_summary () { + echo "Generate Snippet:\n"; + echo " ./script/generate snippet snippet_name [action1 action2 ...]\n"; + echo " for more controller info: ./script/generate snippet\n"; + } + + function help () { + echo "\n"; + echo "Usage: ./script/generate snippet SnippetName [action1 action2 ...]\n"; + echo "\n"; + echo "Description:\n"; + echo "\tThe snippet generator creates a new snippet, it's actions and views,\n"; + echo "\twhich are easily reusable in controller view files.\n"; + echo "\n"; + echo "\tThe generator takes a snippet name and a list of actions as arguments.\n"; + echo "\tThe snippet name may be given in CamelCase or under_score and should\n"; + echo "\tnot be suffixed with 'Snippet'.\n"; + echo "\n"; + echo "\tThe generator creates a snippet class in app/snippets with view\n"; + echo "\ttemplates in app/views/__snippets/snippet_name.\n"; + echo "\n"; + echo "Example:\n"; + echo "\t./script/generate snippet TagCloud user all_users\n"; + echo "\n"; + echo "\tTag cloud snippet is usable with render_snippet() helper.\n"; + echo "\t\tSnippet: app/snippets/tag_cloud_snippet.php\n"; + echo "\t\tViews: app/views/__snippets/tag_cloud/user.phtml [...]\n"; + echo "\t\tHelper: app/helpers/snippet_helpers/tag_cloud_helper.php\n"; + echo "\n"; + } +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/controller.php b/vendor/zynapse/shell_scripts/znap_generator/templates/controller.php new file mode 100644 index 0000000..8cdcd25 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/controller.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/error_404.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/error_404.phtml new file mode 100644 index 0000000..68d1cd2 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/error_404.phtml @@ -0,0 +1,54 @@ + + + + + + + 404 - Page Not Found + + + + + + + +

Error: 404

+
+ The page you requested could not be found, or has been moved. +
+ + + diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/error_500.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/error_500.phtml new file mode 100644 index 0000000..181c365 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/error_500.phtml @@ -0,0 +1,54 @@ + + + + + + + 500 - Internal Server Error + + + + + + + +

Error: 500

+
+ The server encountered an internal error. +
+ + + diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/error_default.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/error_default.phtml new file mode 100644 index 0000000..9ea7521 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/error_default.phtml @@ -0,0 +1,54 @@ + + + + + + + Unknown Error + + + + + + + +

Unknown Error

+
+ An unknown error has been encountered, please try again later. +
+ + + diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/error_development_default.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/error_development_default.phtml new file mode 100644 index 0000000..e0f0d8c --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/error_development_default.phtml @@ -0,0 +1,116 @@ + + + + + + + <?php echo $message; ?> + + + + + + + + + + + +

+ +
+ +
+ + + +

Show framework trace

+
get_trace(); ?>
+ +

Show Znap::$prefs dump

+
+ +

Show $_SESSION dump

+
+ +

Show $_GET dump

+
+ +

Show $_POST dump

+
+ +

Show $_COOKIE dump

+
+ +

Show $_FILES dump

+
+ +

Show Timer dump

+
+ + + diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/helper.php b/vendor/zynapse/shell_scripts/znap_generator/templates/helper.php new file mode 100644 index 0000000..3512a22 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/helper.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/layout.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/layout.phtml new file mode 100644 index 0000000..3d06ca6 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/layout.phtml @@ -0,0 +1,29 @@ + + + + + + + [layout] + + + + + + +
+ +
+ + + + + +
+ page generated in seconds. +
+ + + + diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/model.php b/vendor/zynapse/shell_scripts/znap_generator/templates/model.php new file mode 100644 index 0000000..8196f58 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/model.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/snippet.php b/vendor/zynapse/shell_scripts/znap_generator/templates/snippet.php new file mode 100644 index 0000000..4729119 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/snippet.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/snippet_helper.php b/vendor/zynapse/shell_scripts/znap_generator/templates/snippet_helper.php new file mode 100644 index 0000000..d23563f --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/snippet_helper.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/snippet_view.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/snippet_view.phtml new file mode 100644 index 0000000..e7f2b79 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/snippet_view.phtml @@ -0,0 +1,2 @@ +

[class_name]Snippet->[view]

+

Find me in [view_file]

\ No newline at end of file diff --git a/vendor/zynapse/shell_scripts/znap_generator/templates/view.phtml b/vendor/zynapse/shell_scripts/znap_generator/templates/view.phtml new file mode 100644 index 0000000..be579c2 --- /dev/null +++ b/vendor/zynapse/shell_scripts/znap_generator/templates/view.phtml @@ -0,0 +1,2 @@ +

[class_name]->[view]

+

Find me in [view_file]

\ No newline at end of file diff --git a/vendor/zynapse/snippet_controller.php b/vendor/zynapse/snippet_controller.php new file mode 100644 index 0000000..05edee6 --- /dev/null +++ b/vendor/zynapse/snippet_controller.php @@ -0,0 +1,522 @@ +snippet = $snippet; + + if ( $action != null ) { + $this->action = $action; + } + + if ( is_array($args) && count($args) > 0 ) { + $this->args = $args; + } + + if ( !$this->paths_loaded ) { + $this->init_paths(); + } + + $this->views_path = Znap::$snippet_views_path.'/'.$this->snippet; + + $this->snippet_file = $this->snippets_path.'/'.$this->snippet.'_snippet.php'; + $this->helper_file = $this->helpers_path.'/'.$this->snippet.'_snippet_helper.php'; + $this->class_name = Inflector::camelize($this->snippet).'Snippet'; + + return true; + } + return false; + } + + function init_paths () { + $this->snippets_path = Znap::$snippets_path; + $this->helpers_path = Znap::$snippet_helpers_path; + $this->layouts_path = Znap::$snippet_layouts_path; + $this->views_base_path = Znap::$snippet_views_path; + $this->snippets_class_file = $this->snippets_path.'/snippets.php'; + $this->snippets_helper_file = $this->helpers_path.'/snippets_helper.php'; + } + + function init_filters () { + // check if any filters are pre-defined + if ( isset($this->before_filter) ) { + $this->add_before_filter($this->before_filter); + unset($this->before_filter); + } + if ( isset($this->after_filter) ) { + $this->add_after_filter($this->after_filter); + unset($this->after_filter); + } + if ( isset($this->helper) ) { + $this->add_helper($this->helper); + unset($this->helper); + } + } + + + function call_snippet ($snippet = null, $action = null, $args = array()) { + $this->render_layout = false; + $this->render_view = false; + return $this->render_snippet($snippet, $action, $args); + } + + function render_snippet ($snippet = null, $action = null, $args = array()) { + if ( !$this->initialize($snippet, $action, $args) ) { + return null; + } + + if ( is_file($this->snippets_class_file) ) { + include_once($this->snippets_class_file); + } + + include_once($this->snippet_file); + if ( class_exists($this->class_name, false) ) { + if ( !isset(Znap::$current_snippet_objects[$this->snippet]) ) { + $class = $this->class_name; + $this->snippet_object = new $class(); + if ( is_object($this->snippet_object) ) { + $this->snippet_object->init_filters(); + $this->snippet_object->snippet = $this->snippet; + $this->snippet_object->action = $this->action; + $this->snippet_object->args = $this->args; + $this->snippet_object->snippets_path = &$this->snippets_path; + $this->snippet_object->helpers_path = &$this->helpers_path; + $this->snippet_object->layouts_path = &$this->layouts_path; + $this->snippet_object->views_base_path = &$this->views_base_path; + $this->snippet_object->views_path = $this->views_path; + $this->snippet_object->class_name = $this->class_name; + $this->snippet_object->render_layout = $this->render_layout; + $this->snippet_object->render_view = $this->render_view; + + Znap::$current_snippet_objects[$this->snippet] = &$this->snippet_object; + } + } elseif ( is_object(Znap::$current_snippet_objects[$this->snippet]) ) { + $this->snippet_object = &Znap::$current_snippet_objects[$this->snippet]; + $this->snippet_object->action = $this->action; + $this->snippet_object->args = $this->args; + } + + if ( is_object($this->snippet_object) ) { + + // include main snippets helpers + if ( is_file($this->snippets_helper_file) ) { + include_once($this->snippets_helper_file); + } + + if ( ($before_filters_result = $this->snippet_object->execute_before_filters()) === true ) { + + // include snippet specific preferences + if ( isset($this->snippet_object->has_prefs) && Znap::$prefs->read('snippet_'.$this->snippet, true) ) { + $snippet = 'snippet_'.$this->snippet; + $this->snippet_object->prefs = &Znap::$prefs->$snippet; + } + + // supress output for capture + ob_start(); + + // include snippet specific helper file + if ( is_file($this->helper_file) ) { + include_once($this->helper_file); + } + + // call default action/method if none is defined + if ( $this->action === null ) { + $this->action = $this->default_action; + } + + // execute main method + if ( method_exists($this->snippet_object, $this->action) && !in_array($this->action, get_class_methods('SnippetController')) ) { + $action = $this->action; + $this->result = call_user_func_array(array($this->snippet_object, $action), $this->args); + } elseif ( is_file($this->views_path.'/'.$this->action.'.'.Znap::$views_extension) ) { + $action = $this->action; + } else { + $this->raise('Snippet action "'.$this->action.'" not found in the '.$this->snippet.' snippet class.'); + ob_end_clean(); + return false; + } + + $this->snippet_object->execute_after_filters(); + $this->snippet_object->action_called = true; + + // include any additionaly defined helpers + if ( count($this->snippet_object->helpers) ) { + foreach( $this->snippet_object->helpers as $helper ) { + if ( is_file($this->helpers_path.'/'.$helper.'_helper.php') ) { + include_once($this->helpers_path.'/'.$helper.'_helper.php'); + } + } + } + + // if render_text is defined as a string, render it instead of layout & view files + if ( isset($this->snippet_object->render_text) && $this->snippet_object->render_text != '' ) { + $this->render_text($this->snippet_object->render_text); + } + + // if render_action is defined, used it as the render action + if ( isset($this->snippet_object->render_action) && $this->snippet_object->render_action != '' ) { + $action = $this->snippet_object->render_action; + } + + // render view file + if ( !$this->snippet_object->render_action($action) ) { + $this->raise('No "'.$action.'" view file found for the "'.$this->snippet.'" snippet.'); + ob_end_clean(); + return false; + } + + // grab captured output + $this->snippet_object->content_for_layout = ob_get_contents(); + ob_end_clean(); + + // render or not to render layout (that is the question) + if ( $this->snippet_object->render_layout !== false && ($layout_file = $this->snippet_object->determine_layout()) ) { + if ( !$this->snippet_object->render_file($layout_file) ) { + echo $this->snippet_object->content_for_layout; + } + } else { + echo $this->snippet_object->content_for_layout; + } + return $this->result; + } else { + $this->raise('The "'.$before_filters_result.'" snippet before filter failed.'); + return false; + } + } else { + $this->raise('Failed to initiate snippet object "'.$this->snippet.'".'); + return false; + } + } else { + $this->raise('Snippet "'.$this->snippet.'" not found.'); + return false; + } + } + + + function determine_layout ($full_path = true) { + // if controller defines and sets $layout to NULL, don't use a layout + if ( isset($this->layout) && is_null($this->layout) ) { + return null; + } + + // if _determine_layout() is defined in controller, call it to get layout name + if ( method_exists($this, Znap::$protected_method_prefix.'determine_layout') ) { + $determine_layout_method = Znap::$protected_method_prefix.'determine_layout'; + $layout = $this->$determine_layout_method(); + } else { + $layout = ( isset($this->layout) && $this->layout != '' ) ? $this->layout : $this->snippet ; + } + + $default_layout_file = $this->layouts_path.'/snippets.'.Znap::$views_extension; + + if ( !$full_path && $layout ) { + return $layout; + } elseif ( is_file($this->layouts_path.'/'.$layout.'.'.Znap::$views_extension) ) { + $layout_file = $this->layouts_path.'/'.$layout.'.'.Znap::$views_extension; + } else { + $layout_file = $this->layouts_path.'/snippets.'.Znap::$views_extension; + } + + return $layout_file; + } + + + + function execute_filters ($filters) { + if ( count($this->$filters) ) { + foreach( $this->$filters as $filter ) { + if ( method_exists($this, $filter) ) { + if ( $this->$filter() === false ) { + return $filter; + } + } + } + } + return true; + } + + function execute_before_filters () { + return $this->execute_filters('before_filters'); + } + + function execute_after_filters () { + return $this->execute_filters('after_filters'); + } + + + function add_items_to_list ($filter, $list) { + if ( is_string($filter) && !empty($filter) ) { + if ( strpos($filter, ',') !== false ) { + $filter = explode(',', $filter); + foreach( $filter as $key => $value ) { + if ( !in_array($value, $this->$list) ) { + $this->{$list}[] = trim($value); + } + } + } else { + $this->{$list}[] = $filter; + } + } elseif ( is_array($filter) ) { + if ( count($this->$list) ) { + $this->$list = array_unique(array_merge($this->$list, $filter)); + } else { + $this->$list = $filter; + } + } + } + + function add_before_filter ($filter) { + $this->add_items_to_list($filter, 'before_filters'); + } + + function add_after_filter ($filter) { + $this->add_items_to_list($filter, 'after_filters'); + } + + + function add_helper ($helper) { + $this->add_items_to_list($helper, 'helpers'); + } + + + + function render_text ($text, $options = array()) { + if ( isset($options['layout']) && $options['layout'] != '' ) { + $locals['content_for_layout'] = &$text; + $layout = $this->determine_layout(); + $this->render_file($layout, $locals); + } else { + echo $text; + } + exit; + } + + + function render_action ($action, $layout = null) { + if ( $this->render_performed || $this->render_view === false ) { + return true; + } + + if ( $layout != null ) { + $this->layout = $layout; + } + + if ( !empty($this->view_file) ) { + $len = strlen('.'.Znap::$views_extension); + if ( substr($this->view_file, -$len) != '.'.Znap::$views_extension ) { + $this->view_file .= '.'.Znap::$views_extension; + } + if ( strstr($this->view_file, '/') && is_file($this->views_base_path.'/'.$this->view_file) ) { + $this->view_file = $this->views_base_path.'/'.$this->view_file; + } elseif ( is_file($this->views_path.'/'.$this->view_file) ) { + $this->view_file = $this->views_path.'/'.$this->view_file; + } + } else { + $this->view_file = $this->views_path.'/'.$action.'.'.Znap::$views_extension; + } + + $this->render_performed = true; + + return $this->render_file($this->view_file); + } + + + function render_file ($file, $locals = array(), $use_full_path = false) { + + if ( $use_full_path ) { + $file = $this->views_path.'/'.$file.'.'.Znap::$views_extension; + } + + if ( is_file($file) ) { + if ( is_object($this) ) { + foreach( $this as $tmp_key => $tmp_value ) { + ${$tmp_key} = &$this->$tmp_key; + } + unset($tmp_key, $tmp_value); + } + if ( $this->content_for_layout !== null ) { + $content_for_layout = &$this->content_for_layout; + } + if ( count($locals) ) { + foreach( $locals as $tmp_key => $tmp_value ) { + ${$tmp_key} = &$locals[$tmp_key]; + } + unset($tmp_key, $tmp_value); + } + + unset($use_full_path, $locals); + + Znap::$currently_rendering_snippet = $this->snippet; + $this->currently_rendering_file = $file; + include($file); + Znap::$currently_rendering_snippet = null; + return true; + } + return false; + } + + + function render_partial ($partial, $options = array()) { + + // set file name + if ( strstr($partial, '/') ) { + $file = '_'.substr(strrchr($partial, '/'), 1).'.'.Znap::$views_extension; + $path = substr($partial, 0, strrpos($partial, '/')); + $file_name = $path.'/'.$file; + } else { + $path = ''; + $file_name = $file = '_'.$partial.'.'.Znap::$views_extension; + } + + // determine file path + if ( strstr($file_name, '/') && is_file($this->views_base_path.'/'.$file_name) ) { + $file_name = $this->views_base_path.'/'.$file_name; + } elseif ( is_file(dirname($this->currently_rendering_file).'/'.$file_name) ) { + $file_name = dirname($this->currently_rendering_file).'/'.$file_name; + } elseif ( is_file($this->views_path.'/'.$file_name) ) { + $file_name = $this->views_path.'/'.$file_name; + } elseif ( is_file($this->layouts_path.'/'.$file_name) ) { + $file_name = $this->layouts_path.'/'.$file_name; + } else { + return false; + } + + // continue if partial file exists + if ( is_file($file_name) ) { + $locals = ( array_key_exists('locals', $options) ) ? $options['locals'] : array() ; + + // use collections to render a partial multiple times with new variables available to it each time + if ( array_key_exists('collection', $options) && is_array($options['collection']) ) { + + // spacer template to be rendered between each collection item's partial rendering + if ( array_key_exists('spacer', $options) || array_key_exists('spacer_template', $options) ) { + $spacer_path = (array_key_exists('spacer', $options)) ? $options['spacer'] : $options['spacer_template']; + if ( strstr($spacer_path, '/') ) { + $spacer_file = substr(strrchr($spacer_path, '/'), 1); + $spacer_path = substr($spacer_path, 0, strripos($path, '/')); + $spacer_file_path = Znap::$views_path.'/'.$spacer_path.'/_'.$spacer_file.'.'.Znap::$views_extension; + } else { + $spacer_file = $spacer_path; + $spacer_file_path = $this->views_path.'/'.$spacher_file.'.'.Znap::$views_extension; + } + if ( is_file($spacer_file_path) ) { + $add_spacer = true; + } + } + + // start the rendering + ${$partial.'_counter'} = 0; + foreach( $options['collection'] as $tmp_value ) { + ${$file.'_counter'}++; + $locals[$partial] = $tmp_value; + $locals[$partial.'_counter'] = ${$partial.'_counter'}; + unset($tmp_value); + $this->render_performed = false; + $this->render_file($file_name, $locals); + if ( isset($add_spacer) && ${$partial.'_counter'} < count($options['collection']) ) { + $this->render_performed = false; + $this->render_file($spacer_file_path, $locals); + } + } + $this->render_performed = true; + } else { + return $this->render_file($file_name, $locals); + } + } + } + + + function raise ($message = 'UNKNOWN SNIPPET ERROR') { + error_log($message, 0); + } + + + + + + + + + + + + + + + + + + +} + +?> \ No newline at end of file diff --git a/vendor/zynapse/strings.php b/vendor/zynapse/strings.php new file mode 100644 index 0000000..52f2f9d --- /dev/null +++ b/vendor/zynapse/strings.php @@ -0,0 +1,21 @@ + 'Unknown error with %column%.', + + // html used for error flashing + '_ZNAP_AR_ERROR_TITLE' => 'There was a problem with your request. Please fix the following:', + '_ZNAP_AR_ERROR_BODY_HTML' => '
%title%
    %errors%
', + '_ZNAP_AR_ERROR_ITEM_HTML' => '
  • %error%
  • ', + +); + +?> \ No newline at end of file diff --git a/vendor/zynapse/timer.php b/vendor/zynapse/timer.php new file mode 100644 index 0000000..02db799 --- /dev/null +++ b/vendor/zynapse/timer.php @@ -0,0 +1,149 @@ + \ No newline at end of file diff --git a/vendor/zynapse/znap_error.php b/vendor/zynapse/znap_error.php new file mode 100644 index 0000000..979d7d7 --- /dev/null +++ b/vendor/zynapse/znap_error.php @@ -0,0 +1,80 @@ +details = $details; + parent::__construct($message, $code); + } + + public function getDetails () { + return $this->details; + } + + public function get_trace () { + return str_replace(ZNAP_ROOT.'/', '', $this->getTraceAsString()); + } + +} + + +/* + Action Controller's Exception handling class +*/ +class ActionControllerError extends ZnapError {} + + +/* + Active Record's Exception handling class +*/ +class ActiveRecordError extends ZnapError {} + + +/* + Snippet Controller's Exception handling class +*/ +class SnippetControllerError extends ZnapError {} + +?> \ No newline at end of file diff --git a/vendor/zynapse/znap_error/default/404.phtml b/vendor/zynapse/znap_error/default/404.phtml new file mode 100644 index 0000000..68d1cd2 --- /dev/null +++ b/vendor/zynapse/znap_error/default/404.phtml @@ -0,0 +1,54 @@ + + + + + + + 404 - Page Not Found + + + + + + + +

    Error: 404

    +
    + The page you requested could not be found, or has been moved. +
    + + + diff --git a/vendor/zynapse/znap_error/default/500.phtml b/vendor/zynapse/znap_error/default/500.phtml new file mode 100644 index 0000000..181c365 --- /dev/null +++ b/vendor/zynapse/znap_error/default/500.phtml @@ -0,0 +1,54 @@ + + + + + + + 500 - Internal Server Error + + + + + + + +

    Error: 500

    +
    + The server encountered an internal error. +
    + + + diff --git a/vendor/zynapse/znap_error/default/default.phtml b/vendor/zynapse/znap_error/default/default.phtml new file mode 100644 index 0000000..9ea7521 --- /dev/null +++ b/vendor/zynapse/znap_error/default/default.phtml @@ -0,0 +1,54 @@ + + + + + + + Unknown Error + + + + + + + +

    Unknown Error

    +
    + An unknown error has been encountered, please try again later. +
    + + + diff --git a/vendor/zynapse/znap_error/development/default.phtml b/vendor/zynapse/znap_error/development/default.phtml new file mode 100644 index 0000000..e0f0d8c --- /dev/null +++ b/vendor/zynapse/znap_error/development/default.phtml @@ -0,0 +1,116 @@ + + + + + + + <?php echo $message; ?> + + + + + + + + + + + +

    + +
    + +
    + + + +

    Show framework trace

    +
    get_trace(); ?>
    + +

    Show Znap::$prefs dump

    +
    + +

    Show $_SESSION dump

    +
    + +

    Show $_GET dump

    +
    + +

    Show $_POST dump

    +
    + +

    Show $_COOKIE dump

    +
    + +

    Show $_FILES dump

    +
    + +

    Show Timer dump

    +
    + + + diff --git a/vendor/zynapse/zynapse.php b/vendor/zynapse/zynapse.php new file mode 100644 index 0000000..998a6f8 --- /dev/null +++ b/vendor/zynapse/zynapse.php @@ -0,0 +1,374 @@ +read('_internals'); + self::$prefs->read('application'); + self::$prefs->read('cache', true, self::$tmp_path); + + // initialize the App class - read the comment on the class for more info + App::initialize(); + } + + + // load language specific strings - called by ActionController when needed + function load_strings () { + + // check application prefrences for default language + $language = ( isset(App::$prefs->language) && App::$prefs->language != '' ) ? App::$prefs->language : 'english' ; + + // check current session is set to use non-default language + $language = ( isset($_SESSION['language']) && $_SESSION['language'] != '' ) ? $_SESSION['language'] : $language ; + + if ( is_file(self::$strings_path.'/'.strtolower($language).'.php') ) { + include(self::$strings_path.'/'.strtolower($language).'.php'); + if ( !empty($strings) && is_array($strings) ) { + self::$strings = array_merge(self::$strings, $strings); + } + } + } + + + function start_timer () { + Timer::start(); + self::$timer_enabled = true; + } + +} + + + +/* + + The App class is designed to store application specific + information. "App::$prefs" for exaple stores the application + preferences. These can also be accessed with + "Znap::$prefs->application". + +*/ + +class App { + + public static + $_internals, + $strings, + $preferences, + $cache, + $str, + $prefs; + + function initialize () { + self::$_internals = &Znap::$prefs->_internals; + self::$strings = &Znap::$strings; + self::$preferences = &Znap::$prefs->application; + self::$cache = &Znap::$prefs->cache; + self::$str = &Znap::$strings; + self::$prefs = &Znap::$prefs->application; + } +} + + +// autoload magic +function __autoload ($class_name) { + + // check cache if specified class has been found before + if ( !empty(App::$cache->autoload[$class_name]) ) { + if ( is_file(App::$cache->autoload[$class_name]) ) { + include_once(App::$cache->autoload[$class_name]); + $found = true; + } else { + unset(App::$cache->autoload[$class_name]); + $save_cache = true; + } + } + + if ( empty($found) ) { + + $name = Inflector::underscore($class_name); + + $file = $name.'.php'; + $file_lib = $name.'.lib.php'; + $file_cla = $name.'.class.php'; + + $org_file = $class_name.'.php'; + $org_lib = $class_name.'.lib.php'; + $org_cla = $class_name.'.class.php'; + + $low = strtolower($class_name); + $low_file = $low.'.php'; + $low_lib = $low.'.lib.php'; + $low_cla = $low.'.class.php'; + + + $internal_paths = array( + Znap::$models_path, + Znap::$controllers_path, + Znap::$current_controller_path, + ); + + // autoload model and controller classes + foreach( $internal_paths as $path ) { + if ( is_file($path.'/'.$file) ) { + include_once($path.'/'.$file); + App::$cache->autoload[$class_name] = $path.'/'.$file; + $save_cache = true; + $found = true; + break; + } + } + + // autload classes from libs folder + if ( empty($found) ) { + + $paths = array( + Znap::$lib_path.'/'.$low, + Znap::$lib_path.'/'.$class_name, + Znap::$lib_path.'/'.$name, + Znap::$lib_path, + ); + + $files = array( + $low_lib, $low_cla, $low_file, + $org_lib, $org_cla, $org_file, + $file_lib, $file_cla, $file, + ); + + foreach( $paths as $path ) { + if ( is_dir($path) ) { + foreach( $files as $file ) { + if ( is_file($path.'/'.$file) ) { + include_once($path.'/'.$file); + App::$cache->autoload[$class_name] = $path.'/'.$file; + $save_cache = true; + break 2; + } + } + } + } + + } + + } + if ( !empty($save_cache) ) { + App::$cache->save(); + } + +} + + + +?> \ No newline at end of file