<?

/*

Pixelpost version 1.7.1
Pixelpost www: http://www.pixelpost.org/

PPEndLoop Addon
made by Erik J. Barzeski 
http://nslog.com/plugins/ppendloop

2008-09-24 version 1.0.0 - modified from ImageCycle (http://www.pixelpost.org/extend/addons/imagecycle/)
2008-11-25 version 1.0.1 - Renamed, posted to nslog.com/plugins
2008-11-25 version 1.1 - Added thumbnail and plain URL generation
================================================================

*/

$addon_name "PPEndLoop";
$addon_description "This addon stops the image cycle when a user reaches the first or last image.<br />
You can use these new tags in your templates:<br /><br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_PREV_LINK&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_PREV_THUMB&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_PREV_TITLE&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_PREV_URL&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_NEXT_LINK&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_NEXT_THUMB&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_NEXT_TITLE&gt;<br />
<b>Tag: </b>&lt;IMAGE_ENDLOOP_NEXT_URL&gt;<br />
<br />Tested with Pixelpost version 1.7.1"
;
$addon_version "1.1";



//---------------------------------------------------------------------------
// if no previous image in index.php was found - get newest image
if($previous_row['id'] == ""
    
$prevlink FALSE;
else
    
$prevlink TRUE;

//---------------------------------------------------------------------------
//this section is copied from index.php
$image_previous_name =    $previous_row['image'];
$image_previous_id     =    $previous_row['id'];

if(
$language_abr == $default_language_abr) {

    
$image_previous_title pullout($previous_row['headline']);
}else{

    
$image_previous_title pullout($previous_row['alt_headline']);
}

$image_previous_datetime =     $previous_row['datetime'];
$image_previous_link         =     "<a href=\"$showprefix$image_previous_id\" title=\"$image_previous_title\">$lang_previous</a>";

if(!empty(
$image_previous_name)) { list($local_width,$local_height,$type,$attr) = getimagesize(ltrim($cfgrow['thumbnailpath'], "./")."thumb_".$image_previous_name); }

$image_previous_thumbnail "<a href=\"$showprefix$image_previous_id\" title=\"$image_previous_title\"><img src=\"".ltrim($cfgrow['thumbnailpath'], "./")."thumb_".$image_previous_name."\" width=\"$local_width\" height=\"$local_height\" alt=\"$image_previous_title\" title=\"$image_previous_title\" /></a>";

$image_previous_url "$showprefix$image_previous_id";

if(
$image_previous_id == "") {
    
$image_previous_id                =    $image_id;
    
$image_previous_title         =    "$lang_no_previous";
    
$image_previous_link            =    "";
    
$image_previous_thumbnail =    "";
}





//---------------------------------------------------------------------------
// if no next image in index.php was found - get oldest image
if($next_row['id'] == "")     
    
$nextlink FALSE;
else
    
$nextlink TRUE;


//---------------------------------------------------------------------------
//this section is copied from index.php

$image_next_name =    $next_row['image'];
$image_next_id     =    $next_row['id'];

if(
$language_abr == $default_language_abr) {

    
$image_next_title pullout($next_row['headline']);
}else{

    
$image_next_title pullout($next_row['alt_headline']);
}

$image_next_datetime =    $next_row['datetime'];
$image_next_link         =    "<a href=\"$showprefix$image_next_id\" title=\"$image_next_title\">$lang_next</a>";

if(!empty(
$image_next_name)) { list($local_width,$local_height,$type,$attr) = getimagesize(ltrim($cfgrow['thumbnailpath'], "./")."thumb_".$image_next_name); }

$image_next_thumbnail "<a href=\"$showprefix$image_next_id\" title=\"$image_next_title\"><img src=\"".ltrim($cfgrow['thumbnailpath'], "./")."thumb_".$image_next_name."\" alt=\"$image_next_title\" width=\"$local_width\" height=\"$local_height\" title=\"$image_next_title\" /></a>";

$image_next_url "$showprefix$image_next_id";

if(
$image_next_id == "")
{
    
$image_next_id $image_id;
    
$image_next_title "$lang_no_next";
    
$image_next_link "";
    
$image_next_thumbnail "";
}



if(
$prevlink)
{
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_LINK>"$image_previous_link$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_THUMB>"$image_previous_thumbnail$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_TITLE>"$image_previous_title$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_URL>"$image_previous_url$tpl);
}
else
{
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_LINK>"$lang_previous$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_THUMB>"""$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_TITLE>"$image_previous_title$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_PREV_URL>"""$tpl);
}

if(
$nextlink)
{
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_LINK>"$image_next_link$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_THUMB>"$image_next_thumbnail$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_TITLE>"$image_next_title$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_URL>"$image_next_url$tpl);
}
else
{
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_LINK>"$lang_next$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_THUMB>"""$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_TITLE>"$image_next_title$tpl);
    
$tpl ereg_replace("<IMAGE_ENDLOOP_NEXT_URL>"""$tpl);
}
?>