예제 #1
0
 /**
  * Create menu links.
  *
  * @param array $links
  *   An array of menu link arrays.
  * @param array $defaults
  *   An array of defaults to use for each link. This avoids having to repeat
  *   values in each menu link, like 'menu_name' for example.
  */
 public static function createLinks(array &$links, array $defaults = array())
 {
     foreach ($links as &$link) {
         $link += $defaults;
         if (!url_is_external($link['link_path'])) {
             $link['link_path'] = drupal_get_normal_path($link['link_path']);
         }
         if ($mlid = menu_link_save($link)) {
             $link['mlid'] = $mlid;
             if (!empty($link['children'])) {
                 static::createLinks($link['children'], array('plid' => $mlid) + $defaults);
             }
         } else {
             // Add error logging.
         }
     }
 }
/**
 * Delete/Revert confirm form.
 *
 * @todo -- call back into the object instead.
 */
function ctools_export_ui_delete_confirm_form($form, &$form_state)
{
    _ctools_export_ui_add_form_files($form, $form_state);
    $plugin = $form_state['plugin'];
    $item = $form_state['item'];
    $form = array();
    $export_key = $plugin['export']['key'];
    $question = str_replace('%title', check_plain($item->{$export_key}), $plugin['strings']['confirmation'][$form_state['op']]['question']);
    $path = !empty($_REQUEST['cancel_path']) && !url_is_external($_REQUEST['cancel_path']) ? $_REQUEST['cancel_path'] : ctools_export_ui_plugin_base_path($plugin);
    $form = confirm_form($form, $question, $path, $plugin['strings']['confirmation'][$form_state['op']]['information'], $plugin['allowed operations'][$form_state['op']]['title'], t('Cancel'));
    return $form;
}
예제 #3
0
/**
 * Form for confirming the user wants to deploy this plan.
 */
function deploy_ui_plan_confirm_form($form, $form_state)
{
    $plan = $form_state['plan'];
    $path = 'admin/structure/deploy/plans';
    if (!empty($_REQUEST['cancel_path']) && !url_is_external($_REQUEST['cancel_path'])) {
        $path = $_REQUEST['cancel_path'];
    }
    if (empty($plan->processor) || $plan->fetch_only) {
        drupal_set_message(t("The plan @name can't be deployed in push fashion because it missing a processor plugin or is configured <em>fetch-only</em>.", array('@name' => $plan->name)), 'error');
        drupal_goto($path);
    }
    $form = array();
    $form = confirm_form($form, t('Are you sure you want to deploy %title?', array('%title' => $plan->name)), $path, t("Deploying a plan will push its content to all its endpoints."), t('Deploy'), t('Cancel'));
    return $form;
}
/**
 * Define the preset add/edit form.
 *
 * @see current_search_add_item_submit()
 * @see current_search_settings_form_submit()
 * @ingroup forms
 */
