gallery based on rss from picassaweb.google.com

Gesperrt
borand
Beiträge: 2
Registriert: Di 24. Feb 2009, 21:17
Kontaktdaten:

gallery based on rss from picassaweb.google.com

Beitrag von borand »

i dont know maybe somebody need it
this is just first version (made on c488, not tested with other, without comments/explanations/unsets etc)
maybe i'll try to update it asap if so :)

picasa module for picasaweb.google.com (updated)
module using class XML from http://keithdevens.com/software/phpxml#source

http://andrzej.borowicz.info/files/cont ... Google.zip


INPUT

Code: Alles auswählen

?><?php
/**
* $RCSfile$
*
* Description: picassa gallery config
*
* @version 0.0.1
* @author A.Borowicz
* @copyright andrzej.borowicz.info
*
* {@internal
* created	2009-03-26
* modified	2009-03-26
*
* }}
*
* $Id$
*/

$pGal['link'] = "CMS_VALUE[0]";
$pGal['regenerate'] = "CMS_VALUE[4]";
$pGal['thumbSize'] = "CMS_VALUE[2]";
$pGal['idart'] = $idart;

$pGal['linkMD5'] = md5( $pGal['link'] );
$pGal['file'] = $cfgClient[$client]['path']['frontend'].'cache/picasa_'.$pGal['linkMD5'];

if (!(function_exists('put_file_content'))) {

	function put_file_content( $fileName, $output )
	{	  
	  $f = fopen($fileName, 'w');
	  fwrite($f, $output);
	  fclose($f);
	}
}

$deBugLog = array();
	
function deB($str){
	global $deBugLog;
	$deBugLog[] = date("Y-m-d H:i:s").' - '.$str;
}

//include ('picasaIn.php'); cInclude("frontend", "picasaIn.php");

function regenerateFile($f,$l, $th=false){
	deB( 'regenerate start = '.$f.' '.$l );
	global $deBugLog;
	@unlink( $f );	
	$outPut = file( $l );
	$outData = implode("", $outPut );
	unset($outPut);
	cInclude("frontend", "includes/class.xml2download.php");
	//include("includes/class.xml2download.php");	
	$xmlData = XML_unserialize($outData);
	unset($outData);
	
	$cAr = $xmlData[rss]['channel']['item'];
	
	$cnt = $xmlData['rss']['channel']['openSearch:totalResults'];
	if( $cnt > 1 ){
		if ($thumbSize) {
			$thumbSize = $th.' attr';
		} else {
			$thumbSize = '0 attr';
		}
		for ( $_i = 0; $_i < $cnt; $_i++ ){
				$outAr[$_i]['im'] = $cAr[$_i]['media:group']['media:content attr']['url'];
				$outAr[$_i]['th'] = $cAr[$_i]['media:group']['media:thumbnail'][$thumbSize]['url'];
				$outAr[$_i]['wh'] = ' style="width: '.$cAr[$_i]['media:group']['media:thumbnail'][$thumbSize]['width'].'px; height: '.$cAr[$_i]['media:group']['media:thumbnail'][$thumbSize]['height'].'px;" ';
		}
		unset($cAr);
		put_file_content($f,  serialize($outAr));
		return $outArr;
	} elseif( $cnt == 1 ) {
		$thumbSize = '1 attr';
		$outAr[0]['im'] = $cAr['media:group']['media:content attr']['url'];
		$outAr[0]['th'] = $cAr['media:group']['media:thumbnail'][$thumbSize]['url'];
		$outAr[0]['wh'] = ' style="width: '.$cAr['media:group']['media:thumbnail'][$thumbSize]['width'].'px; height: '.$cAr['media:group']['media:thumbnail'][$thumbSize]['height'].'px;" ';
		put_file_content($f,  serialize($outAr));
		return $outArr;
	} else {
		return 'noItems';	
	}

}


if( strlen($pGal['link']) > 3 ){
 $p = regenerateFile($pGal['file'], $pGal['link']);
}
//echo '<pre>'; print_r($p); echo '</pre>';
//echo '<pre>'; print_r($cfgClient); echo '</pre>';
//$cfgClient[$client]['path']['frontend']

