Skip to content

Commit

Permalink
tentative release
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.2@898 7f39781d-f577-437e-ae19-be835c7a54ca
  • Loading branch information
shish committed Jun 14, 2008
1 parent c4fdf77 commit 5f473af
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 28 deletions.
7 changes: 3 additions & 4 deletions contrib/featured/main.php
Expand Up @@ -49,10 +49,9 @@ public function receive_event($event) {
}
*/

if(is_a($event, 'DisplayingImageEvent')) {
global $user;
if($user->is_admin()) {
$this->theme->display_buttons($event->page, $event->image->id);
if(is_a($event, 'ImageAdminBlockBuildingEvent')) {
if($event->user->is_admin()) {
$event->add_part($this->theme->get_buttons_html($event->image->id));
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions contrib/featured/theme.php
Expand Up @@ -8,14 +8,13 @@ public function display_featured($page, $image) {
$page->add_block(new Block("Featured Image", $this->build_thumb_html($image), "left", 3));
}

public function display_buttons($page, $image_id) {
$html = "
public function get_buttons_html($image_id) {
return "
<form action='".make_link("set_feature")."' method='POST'>
<input type='hidden' name='image_id' value='$image_id'>
<input type='submit' value='Featue This'>
</form>
";
$page->add_block(new Block("Featured Image", $html, "left"));
}
}
?>
18 changes: 12 additions & 6 deletions contrib/handle_flash/main.php
Expand Up @@ -57,12 +57,18 @@ private function create_image_from_data($filename, $metadata) {
$image->tag_array = tag_explode($metadata['tags']);
$image->source = $metadata['source'];

$rect = $this->swf_get_bounds($filename);
if(is_null($rect)) {
return $null;
}
$image->width = $rect[1];
$image->height = $rect[3];
// redundant, since getimagesize() works on SWF o_O
// $rect = $this->swf_get_bounds($filename);
// if(is_null($rect)) {
// return $null;
// }
// $image->width = $rect[1];
// $image->height = $rect[3];

if(!($info = getimagesize($filename))) return null;

$image->width = $info[0];
$image->height = $info[1];

return $image;
}
Expand Down
7 changes: 3 additions & 4 deletions contrib/regen_thumb/main.php
Expand Up @@ -22,10 +22,9 @@ public function receive_event($event) {
}
}

if(is_a($event, 'DisplayingImageEvent')) {
global $user;
if($user->is_admin()) {
$this->theme->display_buttons($event->page, $event->image->id);
if(is_a($event, 'ImageAdminBlockBuildingEvent')) {
if($event->user->is_admin()) {
$event->add_part($this->theme->get_buttons_html($event->image->id));
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions contrib/regen_thumb/theme.php
Expand Up @@ -4,14 +4,13 @@ class RegenThumbTheme extends Themelet {
/*
* Show a form which offers to regenerate the thumb of an image with ID #$image_id
*/
public function display_buttons($page, $image_id) {
$html = "
public function get_buttons_html($image_id) {
return "
<form action='".make_link("regen_thumb")."' method='POST'>
<input type='hidden' name='image_id' value='$image_id'>
<input type='submit' value='Regenerate'>
</form>
";
$page->add_block(new Block("Regen Thumb", $html, "left"));
}

/*
Expand Down
7 changes: 3 additions & 4 deletions ext/admin/main.php
Expand Up @@ -70,10 +70,9 @@ public function receive_event($event) {
}
}

if(is_a($event, 'DisplayingImageEvent')) {
global $user;
if($user->is_admin()) {
$this->theme->display_deleter($event->page, $event->image->id);
if(is_a($event, 'ImageAdminBlockBuildingEvent')) {
if($event->user->is_admin()) {
$event->add_part($this->theme->get_deleter_html($event->image->id));
}
}

Expand Down
4 changes: 2 additions & 2 deletions ext/admin/theme.php
Expand Up @@ -15,15 +15,15 @@ public function display_page($page) {
*
* $image_id = the image to delete
*/
public function display_deleter($page, $image_id) {
public function get_deleter_html($image_id) {
$i_image_id = int_escape($image_id);
$html = "
<form action='".make_link("admin/delete_image")."' method='POST'>
<input type='hidden' name='image_id' value='$i_image_id'>
<input type='submit' value='Delete'>
</form>
";
$page->add_block(new Block("Admin", $html, "left"));
return $html;
}

/*
Expand Down
19 changes: 19 additions & 0 deletions ext/view/main.php
Expand Up @@ -24,6 +24,21 @@ public function ImageInfoSetEvent($image_id) {
}
}

class ImageAdminBlockBuildingEvent extends Event {
var $parts = array();
var $image = null;
var $user = null;

public function ImageAdminBlockBuildingEvent($image, $user) {
$this->image = $image;
$this->user = $user;
}

public function add_part($html, $position=50) {
while(isset($this->parts[$position])) $position++;
$this->parts[$position] = $html;
}
}
class ViewImage extends Extension {
var $theme;

Expand All @@ -38,6 +53,10 @@ public function receive_event($event) {

if(!is_null($image)) {
send_event(new DisplayingImageEvent($image, $event->page));
$iabbe = new ImageAdminBlockBuildingEvent($image, $event->user);
send_event($iabbe);
ksort($iabbe->parts);
$this->theme->display_admin_block($event->page, $iabbe->parts);
}
else {
$this->theme->display_error($event->page, "Image not found", "No image in the database has the ID #$image_id");
Expand Down
6 changes: 6 additions & 0 deletions ext/view/theme.php
Expand Up @@ -12,6 +12,12 @@ public function display_page($page, $image, $editor_parts) {
$page->add_block(new Block(null, $this->build_pin($image->id), "main", 11));
}

public function display_admin_block($page, $parts) {
if(count($parts) > 0) {
$page->add_block(new Block("Image Admin", join("<br>", $parts), "left", 50));
}
}


var $pin = null;

Expand Down
4 changes: 2 additions & 2 deletions index.php
@@ -1,7 +1,7 @@
<?php
// set up and purify the environment
define("DEBUG", true);
define("VERSION", '2.2.0-pre1');
define("DEBUG", false);
define("VERSION", '2.2.0');

require_once "core/util.inc.php";

Expand Down

0 comments on commit 5f473af

Please sign in to comment.