Fix for sample php-handling implementation of a panels content type plugin

  1. /**
  2.  * Note that there is NO check here to ensure that the user has the
  3.  * proper permissions to execute arbitrary php code. That check
  4.  * should be made at the level of the content_types callback property,
  5.  * using a type of required context that we've yet to design.
  6.  */
  7. function panels_content_custom($conf, $panel_args, $context) {
  8.   static $delta = 0;
  9.  
  10.   // Declare the $pane object so that we don't get any E_STRICT warnings;
  11.   $pane = new stdClass();
  12.  
  13.   eval($conf['body']);
  14.  
  15.   // Put our default member values into a separate array.
  16.   $members = array(
  17.     'module'  => 'custom',
  18.     'delta'   => ++$delta,
  19.     'subject' => filter_xss_admin($conf['title']),
  20.     'content' => '',
  21.   );
  22.   // Iterate through the array of defaults and assign put in
  23.   // any values that haven't already been set by the custom
  24.   // php code.
  25.   foreach ($members as $member => $value) {
  26.     if (empty($pane->$member)) {
  27.       $pane->$member = $value;
  28.     }
  29.   }  
  30.  
  31.   return $pane;
  32. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.