block.inc File Reference

(1.1.6.27 2008/07/09 21:58:39 merlinofchaos)

Go to the source code of this file.

Functions

 aggregator_panels_block_info ($module, $delta, &$info)
 block_panels_block_info ($module, $delta, &$info)
 blog_panels_block_info ($module, $delta, &$info)
 book_panels_block_info ($module, $delta, &$info)
 comment_panels_block_info ($module, $delta, &$info)
 forum_panels_block_info ($module, $delta, &$info)
 menu_panels_block_info ($module, $delta, &$info)
 node_panels_block_info ($module, $delta, &$info)
 panels_admin_add_block ($id, $parents, $conf=array())
 panels_admin_content_types_block ()
 panels_admin_edit_block ($id, $parents, $conf)
 panels_admin_fix_block_tree (&$form, $key=NULL)
 panels_admin_submit_block (&$form_values)
 panels_admin_title_block ($conf)
 panels_block_panels_content_types ()
 panels_content_block ($conf)
 panels_default_block_info ($module, $delta, &$info)
 poll_panels_block_info ($module, $delta, &$info)
 profile_panels_block_info ($module, $delta, &$info)
 search_panels_block_info ($module, $delta, &$info)
 user_panels_block_info ($module, $delta, &$info)


Function Documentation

aggregator_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 288 of file block.inc.

00288                                                                {
00289   $info['icon'] = 'icon_core_syndicate.png';
00290   $info['category'] = array(t('Syndicated Feeds'), -3);
00291 }

block_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 293 of file block.inc.

00293                                                           {
00294   $info['icon'] = 'icon_core_block_empty.png';
00295   $info['category'] = array(t('Custom'), -10);
00296 }

blog_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 263 of file block.inc.

00263                                                          {
00264   $info['icon'] = 'icon_core_recentblogposts.png';
00265   $info['category'] = t('Core blocks');
00266 }

book_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 258 of file block.inc.

00258                                                          {
00259   $info['icon'] = 'icon_core_booknavigation.png';
00260   $info['category'] = t('Core blocks');
00261 }

comment_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 273 of file block.inc.

00273                                                             {
00274   $info['icon'] = 'icon_core_recentcomments.png';
00275   $info['category'] = t('Core blocks');
00276 }

forum_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 236 of file block.inc.

References panels_default_block_info().

00236                                                           {
00237   $info['category'] = t('Core blocks');
00238   switch ($delta) {
00239     case '0':
00240       $info['icon'] = 'icon_core_activeforumtopics.png';
00241       break;
00242 
00243     case '1':
00244       $info['icon'] = 'icon_core_newforumtopics.png';
00245       break;
00246 
00247     default:
00248       // safety net
00249       panels_default_block_info($module, $delta, $info);
00250   }
00251 }

Here is the call graph for this function:

menu_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 231 of file block.inc.

00231                                                          {
00232   $info['icon'] = 'icon_core_block_menu.png';
00233   $info['category'] = array(t('Menus'), -2);
00234 }

node_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 283 of file block.inc.

00283                                                          {
00284   $info['icon'] = 'icon_core_syndicate.png';
00285   $info['category'] = t('Core blocks');
00286 }

panels_admin_add_block ( id,
parents,
conf = array() 
)

Returns the form for a new block.

Definition at line 125 of file block.inc.

References panels_admin_edit_block().

00125                                                                 {
00126   list($conf['module'], $conf['delta']) = explode('-', $id, 2);
00127   return panels_admin_edit_block($id, $parents, $conf);
00128 }

Here is the call graph for this function:

panels_admin_content_types_block (  ) 

Return all block content types available.

Modules wanting to make special adjustments the way that panels handles their blocks can implement an extension to the hook_block() family, where the function name is of the form "$module . '_panels_block_info'".

Definition at line 92 of file block.inc.

00092                                             {
00093   $types = array();
00094   foreach (module_list() as $module) {
00095     $module_blocks = module_invoke($module, 'block', 'list');
00096     if ($module_blocks) {
00097       foreach ($module_blocks as $delta => $block) {
00098         // strip_tags used because it goes through check_plain and that
00099         // just looks bad.
00100         $info = array(
00101           'title' => strip_tags($block['info']),
00102         );
00103 
00104         // Ask around for further information by invoking the hook_block() extension.
00105         $function = $module . '_panels_block_info';
00106         if (!function_exists($function)) {
00107           $function = 'panels_default_block_info';
00108         }
00109         $function($module, $delta, $info);
00110 
00111         // this check means modules can remove their blocks; particularly useful
00112         // if they offer the block some other way (like we do for views)
00113         if ($info) {
00114           $types["$module-$delta"] = $info;
00115         }
00116       }
00117     }
00118   }
00119   return $types;
00120 }