function current_search_settings_form(&$form, &$form_state)
{
    $item =& $form_state['item'];
    $form['info']['#weight'] = -30;
    if (empty($item->settings)) {
        $item->settings = current_search_get_defaults();
    }
    // NOTE: We need to add the #id in order for the machine_name to work.
    $form['info']['label'] = array('#id' => 'edit-label', '#title' => t('Name'), '#type' => 'textfield', '#default_value' => $item->label, '#description' => t('The human-readable name of the current search block configuration.'), '#required' => TRUE, '#maxlength' => 255, '#size' => 30);
    $form['info']['name'] = array('#type' => 'machine_name', '#default_value' => $item->name, '#maxlength' => 32, '#machine_name' => array('exists' => 'current_search_config_exists', 'source' => array('info', 'label')), '#disabled' => 'clone' != $form_state['form type'] && !empty($item->name), '#description' => t('The machine readable name of the current search block configuration. This value can only contain letters, numbers, and underscores.'));
    $form['info']['searcher'] = array('#type' => 'select', '#title' => t('Search page'), '#options' => current_search_get_searcher_options(), '#description' => t('The search page this configuration will be active on.'), '#default_value' => current_search_get_default_searcher(), '#access' => empty($item->name));
    // Hide the standard buttons.
    $form['buttons']['#access'] = FALSE;
    // Add our custom buttons.
    $form['actions'] = array('#type' => 'actions', '#weight' => -100);
    // Gets destination from query string which is set when the page is navigated
    // to via a contextual link. Builds messages based on where user came from.
    if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
        $submit_text = t('Save and go back to search page');
        $cancel_title = t('Return to the search page without saving configuration changes.');
        $url = drupal_parse_url($_GET['destination']);
    } else {
        $submit_text = t('Save and go back to list');
        $cancel_title = t('Return to the list without saving configuration changes.');
        $url = array();
    }
    $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save and edit'));
    // Do not show the button if the page was navigated to via a contextual link
    // because it would redirect the user back to the search page.
    $form['actions']['submit_list'] = array('#type' => 'submit', '#value' => $submit_text);
    $form['actions']['cancel'] = array('#type' => 'link', '#title' => t('Cancel'), '#href' => !$url ? 'admin/config/search/current_search' : $url['path'], '#options' => !$url ? array() : array('query' => $url['query']), '#attributes' => array('title' => $cancel_title));
    if (empty($item->name)) {
        $description = t('Add a new current search block configuration.');
    } else {
        $description = t('Add new items to the current search block or configure existing ones.');
    }
    $form['description'] = array('#prefix' => '<div class="current-search-description">', '#suffix' => '</div>', '#markup' => $description, '#weight' => -90);
    drupal_add_css(drupal_get_path('module', 'current_search') . '/current_search.css');
    // If we are creating the configuration, only display the basic config items.
    // Otherwise set the breadcrumb due to possible bug in CTools Export UI.
    if (empty($form['info']['name']['#default_value'])) {
        return;
    }
    // Gets list of plugins, sanitizes label for output.
    $plugins = array_map('check_plain', current_search_get_plugins());
    ////
    ////
    //// Add plugin section
    ////
    ////
    $form['plugins_title'] = array('#type' => 'item', '#title' => t('Add item to block'));
    $form['plugins'] = array('#tree' => TRUE, '#prefix' => '<div class="clearfix">', '#suffix' => '</div>');
    $form['plugins']['plugin'] = array('#type' => 'select', '#title' => t('Type'), '#options' => $plugins, '#prefix' => '<div class="current-search-setting current-search-plugin">', '#suffix' => '</div>');
    $form['plugins']['item_label'] = array('#title' => t('Name'), '#type' => 'textfield', '#default_value' => '', '#required' => FALSE, '#size' => 30, '#prefix' => '<div class="current-search-setting current-search-label">', '#suffix' => '</div>');
    $form['plugins']['item_name'] = array('#type' => 'machine_name', '#default_value' => '', '#maxlength' => 32, '#machine_name' => array('exists' => 'current_search_item_exists', 'source' => array('plugins', 'item_label')), '#required' => FALSE, '#description' => t('The machine readable name of the item being added to the current search block. This value can only contain letters, numbers, and underscores.'));
    $form['plugins']['actions'] = array('#type' => 'actions', '#prefix' => '<div class="current-search-setting current-search-button">', '#suffix' => '</div>');
    $form['plugins']['actions']['add_item'] = array('#type' => 'submit', '#value' => t('Add item'), '#submit' => array('current_search_add_item_submit'), '#validate' => array('current_search_add_item_validate'));
    ////
    ////
    //// Sort settings
    ////
    ////
    // Ensure the theme function is available after upgrading to 7.x-1.3. A cache
    // clear is all that is needed to fix the broken sort table, however this hack
    // ensures that the theme function is available without having to do so.
    // @todo Remove this in later versions of the module.
    // @see http://drupal.org/node/1795556
    module_load_include('inc', 'current_search', 'current_search.theme');
    $form['plugin_sort'] = array('#type' => 'item', '#access' => !empty($item->settings['items']), '#title' => t('Item display order'), '#theme' => 'current_search_sort_settings_table', '#current_search' => $item->settings, '#tree' => TRUE);
    // Builds checkbox options and weight dropboxes.
    foreach ($item->settings['items'] as $name => $settings) {
        $form['plugin_sort'][$name]['item'] = array('#markup' => check_plain($settings['label']));
        $form['plugin_sort'][$name]['remove'] = array('#type' => 'link', '#title' => t('Remove item'), '#href' => 'admin/config/search/current_search/item/' . $item->name . '/delete/' . $name);
        $form['plugin_sort'][$name]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $settings['label'])), '#title_display' => 'invisible', '#delta' => 50, '#default_value' => isset($settings['weight']) ? $settings['weight'] : 0, '#attributes' => array('class' => array('current-search-sort-weight')));
    }
    ////
    ////
    //// Filter settings
    ////
    ////
    $form['plugin_settings_title'] = array('#type' => 'item', '#access' => !empty($item->settings['items']), '#title' => t('Item settings'));
    $form['plugin_settings'] = array('#type' => 'vertical_tabs', '#tree' => TRUE);
    // Builds table, adds settings to vertical tabs.
    $has_settings = FALSE;
    foreach ($item->settings['items'] as $name => $settings) {
        if ($class = ctools_plugin_load_class('current_search', 'items', $settings['id'], 'handler')) {
            $plugin = new $class($name, $item);
            // Initializes vertical tab for the item's settings.
            $form['plugin_settings'][$name] = array('#type' => 'fieldset', '#title' => check_plain($settings['label']), '#group' => 'settings', '#tree' => TRUE);
            $form['plugin_settings'][$name]['id'] = array('#type' => 'value', '#value' => $settings['id']);
            $form['plugin_settings'][$name]['label'] = array('#type' => 'value', '#value' => $settings['label']);
            // Gets settings from plugin.
            $plugin->settingsForm($form['plugin_settings'][$name], $form_state);
            $has_settings = TRUE;
        }
    }
    // Removes fieldset if there aren't any settings.
    if (!$has_settings) {
        unset($form['plugin_settings']);
    }
    ////
    ////
    //// Advanced settings
    ////
    ////
    $form['advanced_settings_title'] = array('#type' => 'item', '#title' => t('Advanced settings'));
    $form['advanced_settings'] = array('#tree' => TRUE);
    // This setting was originally intended as a way for site builders to enable
    // the current search block on pages where no keywords were submitted by the
    // end user, which is known as an "empty search". The display settings were
    // expanded beyond empty searches at http://drupal.org/node/1779670 leaving
    // us with the unfortunate "empty_searches" key which no longer reflects what
    // this setting does.
    $form['advanced_settings']['empty_searches'] = array('#type' => 'radios', '#title' => t('Display settings'), '#options' => array(CURRENT_SEARCH_DISPLAY_KEYS => t('Display only when keywords are entered.'), CURRENT_SEARCH_DISPLAY_ALWAYS => t('Display on empty searches where no keywords are entered.'), CURRENT_SEARCH_DISPLAY_FILTERS => t('Display only when one or more facet items are active.'), CURRENT_SEARCH_DISPLAY_KEYS_FILTERS => t('Display when either keywords are entered one or more facet items are active.')), '#default_value' => $item->settings['advanced']['empty_searches'], '#description' => t('This setting determines when the current search block will be displayed.'));
}
drupal_override_server_variables();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $test_setting_variable;
$test_setting_variable = parse_ini_file(DRUPAL_ROOT . "/tests/configuration.ini", TRUE);
Patchwork\redefine('drupal_goto', function ($path = '', array $options = array(), $http_response_code = 302) {
    // A destination in $_GET always overrides the function arguments.
    // We do not allow absolute URLs to be passed via $_GET, as this can be an attack vector.
    if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
        $destination = drupal_parse_url($_GET['destination']);
        $path = $destination['path'];
        $options['query'] = $destination['query'];
        $options['fragment'] = $destination['fragment'];
    }
    // In some cases modules call drupal_goto(current_path()). We need to ensure
    // that such a redirect is not to an external URL.
    if ($path === current_path() && empty($options['external']) && url_is_external($path)) {
        // Force url() to generate a non-external URL.
        $options['external'] = FALSE;
    }
    drupal_alter('drupal_goto', $path, $options, $http_response_code);
    global $drupal_goto;
    $drupal_goto['path'] = $path;
    $drupal_goto['options'] = $options;
    $drupal_goto['http_response_code'] = $http_response_code;
});
/**
 * Class RedTest_Framework_TestCase
 *
 * @package RedTest\core
 */
class RedTest_Framework_TestCase extends \PHPUnit_Framework_TestCase
예제 #6
0
파일: Router.php 프로젝트: geodesfour/dp741
 /**
  * @param string $url
  *
  * @return bool
  *   TRUE, if external path.
  */
 function urlIsExternal($url)
 {
     return url_is_external($url);
 }