custom_php.inc File Reference

(1.1.2.2 2008/08/05 08:10:59 sdboyer)

Go to the source code of this file.

Functions

 panels_admin_content_custom_php ($display, $pane)
 panels_admin_content_types_custom_php ()
 panels_admin_edit_custom_php ($id, $parents, $conf=NULL)
 panels_admin_title_custom_php ($conf)
 panels_content_custom_php ($conf, $panel_args, $context)
 panels_custom_php_panels_content_types ()


Function Documentation

panels_admin_content_custom_php ( display,
pane 
)

Render callback for when the custom content is in the editor so that people can have a preview on the spot.

Parameters:
panels_display $display
stdClass $pane
Returns:
stdClass $block

Definition at line 62 of file custom_php.inc.

00062                                                           {
00063   $block = new stdClass();
00064   $block->title = filter_xss_admin($pane->configuration['title']);
00065   // We don't want to render php output on preview here, because if something is
00066   // wrong the whole display will be borked.
00067   $block->content = check_markup($pane->configuration['body'], 1);
00068   return $block;
00069 }

panels_admin_content_types_custom_php (  ) 

Return all content types available.

Definition at line 74 of file custom_php.inc.

References panels_get_path().

00074                                                  {
00075   if (filter_access(2)) {
00076     return array(
00077       'custom_php' => array(
00078         'title' => t('Custom PHP content'),
00079         'icon' => 'icon_block_custom.png',
00080         'path' => panels_get_path('content_types/custom'),
00081         'description' => t('Custom PHP block with access to Panels context data. Use sparingly, and with caution!'),
00082         'category' => array(t('Custom'), -10),
00083         'optional context' => new panels_optional_context(t('Context'), 'any'),
00084       ),
00085     );
00086   }
00087 }

Here is the call graph for this function:

panels_admin_edit_custom_php ( id,
parents,
conf = NULL 
)

Returns an edit form for the custom_php type.

Definition at line 92 of file custom_php.inc.

00092                                                                    {
00093   if (!is_array($conf)) {
00094     $conf = array('title' => '', 'body' => '');
00095   }
00096   $form['title'] = array(
00097     '#type' => 'textfield',
00098     '#default_value' => $conf['title'],
00099     '#title' => t('Title'),
00100   );
00101   $body = t('Any content you want to have passed along to theme function for displaying MUST be stored in $block->content.') . "\n\n";
00102   $body .= t('MAKE SURE YOU ERASE ALL OF THIS HELP TEXT. Only error-free php code should be saved in this field.') . "\n\n";
00103   $body .= t('Do NOT use php tags.');
00104   
00105   $form['body'] = array(
00106     '#title' => t('Body'),
00107     '#type' => 'textarea',
00108     '#default_value' => isset($conf['body']) ? $conf['body'] : $body,
00109     '#rows' => 10,
00110     '#description' => t('The PHP code you enter here will be evaluated at render-time. Any context data present in the display will be available to this code in the $context variable. <strong>DO NOT</strong> include <em>@php</em> tags.', array('@php' => '<?php ?>')),
00111   );
00112 
00113   return $form;
00114 }

panels_admin_title_custom_php ( conf  ) 

Returns the administrative title for a type.

Definition at line 119 of file custom_php.inc.

00119                                               {
00120   $output = t('Custom PHP with context');
00121   if ($conf['title']) {
00122     $output .= " (" . filter_xss_admin($conf['title']) . ")";
00123   }
00124   return $output;
00125 }

panels_content_custom_php ( conf,
panel_args,
context 
)

Output function for the 'custom_php' content type. Allows sufficiently privileged users to enter custom php code that is evaluated while $context is in scope. Use with caution!

Definition at line 29 of file custom_php.inc.

00029                                                                  {
00030   static $delta = 0;
00031   $block = new stdClass();
00032   
00033   // eval() the php that has been entered by the user.
00034   eval($conf['body']);
00035   $block->delta = ++$delta;
00036   // Put our default member values into a separate array.
00037   $members = array(
00038     'module'  => 'custom',
00039     'subject' => filter_xss_admin($conf['title']),
00040     'content' => '',
00041   );
00042   // Iterate through the array of defaults and assign put in
00043   // any values that haven't already been set by the custom
00044   // php code.
00045   foreach ($members as $member => $value) {
00046     if (empty($block->$member)) {
00047       $block->$member = $value;
00048     }
00049   }
00050   
00051   return $block;
00052 }

panels_custom_php_panels_content_types (  ) 

Callback function to supply a list of content types.

Definition at line 8 of file custom_php.inc.

00008                                                   {
00009   $items['custom_php'] = array(
00010     'title' => t('Custom PHP'),
00011     'weight' => -10,
00012     'single' => TRUE,
00013     'content_types' => 'panels_admin_content_types_custom_php',
00014     'render callback' => 'panels_content_custom_php',
00015     'editor render callback' => 'panels_admin_content_custom_php',
00016     'add callback' => 'panels_admin_edit_custom_php',
00017     'edit callback' => 'panels_admin_edit_custom_php',
00018     'title callback' => 'panels_admin_title_custom_php',
00019     'no override title' => TRUE,
00020   );
00021   return $items;
00022 }


Generated on Sun Feb 5 05:00:15 2012 for Panels 2 by  doxygen 1.5.6