[SOLVED] XHTML Validation & Kissgallery

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Post Reply
Cowboy
Posts: 10
Joined: Tue Oct 14, 2008 9:02 pm
Location: Freiburg

[SOLVED] XHTML Validation & Kissgallery

Post by Cowboy » Tue Nov 04, 2008 8:22 pm

UPDATE 2008-11-08: For anyone that's interested in an XHTML valid kissgallery (0.4) plugin. Here is the code for a XHTML valid index.php file.
Simply copy it into an empty php-file. Save it as index.php and replace the existing index.php in the kissgallery folder on your server.

Code: Select all

<?php
/*

/* #########################################################################################
/* #### index.php file partly recoded to be XHTML valid by Markus, markus-hilpert@gmx.de ###
/* ##################################### November, 2008 ####################################
/* #########################################################################################

CMSimple kissGallery plugin 
- 0.3 Fixed:
		* Alignment in the css-file fixed
      New:
		* Options/Config show_album_desc: top/bottom/none where to show the album description
- 0.2 First public release
		* Code cleanup
- 0.1 First internal release

kissGallery($func,$sel)
	$func	1 - show all photos
			2 - show group of photos, $sel contains the group id (album)
*/
function kissGallery($func,$sel) {
 	GLOBAL $plugin_cf,$plugin_tx, $sn, $su, $pth , $hjs;

	if (!defined('KISSLIBV')) require dirname(__FILE__)."/kiss.php";
	
	$fngroup=dirname(__FILE__).'/data/album.txt';
	$fnfile=dirname(__FILE__).'/data/photo.txt';
	$plugin=basename(dirname(__FILE__),"/");
    $filepath=$pth['folder']['plugins'].$plugin."/photos";

	if (!isset($hjs)) { $hjs=''; }	
	$hjs .= "\n".'<link rel="stylesheet" type="text/css" href="'.$pth['folder']['plugins'].$plugin.'/slimbox/slimbox.css" />';
	$hjs .= "\n".'<script type="text/javascript" src="'.$pth['folder']['plugins'].$plugin.'/slimbox/mootools_11.js"></script>';
	$hjs .= "\n".'<script type="text/javascript" src="'.$pth['folder']['plugins'].$plugin.'/slimbox/slimbox.js"></script>';

	if (!isset($func)) $func=1;
	if (!isset($sel)) $sel=1;

	$groups=kissRFile($fngroup);
	$files=kissRFile($fnfile);
	
	if ($func==2) {
		$tarr=array();
		foreach ($files as $num => $rec) {
			if ($rec[2]==$sel) {
				$tarr[]=$rec;
			}
		}
		$files=$tarr;
	}
	$txt='<div class="kissgallery">';
	$noofcols=$plugin_cf['kissgallery']['indexpage_no_of_cols'];

	if ($func==2) {
		foreach ($groups as $gnum => $grec) {
			if ($grec[0]==$sel) {
				$gname=$grec[2];
				$gdesc=$grec[3];
			}
		}
		if (kissIsTrue($plugin_cf['kissgallery']['show_album_name'])) {
			$txt.='<div class="kissgallery_name">'.$gname.'</div>';
		}
		if (strtolower($plugin_cf['kissgallery']['show_album_desc'])=='top') {
			$txt.='<div class="kissgallery_desc">'.$gdesc.'</div>';
		}
	}

	if (sizeof($files)>0) {
		$txt.='<table class="kissgallery_index"><tr>';
		foreach ($files as $num => $rec) {
			if ((($num % $noofcols) == 0)&&($num > 0)) $txt.='</tr><tr>';
// record : array($id,$order,$gid,$file_name,$file_datetime,$file_type,$desc);
			$id=$rec[0];
			$gid=$rec[2];
			$file_name=$rec[3];
			$file_datetime=date($plugin_cf['kissgallery']['datetime_format'],$rec[4]);
			$file_type=$rec[5];
			$desc=$rec[6];
			$txt.='<td class="c kissgallery_photo">';
			$txt.='<a href="'.$filepath.'/'.$id.'.jpg" rel="lightbox[testgr]" title="'.$desc.'"><img src="'.$filepath.'/'.$id.'t.jpg" alt=""/></a>';
			$txt.='<div style="display:none">'.$desc.'</div>';
			$txt.='</td>';
		}
		$num=$num+1;
		if (($num % $noofcols)>0) {
			for ($j=1;$j<=($noofcols-($num % $noofcols));$j++) {
				$txt.='<td class="c kissgallery_photo">&nbsp;</td>';
			}
		}
		$txt.='</tr></table>';
	} else {
		$txt.=$plugin_tx['kissgallery']['no_files'];
	}
	if ($func==2) {
		if (strtolower($plugin_cf['kissgallery']['show_album_desc'])=='bottom') {
			$txt.='<div class="kissgallery_desc">'.$gdesc.'</div>';
		}
	}
	$txt.='</div>';
	
	return $txt;
}
?>


___________________________________
Hi Folks,

I do have another problem with the kissgallery. I have setup my page to be xhtml valid. So far so good. I got basically all errors covered. There is just only one error left.

