make the featured image extension work again
This commit is contained in:
parent
d8e027b776
commit
9f40fe689f
@ -11,21 +11,16 @@
|
|||||||
* which will be shown in the side bar of the post list.
|
* which will be shown in the side bar of the post list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Featured implements Extension {
|
class Featured extends SimpleExtension {
|
||||||
var $theme;
|
public function onInitExt($event) {
|
||||||
|
|
||||||
public function receive_event(Event $event) {
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
|
||||||
|
|
||||||
if($event instanceof InitExtEvent) {
|
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int('featured_id', 0);
|
$config->set_default_int('featured_id', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("set_feature")) {
|
public function onPageRequest($event) {
|
||||||
global $user;
|
global $config, $page, $user;
|
||||||
|
if($event->page_matches("set_feature")) {
|
||||||
if($user->is_admin() && isset($_POST['image_id'])) {
|
if($user->is_admin() && isset($_POST['image_id'])) {
|
||||||
global $config;
|
|
||||||
$id = int_escape($_POST['image_id']);
|
$id = int_escape($_POST['image_id']);
|
||||||
if($id > 0) {
|
if($id > 0) {
|
||||||
$config->set_int("featured_id", $id);
|
$config->set_int("featured_id", $id);
|
||||||
@ -34,8 +29,9 @@ class Featured implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof PostListBuildingEvent) {
|
public function onPostListBuilding($event) {
|
||||||
global $config, $page;
|
global $config, $page;
|
||||||
$fid = $config->get_int("featured_id");
|
$fid = $config->get_int("featured_id");
|
||||||
if($fid > 0) {
|
if($fid > 0) {
|
||||||
@ -46,20 +42,11 @@ class Featured implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public function onImageAdminBlockBuilding($event) {
|
||||||
if(($event instanceof SetupBuildingEvent)) {
|
global $user;
|
||||||
$sb = new SetupBlock("Featured Image");
|
if($user->is_admin()) {
|
||||||
$sb->add_int_option("featured_id", "Image ID: ");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($event instanceof ImageAdminBlockBuildingEvent) {
|
|
||||||
if($event->user->is_admin()) {
|
|
||||||
$event->add_part($this->theme->get_buttons_html($event->image->id));
|
$event->add_part($this->theme->get_buttons_html($event->image->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
add_event_listener(new Featured());
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user