1
0

Merge branch 'master' into bharat_dev

This commit is contained in:
Bharat Mediratta 2010-06-06 10:27:54 -07:00
commit 2b75fef32f
18 changed files with 418 additions and 256 deletions

View File

@ -57,7 +57,7 @@
</td>
<td class="g-actions">
<td>
<a href="<?= url::site("admin/product_lines/edit_product_form/$product->id") ?>"
open_text="<?= t("close") ?>"
class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left">

View File

@ -76,7 +76,7 @@
<? $total += $prod_details->cost?>
<?= html::clean(basket::formatMoney($prod_details->cost)) ?>
</td>
<td class="g-actions">
<td>
<!-- a href="<?= url::site("admin/product_lines/edit_product_form/") ?>"
open_text="<?= t("close") ?>"
class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left">

View File

@ -32,6 +32,7 @@ $config["methods"] = array(
"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"),
@ -44,27 +45,10 @@ $config["methods"] = array(
"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")),
"event" => array("admin_menu" => t("Add an admin menu element"),
"album_menu" => t("Add an album menu element"),
"batch_complete" => t("Batch completion"),
"comment_add_form" => t("Comment add form creation"),
"comment_created" => t("Comment created"),
"comment_updated" => t("Comment updated"),
"group_before_delete" => t("Before delete group"),
"group_created" => t("Group created"),
"item_before_delete" => t("Before album or photo deletion"),
"item_created" => t("Album or photo created"),
"item_related_update" => t("Photo meta data update"),
"item_related_update_batch" => t("Photo meta data update"),
"item_updated" => t("Album or photo update"),
"photo_menu" => t("Add a photo menu element"),
"site_menu" => t("Add a site menu element"),
"user_before_delete" => t("Before user deletion"),
"user_created" => t("User created"),
"user_login" => t("User login"),
"user_logout" => t("User logout")));
"thumb_top" => t("Top of thumbnail display")));

View File

