OK, I had a look into this and first attempted to convert this into a plugin, but I figured out that the Java code used is pretty badly done. Therefor, I have come up with a hack that is not very cleverly done itself and therefor fits to the code of the jigsaw puzzle itself.
This is what you do:
1) download the attached mod zip-file and unzip the contents into a temporary folder, preserving the structure within the zip.
2)Upload the content of the tempory folder into the root of your coppermine-driven gallery
3) Edit your custom theme (themes/yourtheme/theme.php) with a plain text editor and find the sections $template_img_navbar =
andfunction theme_html_img_nav_menu()
and edit as suggested below. If your custom theme doesn't contain those sections, copy them first from themes/sample/theme.php and add them into a new line before ?>
of the file themes/yourtheme/theme.php
Then find <td align="center" valign="middle" class="navmenu" width="100%">
{PIC_POS}
</td>
and add after it into a new line <td align="center" valign="middle" class="navmenu" width="100%">
<a href="{PUZZLE_TGT}">Puzzle</a>
</td>
Next, find '{LOCATION}' => $location,
and add after it (into a line of it's own) '{PUZZLE_TGT}' => "puzzle.php?album=$album$cat_link&pid=$pid&pos=$pos",
As I suggested, the underlying Java code is quite badly written: it requires files to be moved around and can not cope with just the position of the files, so I had to come up with a basic garbage collection routine in puzzle.php (that file resides in the zip file).
You'll notice that there are some hard-coded language strings in that file that you might want to edit, and you might want to change the parameters of the applet call in puzzle.php. In my opinion this piece of code should not be used, and it might act up easily. Use at your own risk.
For clarity here's the edited code that needs to go into themes/yourtheme/theme.php:// HTML template for the image navigation bar
$template_img_navbar = <<<EOT
<tr>
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{THUMB_TGT}" class="navmenu_pic" title="{THUMB_TITLE}"><img src="{LOCATION}images/thumbnails.gif" align="middle" border="0" alt="{THUMB_TITLE}" /></a>
</td>
<td align="center" valign="middle" class="navmenu" width="48">
<a href="javascript:;" class="navmenu_pic" onclick="blocking('picinfo','yes', 'block'); return false;" title="{PIC_INFO_TITLE}"><img src="{LOCATION}images/info.gif" border="0" align="middle" alt="{PIC_INFO_TITLE}" /></a>
</td>
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{SLIDESHOW_TGT}" class="navmenu_pic" title="{SLIDESHOW_TITLE}"><img src="{LOCATION}images/slideshow.gif" border="0" align="middle" alt="{SLIDESHOW_TITLE}" /></a>
</td>
<td align="center" valign="middle" class="navmenu" width="100%">
{PIC_POS}
</td>
<td align="center" valign="middle" class="navmenu" width="100%">
<a href="{PUZZLE_TGT}">Puzzle</a>
</td>
<!-- BEGIN report_file_button -->
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{REPORT_TGT}" class="navmenu_pic" title="{REPORT_TITLE}"><img src="{LOCATION}images/report.gif" border="0" align="middle" alt="{REPORT_TITLE}" /></a>
</td>
<!-- END report_file_button -->
<!-- BEGIN ecard_button -->
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{ECARD_TGT}" class="navmenu_pic" title="{ECARD_TITLE}"><img src="{LOCATION}images/ecard.gif" border="0" align="middle" alt="{ECARD_TITLE}" /></a>
</td>
<!-- END ecard_button -->
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{PREV_TGT}" class="navmenu_pic" title="{PREV_TITLE}"><img src="{LOCATION}images/prev.gif" border="0" align="middle" alt="{PREV_TITLE}" /></a>
</td>
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{NEXT_TGT}" class="navmenu_pic" title="{NEXT_TITLE}"><img src="{LOCATION}images/next.gif" border="0" align="middle" alt="{NEXT_TITLE}" /></a>
</td>
</tr>
EOT;
function theme_html_img_nav_menu()
{
global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,
global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;
$cat_link = is_numeric($album) ? '' : '&cat=' . $cat;
$uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&uid=' . $_GET['uid'] : '';
$human_pos = $pos + 1;
$page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
$pid = $CURRENT_PIC_DATA['pid'];
$linebreak = "\r\n";
$start = 0;
$start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$start";
$start_title = $lang_img_nav_bar['go_album_start'];
$meta_nav .= $linebreak . "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />";
$end = $pic_count - 1;
$end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$end";
$end_title = $lang_img_nav_bar['go_album_end'];
$meta_nav .= $linebreak . "<link rel=\"last\" href=\"$end_tgt\" title=\"$end_title\" />";
if ($pos > 0) {
$prev = $pos - 1;
$prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$prev$uid_link";
$prev_title = $lang_img_nav_bar['prev_title'];
$meta_nav .= $linebreak . "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />";
} else {
$prev_tgt = "javascript:;";
$prev_title = "";
}
if ($pos < ($pic_count -1)) {
$next = $pos + 1;
$next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&pos=$next$uid_link";
$next_title = $lang_img_nav_bar['next_title'];
$meta_nav .= $linebreak . "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>";
} else {
$next_tgt = "javascript:;";
$next_title = "";
}
if (USER_CAN_SEND_ECARDS) {
$ecard_tgt = "ecard.php?album=$album$cat_link&pid=$pid&pos=$pos";
$ecard_title = $lang_img_nav_bar['ecard_title'];
} else {
template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
}
//report to moderator buttons
$report_tgt = '';
if (($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS)) {
$report_tgt = "report_file.php?album=$album$cat_link&pid=$pid&pos=$pos";
} else { // remove button if report toggle is off
template_extract_block($template_img_navbar, 'report_file_button');
}
$thumb_tgt = "thumbnails.php?album=$album$cat_link&page=$page$uid_link";
$meta_nav .= $linebreak . "<link rel=\"up\" href=\"$thumb_tgt\" title=\"".$lang_img_nav_bar['thumb_title']."\"/>";
$slideshow_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link$uid_link&pid=$pid&slideshow=".$CONFIG['slideshow_interval'];
$pic_pos = sprintf($lang_img_nav_bar['pic_pos'], $human_pos, $pic_count);
if (defined('THEME_HAS_NAVBAR_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$params = array('{THUMB_TGT}' => $thumb_tgt,
'{THUMB_TITLE}' => $lang_img_nav_bar['thumb_title'],
'{PIC_INFO_TITLE}' => $lang_img_nav_bar['pic_info_title'],
'{SLIDESHOW_TGT}' => $slideshow_tgt,
'{SLIDESHOW_TITLE}' => $lang_img_nav_bar['slideshow_title'],
'{PIC_POS}' => $pic_pos,
'{ECARD_TGT}' => $ecard_tgt,
'{ECARD_TITLE}' => $ecard_title,
'{PREV_TGT}' => $prev_tgt,
'{PREV_TITLE}' => $prev_title,
'{NEXT_TGT}' => $next_tgt,
'{NEXT_TITLE}' => $next_title,
'{PREV_IMAGE}' => ($lang_text_dir=='ltr') ? 'prev' : 'next',
'{NEXT_IMAGE}' => ($lang_text_dir=='ltr') ? 'next' : 'prev',
'{REPORT_TGT}' => $report_tgt,
'{REPORT_TITLE}' => $lang_img_nav_bar['report_title'],
'{LOCATION}' => $location,
'{PUZZLE_TGT}' => "puzzle.php?album=$album$cat_link&pid=$pid&pos=$pos",
);
return template_eval($template_img_navbar, $params);
}
Additionally, here's the code that I have come up with for puzzle.php:<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$pid = (int)$_GET['pid'];
$pos = (int)$_GET['pos'];
$album = (int)$_GET['album'];
$solved = (int)$_GET['solved'];
// Get picture thumbnail url
$result = cpg_db_query("SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'");
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
$row = mysql_fetch_array($result);
$normal_pic_url = get_pic_url($row, 'normal');
if (file_exists($normal_pic_url) != TRUE) {
$normal_pic_url = get_pic_url($row, 'fullsize');
}
$pic_title = $row['title'];
$pic_caption = bb_decode($row['caption']);
if (!is_image($row['filename'])) cpg_die(ERROR, $lang_ecard_php['error_not_image'], __FILE__, __LINE__);
copy($normal_pic_url, 'pictures/'.$CONFIG['normal_pfx'].$row['filename']);
// Gargabe collection
$handle=opendir('pictures');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$Diff = (time() - filectime("$path/$file"))/60/60/24;
if ($Diff > 1) unlink("$path/$file");
}
}
closedir($handle);
$dimension = $CONFIG['picture_width'] + 200;
pageheader('Puzzle');
echo <<< EOT
<h1>Puzzle</h1>
EOT;
if ($solved != 1) {
echo <<< EOT
<applet code="jigsaw.class" width="100%" height="{$dimension}">
<param name="imagename" value="{$CONFIG['normal_pfx']}{$row['filename']}">
<param name="picturelist" value="{$CONFIG['normal_pfx']}{$row['filename']}">
<param name="npieceshor" value="6">
<param name="npiecesver" value="4">
<param name="percent" value="50">
<param name="picture" value="{$CONFIG['normal_pfx']}{$row['filename']}">
<param name="faded" value="no">
<param name="popup" value="no">
<param name="rotations" value="no">
<param name="resize" value="no">
<param name="optionswindow" value="no">
<param name="newpage" value="puzzle.php?solved=1&album=$album&pid=$pid&pos=$pos">
</applet>
EOT;
} else {
echo <<< EOT
Congratulaions! You have solved the puzzle.<br />
EOT;
}
echo <<< EOT
<a href="displayimage.php?album=$album$cat_link&pid=$pid&pos=$pos">Return to intermediate image view</a>
EOT;
pagefooter();
?>
As this is not related to plugins I have moved this thread accordingly.