début de modal sans ctools

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2012-11-01 01:10:02 +01:00
parent df2c715315
commit 1d11663ec4
4 changed files with 138 additions and 123 deletions
+58 -24
View File
@@ -32,34 +32,68 @@ function materio_flag_refresh_block($flag){
}
/**
* materio_flag_createlist($type, $nid, $js)
* materio_flag_createlist($type)
*
*/
function materio_flag_createlist($type, $nid, $js){
// Check whether js is enabled.
if ($js) {
// Include ctools modal plugin.
ctools_include('modal');
function materio_flag_createlist_form($type){
$debug = false;
$form_state = array('ajax' => TRUE);
$path = 'flag-lists/add/' . $type;
// Array with ajax response.
$commands = array();
module_load_include('inc', 'flag_lists', 'flag_lists.admin');
$form_state['title'] = t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list')));
$form_state['build_info']['args'] = array(NULL, $type);
$commands = ctools_modal_form_wrapper('flag_lists_form', $form_state);
// If form was submited.
if (!empty($form_state['executed'])) {
$commands = _materio_flag_addlists_execute_form($form_state, $nid);
}
return array('#type' => 'ajax', '#commands' => $commands);
}else{
// If user has no js support redirect him to standart drupal forms.
// check if request is ajax, if not rediret
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
drupal_goto('flag-lists/add/' . $type);
exit ;
}
// menu_set_active_item($path);
// $return = menu_execute_active_handler($path, FALSE);
// if (is_int($return)) {
// switch ($return) {
// case MENU_NOT_FOUND :
// drupal_add_http_header('Status', '404 Not Found');
// break;
// case MENU_ACCESS_DENIED :
// drupal_add_http_header('Status', '403 Forbidden');
// break;
// case MENU_SITE_OFFLINE :
// drupal_add_http_header('Status', '503 Service unavailable');
// break;
// }
// } elseif (isset($return)) {
$form_state['build_info']['args'] = array(null, $type);
// $form = drupal_get_form('flag_lists_form', $form_state);//, NULL, $type
$form = drupal_build_form('flag_lists_form', $form_state);
dsm($form, 'form');
// if (is_array($return)) {
$return = drupal_render($form);
// }
$rep = array(
'return'=>$return,
);
if ($debug) {
dsm($rep, 'rep');
return "debug display";
}else{
drupal_json_output($rep);
}
// }
}
/**
* materio_flag_createlist($type, $nid)
*
*/
function materio_flag_createlist($title, $nid = null){
drupal_get_form('flag_lists_form', $title);
}