/[drupal]/contributions/modules/flickrstickr/flickrstickr.module
ViewVC logotype

Diff of /contributions/modules/flickrstickr/flickrstickr.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.24, Mon Jan 22 11:03:58 2007 UTC revision 1.25, Mon Jan 22 12:33:51 2007 UTC
# Line 1  Line 1 
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
# Line 385  function flickrstickr_processflickrtag($ Line 385  function flickrstickr_processflickrtag($
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;
# Line 441  function flickrstickr_processflickrtag($ Line 441  function flickrstickr_processflickrtag($
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;
# Line 532  function flickrstickr_saveimages($matche Line 537  function flickrstickr_saveimages($matche
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;
# Line 548  function flickrstickr_saveimages($matche Line 553  function flickrstickr_saveimages($matche
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
# Line 602  function flickrstickr_saveimages($matche Line 607  function flickrstickr_saveimages($matche
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');

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.2