@ -18,6 +18,8 @@
* 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");
@ -51,6 +53,8 @@ class Admin_Developer_Controller extends Admin_Controller {
$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()) {
@ -58,14 +62,14 @@ class Admin_Developer_Controller extends Admin_Controller {
->callback("developer_task::create_module")
->description(t("Create a new module"))
->name(t("Create Module"));
$task = task::create($task_def, array_merge(array("step" => 0), $post->as_array()));
$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()));
print json_encode(array("result" => "started",
"max_iterations" => 15,
"success_msg" => $success_msg, "error_msg" => $error_msg,
"url" => url::site("admin/developer/run_task/{$task->id}?csrf=" .
access::csrf_token()),
"task" => $task->as_array()));
@ -77,6 +81,9 @@ class Admin_Developer_Controller extends Admin_Controller {
}
}
public function _noop_validation(Validation $array, $field) {
}
public function session($key) {
access::verify_csrf();
$input = Input::instance();
@ -85,8 +92,6 @@ class Admin_Developer_Controller extends Admin_Controller {
}
public function test_data_create() {
access::verify_csrf();
list ($form, $errors) = $this->_get_test_data_form();
$post = new Validation($_POST);
@ -128,8 +133,6 @@ class Admin_Developer_Controller extends Admin_Controller {
}
public function run_task($task_id) {
access::verify_csrf();
try {
$task = task::run($task_id);
} catch (Exception $e) {
@ -229,14 +232,53 @@ class Admin_Developer_Controller extends Admin_Controller {
$v = new View("developer_module.html");
$v->action = "admin/developer/module_create";
$v->hidden = array("csrf" => access::csrf_token());
$v->theme = $config["theme"];
$v->event = $config["event"];
$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" => "");
@ -248,7 +290,6 @@ class Admin_Developer_Controller extends Admin_Controller {
private function _get_test_data_view($form, $errors) {
$v = new View("admin_developer_test_data.html");
$v->action = "admin/developer/test_data_create";
$v->hidden = array("csrf" => access::csrf_token());
$album_count = ORM::factory("item")->where("type", "=", "album")->count_all();
$photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();

View File

@ -25,6 +25,7 @@ class developer_task_Core {
static function create_module($task) {
$context = unserialize($task->context);
Kohana_Log::add("error", "task context:\n" . Kohana::debug($context));
if (empty($context["module"])) {
$context["class_name"] = strtr($context["name"], " ", "_");
@ -34,11 +35,11 @@ class developer_task_Core {
switch ($context["step"]) {
case 0: // Create directory tree
foreach (array("", "controllers", "helpers", "js", "views") as $dir) {
foreach (array("", "controllers", "helpers", "views") as $dir) {
$path = "{$context['module_path']}/$dir";
if (!file_exists($path)) {
mkdir($path);
chmod($path, 0777);
chmod($path, 0755);
}
}
break;
@ -103,7 +104,19 @@ class developer_task_Core {
file_put_contents($file, ob_get_contents());
ob_end_clean();
break;
case 9: // Generate module.info (do last)
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");
@ -115,7 +128,7 @@ class developer_task_Core {
break;
}
if (isset($file)) {
chmod($file, 0666);
chmod($file, 0765);
}
$task->done = (++$context["step"]) >= 11;
$task->context = serialize($context);
@ -128,7 +141,6 @@ class developer_task_Core {
$config = Kohana::config("developer.methods");
$file = "{$context["module_path"]}/helpers/{$context["module"]}_{$helper}.php";
touch($file);
chmod($file, 0666);
ob_start();
$v = new View("$helper.txt");
$v->helper = $helper;
@ -184,7 +196,7 @@ class developer_task_Core {
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 = user::active()->id;
$owner_id = identity::active_user()->id;
$test_images = glob(dirname(dirname(__FILE__)) . "/data/*.[Jj][Pp][Gg]");
@ -207,7 +219,7 @@ class developer_task_Core {
$parents[] = $item->save();
} else {
$photo_index = rand(0, count($test_images) - 1);
$item = ORM:factory("item");
$item = ORM::factory("item");
$item->type = "photo";
$item->parent_id = $parent->id;
$item->set_data_file($test_images[$photo_index]);
@ -240,6 +252,7 @@ class developer_task_Core {
$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;

View File

@ -19,7 +19,7 @@
<? endif ?>
});
</script>
<?= form::open($action, array("method" => "post", "id" => "g-generate-test-data"), $hidden) ?>
<?= form::open($action, array("method" => "post", "id" => "g-generate-test-data")) ?>
<? if (!empty($album_count)): ?>
<p><?= t("Currently:") ?><br />
@ -29,6 +29,7 @@
<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")) ?>

View File

@ -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>

View File

@ -1,8 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?= form::open($action, array("method" => "post"), $hidden) ?>
<?= 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"]) ?>
@ -33,14 +34,14 @@
<?= form::label("theme[]", t("Theme callbacks")) ?>
<?= form::dropdown(array("name" => "theme[]", "multiple" => true, "size" => 6), $theme, $form["theme[]"]) ?>
</li>
<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(array("id" => "g-generate-module", "name" => "generate", "class" => "submit", "style" => "clear:both!important"), t("Generate")) ?>
<?= form::submit($submit_attributes, t("Generate")) ?>
</li>
</ul>
</fieldset>

View File

@ -19,98 +19,9 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class <?= $module ?>_event {
<? if (!empty($callbacks["admin_menu"])): ?>
static function admin_menu($menu, $theme) {
<? foreach ($callbacks as $callback => $unused): ?>
<?= $callback ?> {
}
<? endif ?>
<? if (!empty($callbacks["album_menu"])): ?>
static function album_menu($menu, $theme) {
}
<? endif ?>
<? if (!empty($callbacks["batch_complete"])): ?>
static function batch_complete() {
}
<? endif ?>
<? if (!empty($callbacks["comment_add_form"])): ?>
static function comment_add_form($form) {
}
<? endif ?>
<? if (!empty($callbacks["comment_created"])): ?>
static function comment_created($theme, $args) {
}
<? endif ?>
<? if (!empty($callbacks["comment_updated"])): ?>
static function comment_updated($old, $new) {
}
<? endif ?>
<? if (!empty($callbacks["group_before_delete"])): ?>
static function group_before_delete($group) {
}
<? endif ?>
<? if (!empty($callbacks["group_created"])): ?>
static function group_created($group) {
}
<? endif ?>
<? if (!empty($callbacks["item_before_delete"])): ?>
static function item_before_delete($item) {
}
<? endif ?>
<? if (!empty($callbacks["item_created"])): ?>
static function item_created($item) {
}
<? endif ?>
<? if (!empty($callbacks["item_related_update"])): ?>
static function item_related_update($item) {
}
<? endif ?>
<? if (!empty($callbacks["item_related_update_batch"])): ?>
static function item_related_update_batch($sql) {
}
<? endif ?>
<? if (!empty($callbacks["item_updated"])): ?>
static function item_updated($old, $new) {
}
<? endif ?>
<? if (!empty($callbacks["photo_menu"])): ?>
static function photo_menu($menu, $theme) {
}
<? endif ?>
<? if (!empty($callbacks["site_menu"])): ?>
static function site_menu($menu, $theme) {
}
<? endif ?>
<? if (!empty($callbacks["user_before_delete"])): ?>
static function user_before_delete($user) {
}
<? endif ?>
<? if (!empty($callbacks["user_created"])): ?>
static function user_created($user) {
}
<? endif ?>
<? if (!empty($callbacks["user_login"])): ?>
static function user_login($user) {
}
<? endif ?>
<? if (!empty($callbacks["user_logout"])): ?>
static function user_logout($user) {
}
<? endif ?>
<? endforeach ?>
}

View File

@ -93,6 +93,7 @@ class Admin_register_Controller extends Admin_Controller {
private function _get_admin_view($form, $errors) {
$v = new Admin_View("admin.html");
$v->page_title = t("User registration");
$v->content = new View("admin_register.html");
$v->content->action = "admin/register/update";
$v->content->policy_list =

View File

@ -18,18 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class rescue_task_Core {
const LEFT = 0;
const RIGHT = 1;
static function available_tasks() {
return array(Task_Definition::factory()
->callback("rescue_task::fix_mptt")
->name(t("Fix Album/Photo hierarchy"))
->description(t("Fix problems where your album/photo breadcrumbs are out of " .
"sync with your actual hierarchy."))
->severity(log::SUCCESS),
Task_Definition::factory()
->callback("rescue_task::fix_internet_addresses")
->name(t("Fix internet addresses"))
->description(t("Fix internet addresses broken when upgrading to Beta 3"))
@ -37,56 +27,6 @@ class rescue_task_Core {
);
}
static function fix_mptt($task) {
$start = microtime(true);
$total = $task->get("total");
if (empty($total)) {
$task->set("total", $total = db::build()->count_records("items"));
$task->set("stack", "1:" . self::LEFT);
$task->set("ptr", 1);
$task->set("completed", 0);
}
$ptr = $task->get("ptr");
$stack = explode(" ", $task->get("stack"));
$completed = $task->get("completed");
// Implement a depth-first tree walk using a stack. Not the most efficient, but it's simple.
while ($stack && microtime(true) - $start < 1.5) {
list($id, $state) = explode(":", array_pop($stack));
switch ($state) {
case self::LEFT:
self::set_left($id, $ptr++);
$item = ORM::factory("item", $id);
array_push($stack, $id . ":" . self::RIGHT);
foreach (self::children($id) as $child) {
array_push($stack, $child->id . ":" . self::LEFT);
}
break;
case self::RIGHT:
self::set_right($id, $ptr++);
$completed++;
break;
}
}
$task->set("stack", implode(" ", $stack));
$task->set("ptr", $ptr);
$task->set("completed", $completed);
if ($total == $completed) {
$task->done = true;
$task->state = "success";
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / $total);
}
$task->status = t2("One row updated", "%count / %total rows updated", $completed,
array("total" => $total));
}
static function fix_internet_addresses($task) {
$start = microtime(true);
@ -131,29 +71,4 @@ class rescue_task_Core {
$task->status = t2("One row updated", "%count / %total rows updated", $completed,
array("total" => $total));
}
static function children($parent_id) {
return db::build()
->select("id")
->from("items")
->where("parent_id", "=", $parent_id)
->order_by("left_ptr", "ASC")
->execute();
}
static function set_left($id, $value) {
db::build()
->update("items")
->set("left_ptr", $value)
->where("id", "=", $id)
->execute();
}
static function set_right($id, $value) {
db::build()
->update("items")
->set("right_ptr", $value)
->where("id", "=", $id)
->execute();
}
}

View File

@ -0,0 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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.
*/
// Redirect /admin/maintenance to the admin/scheduler
$config["^admin/maintenance(.*)$"] = "admin/schedule$1";

View File

@ -17,25 +17,57 @@
* 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_Schedule_Controller extends Admin_Controller {
class Admin_Schedule_Controller extends Admin_Maintenance_Controller {
/**
* Show a list of all available, running and finished tasks.
*/
public function index() {
$query = db::build()
->update("tasks")
->set("state", "stalled")
->where("done", "=", 0)
->where("state", "<>", "stalled")
->where(new Database_Expression("UNIX_TIMESTAMP(NOW()) - `updated` > 15"))
->execute();
$stalled_count = $query->count();
if ($stalled_count) {
log::warning("tasks",
t2("One task is stalled",
"%count tasks are stalled",
$stalled_count),
t('<a href="%url">view</a>',
array("url" => html::mark_clean(url::site("admin/maintenance")))));
}
$view = new Admin_View("admin.html");
$view->page_title = t("Maintenance tasks");
$view->content = new View("admin_schedule.html");
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
$view->content->finished_tasks = ORM::factory("task")
->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
$view->content->schedule_definitions = scheduler::get_definitions();
print $view;
}
public function form_add($task_callback) {
access::verify_csrf();
$schedule = ORM::factory("schedule");
$schedule->task_callback = $task_callback;
$schedule->next_run_datetime = time();
$v = new View("admin_schedule.html");
$v = new View("admin_schedule_form.html");
$v->form = scheduler::get_form("define", $schedule);
$v->method = "define";
print $v;
}
public function update_form($id) {
public function form_edit($id) {
access::verify_csrf();
$schedule = ORM::factory("schedule", $id);
$v = new View("admin_schedule.html");
$v = new View("admin_schedule_form.html");
$v->form = scheduler::get_form("update", $schedule);
$v->method = "update";
print $v;
@ -48,14 +80,14 @@ class Admin_Schedule_Controller extends Admin_Controller {
$v = new View("admin_schedule_confirm.html");
$v->name = $schedule->name;
$v->form = new Forge("admin/schedule/remove/{$id}", "", "post",
$v->form = new Forge("admin/schedule/remove_event/{$id}", "", "post",
array("id" => "g-remove-schedule"));
$group = $v->form->group("remove");
$group->submit("")->value(t("Continue"));
print $v;
}
public function remove($id) {
public function remove_event($id) {
access::verify_csrf();
$schedule = ORM::factory("schedule", $id);
$schedule->delete();
@ -70,7 +102,7 @@ class Admin_Schedule_Controller extends Admin_Controller {
public function update($id=null) {
$this->_handle_request("update", $id);
}
}
private function _handle_request($method, $id=null) {
$schedule = ORM::factory("schedule", $id);

View File

@ -100,16 +100,12 @@ class scheduler_Core {
}
static function get_definitions() {
$v = "";
$schedule_definitions = array();
$events = ORM::factory("schedule")
->order_by("next_run_datetime", "asc")
->find_all();
if ($events->count()) {
$v = new View("scheduler_definitions.html");
$v->schedule_definitions = array();
foreach ($events as $schedule) {
$entry[] = $schedule->id;
$entry[] = $schedule->name;
$run_date = strftime("%A, %b %e, %Y %H:%M ", $schedule->next_run_datetime);
$intervals = scheduler::intervals();
$interval = $intervals[$schedule->interval];
@ -121,13 +117,13 @@ class scheduler_Core {
$status = t("Scheduled");
}
$v->schedule_definitions[] = (object)array("id" => $schedule->id,
"name" => $schedule->name,
"run_date" => $run_date,
"interval" => $interval,
"status" => $status);
$schedule_definitions[] = (object)array("id" => $schedule->id,
"name" => $schedule->name,
"run_date" => $run_date,
"interval" => $interval,
"status" => $status);
}
}
return $v;
return $schedule_definitions;
}
}

View File

@ -17,15 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class scheduler_event_Core {
static function admin_maintenance_content($maintenance_content) {
$maintenance_content[] = scheduler::get_definitions();
}
static function admin_maintenance_task_buttons($task_buttons) {
$task_buttons[] = (object)array("text" => t("schedule"),
"url" =>url::site("form/add/admin/schedule"));
static function admin_menu($menu, $theme) {
$menu->get("maintenance")
->url(url::site("admin/schedule"));
}
/**

View File

@ -1,11 +1,236 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
#g-define-schedule fieldset fieldset li {
margin-right: .5em;
}
<div id="g-admin-maintenance" class="g-block">
<h1> <?= t("Maintenance tasks") ?> </h1>
<p>
<?= t("Occasionally your Gallery will require some maintenance. Here are some tasks you can use to keep it running smoothly.") ?>
</p>
#g-schedule-time {
width: 40px !important;
}
</style>
<?= $form ?>
<div class="g-block-content">
<div id="g-available-tasks">
<h2> <?= t("Available tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Description") ?>
</th>
<th>
<?= t("Action") ?>
</th>
</tr>
<? foreach ($task_definitions as $task): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?> <?= log::severity_class($task->severity) ?>">
<td class="<?= log::severity_class($task->severity) ?>">
<?= $task->name ?>
</td>
<td>
<?= $task->description ?>
</td>
<td>
<a href="<?= url::site("admin/maintenance/start/$task->callback?csrf=$csrf") ?>"
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
<?= t("run") ?>
</a>
<a href="<?= url::site("form/add/admin/schedule/$task->callback?csrf=$csrf") ?>"
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
<?= t("schedule") ?>
</a>
</a>
</td>
</tr>
<? endforeach ?>
</table>
</div>
<? if (count($schedule_definitions) > 0): ?>
<div id="g-sheduled-tasks">
<h2> <?= t("Scheduled tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Next run") ?>
</th>
<th>
<?= t("Frequency") ?>
</th>
</tr>
<? foreach ($schedule_definitions as $entry): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
<td>
<?= $entry->name ?>
</td>
<td>
<?= $entry->run_date ?>
</td>
<td>
<?= $entry->interval ?>
</td>
<td>
<a href="<?= url::site("form/edit/admin/schedule/$entry->id?csrf=$csrf") ?>"
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
<?= t("edit") ?>
</a>
<a href="<?= url::site("admin/schedule/remove_form/$entry->id?csrf=$csrf") ?>"
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
<?= t("remove") ?>
</a>
</td>
</tr>
<? endforeach ?>
</table>
</div>
<? endif ?>
<? if ($running_tasks->count()): ?>
<div id="g-running-tasks">
<h2> <?= t("Running tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Last updated") ?>
</th>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Status") ?>
</th>
<th>
<?= t("Info") ?>
</th>
<th>
<?= t("Owner") ?>
</th>
<th>
<a href="<?= url::site("admin/maintenance/cancel_running_tasks?csrf=$csrf") ?>"
class="g-button g-right ui-icon-left ui-state-default ui-corner-all">
<?= t("cancel all") ?></a>
<?= t("Action") ?>
</th>
</tr>
<? foreach ($running_tasks as $task): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?> <?= $task->state == "stalled" ? "g-warning" : "" ?>">
<td class="<?= $task->state == "stalled" ? "g-warning" : "" ?>">
<?= gallery::date_time($task->updated) ?>
</td>
<td>
<?= $task->name ?>
</td>
<td>
<? if ($task->done): ?>
<? if ($task->state == "cancelled"): ?>
<?= t("Cancelled") ?>
<? endif ?>
<?= t("Close") ?>
<? elseif ($task->state == "stalled"): ?>
<?= t("Stalled") ?>
<? else: ?>
<?= t("%percent_complete% Complete", array("percent_complete" => $task->percent_complete)) ?>
<? endif ?>
</td>
<td>
<?= $task->status ?>
</td>
<td>
<?= html::clean($task->owner()->name) ?>
</td>
<td>
<a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>"
class="g-button g-right ui-icon-left ui-state-default ui-corner-all">
<?= t("cancel") ?>
</a>
<? if ($task->state == "stalled"): ?>
<a class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all"
href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>">
<?= t("resume") ?>
</a>
<? endif ?>
</td>
</tr>
<? endforeach ?>
</table>
</div>
<? endif ?>
<? if ($finished_tasks->count()): ?>
<div id="g-finished-tasks">
<a href="<?= url::site("admin/maintenance/remove_finished_tasks?csrf=$csrf") ?>"
class="g-button g-right ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-trash"></span><?= t("remove all finished") ?></a>
<h2> <?= t("Finished tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Last updated") ?>
</th>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Status") ?>
</th>
<th>
<?= t("Info") ?>
</th>
<th>
<?= t("Owner") ?>
</th>
<th>
<?= t("Action") ?>
</th>
</tr>
<? foreach ($finished_tasks as $task): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?> <?= $task->state == "success" ? "g-success" : "g-error" ?>">
<td class="<?= $task->state == "success" ? "g-success" : "g-error" ?>">
<?= gallery::date_time($task->updated) ?>
</td>
<td>
<?= $task->name ?>
</td>
<td>
<? if ($task->state == "success"): ?>
<?= t("Success") ?>
<? elseif ($task->state == "error"): ?>
<?= t("Failed") ?>
<? elseif ($task->state == "cancelled"): ?>
<?= t("Cancelled") ?>
<? endif ?>
</td>
<td>
<?= $task->status ?>
</td>
<td>
<?= html::clean($task->owner()->name) ?>
</td>
<td>
<? if ($task->done): ?>
<a href="<?= url::site("admin/maintenance/remove/$task->id?csrf=$csrf") ?>" class="g-button ui-state-default ui-corner-all">
<?= t("remove") ?>
</a>
<? if ($task->get_log()): ?>
<a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all">
<?= t("browse log") ?>
</a>
<? endif ?>
<? else: ?>
<a href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>" class="g-dialog-link g-button" ui-state-default ui-corner-all>
<?= t("resume") ?>
</a>
<a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" class="g-button ui-state-default ui-corner-all">
<?= t("cancel") ?>
</a>
<? endif ?>
</ul>
</td>
</tr>
<? endforeach ?>
</table>
</div>
<? endif ?>
</div>
</div>

View File

@ -0,0 +1,11 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
#g-define-schedule fieldset fieldset li {
margin-right: .5em;
}
#g-schedule-time {
width: 40px !important;
}
</style>
<?= $form ?>

View File

@ -29,4 +29,8 @@ class sso_event {
}
}
}
static function user_menu($menu, $theme) {
$menu->remove("user_menu_logout");
}
}