diff --git a/ext/image_view_counter/main.php b/ext/image_view_counter/main.php index 993ed817..653bbd09 100644 --- a/ext/image_view_counter/main.php +++ b/ext/image_view_counter/main.php @@ -1,7 +1,15 @@ page_matches("popular_images")) { + $sql = "SELECT image_id , count(*) as total_views + FROM image_views,images + WHERE image_views.image_id = image_views.image_id + AND image_views.image_id = images.id + GROUP BY image_views.image_id + ORDER BY total_views desc"; + $result = $database->get_col($sql); + $images = []; + foreach ($result as $id) { + $images[] = Image::by_id(intval($id)); + } + $this->theme->view_popular($images); + } + } + + + + public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) + { + if ($event->parent=="posts") { + $event->add_nav_link("sort_by_visits", new Link('popular_images'), "Popular Images"); + } + } + +//This is the end of the struct + } diff --git a/ext/image_view_counter/theme.php b/ext/image_view_counter/theme.php new file mode 100644 index 00000000..ef000b70 --- /dev/null +++ b/ext/image_view_counter/theme.php @@ -0,0 +1,35 @@ +build_thumb_html($image); + $pop_images .= $thumb_html . "\n"; + } + + + $html = "\n". + "

\n". + " « {$dte[1]} »\n". + "

\n". + "
\n".$pop_images; + + + $nav_html = "Index"; + + $page->set_heading($config->get_string(SetupConfig::TITLE)); + $page->add_block(new Block("Navigation", $nav_html, "left", 10)); + $page->add_block(new Block(null, $html, "main", 30)); + } + + + public function get_help_html() + { + return '

Search for images that have received views by users.

'; + + } +}