diff options
| author | Tristan Zur <tzur@webserver.ccwn.org> | 2015-06-20 23:56:17 +0200 |
|---|---|---|
| committer | Tristan Zur <tzur@webserver.ccwn.org> | 2015-06-20 23:56:17 +0200 |
| commit | 18a1d682ff18ee69d5c252b013a6a6935cd9b5fe (patch) | |
| tree | b1da62c8b7d03341a7b74b3fbb533e6391950be0 /modules/developer | |
| parent | b69c03794f80aa811f0613cf4b802619e7ecdbdd (diff) | |
New modules added
Diffstat (limited to 'modules/developer')
27 files changed, 1401 insertions, 0 deletions
diff --git a/modules/developer/config/developer.php b/modules/developer/config/developer.php new file mode 100644 index 0000000..c9abb92 --- /dev/null +++ b/modules/developer/config/developer.php @@ -0,0 +1,54 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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. + */ + +/** + * Defines the available callback methods + */ +$config["methods"] = array( + "theme" => array("album_blocks" => t("Album block"), + "album_bottom" => t("Bottom of album content"), + "album_top" => t("Top of Album content"), + "admin_credits" => t("Administration page credits"), + "admin_footer" => t("Adminsitration page footer"), + "admin_header_top" => t("Top of administration page header"), + "admin_header_bottom" => t("Bottom of administration page header"), + "admin_page_bottom" => t("Bottom of administration page"), + "admin_page_top" => t("Top of administration page"), + "admin_head" => t("Adminstration page head"), + "body_attributes" => t("Body Attributes"), + "credits" => t("Album or photo page credits"), + "dynamic_bottom" => t("Bottom of dynamic page content"), + "dynamic_top" => t("Top of dynamic page content"), + "footer" => t("Album or photo page footer"), + "head" => t("Album or photo page head"), + "header_bottom" => t("Album or photo header bottom"), + "header_top" => t("Album or photo header top"), + "page_bottom" => t("Album or photo bottom"), + "page_top" => t("Album or photo top"), + "photo_blocks" => t("Photo block"), + "photo_bottom" => t("Bottom of photo content"), + "photo_top" => t("Top of photo content"), + "resize_bottom" => t("Bottom of the resize view"), + "resize_top" => t("Top of the resize view"), + "sidebar_bottom" => t("Bottom of sidebar"), + "sidebar_top" => t("Top of sidebar"), + "thumb_bottom" => t("Bottom of thumbnail"), + "thumb_info" => t("Thumbnail information"), + "thumb_top" => t("Top of thumbnail display"))); diff --git a/modules/developer/controllers/admin_developer.php b/modules/developer/controllers/admin_developer.php new file mode 100644 index 0000000..d723a36 --- /dev/null +++ b/modules/developer/controllers/admin_developer.php @@ -0,0 +1,306 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 Admin_Developer_Controller extends Admin_Controller { + static $event_list = array(); + + public function module() { + $view = new Admin_View("admin.html"); + $view->content = new View("admin_developer.html"); + $view->content->title = t("Generate module"); + + if (!is_writable(MODPATH)) { + message::warning( + t("The module directory is not writable. Please ensure that it is writable by the web server")); + } + list ($form, $errors) = $this->_get_module_form(); + $view->content->developer_content = $this->_get_module_create_content($form, $errors); + print $view; + } + + public function test_data() { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_developer.html"); + $v->content->title = t("Generate Test Data"); + + list ($form, $errors) = $this->_get_module_form(); + $v->content->developer_content = $this->_get_test_data_view($form, $errors); + print $v; + } + + public function module_create() { + access::verify_csrf(); + + list ($form, $errors) = $this->_get_module_form(); + + $post = new Validation($_POST); + $post->add_rules("name", "required"); + $post->add_rules("display_name", "required"); + $post->add_rules("description", "required"); + $post->add_callbacks("theme", array($this, "_noop_validation")); + $post->add_callbacks("event", array($this, "_noop_validation")); + $post->add_callbacks("name", array($this, "_is_module_defined")); + + if ($post->validate()) { + $task_def = Task_Definition::factory() + ->callback("developer_task::create_module") + ->description(t("Create a new module")) + ->name(t("Create Module")); + $success_msg = t("Generation of %module completed successfully", + array("module" => $post->name)); + $error_msg = t("Generation of %module failed.", array("module" => $post->name)); + $task_context = array("step" => 0, "success_msg" => $success_msg, "error_msg" => $error_msg); + $task = task::create($task_def, array_merge($task_context, $post->as_array())); + + json::reply(array("result" => "started", + "max_iterations" => 15, + "url" => url::site("admin/developer/run_task/{$task->id}?csrf=" . + access::csrf_token()), + "task" => $task->as_array())); + } else { + $v = $this->_get_module_create_content(arr::overwrite($form, $post->as_array()), + arr::overwrite($errors, $post->errors())); + json::reply(array("result" => "error", "html" => (string)$v)); + } + } + + public function _noop_validation(Validation $array, $field) { + } + + public function session($key) { + access::verify_csrf(); + $input = Input::instance(); + Session::instance()->set($key, $input->get("value")); + url::redirect($input->server("HTTP_REFERER")); + } + + public function test_data_create() { + list ($form, $errors) = $this->_get_test_data_form(); + + $post = new Validation($_POST); + $post->add_rules("albums", "numeric"); + $post->add_rules("photos", "numeric"); + $post->add_rules("comments", "numeric"); + $post->add_rules("tags", "numeric"); + $post->add_callbacks("albums", array($this, "_set_default")); + $post->add_callbacks("photos", array($this, "_set_default")); + $post->add_callbacks("comments", array($this, "_set_default")); + $post->add_callbacks("tags", array($this, "_set_default")); + + if ($post->validate()) { + $task_def = Task_Definition::factory() + ->callback("developer_task::create_content") + ->description(t("Create test content")) + ->name(t("Create Test Data")); + $total = $post->albums + $post->photos + $post->comments + $post->tags; + $success_msg = t("Successfully generated test data"); + $error_msg = t("Problems with test data generation was encountered"); + $task = task::create($task_def, array("total" => $total, "batch" => (int)ceil($total / 10), + "success_msg" => $success_msg, + "current" => 0, "error_msg" => $error_msg, + "albums" => $post->albums, "photos" => $post->photos, + "comments" => $post->comments, "tags" => $post->tags)); + batch::start(); + + json::reply(array("result" => "started", + "max_iterations" => $total + 5, + "url" => url::site("admin/developer/run_task/{$task->id}?csrf=" . + access::csrf_token()), + "task" => $task->as_array())); + } else { + $v = $this->_get_test_data_view(arr::overwrite($form, $post->as_array()), + arr::overwrite($errors, $post->errors())); + json::reply(array("result" => "error", "html" => (string)$v)); + } + } + + public function run_task($task_id) { + try { + $task = task::run($task_id); + } catch (Exception $e) { + $error_msg = $e->getMessage(); + $task->done = true; + } + + if ($task->done) { + batch::stop(); + $context = unserialize($task->context); + switch ($task->state) { + case "success": + message::success($context["success_msg"]); + break; + + case "error": + message::success(empty($error_msg) ? $context["error_msg"] : $error_msg); + break; + } + json::reply(array("result" => "success", "task" => $task->as_array())); + + } else { + json::reply(array("result" => "in_progress", "task" => $task->as_array())); + } + } + + function mptt() { + $v = new Admin_View("admin.html"); + $v->content = new View("mptt_tree.html"); + + $v->content->tree = $this->_build_tree(); + + if (exec("which /usr/bin/dot")) { + $v->content->url = url::site("admin/developer/mptt_graph"); + } else { + $v->content->url = null; + message::warning(t("The package 'graphviz' is not installed, degrading to text view")); + } + print $v; + } + + function mptt_graph() { + $items = ORM::factory("item")->order_by("id")->find_all(); + $data = $this->_build_tree(); + + $proc = proc_open("/usr/bin/dot -Tsvg", + array(array("pipe", "r"), + array("pipe", "w")), + $pipes, + VARPATH . "tmp"); + fwrite($pipes[0], $data); + fclose($pipes[0]); + + header("Content-Type: image/svg+xml"); + print(stream_get_contents($pipes[1])); + fclose($pipes[1]); + proc_close($proc); + } + + private function _build_tree() { + $items = ORM::factory("item")->order_by("id")->find_all(); + $data = "digraph G {\n"; + foreach ($items as $item) { + $data .= " $item->parent_id -> $item->id\n"; + $data .= + " $item->id [label=\"$item->id [$item->level] <$item->left_ptr, $item->right_ptr>\"]\n"; + } + $data .= "}\n"; + return $data; + } + + public function _is_module_defined(Validation $post, $field) { + $module_name = strtolower(strtr($post[$field], " ", "_")); + if (file_exists(MODPATH . "$module_name/module.info")) { + $post->add_error($field, "module_exists"); + } + } + + public function _set_default(Validation $post, $field) { + if (empty($post->$field)) { + $post->$field = 0; + } + } + + private function _get_module_form() { + $form = array("name" => "", "display_name" => "", "description" => "", "theme[]" => array(), + "event[]" => array()); + $errors = array_fill_keys(array_keys($form), ""); + + return array($form, $errors); + } + + private function _get_module_create_content($form, $errors) { + $config = Kohana::config("developer.methods"); + + $v = new View("developer_module.html"); + $v->action = "admin/developer/module_create"; + $v->theme = $config["theme"]; + $v->event = $this->_get_events(); + $v->form = $form; + $v->errors = $errors; + $submit_attributes = array( + "id" => "g-generate-module", + "name" => "generate", + "class" => "ui-state-default ui-corner-all", + "style" => "clear:both!important"); + + if (!is_writable(MODPATH)) { + $submit_attributes["class"] .= " ui-state-disabled"; + $submit_attributes["disabled"] = "disabled"; + } + $v->submit_attributes = $submit_attributes; + return $v; + } + + private function _get_events() { + if (empty(self::$event_list)) { + $dir = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator(MODPATH)); + foreach ($dir as $file) { + $file_as_string = file_get_contents($file); + if (preg_match_all('#module::event\("(.*?)"(.*)\);#mU', $file_as_string, $matches, PREG_SET_ORDER) > 0) { + foreach ($matches as $match) { + $event_name = $match[1]; + $display_name = ucwords(str_replace("_", " ", $event_name)); + if (!in_array($display_name, self::$event_list)) { + $parameters = array(); + if (!empty($match[2]) && + preg_match_all('#\$[a-zA-Z_]*#', $match[2], $param_names)) { + + foreach ($param_names[0] as $name) { + $parameters[] = $name != '$this' ? $name : '$' . $event_name; + } + } + self::$event_list["static function $event_name(" . implode(", ", $parameters) . ")"] = $display_name; + } + } + ksort(self::$event_list); + } + } + } + return self::$event_list; + } + + private function _get_test_data_form() { + $form = array("albums" => "10", "photos" => "10", "comments" => "10", "tags" => "10", + "generate_albums" => ""); + $errors = array_fill_keys(array_keys($form), ""); + + return array($form, $errors); + } + + private function _get_test_data_view($form, $errors) { + $v = new View("admin_developer_test_data.html"); + $v->action = "admin/developer/test_data_create"; + $album_count = ORM::factory("item")->where("type", "=", "album")->count_all(); + $photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all(); + + $v->comment_installed = module::is_active("comment"); + $comment_count = empty($v->comment_installed) ? 0 : ORM::factory("comment")->count_all(); + + $v->tag_installed = module::is_active("tag"); + $tag_count = empty($v->tag_installed) ? 0 : ORM::factory("tag")->count_all(); + + $v->album_count = t2("%count album", "%count albums", $album_count); + $v->photo_count = t2("%count photo", "%count photos", $photo_count); + $v->comment_count = t2("%count comment", "%count comments", $comment_count); + $v->tag_count = t2("%count tag", "%count tags", $tag_count); + $v->form = $form; + $v->errors = $errors; + return $v; + } +} diff --git a/modules/developer/data/DSC_0003.jpg b/modules/developer/data/DSC_0003.jpg Binary files differnew file mode 100644 index 0000000..5780d9d --- /dev/null +++ b/modules/developer/data/DSC_0003.jpg diff --git a/modules/developer/data/DSC_0005.jpg b/modules/developer/data/DSC_0005.jpg Binary files differnew file mode 100644 index 0000000..4d2b53a --- /dev/null +++ b/modules/developer/data/DSC_0005.jpg diff --git a/modules/developer/data/DSC_0017.jpg b/modules/developer/data/DSC_0017.jpg Binary files differnew file mode 100644 index 0000000..b7f7bb9 --- /dev/null +++ b/modules/developer/data/DSC_0017.jpg diff --git a/modules/developer/data/DSC_0019.jpg b/modules/developer/data/DSC_0019.jpg Binary files differnew file mode 100644 index 0000000..0ce25aa --- /dev/null +++ b/modules/developer/data/DSC_0019.jpg diff --git a/modules/developer/data/DSC_0067.jpg b/modules/developer/data/DSC_0067.jpg Binary files differnew file mode 100644 index 0000000..84f134c --- /dev/null +++ b/modules/developer/data/DSC_0067.jpg diff --git a/modules/developer/data/DSC_0072.jpg b/modules/developer/data/DSC_0072.jpg Binary files differnew file mode 100644 index 0000000..dfad82b --- /dev/null +++ b/modules/developer/data/DSC_0072.jpg diff --git a/modules/developer/data/P4050088.jpg b/modules/developer/data/P4050088.jpg Binary files differnew file mode 100644 index 0000000..62f4749 --- /dev/null +++ b/modules/developer/data/P4050088.jpg diff --git a/modules/developer/helpers/developer_event.php b/modules/developer/helpers/developer_event.php new file mode 100644 index 0000000..849803f --- /dev/null +++ b/modules/developer/helpers/developer_event.php @@ -0,0 +1,70 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 developer_event_Core { + static function admin_menu($menu, $theme) { + $developer_menu = Menu::factory("submenu") + ->id("developer_menu") + ->label(t("Developer tools")); + $menu->append($developer_menu); + + $developer_menu + ->append(Menu::factory("link") + ->id("generate_menu") + ->label(t("Generate module")) + ->url(url::site("admin/developer/module"))) + ->append(Menu::factory("link") + ->id("generate_data") + ->label(t("Generate test data")) + ->url(url::site("admin/developer/test_data"))) + ->append(Menu::factory("link") + ->id("mptt_tree_menu") + ->label(t("MPTT tree")) + ->url(url::site("admin/developer/mptt"))); + + $csrf = access::csrf_token(); + if (Session::instance()->get("profiler", false)) { + $developer_menu->append( + Menu::factory("link") + ->id("scaffold_profiler") + ->label(t("Profiling off")) + ->url(url::site("admin/developer/session/profiler?value=0&csrf=$csrf"))); + } else { + $developer_menu->append( + Menu::factory("link") + ->id("scaffold_profiler") + ->label(t("Profiling on")) + ->url(url::site("admin/developer/session/profiler?value=1&csrf=$csrf"))); + } + + if (Session::instance()->get("debug", false)) { + $developer_menu->append( + Menu::factory("link") + ->id("scaffold_debugger") + ->label(t("Debugging off")) + ->url(url::site("admin/developer/session/debug?value=0&csrf=$csrf"))); + } else { + $developer_menu->append( + Menu::factory("link") + ->id("scaffold_debugger") + ->label(t("Debugging on")) + ->url(url::site("admin/developer/session/debug?value=1&csrf=$csrf"))); + } + } +} diff --git a/modules/developer/helpers/developer_task.php b/modules/developer/helpers/developer_task.php new file mode 100644 index 0000000..3e27b4b --- /dev/null +++ b/modules/developer/helpers/developer_task.php @@ -0,0 +1,335 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 developer_task_Core { + static function available_tasks() { + // Return empty array so nothing appears in the maintenance screen + return array(); + } + + static function create_module($task) { + $context = unserialize($task->context); + + if (empty($context["module"])) { + $context["class_name"] = strtr($context["name"], " ", "_"); + $context["module"] = strtolower($context["class_name"]); + $context["module_path"] = (MODPATH . $context["module"]); + } + + switch ($context["step"]) { + case 0: // Create directory tree + foreach (array("", "controllers", "helpers", "views") as $dir) { + $path = "{$context['module_path']}/$dir"; + if (!file_exists($path)) { + mkdir($path); + chmod($path, 0755); + } + } + break; + case 1: // Generate installer + $context["installer"] = array(); + self::_render_helper_file($context, "installer"); + break; + case 2: // Generate theme helper + $context["theme"] = !isset($context["theme"]) ? array() : $context["theme"]; + self::_render_helper_file($context, "theme"); + break; + case 3: // Generate block helper + $context["block"] = array(); + self::_render_helper_file($context, "block"); + break; + case 4: // Generate event helper + self::_render_helper_file($context, "event"); + break; + case 5: // Generate admin controller + $file = "{$context['module_path']}/controllers/admin_{$context['module']}.php"; + ob_start(); + $v = new View("admin_controller.txt"); + $v->name = $context["name"]; + $v->module = $context["module"]; + $v->class_name = $context["class_name"]; + print $v->render(); + file_put_contents($file, ob_get_contents()); + ob_end_clean(); + break; + case 6: // Generate admin form + $file = "{$context['module_path']}/views/admin_{$context['module']}.html.php"; + ob_start(); + $v = new View("admin_html.txt"); + $v->name = $context["name"]; + $v->module = $context["module"]; + $v->css_id = preg_replace("#\s+#", "", $context["name"]); + print $v->render(); + file_put_contents($file, ob_get_contents()); + ob_end_clean(); + break; + case 7: // 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 8: // 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 9: // Generate dashboard block view + $file = "{$context['module_path']}/views/admin_{$context['module']}_block.html.php"; + ob_start(); + $v = new View("dashboard_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"); + $v->module_name = $context["display_name"]; + $v->module_description = $context["description"]; + print $v->render(); + file_put_contents($file, ob_get_contents()); + ob_end_clean(); + break; + } + if (isset($file)) { + chmod($file, 0765); + } + $task->done = (++$context["step"]) >= 11; + $task->context = serialize($context); + $task->state = "success"; + $task->percent_complete = ($context["step"] / 11.0) * 100; + } + + private static function _render_helper_file($context, $helper) { + if (isset($context[$helper])) { + $config = Kohana::config("developer.methods"); + $file = "{$context["module_path"]}/helpers/{$context["module"]}_{$helper}.php"; + touch($file); + 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()); + ob_end_clean(); + } + } + + static function create_content($task) { + $context = unserialize($task->context); + $batch_cnt = $context["batch"]; + while ($context["albums"] > 0 && $batch_cnt > 0) { + set_time_limit(30); + self::_add_album_or_photo("album"); + + $context["current"]++; + $context["albums"]--; + $batch_cnt--; + } + while ($context["photos"] > 0 && $batch_cnt > 0) { + set_time_limit(30); + self::_add_album_or_photo(); + + $context["current"]++; + $context["photos"]--; + $batch_cnt--; + } + while ($context["comments"] > 0 && $batch_cnt > 0) { + self::_add_comment(); + $context["current"]++; + $context["comments"]--; + $batch_cnt--; + } + while ($context["tags"] > 0 && $batch_cnt > 0) { + self::_add_tag(); + $context["current"]++; + $context["tags"]--; + $batch_cnt--; + } + $task->done = $context["current"] >= $context["total"]; + $task->context = serialize($context); + $task->state = "success"; + $task->percent_complete = $context["current"] / $context["total"] * 100; + } + + private static function _add_album_or_photo($desired_type=null) { + srand(time()); + $parents = ORM::factory("item")->where("type", "=", "album")->find_all()->as_array(); + $owner_id = identity::active_user()->id; + + $test_images = glob(dirname(dirname(__FILE__)) . "/data/*.[Jj][Pp][Gg]"); + + $parent = $parents[array_rand($parents)]; + $parent->reload(); + $type = $desired_type; + if (!$type) { + $type = rand(0, 10) ? "photo" : "album"; + } + if ($type == "album") { + $thumb_size = module::get_var("core", "thumb_size"); + $rand = rand(); + $item = ORM::factory("item"); + $item->type = "album"; + $item->parent_id = $parent->id; + $item->name = "rnd_$rand"; + $item->title = "Rnd $rand"; + $item->description = "random album $rand"; + $item->owner_id = $owner_id; + $parents[] = $item->save(); + } else { + $photo_index = rand(0, count($test_images) - 1); + $item = ORM::factory("item"); + $item->type = "photo"; + $item->parent_id = $parent->id; + $item->set_data_file($test_images[$photo_index]); + $item->name = basename($test_images[$photo_index]); + $item->title = "rnd_" . rand(); + $item->description = "sample thumb"; + $item->owner_id = $owner_id; + $item->save(); + } + } + + private static function _add_comment() { + srand(time()); + $photos = ORM::factory("item")->where("type", "=", "photo")->find_all()->as_array(); + $users = ORM::factory("user")->find_all()->as_array(); + + if (empty($photos)) { + return; + } + + if (module::is_active("akismet")) { + akismet::$test_mode = 1; + } + + $photo = $photos[array_rand($photos)]; + $author = $users[array_rand($users)]; + $guest_name = ucfirst(self::_random_phrase(rand(1, 3))); + $guest_email = sprintf("%s@%s.com", self::_random_phrase(1), self::_random_phrase(1)); + $guest_url = sprintf("http://www.%s.com", self::_random_phrase(1)); + + $comment = ORM::factory("comment"); + $comment->author_id = $author->id; + $comment->item_id = $photo->id; + $comment->text = self::_random_phrase(rand(8, 500)); + $comment->guest_name = $guest_name; + $comment->guest_email = $guest_email; + $comment->guest_url = $guest_url; + $comment->save(); + } + + private static function _add_tag() { + $items = ORM::factory("item")->find_all()->as_array(); + + if (!empty($items)) { + $tags = self::_generateTags(); + + $tag_name = $tags[array_rand($tags)]; + $item = $items[array_rand($items)]; + + tag::add($item, $tag_name); + } + } + + private static function _random_phrase($count) { + static $words; + if (empty($words)) { + $sample_text = "Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium + laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi + architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas + sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione + voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, + amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut + labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis + nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi + consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam + nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla + pariatur? At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis + praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi + sint, obcaecati cupiditate non provident, similique sunt in culpa, qui officia deserunt + mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et + expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio, cumque + nihil impedit, quo minus id, quod maxime placeat, facere possimus, omnis voluptas + assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis + debitis aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint et + molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut + reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores + repellat."; + $words = preg_split('/\s+/', $sample_text); + } + + $chosen = array(); + for ($i = 0; $i < $count; $i++) { + $chosen[] = $words[array_rand($words)]; + } + + return implode(' ', $chosen); + } + + private static function _generateTags($number=10){ + // Words from lorem2.com + $words = explode( + " ", + "Lorem ipsum dolor sit amet consectetuer adipiscing elit Donec odio Quisque volutpat " . + "mattis eros Nullam malesuada erat ut turpis Suspendisse urna nibh viverra non " . + "semper suscipit posuere a pede Donec nec justo eget felis facilisis " . + "fermentum Aliquam porttitor mauris sit amet orci Aenean dignissim pellentesque " . + "felis Morbi in sem quis dui placerat ornare Pellentesque odio nisi euismod in " . + "pharetra a ultricies in diam Sed arcu Cras consequat Praesent dapibus neque " . + "id cursus faucibus tortor neque egestas augue eu vulputate magna eros eu " . + "erat Aliquam erat volutpat Nam dui mi tincidunt quis accumsan porttitor " . + "facilisis luctus metus Phasellus ultrices nulla quis nibh Quisque a " . + "lectus Donec consectetuer ligula vulputate sem tristique cursus Nam nulla quam " . + "gravida non commodo a sodales sit amet nisi Pellentesque fermentum " . + "dolor Aliquam quam lectus facilisis auctor ultrices ut elementum vulputate " . + "nunc Sed adipiscing ornare risus Morbi est est blandit sit amet sagittis vel " . + "euismod vel velit Pellentesque egestas sem Suspendisse commodo ullamcorper " . + "magna"); + + while ($number--) { + $results[] = $words[array_rand($words, 1)]; + } + return $results; + } +}
\ No newline at end of file diff --git a/modules/developer/js/developer.js b/modules/developer/js/developer.js new file mode 100644 index 0000000..065a731 --- /dev/null +++ b/modules/developer/js/developer.js @@ -0,0 +1,42 @@ +var module_success = function(data) { + $("#g-developer-admin").append('<div id="g-module-progress" style="margin-top: 1em;"></div>'); + $("#g-module-progress").progressbar(); + + var task = data.task; + var url = data.url; + var done = false; + var counter = 0; + var max_iterations = data.max_iterations; + while (!done) { + $.ajax({async: false, + success: function(data, textStatus) { + $("#g-module-progress").progressbar("value", data.task.percent_complete); + done = data.task.done; + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + done = true; + }, + dataType: "json", + type: "POST", + url: url + }); + // Leave this in as insurance that we never run away + done = done || ++counter > max_iterations; + } + document.location.reload(); +}; + +function ajaxify_developer_form(selector, success) { + $(selector).ajaxForm({ + dataType: "json", + success: function(data) { + if (data.form && data.result != "started") { + $(selector).replaceWith(data.form); + ajaxify_developer_form(selector, success); + } + if (data.result == "started") { + success(data); + } + } + }); +} diff --git a/modules/developer/module.info b/modules/developer/module.info new file mode 100644 index 0000000..b62a6b6 --- /dev/null +++ b/modules/developer/module.info @@ -0,0 +1,7 @@ +name = Developer +description = "Tools to assist module and theme developers" +version = 1 +author_name = "" +author_url = "" +info_url = "http://codex.gallery2.org/Gallery3:Modules:developer" +discuss_url = "http://gallery.menalto.com/forum_module_developer" diff --git a/modules/developer/views/admin_controller.txt.php b/modules/developer/views/admin_controller.txt.php new file mode 100644 index 0000000..879657e --- /dev/null +++ b/modules/developer/views/admin_controller.txt.php @@ -0,0 +1,57 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");" ?> +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 Admin_<?= $class_name ?>_Controller extends Admin_Controller { + public function index() { + print $this->_get_view(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + // @todo process the admin form + + message::success(t("<?= $name ?> Adminstration Complete Successfully")); + + url::redirect("admin/<?= $module ?>"); + } + + print $this->_get_view($form); + } + + private function _get_view($form=null) { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_<?=$module ?>.html"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; + } + + private function _get_form() { + $form = new Forge("admin/<?= $module ?>/handler", "", "post", + array("id" => "g-adminForm")); + $group = $form->group("group"); + $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/admin_developer.html.php b/modules/developer/views/admin_developer.html.php new file mode 100644 index 0000000..4831f9b --- /dev/null +++ b/modules/developer/views/admin_developer.html.php @@ -0,0 +1,13 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= html::script("modules/developer/js/developer.js") ?> +<script type="text/javascript"> +$("#g-developer-form").ready(function() { + ajaxify_developer_form("#g-developer-form form", module_success); +}); +</script> +<div id="g-developer-admin"> + <h2><?= $title ?></h2> + <div id="g-developer-form" > + <?= $developer_content ?> + </div> +</div> diff --git a/modules/developer/views/admin_developer_test_data.html.php b/modules/developer/views/admin_developer_test_data.html.php new file mode 100644 index 0000000..a29027b --- /dev/null +++ b/modules/developer/views/admin_developer_test_data.html.php @@ -0,0 +1,93 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<script type="text/javascript"> + $("#g-generate-test-data").ready(function() { + $(".g-generate-checkbox").click(function() { + var buttons = $(this).val(); + $(buttons).attr("disabled", !this.checked); + }); + <? if (!empty($form["generate_albums"])): ?> + $("#g-generate-albums").click(); + <? endif ?> + <? if (!empty($form["generate_photos"])): ?> + $("#g-generate-photos").click(); + <? endif ?> + <? if (!empty($form["generate_comments"])): ?> + $("#g-generate-comments").click(); + <? endif ?> + <? if (!empty($form["generate_tags"])): ?> + $("#g-generate-tags").click(); + <? endif ?> + }); +</script> +<?= form::open($action, array("method" => "post", "id" => "g-generate-test-data")) ?> + <? if (!empty($album_count)): ?> + <p><?= t("Currently:") ?><br /> + + <i>(<?= $album_count ?>, <?= $photo_count ?>, <?= $comment_count ?>, <?= $tag_count ?>)</i> + </p> + <? endif ?> + +<fieldset> + <ul> + <li><?= access::csrf_form_field() ?></li> + <li <? if (!empty($errors["albums"])): ?> class="g-error"<? endif ?>> + <fieldset> + <?= form::label("g-generate-albums", t("Generate Albums")) ?> + <?= form::checkbox(array("id" => "g-generate-albums", "name" => "generate_albums", "class" => "g-generate-checkbox", "style" => "display:inline", "checked" => !empty($form["generate_albums"])), ".g-radio-album") ?> + <? foreach (array(1, 10, 50, 100, 500, 1000) as $number): ?> + <span style="float:left;padding-right: .5em;"><?= form::label("album_$number", "$number") ?> + <?= form::radio(array("id" => "album_$number", "name" => "albums", "style" => "display:inline", "checked" => $number == 10, "disabled" => true, "class" => "g-radio-album"), $number) ?></span> + <? endforeach ?> + </fieldset> + <? if (!empty($errors["albums"]) && $errors["albums"] == "numeric"): ?> + <p class="g-error"><?= t("Number to create must be numeric") ?></p> + <? endif ?> + </li> + <li <? if (!empty($errors["photos"])): ?> class="g-error"<? endif ?>> + <fieldset> + <?= form::label("g-generate-photos", t("Generate Photos and Albums")) ?> + <?= form::checkbox(array("id" => "g-generate-photos", "name" => "generate_photos", "class" => "g-generate-checkbox", "style" => "display:inline", "checked" => !empty($form["generate_photos"])), ".g-radio-photo") ?> + <? foreach (array(1, 10, 50, 100, 500, 1000) as $number): ?> + <span style="float:left;padding-right: .5em;"><?= form::label("photo_$number", "$number") ?> + <?= form::radio(array("id" => "photo_$number", "name" => "photos", "style" => "display:inline", "checked" => $number == 10, "disabled" => true, "class" => "g-radio-photo"), $number) ?></span> + <? endforeach ?> + </fieldset> + <? if (!empty($errors["photos"]) && $errors["photos"] == "numeric"): ?> + <p class="g-error"><?= t("Number to create must be numeric") ?></p> + <? endif ?> + </li> + <? if(!empty($comment_installed)): ?> + <li <? if (!empty($errors["comments"])): ?> class="g-error"<? endif ?>> + <fieldset> + <?= form::label("g-generate-comments", t("Generate Comments")) ?> + <?= form::checkbox(array("id" => "g-generate-comments", "name" => "generate_comments", "class" => "g-generate-checkbox", "style" => "display:inline", "checked" => !empty($form["generate_comments"])), ".g-radio-comment") ?> + <? foreach (array(1, 10, 50, 100, 500, 1000) as $number): ?> + <span style="float:left;padding-right: .5em;"><?= form::label("comment_$number", "$number") ?> + <?= form::radio(array("id" => "comment_$number", "name" => "comments", "style" => "display:inline", "checked" => $number == 10, "disabled" => true, "class" => "g-radio-comment"), $number) ?></span> + <? endforeach ?> + </fieldset> + <? if (!empty($errors["comments"]) && $errors["comments"] == "numeric"): ?> + <p class="g-error"><?= t("Number to create must be numeric") ?></p> + <? endif ?> + </li> + <? endif ?> + <? if(!empty($tag_installed)): ?> + <li <? if (!empty($errors["tags"])): ?> class="g-error"<? endif ?>> + <fieldset> + <?= form::label("g-generate-tags", t("Generate Tags")) ?> + <?= form::checkbox(array("id" => "g-generate-tags", "name" => "generate_tags", "class" => "g-generate-checkbox", "style" => "display:inline", "checked" => !empty($form["generate_tags"])), ".g-radio-tag") ?> + <? foreach (array(1, 10, 50, 100, 500, 1000) as $number): ?> + <span style="float:left;padding-right: .5em;"><?= form::label("tag_$number", "$number") ?> + <?= form::radio(array("id" => "tag_$number", "name" => "tags", "style" => "display:inline", "checked" => $number == 10, "disabled" => true, "class" => "g-radio-tag"), $number) ?></span> + <? endforeach ?> + </fieldset> + <? if (!empty($errors["tags"]) && $errors["tags"] == "numeric"): ?> + <p class="g-error"><?= t("Number to create must be numeric") ?></p> + <? endif ?> + </li> + <? endif ?> + <li> + <?= form::submit(array("id" => "g-generate-data", "name" => "generate", "class" => "submit", "style" => "clear:both!important"), t("Generate")) ?> + </li> + </ul> +</fieldset> diff --git a/modules/developer/views/admin_html.txt.php b/modules/developer/views/admin_html.txt.php new file mode 100644 index 0000000..3d230d1 --- /dev/null +++ b/modules/developer/views/admin_html.txt.php @@ -0,0 +1,10 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>" ?> + +<div id="g-admin-<?= $css_id ?>"> + <h2> + <?= "<?= t(\"$name Adminstration\") ?>" ?> + </h2> + <?= "<?= \$form ?>" ?> + +</div> diff --git a/modules/developer/views/block.txt.php b/modules/developer/views/block.txt.php new file mode 100644 index 0000000..fda62c2 --- /dev/null +++ b/modules/developer/views/block.txt.php @@ -0,0 +1,53 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");" ?> + +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 <?= $module ?>_block { + static function get_site_list() { + return array( + "<?= "{$module}_site" ?>" => t("<?= $name ?> Sidebar Block")); + } + + static function get_admin_list() { + return array( + "<?= "{$module}_admin" ?>" => t("<?= $name ?> Dashboard Block")); + } + + static function get($block_id, $theme) { + $block = new Block(); + switch ($block_id) { + case "<?= "{$module}_admin" ?>": + $block->css_id = "g-<?= $css_id ?>-admin"; + $block->title = t("<?= $module ?> Dashboard Block"); + $block->content = new View("admin_<?= $module ?>_block.html"); + + $block->content->item = ORM::factory("item", 1); + break; + case "<?= "{$module}_site" ?>": + $block->css_id = "g-<?= $css_id ?>-site"; + $block->title = t("<?= $module ?> Sidebar Block"); + $block->content = new View("<?= $module ?>_block.html"); + + $block->content->item = ORM::factory("item", 1); + break; + } + return $block; + } +} diff --git a/modules/developer/views/block_html.txt.php b/modules/developer/views/block_html.txt.php new file mode 100644 index 0000000..9942259 --- /dev/null +++ b/modules/developer/views/block_html.txt.php @@ -0,0 +1,10 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>" ?> + +<div class="g-<?= $css_id ?>-block"> + <?= "<a href=\"<?= \$item->url() ?>\">" ?> + + <?= "<?= \$item->thumb_tag(array(\"class\" => \"g-thumbnail\")) ?>" ?> + + </a> +</div> diff --git a/modules/developer/views/controller.txt.php b/modules/developer/views/controller.txt.php new file mode 100644 index 0000000..7c57931 --- /dev/null +++ b/modules/developer/views/controller.txt.php @@ -0,0 +1,50 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");" ?> +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 <?= $class_name ?>_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("<?= $name ?> Processing Successfully")); + + json::reply(array("result" => "success")); + } else { + json::reply(array("result" => "error", "html" => (string)$form)); + } + } + + private function _get_form() { + $form = new Forge("<?= $module ?>/handler", "", "post", + array("id" => "g-<?= $css_id ?>-form")); + $group = $form->group("group")->label(t("<?= $name ?> Handler")); + $group->input("text")->label(t("Text"))->rules("required"); + $group->submit("submit")->value(t("Submit")); + + return $form; + } +} diff --git a/modules/developer/views/dashboard_block_html.txt.php b/modules/developer/views/dashboard_block_html.txt.php new file mode 100644 index 0000000..8b1c8f5 --- /dev/null +++ b/modules/developer/views/dashboard_block_html.txt.php @@ -0,0 +1,10 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>" ?> + +<div class="g-<?= $css_id ?>-block"> + <?= "<a href=\"<?= \$item->url() ?>\">" ?> + + <?= "<?= \$item->thumb_tag(array(\"class\" => \"g-thumbnail\")) ?>" ?> + + </a> +</div> diff --git a/modules/developer/views/developer_module.html.php b/modules/developer/views/developer_module.html.php new file mode 100644 index 0000000..8552942 --- /dev/null +++ b/modules/developer/views/developer_module.html.php @@ -0,0 +1,49 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> + +<?= form::open($action, array("method" => "post")) ?> + <fieldset> + <ul> + <li><?= access::csrf_form_field() ?></li> + <li <? if (!empty($errors["name"])): ?> class="g-error"<? endif ?>> + <?= form::label("name", t("Name")) ?> + <?= form::input("name", $form["name"]) ?> + <? if (!empty($errors["name"]) && $errors["name"] == "required"): ?> + <p class="g-error"><?= t("Module name is required") ?></p> + <? endif ?> + <? if (!empty($errors["name"]) && $errors["name"] == "module_exists"): ?> + <p class="g-error"><?= t("Module is already implemented") ?></p> + <? endif ?> + </li> + <li <? if (!empty($errors["display_name"])): ?> class="g-error"<? endif ?>> + <?= form::label("display_name", t("Display name")) ?> + <?= form::input("display_name", $form["display_name"]) ?> + <? if (!empty($errors["display_name"]) && $errors["display_name"] == "required"): ?> + <p class="g-error"><?= t("Module display_name is required")?></p> + <? endif ?> + </li> + <li <? if (!empty($errors["description"])): ?> class="g-error"<? endif ?>> + <?= form::label("description", t("Description")) ?> + <?= form::input("description", $form["description"]) ?> + <? if (!empty($errors["description"]) && $errors["description"] == "required"): ?> + <p class="g-error"><?= t("Module description is required")?></p> + <? endif ?> + </li> + <li> + <ul> + <li> + <?= form::label("theme[]", t("Theme callbacks")) ?> + <?= form::dropdown(array("name" => "theme[]", "multiple" => true, "size" => 6), $theme, $form["theme[]"]) ?> + </li> + <li style="padding-left: 1em" > + <?= form::label("event[]", t("Gallery event handlers")) ?> + <?= form::dropdown(array("name" => "event[]", "multiple" => true, "size" => 6), $event, $form["event[]"]) ?> + </li> + </ul> + </li> + <li> + <?= form::submit($submit_attributes, t("Generate")) ?> + </li> + </ul> + </fieldset> +</form> + diff --git a/modules/developer/views/event.txt.php b/modules/developer/views/event.txt.php new file mode 100644 index 0000000..1519de2 --- /dev/null +++ b/modules/developer/views/event.txt.php @@ -0,0 +1,27 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");" ?> +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 <?= $module ?>_event { +<? foreach ($callbacks as $callback => $unused): ?> + <?= $callback ?> { + } + +<? endforeach ?> +} diff --git a/modules/developer/views/installer.txt.php b/modules/developer/views/installer.txt.php new file mode 100644 index 0000000..3c78272 --- /dev/null +++ b/modules/developer/views/installer.txt.php @@ -0,0 +1,37 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");" ?> +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 <?= $module ?>_installer { + static function install() { + $version = module::get_version("<?= $module ?>"); + if ($version == 0) { + /* @todo Put database creation here */ + module::set_version("<?= $module ?>", 1); + } + } + + static function upgrade($version) { + } + + static function uninstall() { + /* @todo Put database table drops here */ + module::delete("<?= $module ?>"); + } +} diff --git a/modules/developer/views/module_info.txt.php b/modules/developer/views/module_info.txt.php new file mode 100644 index 0000000..0ea06e7 --- /dev/null +++ b/modules/developer/views/module_info.txt.php @@ -0,0 +1,6 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +name = <?= $module_name ?> + +description = "<?= $module_description ?>" + +version = 1 diff --git a/modules/developer/views/mptt_tree.html.php b/modules/developer/views/mptt_tree.html.php new file mode 100644 index 0000000..db6d4ff --- /dev/null +++ b/modules/developer/views/mptt_tree.html.php @@ -0,0 +1,15 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<div id="g-mptt-tree"> + <h2> + <?= t("MPTT Tree Visualizer") ?> + </h2> + <div id="g-mptt"> + <? if (empty($url)): ?> + <pre><?= $tree ?></pre> + <? else: ?> + <object type="image/svg+xml" data="<?= $url ?>" style="width: 100%; height: 100%;" > + <pre><?= $tree ?></pre> + </object> + <? endif ?> + </div> +</div> diff --git a/modules/developer/views/theme.txt.php b/modules/developer/views/theme.txt.php new file mode 100644 index 0000000..60be3b5 --- /dev/null +++ b/modules/developer/views/theme.txt.php @@ -0,0 +1,157 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");" ?> +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2013 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 <?= $module ?>_theme { +<? if (!empty($callbacks["album_blocks"])): ?> + static function album_blocks($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["album_bottom"])): ?> + static function album_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["album_top"])): ?> + static function album_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["admin_credits"])): ?> + static function admin_credits($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["photo"])): ?> + static function admin_footer($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["admin_header_top"])): ?> + static function admin_header_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["admin_header_bottom"])): ?> + static function admin_header_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["admin_page_bottom"])): ?> + static function admin_page_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["admin_page_top"])): ?> + static function admin_page_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["admin_head"])): ?> + static function admin_head($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["credits"])): ?> + static function credits($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["dynamic_bottom"])): ?> + static function dynamic_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["dynamic_top"])): ?> + static function dynamic_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["footer"])): ?> + static function footer($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["head"])): ?> + static function head($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["header_bottom"])): ?> + static function header_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["header_top"])): ?> + static function header_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["page_bottom"])): ?> + static function page_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["pae_top"])): ?> + static function page_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["photo_blocks"])): ?> + static function photo_blocks($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["photo_bottom"])): ?> + static function photo_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["photo_top"])): ?> + static function photo_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["sidebar_bottom"])): ?> + static function sidebar_bottom($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["sidebar_top"])): ?> + static function sidebar_top($theme) { + } + +<? endif ?> +<? if (!empty($callbacks["thumb_bottom"])): ?> + static function thumb_bottom($theme, $child) { + } + +<? endif ?> +<? if (!empty($callbacks["thumb_info"])): ?> + static function thumb_info($theme, $child) { + } + +<? endif ?> +<? if (!empty($callbacks["thumb_top"])): ?> + static function thumb_top($theme, $child) { + } + +<? endif ?> +} |
