From 6ac6c6a7e0824d8fda81e36240818f9b7e9c4696 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 15 Mar 2009 19:27:30 +0000 Subject: Updates to the developer tool create module. It now creates a fully functional sidebar block, a dialog pop up on the option menu for albums or photos, a dashboard block and an admin screen. --- modules/developer/config/developer.php | 1 - modules/developer/helpers/developer_task.php | 38 ++++++++++--- modules/developer/js/developer.js | 2 - modules/developer/views/admin_controller.txt.php | 21 ++++---- modules/developer/views/admin_html.txt.php | 2 +- modules/developer/views/block.txt.php | 12 +++++ modules/developer/views/block_html.txt.php | 10 ++++ modules/developer/views/controller.txt.php | 53 ++++++++++++++++++ modules/developer/views/helpers.txt.php | 26 --------- modules/developer/views/menu.txt.php | 9 ++++ modules/developer/views/theme.txt.php | 69 +++++++++++++----------- 11 files changed, 163 insertions(+), 80 deletions(-) create mode 100644 modules/developer/views/block_html.txt.php create mode 100644 modules/developer/views/controller.txt.php delete mode 100644 modules/developer/views/helpers.txt.php (limited to 'modules/developer') diff --git a/modules/developer/config/developer.php b/modules/developer/config/developer.php index 35ef0acd..9f5919b3 100644 --- a/modules/developer/config/developer.php +++ b/modules/developer/config/developer.php @@ -44,7 +44,6 @@ $config["methods"] = array( "photo_blocks" => t("Photo block"), "photo_bottom" => t("Bottom of photo content"), "photo_top" => t("Top of photo content"), - "sidebar_blocks" => t("Sidebar block"), "sidebar_bottom" => t("Bottom of sidebar"), "sidebar_top" => t("Top of sidebar"), "thumb_bottom" => t("Bottom of thumbnail"), diff --git a/modules/developer/helpers/developer_task.php b/modules/developer/helpers/developer_task.php index d1b8e288..5f5c6d7e 100644 --- a/modules/developer/helpers/developer_task.php +++ b/modules/developer/helpers/developer_task.php @@ -48,6 +48,7 @@ class developer_task_Core { self::_render_helper_file($context, "installer"); break; case 2: // Generate theme helper + $context["theme"] = 1; self::_render_helper_file($context, "theme"); break; case 3: // Generate block helper @@ -74,18 +75,40 @@ class developer_task_Core { break; case 7: // Generate admin form $file = "{$context['module_path']}/views/admin_{$context['module']}.html.php"; - Kohana::log("debug", $file); ob_start(); $v = new View("admin_html.txt"); $v->name = $context["name"]; $v->module = $context["module"]; - $v->class = strtr($context["name"], " ", ""); - Kohana::log("debug", Kohana::debug($v->render())); + $v->css_id = preg_replace("#\s+#", "", $context["name"]); print $v->render(); file_put_contents($file, ob_get_contents()); ob_end_clean(); break; - case 8: // Generate module.info (do last) + case 8: // Generate controller + $file = "{$context['module_path']}/controllers/{$context['module']}.php"; + ob_start(); + $v = new View("controller.txt"); + $v->name = $context["name"]; + $v->module = $context["module"]; + $v->class_name = $context["class_name"]; + $v->css_id = preg_replace("#\s+#", "", $context["name"]); + print $v->render(); + file_put_contents($file, ob_get_contents()); + ob_end_clean(); + break; + case 9: // Generate sidebar block view + $file = "{$context['module_path']}/views/{$context['module']}_block.html.php"; + ob_start(); + $v = new View("block_html.txt"); + $v->name = $context["name"]; + $v->module = $context["module"]; + $v->class_name = $context["class_name"]; + $v->css_id = preg_replace("#\s+#", "", $context["name"]); + print $v->render(); + file_put_contents($file, ob_get_contents()); + ob_end_clean(); + break; + case 10: // Generate module.info (do last) $file = "{$context["module_path"]}/module.info"; ob_start(); $v = new View("module_info.txt"); @@ -96,10 +119,10 @@ class developer_task_Core { ob_end_clean(); break; } - $task->done = (++$context["step"]) >= 9; + $task->done = (++$context["step"]) >= 11; $task->context = serialize($context); $task->state = "success"; - $task->percent_complete = ($context["step"] / 9.0) * 100; + $task->percent_complete = ($context["step"] / 11.0) * 100; } private static function _render_helper_file($context, $helper) { @@ -111,8 +134,11 @@ class developer_task_Core { ob_start(); $v = new View("$helper.txt"); $v->helper = $helper; + $v->name = $context["name"]; $v->module = $context["module"]; $v->module_name = $context["name"]; + $v->css_id = strtr($context["name"], " ", ""); + $v->css_id = preg_replace("#\s#", "", $context["name"]); $v->callbacks = empty($context[$helper]) ? array() : array_fill_keys($context[$helper], 1); print $v->render(); file_put_contents($file, ob_get_contents()); diff --git a/modules/developer/js/developer.js b/modules/developer/js/developer.js index 4d60b5da..78a95af4 100644 --- a/modules/developer/js/developer.js +++ b/modules/developer/js/developer.js @@ -9,7 +9,6 @@ var module_success = function(data) { var task = data.task; var url = data.url; var done = false; - var counter = 0; while (!done) { $.ajax({async: false, success: function(data, textStatus) { @@ -20,7 +19,6 @@ var module_success = function(data) { type: "POST", url: url }); - done = done || ++counter >= 10; } document.location.reload(); }; diff --git a/modules/developer/views/admin_controller.txt.php b/modules/developer/views/admin_controller.txt.php index 42b5ff38..7f741378 100644 --- a/modules/developer/views/admin_controller.txt.php +++ b/modules/developer/views/admin_controller.txt.php @@ -20,17 +20,13 @@ */ class Admin__Controller extends Admin_Controller { public function index() { - $view = new Admin_View("admin.html"); - $view->content = new View("admin_.html"); - $view->content->form = $this->_get_admin_form(); - - print $view; + print $this->_get_view(); } public function handler() { access::verify_csrf(); - $form = $this->_get_admin_form(); + $form = $this->_get_form(); if ($form->validate()) { // @todo process the admin form @@ -38,17 +34,18 @@ class Admin__Controller extends Admin_Controller { url::redirect("admin/"); } - $view = new Admin_View("admin.html"); - $view->content = new View("admin_.html"); - $view->content->form = $form; - print $view; + print $this->_get_view($form); } - private function _get_admin_view($form=null) { + private function _get_view($form=null) { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_.html"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; } - private function _get_admin_form() { + private function _get_form() { $form = new Forge("admin//handler", "", "post", array("id" => "gAdminForm")); $group = $form->group("group"); diff --git a/modules/developer/views/admin_html.txt.php b/modules/developer/views/admin_html.txt.php index 34b699d7..5408cdab 100644 --- a/modules/developer/views/admin_html.txt.php +++ b/modules/developer/views/admin_html.txt.php @@ -1,7 +1,7 @@ " ?> -
+

" ?>

diff --git a/modules/developer/views/block.txt.php b/modules/developer/views/block.txt.php index b8a96da0..56c0bf8c 100644 --- a/modules/developer/views/block.txt.php +++ b/modules/developer/views/block.txt.php @@ -20,7 +20,19 @@ */ class _block { static function get($block_id) { + $block = new Block(); + if ($block_id == "") { + $block->css_id = "gAdmin"; + $block->title = t(" Dashboard Block"); + $block->content = new View("block.html"); + + $block->content->item = ORM::factory("item", 1); + } + return $block; } + static function get_list() { + return array( + "" => t(" Dashboard Block")); } } diff --git a/modules/developer/views/block_html.txt.php b/modules/developer/views/block_html.txt.php new file mode 100644 index 00000000..b0e07a1a --- /dev/null +++ b/modules/developer/views/block_html.txt.php @@ -0,0 +1,10 @@ + +" ?> + +
+ url() ?>\">" ?> + + thumb_tag(array(\"class\" => \"gThumbnail\")) ?>" ?> + + +
diff --git a/modules/developer/views/controller.txt.php b/modules/developer/views/controller.txt.php new file mode 100644 index 00000000..b11fa5f3 --- /dev/null +++ b/modules/developer/views/controller.txt.php @@ -0,0 +1,53 @@ + + +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class _Controller extends Controller { + public function index() { + print $this->_get_form(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + // @todo process the admin form + + message::success(t(" Processing Successfully")); + + print json_encode( + array("result" => "success")); + } else { + print json_encode( + array("result" => "error", + "form" => $form->__toString())); + } + } + + private function _get_form() { + $form = new Forge("/handler", "", "post", + array("id" => "gForm")); + $group = $form->group("group")->label(t(" Handler")); + $group->input("text")->label(t("Text"))->rules("required"); + $group->submit("submit")->value(t("Submit")); + + return $form; + } +} \ No newline at end of file diff --git a/modules/developer/views/helpers.txt.php b/modules/developer/views/helpers.txt.php deleted file mode 100644 index 648015d0..00000000 --- a/modules/developer/views/helpers.txt.php +++ /dev/null @@ -1,26 +0,0 @@ - - -/** - * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2008 Bharat Mediratta - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ -class _ { - $args): ?> - static function () { - } - -} diff --git a/modules/developer/views/menu.txt.php b/modules/developer/views/menu.txt.php index 5404f6c5..dd315972 100644 --- a/modules/developer/views/menu.txt.php +++ b/modules/developer/views/menu.txt.php @@ -38,5 +38,14 @@ class _menu { static function site($menu, $theme) { + $item = $theme->item(); + + if ($item && access::can("edit", $item)) { + $options_menu = $menu->get("options_menu") + ->append(Menu::factory("dialog") + ->id("") + ->label(t("Peform Processing")) + ->url(url::site("/index/$item->id"))); + } } } diff --git a/modules/developer/views/theme.txt.php b/modules/developer/views/theme.txt.php index df7b18e0..339a7553 100644 --- a/modules/developer/views/theme.txt.php +++ b/modules/developer/views/theme.txt.php @@ -19,144 +19,149 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class _theme { + static function sidebar_blocks($theme) { + $block = new Block(); + $block->css_id = "g"; + $block->title = t(""); + $block->content = new View("_block.html"); + $block->content->item = ORM::factory("item", 1); + + return $block; + } + - static function album_blocks() { + static function album_blocks($theme) { } - static function album_bottom() { + static function album_bottom($theme) { } - static function album_top() { + static function album_top($theme) { } - static function admin_credits() { + static function admin_credits($theme) { } - static function admin_footer() { + static function admin_footer($theme) { } - static function admin_header_top() { + static function admin_header_top($theme) { } - static function admin_header_bottom() { + static function admin_header_bottom($theme) { } - static function admin_page_bottom() { + static function admin_page_bottom($theme) { } - static function admin_page_top() { + static function admin_page_top($theme) { } - static function admin_head() { + static function admin_head($theme) { } - static function credits() { + static function credits($theme) { } - static function dynamic_bottom() { + static function dynamic_bottom($theme) { } - static function dynamic_top() { + static function dynamic_top($theme) { } - static function footer() { + static function footer($theme) { } - static function head() { + static function head($theme) { } - static function header_bottom() { + static function header_bottom($theme) { } - static function header_top() { + static function header_top($theme) { } - static function page_bottom() { + static function page_bottom($theme) { } - static function page_top() { + static function page_top($theme) { } - static function photo_blocks() { + static function photo_blocks($theme) { } - static function photo_bottom() { + static function photo_bottom($theme) { } - static function photo_top() { - } - - - - static function sidebar_blocks() { + static function photo_top($theme) { } - static function sidebar_bottom() { + static function sidebar_bottom($theme) { } - static function sidebar_top() { + static function sidebar_top($theme) { } - static function thumb_bottom($child) { + static function thumb_bottom($theme, $child) { } - static function thumb_info($child) { + static function thumb_info($theme, $child) { } - static function thumb_top($child) { + static function thumb_top($theme, $child) { } -- cgit v1.2.3