panels_admin_edit_block ( id,
parents,
conf 
)

Returns an edit form for a block.

Definition at line 133 of file block.inc.

References panels_admin_fix_block_tree().

Referenced by panels_admin_add_block().

00133                                                        {
00134   $form['module'] = array(
00135     '#type' => 'value',
00136     '#value' => $conf['module'],
00137   );
00138   $form['delta'] = array(
00139     '#type' => 'value',
00140     '#value' => $conf['delta'],
00141   );
00142 
00143   if (user_access('administer advanced pane settings')) {
00144     $form['block_visibility'] = array(
00145       '#type' => 'checkbox',
00146       '#title' => t('Use block visibility settings (see block config)'),
00147       '#default_value' => $conf['block_visibility'],
00148       '#description' => t('If checked, the block visibility settings for this block will apply to this block.'),
00149     );
00150     // Module-specific block configurations.
00151     if ($settings = module_invoke($conf['module'], 'block', 'configure', $conf['delta'])) {
00152       // Specifically modify a couple of core block forms.
00153       if ($conf['module'] == 'block') {
00154         unset($settings['submit']);
00155         $settings['info']['#type'] = 'value';
00156         $settings['info']['#value'] = $settings['info']['#default_value'];
00157       }
00158       panels_admin_fix_block_tree($settings);
00159       $form['block_settings'] = array(
00160         '#type' => 'fieldset',
00161         '#title' => t('Block settings'),
00162         '#description' => t('Settings in this section are global and are for all blocks of this type, anywhere in the system.'),
00163         '#tree' => FALSE,
00164       );
00165 
00166 
00167       $form['block_settings'] += $settings;
00168     }
00169   }
00170 
00171   return $form;
00172 }

Here is the call graph for this function:

Here is the caller graph for this function:

panels_admin_fix_block_tree ( &$  form,
key = NULL 
)

Because form api cannot collapse just part of a tree, and the block settings assume no tree, we have to collapse the tree ourselves.

Definition at line 184 of file block.inc.

Referenced by panels_admin_edit_block().

00184                                                           {
00185   if ($key) {
00186     if (!empty($form['#parents'])) {
00187       $form['#parents'] = array_merge(array('configuration', 'block_settings'), $form['#parents']);
00188     }
00189     else if (empty($form['#tree'])) {
00190       $form['#parents'] = array('configuration', 'block_settings', $key);
00191     }
00192   }
00193 
00194   if ($form['#type'] == 'textarea' && !empty($form['#rows']) && $form['#rows'] > 10) {
00195     $form['#rows'] = 10;
00196   }
00197 
00198   foreach (element_children($form) as $key) {
00199     panels_admin_fix_block_tree($form[$key], $key);
00200   }
00201 }

Here is the caller graph for this function:

panels_admin_submit_block ( &$  form_values  ) 

Definition at line 174 of file block.inc.

00174                                                   {
00175   if (!empty($form_values['block_settings'])) {
00176     module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values['block_settings']);
00177   }
00178 }

panels_admin_title_block ( conf  ) 

Returns the administrative title for a type.

Definition at line 206 of file block.inc.

00206                                          {
00207   $block = module_invoke($conf['module'], 'block', 'list');
00208   if (empty($block) || empty($block[$conf['delta']])) {
00209     return t('Deleted/missing block @module-@delta', array('@module' => $conf['module'], '@delta' => $conf['delta']));
00210   }
00211 
00212   $title = filter_xss_admin($block[$conf['delta']]['info']);
00213   return $title;
00214 }

panels_block_panels_content_types (  ) 

Callback function to supply a list of content types.

Definition at line 8 of file block.inc.

00008                                              {
00009   $items['block'] = array(
00010     'title' => t('Block'),
00011     'content_types' => 'panels_admin_content_types_block',
00012     'render callback' => 'panels_content_block',
00013     'add callback' => 'panels_admin_add_block',
00014     'edit callback' => 'panels_admin_edit_block',
00015     'title callback' => 'panels_admin_title_block',
00016     'add submit callback' => 'panels_admin_submit_block',
00017     'edit submit callback' => 'panels_admin_submit_block',
00018     //'validate callback' => 'panels_admin_validate_block',
00019   );
00020   return $items;
00021 }

panels_content_block ( conf  ) 

