custom.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: custom.inc,v 1.2.6.22 2008/07/15 04:14:30 sdboyer Exp $
00003 
00004 
00005 /**
00006  * Callback function to supply a list of content types.
00007  */
00008 function panels_custom_panels_content_types() {
00009   $items['custom'] = array(
00010     'title' => t('Custom'),
00011     'weight' => -10,
00012     'single' => TRUE,
00013     'content_types' => 'panels_admin_content_types_custom',
00014     'render callback' => 'panels_content_custom',
00015     'editor render callback' => 'panels_admin_content_custom',
00016     'add callback' => 'panels_admin_edit_custom',
00017     'edit callback' => 'panels_admin_edit_custom',
00018     'title callback' => 'panels_admin_title_custom',
00019     'no override title' => TRUE,
00020   );
00021   return $items;
00022 }
00023 
00024 /**
00025  * Output function for the 'custom' content type. Outputs a custom
00026  * based on the module and delta supplied in the configuration.
00027  */
00028 function panels_content_custom($conf) {
00029   static $delta = 0;
00030 
00031   $block          = new stdClass();
00032   $block->module  = 'custom';
00033   $block->delta   = ++$delta;
00034   $block->subject = filter_xss_admin($conf['title']);
00035   $block->content = check_markup($conf['body'], $conf['format'], FALSE);
00036 
00037   return $block;
00038 }
00039 
00040 /**
00041  * Render callback for when the custom content is in the editor so that people
00042  * can have a preview on the spot.
00043  *
00044  * @param panels_display $display
00045  * @param stdClass $pane
00046  * @return stdClass $block
00047  */
00048 function panels_admin_content_custom($display, $pane) {
00049   $block = new stdClass();
00050   $block->title = filter_xss_admin($pane->configuration['title']);
00051   // We don't want to render php output on preview here, because if something is
00052   // wrong the whole display will be borked. So we check to see if the php
00053   // evaluator filter is being used, and make a temporary change to the filter
00054   // so that we get the printed php, not the eval'ed php.
00055   $php_filter = FALSE;
00056   foreach (filter_list_format($pane->configuration['format']) as $filter) {
00057     if ($filter->name == 'PHP evaluator') { // TODO stupid way to check
00058       $php_filter = TRUE;
00059     }
00060   }
00061   // If a php filter is active, pass 1 to use core's most restrictive filter.
00062   $block->content = check_markup($pane->configuration['body'], $php_filter ? 1 : $pane->configuration['format']);
00063   return $block;
00064 }
00065 
00066 /**
00067  * Return all content types available.
00068  */
00069 function panels_admin_content_types_custom() {
00070   return array(
00071     'custom' => array(
00072       'title' => t('New custom content'),
00073       'icon' => 'icon_block_custom.png',
00074       'path' => panels_get_path('content_types/custom'),
00075       'description' => t('Create a completely custom piece of HTML content.'),
00076       'category' => array(t('Custom'), -10),
00077     ),
00078   );
00079 }
00080 
00081 /**
00082  * Returns an edit form for the custom type.
00083  */
00084 function panels_admin_edit_custom($id, $parents, $conf = NULL) {
00085   if (!is_array($conf)) {
00086     $conf = array('title' => '', 'body' => '');
00087   }
00088   $form['title'] = array(
00089     '#type' => 'textfield',
00090     '#default_value' => $conf['title'],
00091     '#title' => t('Title'),
00092   );
00093   $form['body'] = array(
00094     '#title' => t('Body'),
00095     '#type' => 'textarea',
00096     '#default_value' => $conf['body'],
00097   );
00098   $parents[] = 'format';
00099   $form['format'] = filter_form($conf['format'], 1, $parents);
00100 
00101   return $form;
00102 }
00103 
00104 /**
00105  * Returns the administrative title for a type.
00106  */
00107 function panels_admin_title_custom($conf) {
00108   $output = t('Custom');
00109   if ($conf['title']) {
00110     $output .= " (" . filter_xss_admin($conf['title']) . ")";
00111   }
00112   return $output;
00113 }
00114 

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