Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/embedded.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andy Loftus  >  Photo Album  >  examples/embedded.php  >  Download  
File: examples/embedded.php
Role: Example script
Content type: text/plain
Description: Sample php script showing how a PhotoAlbum might be embedded in an existing web page.
Class: Photo Album
Display interactive photo album
Author: By
Last change: Fixed print statement so it works now.
Date: 7 years ago
Size: 3,974 bytes
 

Contents

Class file image Download
<?php
    ob_start
();

    
// Synopsis:    1. Create page as normal.
    //              2. Add PhotoAlbum <head> elements to normal html
    //                 <head>.
    //              3. Create a <div> where you want the PhotoAlbum.
    //              4. Print output from $album->generate_html_content.
    //              5. Close the </div>.

    
$doc_root '/var/www/htdocs/pictures';
    
$web_root '/pictures';
    require_once(
"$doc_root/php/PhotoAlbum.php");

    
// NOTE: It is important to have some way to put the PhotoAlbum
    //       headers in the HTML <head> section.  The method shown
    //       below puts all existing headers in an array and then
    //       appends the photo album headers to the array.   If this
    //       isn't possible in your existing webpage, take a look at
    //       the file embedded_alternate.php, which uses
    //       ob_get_contents() and preg_replace() to modify the <head>
    //       section that was already sent.
    //
    
$html_head[] = '<title>PhotoAlbum Sample - Embedded PhotoAlbum</title>';
    
$html_head[] = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
    
$html_head[] = "<link href=\"$web_root/css/main.css\" rel=\"stylesheet\" type="\text/css\" />";

    
// Create new photo album object
    
$album = new PhotoAlbum;

    
// Set album variables
    
$album->CELLS_PER_ROW 5;
    
$album->IMAGE_MAX_SIZE 700;
    
$album->THUMB_MAX_SIZE 100;
    
$album->IMAGE_QUALITY 85;
    
$album->KEEP_ORIGINALS TRUE;
    
$album->SHOW_SUBDIR_HEADER FALSE;
    
// doctype unused for embedded page
    //$album->DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
    // title unused for embedded page
    //$album->TITLE = 'CREW Mission Archives - Photo Documentary';

    // Where to find required files for include
    
$album->LIGHTBOX_JS "$web_root/js/lightbox.js";
    
$album->LIGHTBOX_CSS "$web_root/css/lightbox.css";
    
$album->PROTOTYPE_JS "$web_root/js/prototype.lite.js";
    
$album->MOO_FX_JS "$web_root/js/moo.fx.js";
    
$album->MOO_FX_PACK_JS "$web_root/js/moo.fx.pack.js";

    
// Add any optional HTML settings
    
$album->LINKS[] = 
        
'<link rel="stylesheet" type="text/css" href="/crew/css/photoalbum.css" />';
    
$album->SCRIPTS[] = 
        
'<script type="text/javascript">' .
        
file_get_contents("$doc_root/js/photoalbum.js") .
        
'</script>';
    
    
// Create photo album
    
$rv $album->create_album();
    if(
$rv !== TRUE)
    {
        exit(
'Error: The following problem occurred: '.$album->ERR);
    }

    
// Merge photo_album headers with existing headers
    // NOTE: This is step 2 from the Synopsis above
    
$new_headers = array();
    
$retval $album->generate_html_head($new_headers);
    if(
$retval !== TRUE)
    {
        exit(
"Error in album.generate_html_head, album said: $album-ERR");
    }
    
$html_head array_merge($html_head$new_headers);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml: lang="en" lang="en">
<?php
    
print('<head>' join("\n",$html_head) . '</head>');
?>
<body>
<div id="main_contents">
<h3>PhotoAlbum embedded in existing webpage.</h3>
This sample puts existing headers in a php array, then appends
PhotoAlbum headers to that array.
</div>
<div id="photo_album">
<?php
    
// Add photo_album content to the html body
    
$content = array();
    
$retval $album->generate_html_content($content);
    if(
$retval !== TRUE)
    {
        print(
"Error in album.generate_html_content, album said: $album-ERR");
    }
    else
    {
        print(
join(''$content));
    }
?>
</div>
<div style="height: 2em; width: 100%; background-color: #000000;
color: #000000;"><div>
</body>
</html>