You are here

function custom_pub_admin in Custom Publishing Options 6

Same name and namespace in other branches
  1. 7 custom_pub.admin.inc \custom_pub_admin()

Callback function for our menu item.

1 string reference to 'custom_pub_admin'
custom_pub_menu in ./custom_pub.module
Implements hook_menu().

File

./custom_pub.module, line 63
Adds the ability to add Custom publishing options to the node Add/Edit form.

Code

function custom_pub_admin() {
  $table = '';

  //add the js for the admin page
  drupal_add_js(drupal_get_path('module', 'custom_pub') . '/custom_pub.admin.js');
  $types = variable_get('custom_pub_types', array());

  //get the current custom publishing types
  foreach ($types as $type) {

    // Build table rows for the
    $form_row = array();
    $types_of_nodes = '';
    if (isset($type['node_types']) && is_array($type['node_types'])) {
      $types_of_nodes = implode(', ', $type['node_types']);
    }
    $row = array(
      check_plain($type['name']),
      $type['type'],
      $types_of_nodes,
      array(
        'data' => '',
        'class' => 'custom_pub-option-edit-cell',
      ),
    );
    $form_row[] = array(
      'data' => drupal_get_form('custom_pub_edit_' . $type['type'], $type),
      'colspan' => 4,
    );
    $rows[] = array(
      'data' => $row,
      'class' => 'custom_pub-option-row',
    );
    $rows[] = array(
      'data' => $form_row,
      'class' => 'custom_pub-form-edit',
    );
  }
  if (!empty($rows)) {
    $table = theme('table', array(
      t('Label'),
      t('Machine Name'),
      t('Node Types'),
      array(
        'data' => '',
        'class' => 'custom_pub-head-edit',
      ),
    ), $rows);

    //generate the table for the current options
  }
  return $table . drupal_get_form('custom_pub_add');
}