Changeset 8263


Ignore:
Timestamp:
Dec 23, 2010, 9:46:16 PM (13 years ago)
Author:
rvelices
Message:
  • faster trigger_event/trigger_action (it was overly complicated)
  • added a new param to get_thumbnail_url event
  • get_thumbnail_location is called only if the thumbnail does not exist
Location:
trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r7495 r8263  
    736736function get_thumbnail_url($element_info)
    737737{
    738   $path = get_thumbnail_location($element_info);
    739   if ( !url_is_remote($path) )
    740   {
    741     $path = embellish_url(get_root_url().$path);
    742   }
    743 
     738  $loc = $url = get_thumbnail_location($element_info);
     739  if ( !url_is_remote($loc) )
     740  {
     741    $url = (get_root_url().$loc);
     742  }
    744743  // plugins want another url ?
    745   $path = trigger_event('get_thumbnail_url', $path, $element_info);
    746   return $path;
     744  $url = trigger_event('get_thumbnail_url', $url, $element_info, $loc);
     745  return embellish_url($url);
    747746}
    748747
     
    767766    $path = get_themeconf('mime_icon_dir')
    768767        .strtolower(get_extension($element_info['path'])).'.png';
    769   }
    770 
    771   // plugins want another location ?
    772   $path = trigger_event( 'get_thumbnail_location', $path, $element_info);
     768    // plugins want another location ?
     769    $path = trigger_event( 'get_thumbnail_location', $path, $element_info);
     770  }
    773771  return $path;
    774772}
  • trunk/include/functions_plugins.inc.php

    r6363 r8263  
    120120    return $data;
    121121  }
    122   $args = array_slice(func_get_args(), 2);
     122  $args = func_get_args();
    123123
    124124  foreach ($pwg_event_handlers[$event] as $priority => $handlers)
     
    126126    foreach($handlers as $handler)
    127127    {
    128       $all_args = array_merge( array($data), $args);
    129128      $function_name = $handler['function'];
    130129      $accepted_args = $handler['accepted_args'];
    131 
    132       if ( $accepted_args == 1 )
    133         $the_args = array($data);
    134       elseif ( $accepted_args > 1 )
    135         $the_args = array_slice($all_args, 0, $accepted_args);
    136       elseif ( $accepted_args == 0 )
    137         $the_args = NULL;
    138       else
    139         $the_args = $all_args;
    140 
    141       $data = call_user_func_array($function_name, $the_args);
     130      $args[1] = $data;
     131      $data = call_user_func_array($function_name, array_slice($args,1,$accepted_args) );
    142132    }
    143133  }
     
    160150    return;
    161151  }
    162   $args = array_slice(func_get_args(), 2);
     152  $args = func_get_args();
    163153
    164154  foreach ($pwg_event_handlers[$event] as $priority => $handlers)
     
    166156    foreach($handlers as $handler)
    167157    {
    168       $all_args = array_merge( array($data), $args);
    169158      $function_name = $handler['function'];
    170159      $accepted_args = $handler['accepted_args'];
    171160
    172       if ( $accepted_args == 1 )
    173         $the_args = array($data);
    174       elseif ( $accepted_args > 1 )
    175         $the_args = array_slice($all_args, 0, $accepted_args);
    176       elseif ( $accepted_args == 0 )
    177         $the_args = NULL;
    178       else
    179         $the_args = $all_args;
    180 
    181       call_user_func_array($function_name, $the_args);
     161      call_user_func_array($function_name, array_slice($args,1,$accepted_args) );
    182162    }
    183163  }
Note: See TracChangeset for help on using the changeset viewer.