diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 3d62d3da..6f189552 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -56,7 +56,7 @@ class BaseThemelet { $h_tip = html_escape($image->get_tooltip()); $h_tags = strtolower($image->get_tag_list()); - $extArr = array_flip(array('swf', 'svg', 'mp4', 'ogv', 'webm', 'flv')); //List of thumbless filetypes + $extArr = array_flip(array('swf', 'svg')); //List of thumbless filetypes if(!isset($extArr[$image->ext])){ $tsize = get_thumbnail_size($image->width, $image->height); }else{ diff --git a/core/page.class.php b/core/page.class.php index 903014c0..ae083bd2 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -292,7 +292,7 @@ class Page { $css_files[] = $css; $css_latest = max($css_latest, filemtime($css)); } - $css_cache_file = data_path("cache/style.$css_latest.css"); + $css_cache_file = data_path("cache/style.$theme_name.$css_latest.css"); if(!file_exists($css_cache_file)) { $css_data = ""; foreach($css_files as $file) { @@ -312,7 +312,7 @@ class Page { $js_files[] = $js; $js_latest = max($js_latest, filemtime($js)); } - $js_cache_file = data_path("cache/script.$js_latest.js"); + $js_cache_file = data_path("cache/script.$theme_name.$js_latest.js"); if(!file_exists($js_cache_file)) { $js_data = ""; foreach($js_files as $file) { diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index d9d0cfd3..781a9220 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -70,7 +70,8 @@ class VideoFileHandler extends DataHandlerExtension { $inname = escapeshellarg(warehouse_path("images", $hash)); $outname = escapeshellarg(warehouse_path("thumbs", $hash)); - $cmd = escapeshellcmd("{$ffmpeg} -i {$inname} -s {$w}x{$h} -ss 00:00:00.0 -f image2 -vframes 1 {$outname}"); + $cmd = escapeshellcmd("{$ffmpeg} -i {$inname} -vf scale='if(gt(a,{$w}/{$h}),{$w},-1)':'if(gt(a,{$w}/{$h}),-1,{$h})' -ss 00:00:00.0 -f image2 -vframes 1 {$outname}"); + exec($cmd, $output, $ret); // TODO: We should really check the result of the exec to see if it really succeeded. diff --git a/ext/pools/main.php b/ext/pools/main.php index f4a12f6d..08105b61 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -1,7 +1,7 @@ , jgen + * Author: Sein Kraft , jgen , Daku * License: GPLv2 * Description: Allow users to create groups of images and order them. * Documentation: This extension allows users to created named groups of @@ -80,6 +80,13 @@ class Pools extends Extension { $config->set_int("ext_pools_version", 2); } + + if ($config->get_int("ext_pools_version") < 3){ + $config->set_bool("poolsShowNavLinks","N"); //A $config->rename() function would be nice here... + $config->set_bool("poolsAutoIncrementOrder","N"); + + $config->set_int("ext_pools_version", 3); + } } // Add a block to the Board Config / Setup @@ -90,8 +97,10 @@ class Pools extends Extension { $sb->add_int_option("poolsListsPerPage", "
Index list items per page: "); $sb->add_int_option("poolsUpdatedPerPage", "
Updated list items per page: "); $sb->add_bool_option("poolsInfoOnViewImage", "
Show pool info on image: "); - $sb->add_bool_option("poolsShowNextLink", "
Show 'Next' link when viewing pool images: "); + $sb->add_bool_option("poolsShowNavLinks", "
Show 'Prev' & 'Next' links when viewing pool images: "); + $sb->add_bool_option("poolsAutoIncrementOrder", "
Autoincrement order when post is added to pool:"); //$sb->add_bool_option("poolsAdderOnViewImage", "
Show pool adder on image: "); + $event->panel->add_block($sb); } @@ -99,10 +108,9 @@ class Pools extends Extension { global $page, $user; if ($event->page_matches("pool")) { - $pool_id = 0; $pool = array(); - + // Check if we have pool id, since this is most often the case. if (isset($_POST["pool_id"])) { $pool_id = int_escape($_POST["pool_id"]); @@ -258,25 +266,22 @@ class Pools extends Extension { if($config->get_bool("poolsInfoOnViewImage")) { $imageID = $event->image->id; $poolsIDs = $this->get_pool_id($imageID); - - $show_next = $config->get_bool("poolsShowNextLink", false); - $linksPools = array(); + $show_nav = $config->get_bool("poolsShowNavLinks", false); + + $navInfo = array(); foreach($poolsIDs as $poolID) { - $pools = $this->get_pool($poolID['pool_id']); - foreach ($pools as $pool){ - $linksPools[] = "".html_escape($pool['title']).""; - - // Optionally show a link the Next image in the Pool. - if ($show_next) { - $next_image_in_pool = $this->get_next_post($pool, $imageID); - if (!empty($next_image_in_pool)) { - $linksPools[] = 'Next'; - } - } + $pool = $this->get_single_pool($poolID['pool_id']); + + $navInfo[$pool['id']] = array(); + $navInfo[$pool['id']]['info'] = $pool; + + // Optionally show a link the Prev/Next image in the Pool. + if ($show_nav) { + $navInfo[$pool['id']]['nav'] = $this->get_nav_posts($pool, $imageID); } } - $this->theme->pool_info($linksPools); + $this->theme->pool_info($navInfo); } } @@ -320,19 +325,24 @@ class Pools extends Extension { public function onTagTermParse(TagTermParseEvent $event) { $matches = array(); - if(preg_match("/^pool[=|:](.*)$/i", $event->term, $matches)) { + if(preg_match("/^pool[=|:]([^:]*|lastcreated):?([0-9]*)$/i", $event->term, $matches)) { global $user; $poolTag = (string) str_replace("_", " ", $matches[1]); $pool = null; - if(ctype_digit($poolTag)){ //If only digits, assume PoolID + if($poolTag == 'lastcreated'){ + $pool = $this->get_last_userpool($user->id); + } + elseif(ctype_digit($poolTag)){ //If only digits, assume PoolID $pool = $this->get_single_pool($poolTag); }else{ //assume PoolTitle $pool = $this->get_single_pool_from_title($poolTag); } + if($pool ? $this->have_permission($user, $pool) : FALSE){ - $this->add_post($pool['id'], $event->id, true); + $image_order = ($matches[2] ?: 0); + $this->add_post($pool['id'], $event->id, true, $image_order); } } @@ -486,6 +496,16 @@ class Pools extends Extension { return $database->get_all("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID)); } + /** + * Retrieve information about the last pool the given userID created + * @param int $userID + * @return array + */ + private function get_last_userpool(/*int*/ $userID){ + global $database; + return $database->get_row("SELECT * FROM pools WHERE user_id=:uid ORDER BY id DESC", array("uid"=>$userID)); + } + /** * HERE WE GET THE IMAGES FROM THE TAG ON IMPORT * @param int $pool_id @@ -496,7 +516,7 @@ class Pools extends Extension { $poolsMaxResults = $config->get_int("poolsMaxImportResults", 1000); $images = $images = Image::find_images(0, $poolsMaxResults, Tag::explode($_POST["pool_tag"])); - $this->theme->pool_result($page, $images, $pool_id); + $this->theme->pool_result($page, $images, $this->get_pool($pool_id)); } @@ -612,26 +632,49 @@ class Pools extends Extension { } /** - * Gets the next successive image from a pool, given a pool ID and an image ID. + * Gets the previous and next successive images from a pool, given a pool ID and an image ID. * * @param array $pool Array for the given pool * @param int $imageID Integer - * @return int Integer which is the next Image ID or NULL if none. + * @return array Array returning two elements (prev, next) in 1 dimension. Each returns ImageID or NULL if none. */ - private function get_next_post(/*array*/ $pool, /*int*/ $imageID) { + private function get_nav_posts(/*array*/ $pool, /*int*/ $imageID) { global $database; if (empty($pool) || empty($imageID)) return null; - $result = $database->get_one(" - SELECT image_id - FROM pool_images - WHERE pool_id=:pid - AND image_order > (SELECT image_order FROM pool_images WHERE pool_id=:pid AND image_id =:iid LIMIT 1 ) - ORDER BY image_order ASC LIMIT 1", + $result = $database->get_row(" + SELECT ( + SELECT image_id + FROM pool_images + WHERE pool_id = :pid + AND image_order < ( + SELECT image_order + FROM pool_images + WHERE pool_id = :pid + AND image_id = :iid + LIMIT 1 + ) + ORDER BY image_order DESC LIMIT 1 + ) AS prev, + ( + SELECT image_id + FROM pool_images + WHERE pool_id = :pid + AND image_order > ( + SELECT image_order + FROM pool_images + WHERE pool_id = :pid + AND image_id = :iid + LIMIT 1 + ) + ORDER BY image_order ASC LIMIT 1 + ) AS next + + LIMIT 1", array("pid"=>$pool['id'], "iid"=>$imageID) ); - + if (empty($result)) { // assume that we are at the end of the pool return null; @@ -875,15 +918,24 @@ class Pools extends Extension { * @param int $poolID * @param int $imageID * @param bool $history + * @param int $imageOrder */ - private function add_post(/*int*/ $poolID, /*int*/ $imageID, $history=false) { - global $database; + private function add_post(/*int*/ $poolID, /*int*/ $imageID, $history=false, $imageOrder=0) { + global $database, $config; if(!$this->check_post($poolID, $imageID)) { + if($config->get_bool("poolsAutoIncrementOrder") && $imageOrder === 0){ + $imageOrder = $database->get_one(" + SELECT CASE WHEN image_order IS NOT NULL THEN MAX(image_order) + 1 ELSE 0 END + FROM pool_images + WHERE pool_id = :pid", + array("pid"=>$poolID)); + } + $database->execute(" - INSERT INTO pool_images (pool_id, image_id) - VALUES (:pid, :iid)", - array("pid"=>$poolID, "iid"=>$imageID)); + INSERT INTO pool_images (pool_id, image_id, image_order) + VALUES (:pid, :iid, :ord)", + array("pid"=>$poolID, "iid"=>$imageID, "ord"=>$imageOrder)); } $database->execute("UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid) WHERE id=:pid", array("pid"=>$poolID)); diff --git a/ext/pools/style.css b/ext/pools/style.css new file mode 100644 index 00000000..f64c0e40 --- /dev/null +++ b/ext/pools/style.css @@ -0,0 +1,13 @@ +.pools_next_img { + display: block; + font-size: 77%; + text-align: right; + float: right; +} + +.pools_prev_img { + display: block; + font-size: 77%; + text-align: left; + float: left; +} diff --git a/ext/pools/theme.php b/ext/pools/theme.php index efa86f94..fd8bf756 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -3,9 +3,29 @@ class PoolsTheme extends Themelet { /** * Adds a block to the panel with information on the pool(s) the image is in. + * @param array Multidimensional array containing pool id, info & nav IDs. */ - public function pool_info($linksPools) { + public function pool_info(/*array*/ $navIDs) { global $page; + + $linksPools = array(); + foreach($navIDs as $poolID => $pool){ + $linksPools[] = "".html_escape($pool['info']['title']).""; + + if (array_key_exists('nav', $pool)){ + $navlinks = ""; + if (!empty($pool['nav']['prev'])) { + $navlinks .= 'Prev'; + } + if (!empty($pool['nav']['next'])) { + $navlinks .= 'Next'; + } + if(!empty($navlinks)){ + $linksPools[] = $navlinks; + } + } + } + if(count($linksPools) > 0) { $page->add_block(new Block("Pools", implode("
", $linksPools), "left")); } @@ -67,12 +87,6 @@ class PoolsTheme extends Themelet { $html .= ""; - $nav_html = ' - Index -
Create Pool -
Pool Changes - '; - $order_html = ' '; - $blockTitle = "Pools"; - $page->set_title(html_escape($blockTitle)); - $page->set_heading(html_escape($blockTitle)); - $page->add_block(new Block($blockTitle, $html, "main", 10)); - $page->add_block(new Block("Navigation", $nav_html, "left", 10)); + $this->display_top(null, "Pools"); $page->add_block(new Block("Order By", $order_html, "left", 15)); + $page->add_block(new Block("Pools", $html, "main", 10)); + + + $this->display_paginator($page, "pool/list", null, $pageNumber, $totalPages); } - /* * HERE WE DISPLAY THE NEW POOL COMPOSER */ @@ -108,9 +121,7 @@ class PoolsTheme extends Themelet { "; - $blockTitle = "Create Pool"; - $page->set_title(html_escape($blockTitle)); - $page->set_heading(html_escape($blockTitle)); + $this->display_top(null, "Create Pool"); $page->add_block(new Block("Create Pool", $create_html, "main", 20)); } @@ -124,6 +135,17 @@ class PoolsTheme extends Themelet { $page->set_title($heading); $page->set_heading($heading); + + $nav_html = 'Index'; + $poolnav_html = ' + Pool Index +
Create Pool +
Pool Changes + '; + + $page->add_block(new Block($nav_html, null, "left", 5)); + $page->add_block(new Block("Pool Navigation", $poolnav_html, "left", 10)); + if(count($pools) == 1) { $pool = $pools[0]; if($pool['public'] == "Y" || $user->is_admin()) {// IF THE POOL IS PUBLIC OR IS ADMIN SHOW EDIT PANEL @@ -135,34 +157,8 @@ class PoolsTheme extends Themelet { $bb = new BBCode(); $page->add_block(new Block(html_escape($pool['title']), $bb->format($pool['description']), "main", 10)); } - else { - $pool_info = ' - - - - - '; - - foreach($pools as $pool) { - $pool_info .= "". - "". - "". - ""; - - // this will make disasters if more than one pool comes in the parameter - if($pool['public'] == "Y" || $user->is_admin()) {// IF THE POOL IS PUBLIC OR IS ADMIN SHOW EDIT PANEL - if(!$user->is_anonymous()) {// IF THE USER IS REGISTERED AND LOGGED IN SHOW EDIT PANEL - $this->sidebar_options($page, $pool, $check_all); - } - } - } - - $pool_info .= "
TitleDescription
".html_escape($pool['title'])."".html_escape($pool['description'])."
"; - $page->add_block(new Block($heading, $pool_info, "main", 10)); - } } - /** * HERE WE DISPLAY THE POOL WITH TITLE DESCRIPTION AND IMAGES WITH PAGINATION. * @@ -182,14 +178,7 @@ class PoolsTheme extends Themelet { $pool_images .= "\n".$thumb_html."\n"; } - $nav_html = ' - Index -
Create Pool -
Pool Changes - '; - - $page->add_block(new Block("Navigation", $nav_html, "left", 10)); - $page->add_block(new Block("Viewing Posts", $pool_images, "main", 30)); + $page->add_block(new Block("Viewing Posts", $pool_images, "main", 30)); $this->display_paginator($page, "pool/view/".$pools[0]['id'], null, $pageNumber, $totalPages); } @@ -245,12 +234,7 @@ class PoolsTheme extends Themelet { @@ -258,7 +242,7 @@ class PoolsTheme extends Themelet { "; } - $page->add_block(new Block("Manage Pool", $editor, "left", 10)); + $page->add_block(new Block("Manage Pool", $editor, "left", 15)); } @@ -267,22 +251,14 @@ class PoolsTheme extends Themelet { * * @param Page $page * @param array $images - * @param int $pool_id + * @param array $pool */ - public function pool_result(Page $page, /*array*/ $images, /*int*/ $pool_id) { - // TODO: this could / should be done using jQuery + public function pool_result(Page $page, /*array*/ $images, /*array*/ $pool) { + + $this->display_top($pool, "Importing Posts", true); $pool_images = "