Guest User

Untitled

a guest
Jun 18th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ffield_menu(){
  2. // Модальное окно
  3.   $items['ffield/%ctools_js/select'] = array(
  4.     'title' => 'Select',
  5.     'page callback' => 'ffield_select_callback',
  6.     'page arguments' => array(1),
  7.     'access arguments' => array('access content'),
  8.     'delivery callback' => 'ajax_deliver',
  9.     'theme callback' => 'ajax_base_page_theme',
  10.   );
  11.   // Следующая страница
  12.   $items['ffield/%ctools_js/list/%id'] = array(
  13.     'title' => 'List',
  14.     'page callback' => 'ffield_list_callback',
  15.     'page arguments' => array(1, 2),
  16.     'access arguments' => array('access content'),
  17.     'delivery callback' => 'ajax_deliver',
  18.     //'theme callback' => 'ajax_base_page_theme',
  19.   );
  20. return $items;
  21. }
  22.  
  23. function ffield_select_callback($js = NULL) {
  24.   if ($js) {
  25.     ctools_include('modal');
  26.     $form_state = array(
  27.       'title' => t('Выберите адрес'),
  28.       'ajax' => TRUE,
  29.       'build_info' => array(
  30.         'args' => array(),
  31.       ),
  32.     );
  33.  
  34.     form_load_include($form_state, 'inc', 'ffield', 'select_add.pages');
  35.  
  36.     $commands = array();
  37.     $commands = ctools_modal_form_wrapper('select_form', $form_state);
  38.     return array('#type' => 'ajax', '#commands' => $commands);
  39.   }
  40. }
  41.  
  42. function ffield_list_callback($js = NULL, $id = NULL){
  43.   //dd('this');
  44.   if ($js){
  45.     ctools_include('ajax');
  46.     $q = db_select('ffield_AS_ADDROBJ', 'faddr')
  47.         ->fields('faddr', array('id', 'AOGUID', 'PARENTGUID', 'FORMALNAME', 'SHORTNAME'))
  48.         ->condition('PARENTGUID', $id, '=')
  49.         ->orderBy('FORMALNAME', 'ASC')
  50.         ->execute()
  51.         ->fetchAll();
  52.   }
  53. }
  54.  
  55. // Форма которая выводится в модальном окне
  56. function select_form($form, &$form_state) {
  57. //....
  58. ctools_include('ajax');
  59. $form['link-' . $obj->id] = array(
  60.       '#type' => 'link',
  61.       '#href' => 'ffield/nojs/' . $obj->AOGUID,
  62.       '#title' => $obj->FORMALNAME . ' ' . $obj->SHORTNAME . '.',
  63.       '#attributes' => array(
  64.         'class' => array('ctools-use-ajax'),
  65.       ),
  66.     );
  67. // ....
  68. return $form;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment