You are here

function authcache_panels_pane_machine_name_generate in Authenticated User Page Caching (Authcache) 7.2

Given a pane, generate an initial machine name.

1 call to authcache_panels_pane_machine_name_generate()
authcache_panels_cache_settings_form in modules/authcache_panels/plugins/cache/authcache_panels.inc
Settings form.

File

modules/authcache_panels/authcache_panels.module, line 106
Authcache support for Panels.

Code

function authcache_panels_pane_machine_name_generate($display, $pid) {
  ctools_include('content');
  $suffix = '';
  for ($attempt = 0; $attempt < 100; $attempt++) {
    $pane = $display->content[$pid];
    $content_type = ctools_get_content_type($pane->type);
    $title = ctools_content_admin_title($content_type, $pane->subtype, $pane->configuration, $display->context);
    if (!$title) {
      $title = t('Deleted/missing content type @type', array(
        '@type' => $pane->type,
      ));
    }
    if ($attempt > 0) {
      $suffix = '-' . $attempt;
    }
    $machine_name = preg_replace('/[^a-z0-9-]+/', '_', strtolower($title));
    $machine_name = substr($machine_name, 0, 64 - strlen($suffix)) . $suffix;
    if (!authcache_panels_pane_machine_name_exists($machine_name)) {
      return $machine_name;
    }
  }
}