@@ -50,13 +50,18 @@ function materio_flag_menu() {
|
||||
'page arguments' => array(3),
|
||||
);
|
||||
|
||||
$items['materioflag/createlist/%/%/%ctools_js'] = $base+array(
|
||||
$items['materioflag/createlist/form/%'] = $base+array(
|
||||
'access arguments' => array('create flag lists'),
|
||||
'access callback' => 'user_access',
|
||||
'page callback' => 'materio_flag_createlist_form',
|
||||
'page arguments' => array(3),
|
||||
);
|
||||
|
||||
$items['materioflag/createlist/%'] = $base+array(
|
||||
'access arguments' => array('create flag lists'),
|
||||
'access callback' => 'user_access',
|
||||
'page callback' => 'materio_flag_createlist',
|
||||
'page arguments' => array(2,3,4),
|
||||
'delivery callback' => 'ajax_deliver',
|
||||
'theme callback' => 'ajax_base_page_theme',
|
||||
'page arguments' => array(2, 3),
|
||||
);
|
||||
|
||||
return $items;
|
||||
@@ -241,35 +246,25 @@ function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
|
||||
}
|
||||
|
||||
#create new list
|
||||
// $link = l(
|
||||
// t('New @name', array('@name' => variable_get('flag_lists_name', t('list')))),
|
||||
// 'flag-lists/add/' . $entity->type,// . '/js',
|
||||
// array(
|
||||
// 'query' => drupal_get_destination(),
|
||||
// 'attributes' => array(
|
||||
// 'class' => array('flag-lists-create'),
|
||||
// 'title' => t('create a new @name and use it.', array('@name'=>variable_get('flag_lists_name', t('list'))))
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
|
||||
_materio_flag_include_modal();
|
||||
|
||||
$linktext = t('New @name', array('@name' => variable_get('flag_lists_name', t('list'))));
|
||||
$link = ctools_modal_text_button(
|
||||
$linktext,
|
||||
'materioflag/createlist/'.$entity->type.'/'.$entity->nid.'/nojs',
|
||||
t('Create a new @name and use it.', array('@name'=>variable_get('flag_lists_name', t('list')))),
|
||||
'ctools-modal-ctools-materio-flag-style'
|
||||
$link = l(
|
||||
t('New @name', array('@name' => variable_get('flag_lists_name', t('list')))),
|
||||
'flag-lists/add/' . $entity->type,
|
||||
array(
|
||||
// 'query' => drupal_get_destination(),
|
||||
'attributes' => array(
|
||||
'class' => array('flag-lists-create'),
|
||||
'title' => t('create a new @name and use it.', array('@name'=>variable_get('flag_lists_name', t('list'))))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
$create = array(
|
||||
'data' => $link,// . '<i class="icon-plus"></i>',
|
||||
'class' => array('flag-lists-create'),
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if( (!isset($items) || !count($items)) && !isset($create))
|
||||
@@ -283,86 +278,16 @@ function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
|
||||
if(isset($create))
|
||||
$ops['create'] = $create;
|
||||
|
||||
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag-ck.js');
|
||||
|
||||
$flaglists_links = theme('materio_flag_mylists_entity_links', $ops);
|
||||
|
||||
|
||||
|
||||
$entity->content['links']['flaglistslinks'] = array('#markup' => $flaglists_links,"#html"=>true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add css and javascript for modal dialog.
|
||||
*/
|
||||
function _materio_flag_include_modal() {
|
||||
static $added = FALSE;
|
||||
if ($added == FALSE) {
|
||||
|
||||
// Do not add css and scripts again.
|
||||
$added = TRUE;
|
||||
|
||||
// Include the CTools tools that we need.
|
||||
ctools_include('modal');
|
||||
ctools_include('ajax');
|
||||
ctools_modal_add_js();
|
||||
|
||||
// Create our own javascript that will be used to theme a modal.
|
||||
$materio_flag_style = array(
|
||||
'ctools-materio-flag-style' => array(
|
||||
'modalSize' => array(
|
||||
'type' => 'fixed',
|
||||
'width' => 400,
|
||||
'height' => 160,
|
||||
'contentRight' => 30,
|
||||
'contentBottom' => 0,
|
||||
),
|
||||
'modalOptions' => array(
|
||||
'opacity' => 0.8,
|
||||
'background-color' => '#FFF',
|
||||
),
|
||||
'closeText' => '',
|
||||
'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'ajax_register'))),
|
||||
'animation' => 'fadeIn',
|
||||
'animationSpeed' => 'fast',
|
||||
),
|
||||
);
|
||||
drupal_add_js($materio_flag_style, 'setting');
|
||||
|
||||
// Add module css and js.
|
||||
//ctools_add_css('ajax-register', 'ajax_register');
|
||||
//ctools_add_js('ajax-register', 'ajax_register');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes form.
|
||||
*
|
||||
* see _ajax_register_execute_form()
|
||||
*/
|
||||
function _materio_flag_addlists_execute_form($form_state, $nid){
|
||||
|
||||
$node = node_load($nid);
|
||||
|
||||
|
||||
|
||||
// Include additional ajax commands.
|
||||
ctools_include('ajax');
|
||||
ctools_include('modal');
|
||||
$message = t('@node has been added to newly created @name @title. The current page will be reloaded.', array(
|
||||
'@node' => $node->title,
|
||||
'@name' => variable_get('flag_lists_name', 'list'),
|
||||
'@title' => $form_state['values']['title'])
|
||||
);
|
||||
|
||||
$commands[] = ctools_modal_command_display(t('@title created', array('@title' => $form_state['values']['title'])), '<div>'.$message.'</div>'.theme('status_messages'));
|
||||
// $commands[] = ctools_ajax_command_reload();
|
||||
// dsm($form_state);
|
||||
return $commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user