Cleaned up how the Image Replace html is made.

This commit is contained in:
green-ponies (jgen) 2011-09-03 16:03:21 -04:00
parent cc1545188c
commit 8e68d650a1
2 changed files with 24 additions and 13 deletions

View File

@ -200,12 +200,20 @@ class ImageIO extends SimpleExtension {
}
public function onUserPageBuilding($event) {
global $user;
global $config;
$u_id = url_escape($event->display_user->id);
$i_image_count = Image::count_images(array("user_id={$event->display_user->id}"));
$i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
$h_image_rate = sprintf("%.1f", ($i_image_count / $i_days_old));
$images_link = make_link("post/list/user_id=$u_id/1");
$event->add_stats("<a href='$images_link'>Images uploaded</a>: $i_image_count, $h_image_rate per day");
/* In the future, could perhaps allow users to replace images that they own as well... */
if ($user->is_admin() && $config->get_bool("upload_replace")) {
$event->add_part($this->theme->get_replace_html($event->image->id));
}
}
public function onSetupBuilding($event) {

View File

@ -1,41 +1,44 @@
<?php
class ImageIOTheme {
/*
/**
* Display a link to delete an image
* (Added inline Javascript to confirm the deletion)
*
* $image_id = the image to delete
* @param $image_id The image to delete
*/
public function get_deleter_html($image_id) {
global $user;
global $config;
$i_image_id = int_escape($image_id);
if($config->get_bool("jquery_confirm")) {
$html = "
".make_form(make_link("image_admin/delete"),'POST',false,'delete_image')."
<input type='hidden' name='image_id' value='$i_image_id' />
<input type='hidden' name='image_id' value='$image_id' />
<input type='submit' value='Delete' id='delete_image_submit' />
</form>
";
} else {
$html = "
".make_form(make_link("image_admin/delete"))."
<input type='hidden' name='image_id' value='$i_image_id' />
<input type='hidden' name='image_id' value='$image_id' />
<input type='submit' value='Delete' onclick='return confirm(\"Delete the image?\");' />
</form>
";
}
}
if($config->get_bool("upload_replace") && $user->is_admin()) {
$html .= "
/**
* Display link to replace the image
*
* @param $image_id The image to replace
*/
public function get_deleter_html($image_id) {
$html = "
".make_form(make_link("image_admin/replace"))."
<input type='hidden' name='image_id' value='$i_image_id' />
<input type='hidden' name='image_id' value='$image_id' />
<input type='submit' value='Replace' />
</form>
";
}
</form>";
return $html;
}