You are here

function _asset_wizard_page_match in Asset 6

Same name and namespace in other branches
  1. 5.2 asset_wizard.module \_asset_wizard_page_match()

Should we show the insert asset link, determined by admin setting Borrowed from tinymce.module

Return value

TRUE if can render, FALSE if not allowed.

1 call to _asset_wizard_page_match()
asset_wizard_textarea in ./asset_wizard.module
The #process callback function for the textareas

File

./asset_wizard.module, line 308
Wizard-style interface for Asset.

Code

function _asset_wizard_page_match() {
  $page_match = FALSE;
  $access_option = variable_get('asset_wizard_access_option', 1);
  $access_pages = variable_get('asset_wizard_access_pages', "node/add/*\nnode/*/edit");
  if ($access_pages) {

    // If the PHP option wasn't selected
    if ($access_option < 2) {
      $path = drupal_get_path_alias($_GET['q']);
      $regexp = '/^(' . preg_replace(array(
        '/(\\r\\n?|\\n)/',
        '/\\\\\\*/',
        '/(^|\\|)\\\\<front\\\\>($|\\|)/',
      ), array(
        '|',
        '.*',
        '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
      ), preg_quote($access_pages, '/')) . ')$/';
      $page_match = !($access_option xor preg_match($regexp, $path));
    }
    else {
      $page_match = drupal_eval($access_pages);
    }
  }
  else {
    $page_match = TRUE;
  }
  return $page_match;
}