$_SESSION['selected_tags'] = split(',', $_GET['tags']);
}
break;
+ case 'export':
+ $this->tmpl->show("export.tpl");
+ return;
+ break;
+
}
$this->tmpl->assign('content_page', 'welcome.tpl');
} // get_photo_details
- public function getPhotoName($idx)
+ public function getPhotoName($idx, $limit = 0)
{
if($details = $this->get_photo_details($idx)) {
-
$name = $details['name'];
-
- if(strlen($name) > 15) {
- $name = substr($name, 0, 10) ."...". substr($name, -10);
+ if($limit != 0 && strlen($name) > $limit) {
+ $name = substr($name, 0, $limit-5) ."...". substr($name, -($limit-5));
}
-
return $name;
-
}
} // getPhotoName()
public function getSelectedTags()
{
+ $output = "";
foreach($this->avail_tags as $tag)
{
// return all selected tags
if(isset($_SESSION['selected_tags']) && in_array($tag, $_SESSION['selected_tags'])) {
- print "<a href=\"javascript:Tags('del', ". $tag .");\" class=\"tag\">". $this->tags[$tag] ."</a> ";
+ $output.= "<a href=\"javascript:Tags('del', ". $tag .");\" class=\"tag\">". $this->tags[$tag] ."</a>, ";
}
-
}
+ $output = substr($output, 0, strlen($output)-2);
+ print $output;
+
} // getSelectedTags()
public function addTag($tag)
}
elseif($_SESSION['tag_condition'] == 'and') {
+ if(count($_SESSION['selected_tags']) >= 32) {
+ print "A SQLite limit of 32 tables within a JOIN SELECT avoids to<br />\n";
+ print "evaluate your tag selection. Please remove some tags from your selection.\n";
+ return Array();
+ }
+
/* Join together a table looking like
pt1.photo_id pt1.tag_id pt2.photo_id pt2.tag_id ...
$img_width[$rows] = Array();
$img_id[$rows] = Array();
$img_name[$rows] = Array();
+ $img_title = Array();
for($i = $begin_with; $i < $end_with; $i++) {
$images[$rows][$cols] = $photos[$i];
$img_id[$rows][$cols] = $i;
- $img_name[$rows][$cols] = $this->getPhotoName($photos[$i]);
+ $img_name[$rows][$cols] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
+ $img_title[$rows][$cols] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
$thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->thumb_width ."_". $this->getMD5($photos[$i]);
if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '')
$this->tmpl->assign('searchfor', $_SESSION['searchfor']);
+ /* do we have to display the page selector ? */
if($this->cfg->rows_per_page != 0) {
/* calculate the page switchers */
if($end_with < $count)
$this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");");
- /* page selector */
$photo_per_page = $this->cfg->rows_per_page * $this->cfg->thumbs_per_row;
-
- /* until 6 pages we show the selector from 1-6
- everything large will be
- 1 ... 2 3 4 (5) 6 7 ... 9
- */
$last_page = ceil($count / $photo_per_page);
+ /* get the current selected page */
if($begin_with == 0) {
$current_page = 1;
- }
- else {
+ } else {
$current_page = 0;
for($i = $begin_with; $i >= 0; $i-=$photo_per_page) {
$current_page++;
else
$style = "";
- $page_select.= "<a href=\"javascript:showPhotoIndex(". (($i*$photo_per_page)-$photo_per_page) .");\"";
- if($style != "")
- $page_select.= $style;
- $page_select.= ">". $i ."</a> ";
+ $select = "<a href=\"javascript:showPhotoIndex(". (($i*$photo_per_page)-$photo_per_page) .");\"";
+ if($style != "")
+ $select.= $style;
+ $select.= ">". $i ."</a> ";
+
+ // until 9 pages we show the selector from 1-9
+ if($last_page <= 9) {
+ $page_select.= $select;
+ continue;
+ } else {
+ if($i == 1 /* first page */ ||
+ $i == $last_page /* last page */ ||
+ $i == $current_page /* current page */ ||
+ $i == ceil($last_page * 0.25) /* first quater */ ||
+ $i == ceil($last_page * 0.5) /* half */ ||
+ $i == ceil($last_page * 0.75) /* third quater */ ||
+ (in_array($i, array(1,2,3,4,5,6)) && $current_page <= 4) /* the first 6 */ ||
+ (in_array($i, array($last_page, $last_page-1, $last_page-2, $last_page-3, $last_page-4, $last_page-5)) && $current_page >= $last_page-4) /* the last 6 */ ||
+ $i == $current_page-3 || $i == $current_page-2 || $i == $current_page-1 /* three before */ ||
+ $i == $current_page+3 || $i == $current_page+2 || $i == $current_page+1 /* three after */) {
+
+ $page_select.= $select;
+ continue;
+
+ }
+ }
+ $page_select.= ".";
}
/* only show the page selector if we have more then one page */
$current_tags = substr($current_tags, 0, strlen($current_tags)-1);
}
- $extern_link = "http://". $_SERVER['SERVER_NAME'] ."/index.php?mode=showpi";
+ $extern_link = "index.php?mode=showpi";
if($current_tags != "") {
$extern_link.= "&tags=". $current_tags;
}
+ $export_link = "index.php?mode=export";
+
$this->tmpl->assign('extern_link', $extern_link);
+ $this->tmpl->assign('export_link', $export_link);
$this->tmpl->assign('count', $count);
$this->tmpl->assign('width', $this->cfg->thumb_width);
$this->tmpl->assign('images', $images);
$this->tmpl->assign('img_height', $img_height);
$this->tmpl->assign('img_id', $img_id);
$this->tmpl->assign('img_name', $img_name);
+ $this->tmpl->assign('img_title', $img_title);
$this->tmpl->assign('rows', $rows);
$this->tmpl->assign('columns', $this->cfg->thumbs_per_row);
} // get_calendar()
+ public function getExport($mode)
+ {
+ $pictures = $this->getPhotoSelection();
+
+ if(!isset($_SERVER['HTTPS'])) $protocol = "http";
+ else $protocol = "https";
+
+ $server_name = $_SERVER['SERVER_NAME'];
+
+ foreach($pictures as $picture) {
+
+ $orig_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->photo_width;
+ $thumb_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width;
+
+ switch($mode) {
+
+ case 'HTML':
+ // <a href="%pictureurl%"><img src="%thumbnailurl%" ></a>
+ print htmlspecialchars("<a href=\"". $orig_url ."\"><img src=\"". $thumb_url ."\" /></a>") ."<br />\n";
+ break;
+
+ case 'MoinMoin':
+ // [%pictureurl% %thumbnailurl%]
+ print htmlspecialchars("[$orig_url $thumb_url]") ."<br />\n";
+ break;
+ }
+
+ }
+
+ } // getExport()
+
}
?>