View source
<?php
function path_breadcrumbs_ui_configure_arguments_page($path_name, $keyword) {
ctools_include('modal');
$form_state = array(
'storage' => array(
'path_name' => $path_name,
'keyword' => $keyword,
),
);
$form = drupal_build_form('path_breadcrumbs_ui_argument_context_form', $form_state);
$commands = ctools_modal_form_render(array(
'title' => t('Choose argument'),
), $form);
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}
function path_breadcrumbs_ui_change_arguments_page($path_name, $keyword) {
ctools_include('modal');
$breadcrumb = path_breadcrumbs_object_cache_get($path_name);
$form_state = array(
'storage' => array(
'step' => 2,
'path_name' => $path_name,
'keyword' => $keyword,
'argument' => $breadcrumb->arguments[$keyword]['argument'],
),
);
$form = drupal_build_form('path_breadcrumbs_ui_argument_context_form', $form_state);
$commands = ctools_modal_form_render(array(
'title' => t('Choose argument'),
), $form);
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}
function path_breadcrumbs_ui_edit_page($path_breadcrumb) {
$page['content']['#prefix'] = '<div id="path-breadcrumbs-ui-wrapper" class="clearfix">';
$page['content']['#suffix'] = '</div>';
path_breadcrumbs_object_cache_set($path_breadcrumb->machine_name, $path_breadcrumb);
$links[] = array(
'#type' => 'link',
'#title' => t('Basic'),
'#href' => 'admin/structure/path-breadcrumbs/edit/' . $path_breadcrumb->machine_name . '/ajax/1',
'#attributes' => array(
'class' => array(
'use-ajax',
'active',
),
),
);
$links[] = array(
'#type' => 'link',
'#title' => t('Arguments'),
'#href' => 'admin/structure/path-breadcrumbs/edit/' . $path_breadcrumb->machine_name . '/ajax/2',
'#attributes' => array(
'class' => array(
'use-ajax',
),
),
);
$links[] = array(
'#type' => 'link',
'#title' => t('Selection rules'),
'#href' => 'admin/structure/path-breadcrumbs/edit/' . $path_breadcrumb->machine_name . '/ajax/3',
'#attributes' => array(
'class' => array(
'use-ajax',
),
),
);
$links[] = array(
'#type' => 'link',
'#title' => t('Breadcrumbs'),
'#href' => 'admin/structure/path-breadcrumbs/edit/' . $path_breadcrumb->machine_name . '/ajax/4',
'#attributes' => array(
'class' => array(
'use-ajax',
),
),
);
$rendered_links = array();
foreach ($links as $link) {
$rendered_links[] = render($link);
}
$page['content']['menu'] = array(
'#markup' => '<div id="path-breadcrumbs-ui-menu">' . theme('item_list', array(
'items' => $rendered_links,
)) . '</div>',
);
$form_state = array(
'storage' => array(
'machine_name' => $path_breadcrumb->machine_name,
'step' => 1,
),
);
$form = drupal_build_form('path_breadcrumbs_ui_edit_form', $form_state);
$page['content']['edit_form'] = array(
'#markup' => render($form),
);
drupal_add_library('system', 'drupal.ajax');
drupal_add_css(drupal_get_path('module', 'path_breadcrumbs_ui') . '/path_breadcrumbs_ui.css');
return $page;
}
function path_breadcrumbs_ui_edit_form_ajax_links($breadcrumb, $step) {
$form_state = array(
'storage' => array(
'machine_name' => $breadcrumb->machine_name,
'step' => $step,
),
);
$form = drupal_build_form('path_breadcrumbs_ui_edit_form', $form_state);
$commands = array();
$commands[] = ajax_command_replace('#path-breadcrumbs-ui-form-wrapper', render($form));
$commands[] = ajax_command_invoke('#path-breadcrumbs-ui-menu li a', 'removeClass', array(
'active',
));
$commands[] = ajax_command_invoke('#path-breadcrumbs-ui-menu li a:eq(' . --$step . ')', 'addClass', array(
'active',
));
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}
function path_breadcrumbs_ui_disable_breadcrumbs_page($path_breadcrumbs) {
ctools_include('export');
ctools_export_crud_disable('path_breadcrumbs', $path_breadcrumbs);
cache_clear_all('path_breadcrumbs', 'cache', TRUE);
drupal_set_message(t('Breadcrumb %name was disabled', array(
'%name' => $path_breadcrumbs->name,
)));
drupal_goto('admin/structure/path-breadcrumbs');
}
function path_breadcrumbs_ui_enable_breadcrumbs_page($path_breadcrumbs) {
ctools_include('export');
ctools_export_crud_enable('path_breadcrumbs', $path_breadcrumbs);
cache_clear_all('path_breadcrumbs', 'cache', TRUE);
drupal_set_message(t('Breadcrumb %name was enabled', array(
'%name' => $path_breadcrumbs->name,
)));
drupal_goto('admin/structure/path-breadcrumbs');
}