?>
<table border="0">
	<tr>
		<td><?php echo mi18n("picasaweb.google.com RSS link");?>
<a href="http://picasaweb.google.com/data/feed/base/user/maludan/albumid/5045643446315308161?kind=photo&alt=rss&hl=en_US">
<?php echo mi18n("example RSS");?> </a></td>
		<td><input type="text" name="<?php echo "CMS_VAR[0]";?>" value="<?php echo "CMS_VALUE[0]"; ?>" style="width: 400px;">
	</tr>
	<tr>
		<td><?php echo mi18n("last regenerate");?>: <?php echo "CMS_VALUE[4]"; ?></td>
		<td>
<?php 

//$sSubmitLink = '<a href="javascript:if (document.tplcfgform.send) {document.tplcfgform.send.value = 0}; document.tplcfgform.submit();"><img src="images/submit.gif" /></a>';

$regenerate =  "CMS_VALUE[1]";

if($regenerate == 1){
?>

<input type="hidden" name="<?php echo "CMS_VAR[4]";?>" value="<?php echo time(); ?>" >
<input type="hidden" name="<?php echo "CMS_VAR[1]";?>" value="0" >

<?php
} else {
?>

<input type="hidden" name="<?php echo "CMS_VAR[4]";?>" value="<?php echo "CMS_VALUE[4]"; ?>" >
<input type="hidden" name="<?php echo "CMS_VAR[1]";?>" value="1"; >

<?php
} 
?>
		</td>
	</tr>
<?php
	switch("CMS_VALUE[2]"){
		default:
		case '1':
				$s1 = ' checked  ="checked" ';
			break;
		case '2':
				$s2 = ' checked  ="checked" ';
			break;
		case '3':
				$s3 = ' checked  ="checked" ';
			break;
	}
?>
	<tr>
		<td><?php echo mi18n("thumb size");?> </td>
		<td>
			<input type="radio" name="<?php echo "CMS_VAR[2]";?>" value="1" <?php echo $s1; ?> /> 72x48 
			<br />
			<input type="radio" name="<?php echo "CMS_VAR[2]";?>" value="2" <?php echo $s2; ?> /> 144x96 
			<br />
			<input type="radio" name="<?php echo "CMS_VAR[2]";?>" value="3" <?php echo $s3; ?> /> 288x192
			<br />
		</td>
	</tr>
</table>

<?php
OUTPUT

Code: Alles auswählen

<?php
/**
* $RCSfile$
*
* Description: Picassa galery
*
* @version 0.0.1
* @author A.Borowicz
* @copyright andrzej.borowicz.info
*
* {@internal
* created	2009-03-26
* modified	2009-03-26
*
* }}
*
* $Id$
*/


$pGal['link'] = "CMS_VALUE[0]";
$pGal['regenerate'] = "CMS_VALUE[4]";
$pGal['thumbSize'] = "CMS_VALUE[2]";
$pGal['idart'] = $idart;

//include('picasa.php');

?>
<?php

/*


$pGal['link'] = "CMS_VALUE[0]";
$pGal['regenerate'] = "CMS_VALUE[4]";
$pGal['thumbSize'] = "CMS_VALUE[2]";
$pGal['idart'] = $idart;

*/

$pGal['linkMD5'] = md5( $pGal['link'] );
$pGal['file'] = 'cache/picasa_'.$pGal['linkMD5'];

if (!(function_exists('put_file_content'))) {

	function put_file_content( $fileName, $output )
	{	  
	  $f = fopen($fileName, 'w');
	  fwrite($f, $output);
	  fclose($f);
	}
}

function deB($str){
	global $deBugLog;
	$deBugLog[] = date("Y-m-d H:i:s").' - '.$str;
}

