menu = new FlexyWiki_MenuParser; $this->menu->baseURL = "{$this->rootURL}/wiki.php"; $this->menu->currentPage = '/photo.php'; $this->menu->parseMenu(); // load photo galleries here??? } var $categories; var $data = array(); function loadData() { // dl('domxml.so'); // phpinfo(); // todo - caching? $cache = ini_get('session.save_path') .'/AlbumData.xml.serialized'; $original = '/home/iPhoto Library/AlbumData.xml'; if (filemtime($cache) >= filemtime($original)) { // echo "LOADING FROM CACHE?"; $this->data = unserialize(file_get_contents($cache)); return; } $dom = new DOMDocument(); $dom->load('/home/iPhoto Library/AlbumData.xml'); //$e = $dom->document_element(); $c = $dom->getElementsByTagName('plist'); set_time_limit(30000); $ar = $this->toArrayDom($c->item(0)); $this->data = $ar[0]; // top level only contains a plist.. file_put_contents($cache, serialize($this->data)); touch($cache, filemtime($original)); } var $albums = array(); function loadAlbums() { $ar = $this->data['List of Albums']; foreach($ar as $a) { if (empty($a['Album Type']) || ($a['Album Type'] != 'Regular')) { continue; } $a['domid']='_album'.$a['AlbumId']; $this->albums[$a['AlbumId']] = $a; } //echo '
'; print_r($this->albums); echo ''; } function loadPhotos($a) { $real = rawurldecode($a); if (empty($real) || empty($this->albums[$real])) { return; } $o = PEAR::getStaticProperty('FlexyWiki','options'); // echo '
';print_r($this->albums[$real]);
$photoIDs = $this->albums[$real]['KeyList'];
//echo '';print_r($this->data);
foreach($photoIDs as $id) {
$detail = $this->data['Master Image List'][$id];
$realfile = str_replace(
'/Users/User/Pictures/',
'/home/',
$detail['ImagePath']
);
$thumbfile = str_replace(
'/Users/User/Pictures/',
'/home/',
$detail['ThumbPath']
);
require_once 'FlexyPhoto/ImageCache.php';
$x = new FlexyPhoto_ImageCache;
$info = $x->createThumbnail($realfile,150,110);
$infoL = $x->createThumbnail($realfile,1024);
$row = array(
'id' => $id,
'link' => $this->baseURL .'/View/'. $a . '/' . $id .'/'. basename($detail['ImagePath']),
'name' => $detail['Caption'],
'size' => sprintf("%0.2f",filesize($realfile) / 1000000),
'url' => $this->baseURL . $info['url'],
'urlL' => $this->baseURL . $infoL['url'],
'info' => $info,
'infoL' => $infoL,
);
$this->imagecols[] = (object) $row;
/*
[MediaType] => Image
[Caption] => DSC01285.JPG
[Comment] =>
[Aspect Ratio] => 1.333333
[Rating] => 0
[Roll] => 21
[DateAsTimerInterval] => 134535110
[ModDateAsTimerInterval] => 134535110
[MetaModDateAsTimerInterval] => 139576177.665
[ImagePath] => /Users/User/Pictures/iPhoto Library/2005/04/07/DSC01285.JPG
[ThumbPath] => /Users/User/Pictures/iPhoto Library/2005/04/07/Thumbs/86.jpg
*/
//echo '';print_R($detail);
}
//print_r($this->imagecols);
/*
*/
}
function get($u,$args=array())
{
return HTML_FlexyFramework::run('Photo');
//echo '';
$this->loadMenu();
$this->loadData();
$this->loadAlbums();
$bits = explode('/',$u);
if (isset($bits[0])) {
$this->loadPhotos($bits[0]);
$this->albums[$bits[0]]['domid'] = "active1";
}
}
function toArrayDom($n)
{
if (!isset($n->tagName)) {
print_r($n);
return '';
}
// echo $n->tagname."
";
switch($n->tagName)
{
case 'plist':
case 'array':
$ret = array();
$cns = $n->childNodes;
for ($i=0;$i<$cns->length;$i++) {
if ($cns->item($i)->nodeType != 1) {
continue;
}
$ret[] = $this->toArrayDom($cns->item($i));
}
return $ret;
case 'dict':
$ret = array();
$cns = $n->childNodes;
for ($i=0;$i<$cns->length;$i++) {
if ($cns->item($i)->nodeType != 1) {
continue;
}
if ($cns->item($i)->tagName != 'key') {
echo "not a key??";
}
$key = $cns->item($i)->textContent;
$i++;
while($cns->item($i)->nodeType != 1) {
$i++;
}
$val = $this->toArrayDom($cns->item($i));
$ret[$key] = $val;
}
return $ret;
case 'string':
return $n->textContent;
case 'integer':
return (int) $n->textContent;
case 'true':
return true;
case 'false':
return false;
case 'real':
return (float) $n->textContent;
default:
echo "OOPS";
print_r($n);
exit;
}
}
function outputBlogBody()
{
return $this->outputBody();
}
}