This error is based on the kissgallery 0.4 I have installed. Initially I had three kissgallery error. Two of them I got covered by doing small modifications to the kissgallery index.php

Here is the description of the remaining error:
Validation Output: 1 Error

1. Error Line 83, Column 66: end tag for "tr" which is not finished .

…le class="kissgallery_index"><tr></tr><tr><td class="c kissgallery_photo"><a

Most likely, you nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>
Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.
And here is the complete code of Line 83:
<div class="kissgallery"><table class="kissgallery_index"><tr></tr><tr><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/1.jpg" rel="lightbox[testgr]" title="Accessoire"><img src="./plugins/kissgallery/photos/1t.jpg" alt=""/></a><div style="display:none">Accessoire</div></td><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/2.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/2t.jpg" alt=""/></a><div style="display:none"></div></td><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/3.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/3t.jpg" alt=""/></a><div style="display:none"></div></td></tr><tr><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/4.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/4t.jpg" alt=""/></a><div style="display:none"></div></td><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/11.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/11t.jpg" alt=""/></a><div style="display:none"></div></td><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/13.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/13t.jpg" alt=""/></a><div style="display:none"></div></td></tr><tr><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/14.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/14t.jpg" alt=""/></a><div style="display:none"></div></td><td class="c kissgallery_photo"><a href="./plugins/kissgallery/photos/16.jpg" rel="lightbox[testgr]" title=""><img src="./plugins/kissgallery/photos/16t.jpg" alt=""/></a><div style="display:none"></div></td><td class="c kissgallery_photo">&nbsp;</td></tr></table></div> <h4>Untermenü</h4><ul class="submenu"><li class="doc"><a href="/?Ausstellung:Bildergallerie">Bildergallerie</a></li></ul> </div>
Anyone an idea what to do?

Thanks
Cowboy
Last edited by Cowboy on Thu Nov 06, 2008 8:35 am, edited 2 times in total.

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: XHTML Validation & Kissgallery

Post by Holger » Wed Nov 05, 2008 7:02 am

What's the DTD of the page?
A table row without content like "<tr></tr>" is invalid markup.
It's the same like an empty "<p></p>".

Holger

Cowboy
Posts: 10
Joined: Tue Oct 14, 2008 9:02 pm
Location: Freiburg

Re: XHTML Validation & Kissgallery

Post by Cowboy » Wed Nov 05, 2008 1:04 pm

Hi Holger,

thanks for the hints.
Here is the DTD I've used:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de-DE">

You are stating that a table row without content like "<tr></tr>" is invalid markup. Ok, but how do I get rid of that.

Here is the section of the kissgallery index.php that is producing "<tr></tr>".
if (sizeof($files)>0) {
$txt.='<table class="kissgallery_index"><tr>';
foreach ($files as $num => $rec) {
if (($num % $noofcols) == 0) $txt.='</tr><tr>';
// record : array($id,$order,$gid,$file_name,$file_datetime,$file_type,$desc);
$id=$rec[0];
$gid=$rec[2];
$file_name=$rec[3];
$file_datetime=date($plugin_cf['kissgallery']['datetime_format'],$rec[4]);
$file_type=$rec[5];
$desc=$rec[6];
$txt.='<td class="c kissgallery_photo">';
$txt.='<a href="'.$filepath.'/'.$id.'.jpg" rel="lightbox[testgr]" title="'.$desc.'"><img src="'.$filepath.'/'.$id.'t.jpg" alt=""/></a>';
$txt.='<div style="display:none">'.$desc.'</div>';
$txt.='</td>';
}
$num=$num+1;
if (($num % $noofcols)>0) {
for ($j=1;$j<=($noofcols-($num % $noofcols));$j++) {
$txt.='<td class="c kissgallery_photo">&nbsp;</td>';
}
}
$txt.='</tr></table>';
} else {
$txt.=$plugin_tx['kissgallery']['no_files'];
}
if ($func==2) {
if (strtolower($plugin_cf['kissgallery']['show_album_desc'])=='bottom') {
$txt.='<div class="kissgallery_desc">'.$gdesc.'</div>';
}
}
$txt.='</div>';

return $txt;
}
?>
I am not an expert about html / xhtml coding.

Could you please help me out? How do I have to modify the code?
Thanks.

Cowboy.

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: XHTML Validation & Kissgallery

Post by Holger » Wed Nov 05, 2008 6:46 pm

Hmm, maybe this can help:

replace the line

Code: Select all

if (($num % $noofcols) == 0) $txt.='</tr><tr>';
with:

Code: Select all

if ((($num % $noofcols) == 0)&&($num > 0)) $txt.='</tr><tr>';
But I haven't the time to test it at the moment :?

Holger

Cowboy
Posts: 10
Joined: Tue Oct 14, 2008 9:02 pm
Location: Freiburg

Re: XHTML Validation & Kissgallery

Post by Cowboy » Thu Nov 06, 2008 8:13 am

Hi Holger,

you are the man. I changed the code as you suggested and guess what ... it worked out perfect.

Thanks.
Cowboy

Post Reply