function regenerateFile($f,$l, $th=false){
	global $deBugLog;
	@unlink( $f );	
	$outPut = file( $l );
	$outData = implode("", $outPut );
	unset($outPut);
	cInclude("frontend", "includes/class.xml2download.php");
	//include("includes/class.xml2download.php");	
	$xmlData = XML_unserialize($outData);
	unset($outData);
	
	$cAr = $xmlData[rss]['channel']['item'];
	
	$cnt = $xmlData['rss']['channel']['openSearch:totalResults'];
	if( $cnt > 1 ){
		if ($thumbSize) {
			$thumbSize = $th.' attr';
		} else {
			$thumbSize = '0 attr';
		}
		for ( $_i = 0; $_i < $cnt; $_i++ ){
				$outAr[$_i]['im'] = $cAr[$_i]['media:group']['media:content attr']['url'];
				$outAr[$_i]['th'] = $cAr[$_i]['media:group']['media:thumbnail'][$thumbSize]['url'];
				$outAr[$_i]['wh'] = ' style="width: '.$cAr[$_i]['media:group']['media:thumbnail'][$thumbSize]['width'].'px; height: '.$cAr[$_i]['media:group']['media:thumbnail'][$thumbSize]['height'].'px;" ';
		}
		unset($cAr);
		put_file_content($f,  serialize($outAr));
		return $outArr;
	} elseif( $cnt == 1 ) {
		$thumbSize = '1 attr';
		$outAr[0]['im'] = $cAr['media:group']['media:content attr']['url'];
		$outAr[0]['th'] = $cAr['media:group']['media:thumbnail'][$thumbSize]['url'];
		$outAr[0]['wh'] = ' style="width: '.$cAr['media:group']['media:thumbnail'][$thumbSize]['width'].'px; height: '.$cAr['media:group']['media:thumbnail'][$thumbSize]['height'].'px;" ';
		put_file_content($f,  serialize($outAr));
		return $outArr;
	} else {
		return 'noItems';	
	}

}

function showGal($ar){
	global $deBugLog;
	
	if(is_array($ar)){
		$oGall = '';
		$oGall.= '
		<div class="picassaGalleryImg">';

			foreach($ar AS $k => $v){
				$oGall.= '
	<a href="'.$v['im'].'" class="thickbox" rel="gallery-plants"><img src="'.$v['th'].'" '.$v['wh'].' class="picassaGallerySmall" /></a>';
	//<a href="'.$_SERVER['PHP_SELF'].'?idart='.$pGal['idart'].'&picasaWebID='.$k.'"><img src="'.$o[$k]['th'].'" '.$o[$k]['wh'].' class="picassaGallerySmall" /></a>';
			}
		$oGall.= '
			<br />
		</div>';

		return $oGall;
	} else {
		return ' no items try to reload ';
	}
}

if( strlen($pGal['link']) > 3 ){
	deB( 'link exist - $pGal[link]: '.$pGal['link'] );
	if (file_exists($pGal['file'])){
		
		deB( 'file exist - $pGal[file]'.$pGal['file'] );
		$outPut = file( $pGal['file'] );
		$outData = implode("", $outPut );
		unset($outPut);
		
		$p = unserialize($outData);
		
		if( count($p)>1 ){
			deB( 'array exist $galArr: cnt = '.count($p) );
			echo showGal($p);
		} else {
			deB( 'array NOT exist $galArr: cnt = '.count($p) );
			$p = regenerateFile($pGal['file'], $pGal['link']);
			deB( 'file exist - $pGal[file]'.$pGal['file'] );
			$outPut = file( $pGal['file'] );
			$outData = implode("", $outPut );
			unset($outPut);
			
			$p = unserialize($outData);
			echo showGal($p);
		}
		
	} else {
		deB( 'file NOT exist - $pGal[link]: '.$pGal['link'] );
		$p = regenerateFile($pGal['file'], $pGal['link']);
		$outPut = file( $pGal['file'] );
		$outData = implode("", $outPut );
		unset($outPut);
		$p = unserialize($outData);
		unset($outData);
		echo showGal($p);
	}
}

if(deBUG){
}

?>

any comments/remarks?
Gesperrt