function views_block_configure

Implements hook_block_configure().

File

./views.module, line 758

Code

function views_block_configure($delta = '') {
    // If there's no Views UI module there's nothing to link to.
    if (!module_exists('views_ui')) {
        return array();
    }
    // If the user doesn't have access to edit the view then don't bother with
    // anything else.
    if (!user_access('administer views')) {
        return array();
    }
    // If this is 32, this should be an md5 hash.
    if (strlen($delta) == 32) {
        $hashes = variable_get('views_block_hashes', array());
        if (!empty($hashes[$delta])) {
            $delta = $hashes[$delta];
        }
    }
    // Some added precaution in case the delta is missing values.
    list($view_name, $display_id) = explode('-', $delta, 2) + array(
        '',
        '',
    );
    // If the view name or display ID can't be found, there's something wrong.
    if ($view_name === '' || $display_id === '') {
        return array();
    }
    $view = views_get_view($view_name);
    if (empty($view)) {
        return array();
    }
    if (!isset($view->display[$display_id])) {
        return array();
    }
    
    /** @var \views_display $display */
    $display = $view->display[$display_id];
    $view_label = $view->get_human_name();
    $display_label = $display->display_title;
    $path = "admin/structure/views/view/{$view_name}/edit/{$display_id}";
    return array(
        'fieldset' => array(
            '#type' => 'fieldset',
            '#title' => t('Configure this views display'),
            'content' => array(
                '#markup' => l($view_label . ' - ' . $display_label, $path),
            ),
        ),
    );
}