| 
<?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: PhotoAlbum creates headers that must go in the <head>
 //       section.
 //       This example shows how to accomplish this if you don't
 //       have access to the webpage template or can't use the
 //       method shown in "embedded.php".
 //       This method uses the ob_get_contents() php function to
 //       read the current ob into a string, then uses the
 //       preg_replace() function to replace the </head> tag with
 //       the PhotoAlbum headers prepended to it.  Then just print
 //       the string and it will re-populate the output buffer.
 //
 
 // 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);
 }
 
 // Get photo_album headers.  These will be added to HTML head later.
 // 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");
 }
 
 // Get html content for PhotoAlbum
 $album_content = array();
 $retval = $album->generate_html_content($album_content);
 if($retval !== TRUE)
 {
 $album_content = array("Error in album.generate_html_content, album said: $album-ERR");
 }
 ?>
 
 <!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">
 <head>
 <title>PhotoAlbum Sample - Embedded PhotoAlbum</title>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <link href="/pictures/css/main.css" rel="stylesheet" type="text/css" />
 </head>
 <body>
 <div id="main_contents">
 <h3>PhotoAlbum embedded in existing webpage.</h3>
 This sample uses php <tt>ob_get_contents()</tt> to add additional
 headers into <head>.
 </div>
 <div id="photo_album">
 <?php
 // Add PhotoAlbum headers to html head
 $ob_str = ob_get_contents();
 ob_clean();
 $new_headers[] = '</head>';
 $ob_str = preg_replace('/<\/head>/', join('', $new_headers), $ob_str);
 print($ob_str);
 
 // Add photo_album content to the html body
 print(join('',$album_content));
 ?>
 </div>
 <div style="height: 2em; width: 100%; background-color: #000000;
 color: #000000;"><div>
 </body>
 </html>
 
 |