2008-05-19 02:19:46 +00:00
|
|
|
<?php
|
2009-08-20 22:37:17 +00:00
|
|
|
/*
|
2008-05-19 02:19:46 +00:00
|
|
|
* Name: Featured Image
|
|
|
|
* Author: Shish <webmaster@shishnet.org>
|
|
|
|
* License: GPLv2
|
|
|
|
* Description: Bring a specific image to the users' attentions
|
2009-01-16 08:18:41 +00:00
|
|
|
* Documentation:
|
|
|
|
* Once enabled, a new "feature this" button will appear next
|
|
|
|
* to the other image control buttons (delete, rotate, etc).
|
|
|
|
* Clicking it will set the image as the site's current feature,
|
|
|
|
* which will be shown in the side bar of the post list.
|
2008-05-19 02:19:46 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-19 06:28:54 +00:00
|
|
|
class Featured extends SimpleExtension {
|
|
|
|
public function onInitExt($event) {
|
|
|
|
global $config;
|
|
|
|
$config->set_default_int('featured_id', 0);
|
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2009-07-19 06:28:54 +00:00
|
|
|
public function onPageRequest($event) {
|
|
|
|
global $config, $page, $user;
|
|
|
|
if($event->page_matches("set_feature")) {
|
2008-05-19 02:19:46 +00:00
|
|
|
if($user->is_admin() && isset($_POST['image_id'])) {
|
|
|
|
$id = int_escape($_POST['image_id']);
|
|
|
|
if($id > 0) {
|
|
|
|
$config->set_int("featured_id", $id);
|
2009-05-11 14:04:33 +00:00
|
|
|
$page->set_mode("redirect");
|
|
|
|
$page->set_redirect(make_link("post/view/$id"));
|
2008-05-19 02:19:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-19 06:28:54 +00:00
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2009-07-19 06:28:54 +00:00
|
|
|
public function onPostListBuilding($event) {
|
2009-12-30 08:17:46 +00:00
|
|
|
global $config, $page, $user;
|
2009-07-19 06:28:54 +00:00
|
|
|
$fid = $config->get_int("featured_id");
|
|
|
|
if($fid > 0) {
|
|
|
|
$image = Image::by_id($fid);
|
|
|
|
if(!is_null($image)) {
|
2009-12-30 08:17:46 +00:00
|
|
|
if(class_exists("Ratings")) {
|
|
|
|
if(strpos(Ratings::get_user_privs($user), $image->rating) === FALSE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2009-07-19 06:28:54 +00:00
|
|
|
$this->theme->display_featured($page, $image);
|
2008-05-19 02:19:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-19 06:28:54 +00:00
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2009-07-19 06:28:54 +00:00
|
|
|
public function onImageAdminBlockBuilding($event) {
|
|
|
|
global $user;
|
|
|
|
if($user->is_admin()) {
|
|
|
|
$event->add_part($this->theme->get_buttons_html($event->image->id));
|
2008-05-19 02:19:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|