65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* materio_flag_refresh_block($flag)
|
|
*
|
|
*/
|
|
function materio_flag_refresh_block($flag){
|
|
$rep = array();
|
|
|
|
switch ($flag) {
|
|
case 'bookmarks':
|
|
$block_name = 'materio_flag_mybookmarks';
|
|
break;
|
|
case 'mylists':
|
|
$block_name = 'materio_flag_mylists';
|
|
break;
|
|
}
|
|
|
|
if(!isset($block_name))
|
|
return;
|
|
|
|
// $block_content = module_invoke('block', 'block_view', 'materio_flag_mybookmarks');
|
|
|
|
$block = block_load('materio_flag', $block_name);
|
|
$block_content = _block_render_blocks(array($block));
|
|
$build = _block_get_renderable_array($block_content);
|
|
$block_rendered = drupal_render($build);
|
|
|
|
$rep['block'] = $block_rendered;
|
|
|
|
drupal_json_output($rep);
|
|
}
|
|
|
|
/**
|
|
* materio_flag_createlist($type, $nid, $js)
|
|
*
|
|
*/
|
|
function materio_flag_createlist($type, $nid, $js){
|
|
// Check whether js is enabled.
|
|
if ($js) {
|
|
// Include ctools modal plugin.
|
|
ctools_include('modal');
|
|
|
|
$form_state = array('ajax' => TRUE);
|
|
|
|
// 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.
|
|
drupal_goto('flag-lists/add/' . $type);
|
|
}
|
|
} |