You are here

function custom_pub_admin in Custom Publishing Options 7

Same name and namespace in other branches
  1. 6 custom_pub.module \custom_pub_admin()

Callback function for Custom Publishing Options menu item.

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

File

./custom_pub.admin.inc, line 10
Admin functions.

Code

function custom_pub_admin() {
  $output = '<h3>Custom Publishing Options</h3>';
  $output .= '<p>Creating/editing/deleting options requires clearing the Drupal cache before you can use them. It is advised to make as many edits here that you need, and then clear the cache to propogate the updates to the node system.</p>';
  $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(
      $type['name'],
      $type['type'],
      $types_of_nodes,
      array(
        'data' => '',
        'class' => array(
          'custom_pub-option-edit-cell',
        ),
      ),
    );
    $form_row[] = array(
      'data' => drupal_get_form('custom_pub_edit_' . $type['type'], $type),
      'colspan' => 4,
      'class' => array(
        'custom_pub-form-edit',
      ),
    );
    $rows[] = array(
      'data' => $row,
      'class' => array(
        'custom_pub-option-row',
      ),
    );
    $rows[] = array(
      'data' => $form_row,
      'class' => array(
        'custom_pub-form-edit',
      ),
    );
  }
  if (!empty($rows)) {
    $vars = array(
      'header' => array(
        t('Label'),
        t('Machine Name'),
        t('Node Types'),
        array(
          'data' => '',
          'class' => array(
            'custom_pub-head-edit',
          ),
        ),
      ),
      'rows' => $rows,
    );
    $table = theme('table', $vars);
  }
  return $output . $table;
}