Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

New Photo Gallery


Go to End
Reply


1543 Views

Avatar
steve_nyhof

Community Member, 224 Posts

30 May 2008 at 4:22pm

We are putting together a new photo gallery using Dynamic Drive... http://www.dynamicdrive.com/dynamicindex4/cmotiongallery.htm
and Slideshow2
http://www.electricprism.com/aeron/slideshow/

You can see it here...
http://websidedesigner.com/galley/

We are using folders for the categories inside "assets/Galleries/'+folder+'"
Any help and guidance???
Galleries.php:

<?php

class Galleries extends Page {
	static $db = array(
	);
	static $has_one = array(
   );
   static $icon = "galleries/images/window";
   
  
  function getMotionGallery($limitFolders=50,$limitImages=1){
  

   
   // get All the Folders that are on root
   
  $folders  = $this->getFolders($limitFolders);
  
  foreach($folders as $folder){
    
     $folder->CatName = $folder->Name;
	 $items = $this->Items((string)$folder->ID,$limitImages);
	  $data = "";   
	  if($items){
	  $i=1;
	  $j=0;
	  foreach($items as $item){
	  $j++;
	  }
	  
	  foreach($items as $item){
	   if( $i == 1 ){
	   $folder->Filename =  $item->Filename;
	   }
	   if($i < $j ){
	  
	   //$item->comma =  " ,";
	   $data.= "$item->Name,";
	   } else {
	   //$item->comma =  " ";
	   $data.= "$item->Name";
	   }
	  $i++;

	  
	  }
    
	 
	
	}
  $folder->Dataforjavascript = $data;
  
  }
  
  return $folders;
  
  }
  function getDefaultFolder(){
  
  
   
   // get All the Folders that are on root
   
  $folders  = $this->getFolders(1);
  
  foreach($folders as $folder){
   
     $folder->ID = $folder->ID; 
     $folder->CatName = $folder->Name;
	 $items = $this->Items((string)$folder->ID,1);
	  if($items){   
	  foreach($items as $item){
	  
	   $folder->Filename =  $item->Filename;
	   
	  
	  }
     }
  }
  
  return $folders;
  
  }
  
  function getFolders($limit = 1){
  
   
   $sort = "`File`.`Created` DESC";
   
   $Galleries = DataObject::get("File", "ClassName = 'Folder' AND ParentID = 0 AND  Name = 'Galleries'", $sort, "", $limit);
   foreach($Galleries as $Gallery){
   $Gallery->ID = $Gallery->ID;
   }
   return DataObject::get("File", "ClassName = 'Folder' AND ParentID = $Gallery->ID ", $sort, "", $limit);
  
  }
  
  function Items( $parentID ,$limit = 1) {

   
     $sort = "`File`.`Name` ASC";
   
     return DataObject::get("File", "ClassName = 'Image' AND ParentID = $parentID ", $sort, "", $limit);
	
	}
  
/*function getImagesInFolder($parentID ,$limit = 1){
    
	$sort = "`File`.`Name` ASC";
	
    $items = DataObject::get("File", "ClassName = 'Image' AND ParentID = $parentID ", $sort, "", $limit);
	  if($items){   
	  foreach($items as $item){
	  
	   $item->Filename1 =  $item->Filename;
	   
	  
	  }
   }
  return $items;

 }*/
 function getImagesInFolder($parentID = 0 ,$limit = 1){
    
	$sort = "`File`.`Name` ASC";
	
  $Galleries = DataObject::get("File", "ClassName = 'Folder' AND ParentID = 0 AND  Name = 'Galleries'", $sort, "", $limit);
   foreach($Galleries as $Gallery){
   $Gallery->ID = $Gallery->ID;
   }
  $sort = "`File`.`Name` ASC";
  $folders = DataObject::get("File", "ClassName = 'Folder' AND ParentID = $Gallery->ID ", $sort, "", $limit);
   foreach($folders as $folder){
   $folder->ID = $folder->ID;
   }
  	
    $items = DataObject::get("File", "ClassName = 'Image' AND ParentID = $folder->ID", $sort, "", 100);
	
	if($items){   
	  $i=1;
	  $j=0;
	  foreach($items as $item){
	  $j++;
	  }
	  
	  foreach($items as $item){
	  $item->Name = $item->Name;
	   if($i < $j ){
	  
	   $item->comma =  " ,";
	   
	   } else {
	   $item->comma =  " ";
	   
	   }
	  $i++;
	  }
   }
  return $items;

 }
 
}
class Galleries_Controller extends Page_Controller {
	function init() {
		parent::init();
		
		Requirements::themedCSS("layout");
		Requirements::themedCSS("typography");
		
		Requirements::css("galleries/css/slideshow.css");
        Requirements::javascript("galleries/javascript/mootools.js");
		Requirements::javascript("galleries/javascript/slideshow.js");
        
		//Requirements::themedCSS("form");
	}
}

?>

Galleries.ss:

<div class="typography">
	
 <div id="Content" >
		
		<h2>$Title</h2>
	
	
		  $Content 
		  <div id="motioncontainer" style="position:relative;overflow:hidden;">
<div id="motiongallery" style="position:absolute;left:0;top:0;white-space: nowrap;">

<nobr id="trueContainer">

<% control getMotionGallery(10,10) %>
<a  class="highlightit" href='javascript:loadSlideShow("$Dataforjavascript","$CatName");'><img src="$Filename" border="1" width="100" height="75" title ="$CatName"></a>
  		
 <% end_control %>
  </nobr>
  </div>
</div>
<div style="background-image:url(galleries/images/slideshow.jpg); background-repeat:no-repeat; height:500px;">

	
		<br>
			
<% control getDefaultFolder %>


<script type="text/javascript">		
	var myShow ;
	//<![CDATA[
	  
	  window.addEvent('domready', function(){
	    
	    
	     myShow = new Slideshow('my_show', data, { captions: true, controller: true, hu: 'assets/Galleries/$CatName' });
		//Nauman: 'assets/Galleries/$folders ?? - the '/' is in the slideshow.js file - see hu on line 28
	  });
	//]]>
	</script>

<br><br>
<div id="my_show" class="slideshow">
    <img src="$Filename" width="500" height="390"/>	
	</div>
<% end_control %>
</div>
<script type="text/javascript">

var data = {
	      <% control getImagesInFolder %>
		  
		  '$Name': { 'caption': '$Name' } $comma
	      
		  <% end_control %>
		 
		}
</script>	
		$Form
		$PageComments
	
	  </div>

</div>
<br><br>
<script type="text/javascript">

function loadSlideShow(data,folder){

//alert(data);
var dataArray = explodeArray(data,",");
//alert(dataArray.length);
var dataString = "{ ";
for(i=0;i<dataArray.length;i++){
   
    if(i == ( dataArray.length-1 ) ){
   dataString = dataString + "' "+ dataArray+"'";
   }else{
   dataString = dataString + "' "+ dataArray+"',";
  }
}
dataString = dataString + "}";
var captionString =  "{ controller: true, hu: 'assets/Galleries/"+folder+"'  }";
alert(captionString);
myShow.destroy("empty");
 myShow = new Slideshow('my_show', dataString, { controller: true, hu: "assets/Galleries/'+folder+'"  } );

}
function explodeArray(item,delimiter) { 
tempArray=new Array(1); 
var Count=0; 
var tempString=new String(item); 

while (tempString.indexOf(delimiter)>0) { 
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter)); 
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
Count=Count+1 
} 

tempArray[Count]=tempString; 
return tempArray; 
} 

</script>