Output function for the 'block' content type. Outputs a block based on the module and delta supplied in the configuration.

Definition at line 27 of file block.inc.

00027                                      {
00028   $block = (object) module_invoke($conf['module'], 'block', 'view', $conf['delta']);
00029   if (empty($block)) {
00030     return;
00031   }
00032 
00033   $block->module = $conf['module'];
00034   $block->delta = $conf['delta'];
00035 
00036   if (user_access('administer blocks')) {
00037     $block->admin_links = array(
00038       array(
00039         'title' => t('Configure block'),
00040         'alt' => t("Configure this pane's 'block settings' in administer >> site building >> blocks"),
00041         'href' => "admin/build/block/configure/$block->module/$block->delta",
00042         'query' => drupal_get_destination(),
00043       ),
00044     );
00045   }
00046 
00047   // This seems extra but it prevents an unnecessary query sometimes.
00048   if (empty($conf['block_visibility']) && $block->module != 'block') {
00049     return $block;
00050   }
00051 
00052   // Test for block visibility
00053   $result = db_query("SELECT title, pages, visibility FROM {blocks} WHERE module = '%s' AND delta = '%s'", $block->module, $block->delta);
00054   $block_visibility = db_fetch_object($result);
00055 
00056   if ($block->module == 'block') {
00057     $block->title = $block_visibility->title;
00058   }
00059 
00060   if (empty($conf['block_visibility'])) {
00061     return $block;
00062   }
00063 
00064   if ($block_visibility && $block_visibility->pages) {
00065     if ($block_visibility->visibility < 2) {
00066       $path       = drupal_get_path_alias($_GET['q']);
00067       $regexp     = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block_visibility->pages, '/')) .')$/';
00068       $page_match = !($block_visibility->visibility xor preg_match($regexp, $path));
00069     }
00070     else {
00071       $page_match = drupal_eval($block_visibility->pages);
00072     }
00073   }
00074   else {
00075     $page_match = TRUE;
00076   }
00077 
00078   if ($page_match) {
00079     return $block;
00080   }
00081 }

panels_default_block_info ( module,
delta,
&$  info 
)

Definition at line 216 of file block.inc.

Referenced by forum_panels_block_info(), and user_panels_block_info().

00216                                                             {
00217   $core_modules = array('aggregator', 'block', 'blog', 'blogapi', 'book', 'color', 'comment', 'contact', 'drupal', 'filter', 'forum', 'help', 'legacy', 'locale', 'menu', 'node', 'path', 'ping', 'poll', 'profile', 'search', 'statistics', 'taxonomy', 'throttle', 'tracker', 'upload', 'user', 'watchdog', 'system');
00218 
00219   if (in_array($module, $core_modules)) {
00220     $info['icon'] = 'icon_core_block.png';
00221     $info['category'] = array(t('Core blocks'), -5);
00222   }
00223   else {
00224     $info['icon'] = 'icon_contrib_block.png';
00225     $info['category'] = t('Contributed blocks');
00226   }
00227 }

Here is the caller graph for this function:

poll_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 268 of file block.inc.

00268                                                          {
00269   $info['icon'] = 'icon_core_recentpoll.png';
00270   $info['category'] = t('Core blocks');
00271 }

profile_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 253 of file block.inc.

00253                                                             {
00254   $info['icon'] = 'icon_core_authorinformation.png';
00255   $info['category'] = t('Core blocks');
00256 }

search_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 278 of file block.inc.

00278                                                            {
00279   $info['icon'] = 'icon_core_searchform.png';
00280   $info['category'] = t('Core blocks');
00281 }

user_panels_block_info ( module,
delta,
&$  info 
)

Definition at line 298 of file block.inc.

References panels_default_block_info().

00298                                                          {
00299   $info['category'] = t('Core blocks');
00300   switch ($delta) {
00301     case '0':
00302       $info['icon'] = 'icon_core_userlogin.png';
00303       break;
00304 
00305     case '1':
00306       $info['icon'] = 'icon_core_navigation.png';
00307       $info['category'] = array(t('Menus'), -2);
00308       break;
00309 
00310     case '2':
00311       $info['icon'] = 'icon_core_whosnew.png';
00312       break;
00313 
00314     case '2':
00315       $info['icon'] = 'icon_core_whosonline.png';
00316       break;
00317 
00318     default:
00319       // safety net
00320       panels_default_block_info($module, $delta, $info);
00321   }
00322 }

Here is the call graph for this function:


Generated on Wed Mar 17 05:00:16 2010 for Panels 2 by  doxygen 1.5.6