Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Matías Gentiletti  >  Picasa Photo Gallery  >  index.php  >  Download  
File: index.php
Role: Application script
Content type: text/plain
Description: Index
Class: Picasa Photo Gallery
Extract data picture galleries from Picasa site
Author: By
Last change:
Date: 2008-08-27 21:48
Size: 1,943 bytes
 

Contents

Class file image Download
<?php

## Includes
include('config/config.php');
include(
'lib/ErrorException.class.php');
include(
'lib/PhotoGallery.class.php');

## Initialize variables
if(!isset($_GET['album']))     $_GET['album']='';
if(!isset(
$photos))         $photos=array();
if(!isset(
$album_title))     $album_title='';

## Command for clear cache
if($_GET['album']=='cc'PhotoGallery::clearCache();

## Root url
define('ROOT_URL'PhotoGallery::getRootUrl());

## Validate if the file exists
if(!file_exists(MAIN_FILENAME))
{
    
$cache PhotoGallery::getData(URL_FEED);
    
$create PhotoGallery::createCacheFile(MAIN_FILENAME$cache);
    if(!
$create)
    {
        throw new 
Exception('Cannot write the cache file. Remember to set permissions chmod 777 to folder cache.');
    }
}

## Get all galleries
$galleries PhotoGallery::allGalleries(MAIN_FILENAMEACCOUNT_NAME);

## Count galleries
$gallery_count count($galleries);

## If variable album isn't empty
if($_GET['album'])
{
    
## Content of xml file
    
$data PhotoGallery::getContentOfXml(ACCOUNT_NAME$_GET['album']);
    
    
## RSS link
    
$rss_link PhotoGallery::getRssLink($data);
    
    
## Name of the cache file
    
$filename 'cache/picasa.'.md5($rss_link).'.html';
    
    
## Validate if the file exists
    
if(!file_exists($filename))
    {
        
$data PhotoGallery::getData($rss_link);
        
$create PhotoGallery::createCacheFile($filename$data);
        if(!
$create)
        {
            throw new 
Exception('Cannot write the cache file. Remember to set permissions chmod 777 to folder cache.');
        }
    }
    
    
$galleries = array();
    
    
## Album data
    
$album PhotoGallery::getAlbum($filename);
    
    if(!
$album)
    {
        throw new 
Exception('Google Error 500');
    }
    
    
## All photos of a album
    
$photos $album['photos'];
    
    
## Count photos
    
$photos_count count($photos);
    
    
## Title of a album
    
$album_title $album['title'];
    
    
## Url for the embed tag of picasa
    
$url_api PhotoGallery::formatUrlForEmbedTag($rss_link);
}

## Templates
include('templates/index.php');

?>