| 1 |
<?php |
<?php |
| 2 |
// $Id: flickrstickr.module,v 1.23 2007/01/22 10:46:12 aronnovak Exp $ |
// $Id: flickrstickr.module,v 1.24 2007/01/22 11:03:58 aronnovak Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 385 |
while ($img = db_fetch_array($result)) { |
while ($img = db_fetch_array($result)) { |
| 386 |
$paths[$i] = 'files/' . $img['filepath']; |
$paths[$i] = 'files/' . $img['filepath']; |
| 387 |
$img_details = image_get_info($paths[$i]); |
$img_details = image_get_info($paths[$i]); |
| 388 |
$avail_sizes[$i] = $orient ? $img_details['width'] : $img_details['height']; |
$avail_sizes[$i] = $img_details['width']; |
| 389 |
$diffs[$i] = abs($size - $avail_sizes[$i]); |
$diffs[$i] = abs($size - $avail_sizes[$i]); |
| 390 |
$diffs_pop[$i] = abs($popup_size - $avail_sizes[$i]); |
$diffs_pop[$i] = abs($popup_size - $avail_sizes[$i]); |
| 391 |
++$i; |
++$i; |
| 441 |
* |
* |
| 442 |
*/ |
*/ |
| 443 |
function flickrstickr_processappendix($matches) { |
function flickrstickr_processappendix($matches) { |
| 444 |
|
// If user has specifiy a size trough tinymce we should handle it |
| 445 |
|
preg_match('/width="([0-9]*)"/', $matches[0], $size); |
| 446 |
|
if (isset($size[1])) { |
| 447 |
|
$matches[5] = $size[1]; |
| 448 |
|
} |
| 449 |
$flickrtag = '[flickr:' . $matches[1] . '/' . $matches[2] . '/' . $matches[3] |
$flickrtag = '[flickr:' . $matches[1] . '/' . $matches[2] . '/' . $matches[3] |
| 450 |
. '|' . $matches[4] . '|' . $matches[5] . '|' . $matches[6] . ']'; |
. '|' . $matches[4] . '|' . $matches[5] . '|' . $matches[6] . ']'; |
| 451 |
return $flickrtag; |
return $flickrtag; |
| 537 |
// Check if image module is available |
// Check if image module is available |
| 538 |
if (!function_exists('_image_build_derivatives')) { |
if (!function_exists('_image_build_derivatives')) { |
| 539 |
drupal_set_message(t('Flickrstickr requires image module. Please install or enable it!'), 'error'); |
drupal_set_message(t('Flickrstickr requires image module. Please install or enable it!'), 'error'); |
| 540 |
return ''; |
return; |
| 541 |
} |
} |
| 542 |
|
|
| 543 |
global $user; |
global $user; |
| 553 |
$result = db_query("SELECT nid FROM {files} WHERE filepath LIKE %'%s'%", $filepath); |
$result = db_query("SELECT nid FROM {files} WHERE filepath LIKE %'%s'%", $filepath); |
| 554 |
$image = db_fetch_object($result); |
$image = db_fetch_object($result); |
| 555 |
if ($image) { |
if ($image) { |
| 556 |
return ''; |
return; |
| 557 |
} |
} |
| 558 |
} |
} |
| 559 |
// change alex - this shows me wether a flickr image i added was already in the directory |
// change alex - this shows me wether a flickr image i added was already in the directory |
| 607 |
if ($node->validated) { |
if ($node->validated) { |
| 608 |
node_save($node); |
node_save($node); |
| 609 |
_image_build_derivatives($node); |
_image_build_derivatives($node); |
| 610 |
|
|
| 611 |
|
// Create exact flickr size |
| 612 |
|
|
| 613 |
|
$source = file_create_path($node->images['_original']); |
| 614 |
|
$destination = _image_filename(basename($source), 'exact_flickr_size', $temp); |
| 615 |
|
if (!image_scale($source, file_create_path($destination), $matches[5], $matches[5])) { |
| 616 |
|
drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), 'error'); |
| 617 |
|
} |
| 618 |
|
else { |
| 619 |
|
$node->images[$size['label']] = $destination; |
| 620 |
|
if (!$temp) { |
| 621 |
|
_image_insert($node, 'exact_flickr_size', file_create_path($destination)); |
| 622 |
|
} |
| 623 |
|
} |
| 624 |
} |
} |
| 625 |
else { |
else { |
| 626 |
drupal_set_message(t('Unable to create image node.'), 'error'); |
drupal_set_message(t('Unable to create image node.'), 'error'); |