[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/module_builder/includes/ -> module_builder.admin.inc (source)

   1  <?php
   2  
   3  /**
   4   * @file
   5   *   Menu callbacks for admin pages.
   6   *
   7   */
   8   
   9   
  10  /**
  11   * Admin settings page.
  12   *
  13   * @ingroup module_builder_core
  14   */
  15  function module_builder_admin_settings($form_state) {
  16  
  17    $form['module_builder_hooks_directory'] = array(
  18      '#type' => 'textfield',
  19      '#title' => t('Path to hook documentation directory'),
  20      '#description' => t('Subdirectory in the directory "%dir" where local copies of hook documentation should be stored.', array('%dir' => file_directory_path() .'/')),
  21      '#default_value' => variable_get('module_builder_hooks_directory', 'hooks'),
  22    );
  23  
  24    $form['module_builder_write_directory'] = array(
  25      '#type' => 'textfield',
  26      '#title' => t('Path to write module files'),
  27      '#description' => t('Subdirectory in the directory "%dir" where module files should be written.', array('%dir' => file_directory_path() .'/')),
  28      '#default_value' => variable_get('module_builder_write_directory', 'modules'),
  29    );
  30  
  31    $form['module_builder_header'] = array(
  32      '#type' => 'textarea',
  33      '#title' => t('Module header'),
  34      '#description' => t('This is the code that will be displayed at the top of your module file.'),
  35      '#rows' => 15,
  36      '#default_value' => variable_get('module_builder_header', MODULE_BUILDER_HEADER_DEFAULT),
  37      // TODO: kill MODULE_BUILDER_HEADER_DEFAULT
  38    );
  39    $form['module_builder_footer'] = array(
  40      '#type' => 'textarea',
  41      '#title' => t('Module footer'),
  42      '#description' => t('This is the code that will be displayed at the bottom of your module file.'),
  43      '#rows' => 15,
  44      '#default_value' => variable_get('module_builder_footer', ''),
  45    );
  46    $form['module_builder_detail'] = array(
  47      '#type' => 'radios',
  48      '#title' => t('Code detail level'),
  49      '#description' => t('This setting will either display or suppress additional explanatory comments in the resulting module code to help new developers.'),
  50      '#options' => array(
  51        1 => t("<strong>Beginner</strong>: I'm just starting out with Drupal development; please display lots of helpful comments in my module code!"),
  52        0 => t("<strong>Advanced</strong>: I already know what I'm doing; don't put in a bunch of crap in my module file that I don't need!"),
  53      ),
  54      '#default_value' => variable_get('module_builder_detail', 0),
  55    );
  56    /*
  57    $form['module_builder_download'] = array(
  58      '#type' => 'radios',
  59      '#title' => t('Download module file checkbox defaults to'),
  60      '#description' => t('When checked, this will automatically generate your module file for you and prompt your browser to download it.'),
  61      '#options' => array(
  62        1 => t('Enabled'),
  63        0 => t('Disabled'),
  64      ),
  65      '#default_value' => variable_get('module_builder_download', 1),
  66    );
  67    */
  68    return system_settings_form($form);
  69  }
  70  
  71  /**
  72   * Admin hook update form.
  73   */
  74  function module_builder_admin_update($form_state) {
  75    // Include generating component file.
  76    module_builder_include('process');
  77  
  78    $last_update = module_builder_get_hook_data_last_updated();
  79  
  80    $form['last_update'] = array(
  81      '#type' => 'item',
  82      '#value' => $last_update ?
  83          t('Your last hook documentation update was %date.', array('%date' => $last_update)) :
  84          t('The hook documentation has not yet been downloaded.'),
  85    );
  86  
  87    $doc_files = module_builder_get_doc_files();
  88    $dir = _module_builder_get_hooks_directory();
  89    if (count($doc_files)) {
  90      $form["files"] = array(
  91        '#type' => 'item',
  92        '#value' => "You have the following hook definition files saved in $dir: " .
  93           theme('item_list', $doc_files),
  94      );
  95    }
  96  
  97    $form['update'] = array(
  98      '#type' => 'submit',
  99      '#value' => 'Download',
 100    );
 101    
 102    return $form;
 103  }
 104  
 105  /**
 106   * Admin hook update form submit handler.
 107   */
 108  function module_builder_admin_update_submit($form, $form_state) {
 109    _module_builder_check_settings();
 110    module_builder_update_data();
 111  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7