For Acidfree images
Last modified: August 26, 2009 - 23:58
Here is the code to add next, previous buttons to acidfree images. The images are ordered according to weightings. Place the code in template.php in your theme directory. (I know, I know, i'm supposed to use joins...). It works for both images and videos in acid free.
<?php
function next_prev_acidfree($current_nid, $label, $class) {
# get its parent
$query = db_query("SELECT parent FROM `acidfree_hierarchy` WHERE child = $current_nid;");
$parent = db_result($query);
# root gallery
if ($parent == -1) {
$arr ['parent'] = l("Photo Gallery", 'acidfree', array("title" => $label, "class" => $class));
}else {
# Get the parent
$query = db_query("SELECT title FROM `node` WHERE nid = $parent;");
$parent_title = db_result($query);
$arr ['parent'] = l($parent_title, 'node/'.$parent, array("title" => $label, "class" => $class));
}
# Get all the other photos videos that have the same parent
//$sql = "SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid ";
$sql = "SELECT a.aid, n.title, nid FROM {node} n, {acidfree} a, {acidfree_hierarchy} ah ".
" WHERE n.type='acidfree' AND n.nid = a.aid AND (a.class='photo' || a.class='video')".
" AND ah.parent = $parent AND ah.child=a.aid ".
" ORDER BY a.weight ASC, n.nid DESC";
$result = db_query($sql);
if (!db_num_rows($result)) {
$arr ['next'] = null;
$arr ['previous'] = null;
} else {
while ($row = db_fetch_array($result)) {
if ($row['nid'] == $current_nid && $before) {
$arr ['previous'] = l("< < Previous", "node/".$before['nid'], array("title" => $label, "class" => $class));
}
if ($before['nid'] == $current_nid) {
$arr ['next'] = l("Next > >", "node/".$row['nid'], array("title" => $label, "class" => $class));
}
$before = $row;
}
}
return $arr;
}
function phptemplate_display_next_previous($node) {
$arr = next_prev_acidfree($node->nid, 'Navigation', 'test');
//echo $previous . " | " . $next ."";
$output .= "<table class='acidfree-next-previous'>";
$output .= "<tr>";
$output .= "<td class='acidfree-previous'>".$arr['previous']."</td>";
$output .= "<td class='acidfree-parent'>".$arr['parent']."</td>";
$output .= "<td class='acidfree-next'>".$arr['next']."</td>";
$output . "</tr>";
$output .= "</table>";
return $output;
}
function phptemplate_acidfree_print_full_photo(&$node) {
if (!$node->small)
return '';
$output .= acidfree_pager_creator($node);
$output .= phptemplate_display_next_previous($node);
$output .= "<div class='acidfree-full'>";
$largeurl = _acidfree_get_large_url($node);
if (!$largeurl) {
$output .= theme('image', _acidfree_get_small_url($node),
$node->title, $node->title, NULL, false);
} else {
$output .= "<a href='"._acidfree_get_large_url($node)."'>".
theme('image', _acidfree_get_small_url($node),
$node->title, $node->title, NULL, false).
"</a>";
}
$output .= "</div><div class='acidfree-body'>{$node->body}</div>";
if (variable_get('acidfree_show_exif_data', false)) {
$output .= theme('acidfree_exif_data', $node);
}
return $output;
}
function phptemplate_acidfree_print_full_video(&$node) {
if (!$node->large)
return '';
// get the pager
$output = acidfree_pager_creator($node);
$output .= phptemplate_display_next_previous($node);
$id = $node->nid;
$name = $node->title;
// icon link to the full size video
$full_video = _acidfree_get_large_url($node);
$output .= "<a href='$full_video'>".t('download video').'</a><br/>';
$ext = pathinfo(_acidfree_get_large_path($node), PATHINFO_EXTENSION);
switch ($ext) {
case 'rm':
$type = 'realmedia';
break;
case 'mp4':
case 'mov':
$type = 'quicktime';
break;
default:
$type = 'windowsmedia';
break;
}
$finfo = image_get_info(_acidfree_get_small_path($node, true));
$node->videoy = $finfo['height'];
$node->videox = $finfo['width'];
$output .= acidfree_call("theme_video_{$type}_control",Array(&$node));
$output .= "<div class='acidfree-body'>{$node->body}</div>\n";
return $output;
}
?>code ..............................
