You are here

function content_theme_admin_content_node in Content Theme 6

Same name and namespace in other branches
  1. 7.2 content_theme.admin.inc \content_theme_admin_content_node()
  2. 7 content_theme.admin.inc \content_theme_admin_content_node()

Menu callback; configures content node themes.

1 string reference to 'content_theme_admin_content_node'
content_theme_menu in ./content_theme.module
Implementation of hook_menu().

File

./content_theme.admin.inc, line 12
Admin page callbacks for the content_theme module.

Code

function content_theme_admin_content_node() {
  $nodes = $nodes_select = array();
  $destination = drupal_get_destination();
  $sql_query = 'SELECT n.nid, n.title, nt.name AS type_name FROM {node} n LEFT JOIN {node_type} nt ON nt.type = n.type ORDER BY n.changed DESC';
  $sql_count = 'SELECT COUNT(nid) FROM {node}';
  $result = pager_query($sql_query, 50, 0, $sql_count);
  while ($node = db_fetch_object($result)) {
    $result_tmp = db_query('SELECT theme FROM {content_theme_node} WHERE nid = %d AND action = "edit"', $node->nid);
    $edit_theme = ($theme = db_fetch_object($result_tmp)) ? $theme->theme : '-content_type-';
    $result_tmp = db_query('SELECT theme FROM {content_theme_node} WHERE nid = %d AND action = "view"', $node->nid);
    $view_theme = ($theme = db_fetch_object($result_tmp)) ? $theme->theme : '-content_type-';
    $row = array();
    $row['node_title'] = array(
      '#value' => l(check_plain($node->title), 'node/' . $node->nid),
    );
    $row['node_type_name'] = array(
      '#value' => check_plain($node->type_name),
    );
    $row['node_theme_edit'] = array(
      '#value' => content_theme_get_theme_name($edit_theme),
    );
    $row['node_theme_view'] = array(
      '#value' => content_theme_get_theme_name($view_theme),
    );
    $row['op_edit'] = array(
      '#value' => l(t('edit'), 'node/' . $node->nid . '/edit', array(
        'query' => $destination,
      )),
    );
    $nodes[$node->nid] = $row;
    $nodes_select[$node->nid] = '';
  }
  $form = array();
  $form['update'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update content node themes'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['update']['content_theme_edit'] = array(
    '#type' => 'select',
    '#title' => t('Editing theme'),
    '#description' => t('Choose which theme the content creating and editing pages should display in. Content wide theme: %content_wide_theme; system default theme: %system_default_theme.', array(
      '%content_wide_theme' => content_theme_get_info_theme_name('content_wide', 'edit'),
      '%system_default_theme' => content_theme_get_info_theme_name(),
    )),
    '#default_value' => '-content_type-',
    '#options' => content_theme_get_content_node_options(),
  );
  $form['update']['content_theme_view'] = array(
    '#type' => 'select',
    '#title' => t('Viewing theme'),
    '#description' => t('Choose which theme the content viewing pages should display in. Content wide theme: %content_wide_theme; system default theme: %system_default_theme.', array(
      '%content_wide_theme' => content_theme_get_info_theme_name('content_wide', 'view'),
      '%system_default_theme' => content_theme_get_info_theme_name(),
    )),
    '#default_value' => '-content_type-',
    '#options' => content_theme_get_content_node_options(),
  );
  $form['update']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update themes'),
  );
  $form['nodes_select'] = array(
    '#type' => 'checkboxes',
    '#options' => $nodes_select,
  );
  $form['nodes'] = $nodes;
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}