| 1 |
<?php |
<?php |
| 2 |
// $Id: pblog.module,v 1.5 2008/02/11 09:58:43 baldy Exp $ |
// $Id: pblog.module,v 1.5.2.1 2008/02/20 14:10:01 baldy Exp $ |
| 3 |
/** |
/** |
| 4 |
* Work in progress Photo/Picture blog or pblog |
* Work in progress Photo/Picture blog or pblog |
| 5 |
* laurence.baldwin@gmail.com |
* laurence.baldwin@gmail.com |
| 88 |
$image_tag = theme_image("$file_dir/pblog/$node->nid$img_array[$counter]"); |
$image_tag = theme_image("$file_dir/pblog/$node->nid$img_array[$counter]"); |
| 89 |
$node->body .= l($image_tag, "pblog/$node->nid$med_image", array('attributes' => null, 'query' => null, 'fragment' => null, 'absolute' => TRUE, 'html' => TRUE)); |
$node->body .= l($image_tag, "pblog/$node->nid$med_image", array('attributes' => null, 'query' => null, 'fragment' => null, 'absolute' => TRUE, 'html' => TRUE)); |
| 90 |
$int = $counter + 1; |
$int = $counter + 1; |
| 91 |
if ( $int % 4 == 0 ) { $node->body .= '<br>'; } |
if ( $int % 4 == 0 ) { |
| 92 |
|
$node->body .= '<br>'; |
| 93 |
|
} |
| 94 |
} |
} |
| 95 |
|
|
| 96 |
$node = node_prepare($node, "$teaser"); |
$node = node_prepare($node, "$teaser"); |
| 155 |
} |
} |
| 156 |
else { |
else { |
| 157 |
$node = node_load($nid); |
$node = node_load($nid); |
| 158 |
drupal_set_title($title .= t(l($node->title,"node/$node->nid") ." - ". $picture)); |
drupal_set_title($title .= t(l($node->title, "node/$node->nid") ." - ". $picture)); |
| 159 |
|
|
| 160 |
// to work out whats in front and behind we need to create an array of all the images in the directory |
// to work out whats in front and behind we need to create an array of all the images in the directory |
| 161 |
// then find the current one. |
// then find the current one. |
| 187 |
$main_image =l($image_tag, "$file_dir/pblog/$nid$full_image", array('attributes' => null, 'query' => null, 'fragment' => null, 'absolute' => TRUE, 'html' => TRUE)); |
$main_image =l($image_tag, "$file_dir/pblog/$nid$full_image", array('attributes' => null, 'query' => null, 'fragment' => null, 'absolute' => TRUE, 'html' => TRUE)); |
| 188 |
$output = "$main_image"; |
$output = "$main_image"; |
| 189 |
|
|
| 190 |
if ($current_image >= $num_images - 2) { $next_image1 = $img_array[0]; } |
if ($current_image >= $num_images - 2) { |
| 191 |
else $next_image1 = $img_array[$current_image + 2]; |
$next_image1 = $img_array[0]; |
| 192 |
if ($current_image >= $num_images - 1) { $next_image = $img_array[1]; } |
} |
| 193 |
else $next_image = $img_array[$current_image + 1]; |
else $next_image1 = $img_array[$current_image + 2]; |
| 194 |
|
|
| 195 |
|
if ($current_image >= $num_images - 1) { |
| 196 |
|
$next_image = $img_array[1]; |
| 197 |
|
} |
| 198 |
|
else $next_image = $img_array[$current_image + 1]; |
| 199 |
|
|
| 200 |
$cur_image = $img_array[$current_image]; |
$cur_image = $img_array[$current_image]; |
| 201 |
if ($current_image == 1 || $current_image == 0) { $prev_image1 = $img_array[$num_images - 1];} |
if ($current_image == 1 || $current_image == 0) { |
| 202 |
else $prev_image1 = $img_array[$current_image - 2]; |
$prev_image1 = $img_array[$num_images - 1]; |
| 203 |
if ($current_image == 0) { $prev_image = $img_array[$num_images - 2]; } |
} |
| 204 |
else $prev_image = $img_array[$current_image - 1]; |
else $prev_image1 = $img_array[$current_image - 2]; |
| 205 |
|
|
| 206 |
|
if ($current_image == 0) { |
| 207 |
|
$prev_image = $img_array[$num_images - 2]; |
| 208 |
|
} |
| 209 |
|
else $prev_image = $img_array[$current_image - 1]; |
| 210 |
|
|
| 211 |
$trans = array("med" => "mini"); |
$trans = array("med" => "mini"); |
| 212 |
$trans2 = array("-med" => ""); |
$trans2 = array("-med" => ""); |
| 255 |
if ($file) { |
if ($file) { |
| 256 |
drupal_set_message("file_check_upload = SUCCESS", 'status'); |
drupal_set_message("file_check_upload = SUCCESS", 'status'); |
| 257 |
// for extra debugging drupal_set_message('$file = '. print_r($file, true), 'status'); |
// for extra debugging drupal_set_message('$file = '. print_r($file, true), 'status'); |
| 258 |
} else{ |
} |
| 259 |
drupal_set_message("file_save_upload = FAILURE ". print_r($node, true), 'status'); |
else { |
| 260 |
} |
drupal_set_message("file_save_upload = FAILURE ". print_r($node, true), 'status'); |
| 261 |
|
} |
| 262 |
|
|
| 263 |
// full path to the file |
// full path to the file |
| 264 |
$fpath = escapeshellcmd($file->filepath); |
$fpath = escapeshellcmd($file->filepath); |
| 265 |
|
|
| 266 |
// first make a dir with the node id |
// first make a dir with the node id |
| 267 |
$pblog_dir = file_create_path("/pblog"); |
$pblog_dir = file_create_path("/pblog"); |
| 268 |
if (!file_exists($pblog_dir)) { mkdir($pblog_dir); } |
if (!file_exists($pblog_dir)) { |
| 269 |
|
mkdir($pblog_dir); |
| 270 |
|
} |
| 271 |
$image_dir = file_create_path("pblog/$node->nid"); |
$image_dir = file_create_path("pblog/$node->nid"); |
| 272 |
|
|
| 273 |
if (!file_exists("$image_dir")) { mkdir("$image_dir"); } |
if (!file_exists("$image_dir")) { |
| 274 |
|
mkdir("$image_dir"); |
| 275 |
|
} |
| 276 |
|
|
| 277 |
// check what kind of file it is, zip gzip or just a pic. Then move |
// check what kind of file it is, zip gzip or just a pic. Then move |
| 278 |
// unzip or do what ever. |
// unzip or do what ever. |
| 287 |
// assume unzip file into dir |
// assume unzip file into dir |
| 288 |
// `unzip /tmp/$f -d $image_dir`; |
// `unzip /tmp/$f -d $image_dir`; |
| 289 |
// More complex but more portable way of doing things |
// More complex but more portable way of doing things |
| 290 |
if (class_exists('ZipArchive')){ |
if (class_exists('ZipArchive')) { |
| 291 |
$zip = new ZipArchive; |
$zip = new ZipArchive; |
| 292 |
if ($zip->open($fpath) === TRUE) { |
if ($zip->open($fpath) === TRUE) { |
| 293 |
$zip->extractTo($image_dir); |
$zip->extractTo($image_dir); |
| 294 |
$zip->close(); |
$zip->close(); |
| 295 |
} else { |
} |
| 296 |
form_set_error('image', t('The uploaded file was not a zip archive.')); |
else { |
| 297 |
|
form_set_error('image', t('The uploaded file was not a zip archive.')); |
| 298 |
|
} |
| 299 |
|
} |
| 300 |
|
else { |
| 301 |
|
drupal_set_message("php does not have built in zip support using system call to the unzip binary".'status'); |
| 302 |
|
`unzip $fpath -d $image_dir`; |
| 303 |
} |
} |
|
} else { |
|
|
drupal_set_message("php does not have built in zip support using system call to the unzip binary". 'status'); |
|
|
`unzip $fpath -d $image_dir`; |
|
|
} |
|
| 304 |
|
|
| 305 |
`rm $fpath`; |
`rm $fpath`; |
| 306 |
break; |
break; |
| 331 |
$command3 = 'convert -size 500x375 "'. $image_dir .'/'. $s .'" -resize 500x375 +profile "*" "'. $image_dir .'/'. $s_root .'-med.jpg"'; |
$command3 = 'convert -size 500x375 "'. $image_dir .'/'. $s .'" -resize 500x375 +profile "*" "'. $image_dir .'/'. $s_root .'-med.jpg"'; |
| 332 |
exec($command3); |
exec($command3); |
| 333 |
*/ |
*/ |
| 334 |
image_scale($image_dir .'/'. $s, $image_dir .'/'. $s_root .'-mini.jpg', 120, 120); |
image_scale($image_dir .'/'. $s, $image_dir .'/'. $s_root .'-mini.jpg', 120, 120); |
| 335 |
image_scale($image_dir .'/'. $s, $image_dir .'/'. $s_root .'-med.jpg', 500, 375); |
image_scale($image_dir .'/'. $s, $image_dir .'/'. $s_root .'-med.jpg', 500, 375); |
| 336 |
} |
} |
| 337 |
} |
} |
| 338 |
} |
} |