drupal_render($form['submit']), 'colspan' => 2),
array('data' => t('Operations'), 'colspan' => 2)
);
if (isset($form['info']) && is_array($form['info'])) {
foreach (element_children($form['info']) as $key) {
$row = array();
if (isset($form['operations'][$key][0])) {
// Note: even if the commands for revert and delete are not permitted,
// the array is not empty since we set a dummy in this case.
$row[] = drupal_render($form['info'][$key]);
$row[] = drupal_render($form['diff']['old'][$key]);
$row[] = drupal_render($form['diff']['new'][$key]);
$row[] = drupal_render($form['operations'][$key][0]);
$row[] = drupal_render($form['operations'][$key][1]);
$rows[] = $row;
}
else {
// its the current revision (no commands to revert or delete)
$row[] = array('data' => drupal_render($form['info'][$key]), 'class' => 'revision-current');
$row[] = array('data' => drupal_render($form['diff']['old'][$key]), 'class' => 'revision-current');
$row[] = array('data' => drupal_render($form['diff']['new'][$key]), 'class' => 'revision-current');
$row[] = array('data' => theme('placeholder', t('current revision')), 'class' => 'revision-current', 'colspan' => '2');
$rows[] = array(
'data' => $row,
'class' => 'error',
);
}
}
}
$output .= theme('table', $header, $rows);
$output .= drupal_render($form);
return $output;
}
/**
* Theme functions
*/
/**
* Return a themed table. This is a modified version of theme_table, adding
* colgroup tag and col tag options.
*
* @param $header
* An array containing the table headers. Each element of the array can be
* either a localized string or an associative array with the following keys:
* - "data": The localized title of the table column.
* - "field": The database field represented in the table column (required if
* user is to be able to sort on this column).
* - "sort": A default sort order for this column ("asc" or "desc").
* - Any HTML attributes, such as "colspan", to apply to the column header cell.
* @param $rows
* An array of table rows. Every row is an array of cells, or an associative
* array with the following keys:
* - "data": an array of cells
* - Any HTML attributes, such as "class", to apply to the table row.
*
* Each cell can be either a string or an associative array with the following keys:
* - "data": The string to display in the table cell.
* - "header": Indicates this cell is a header.
* - Any HTML attributes, such as "colspan", to apply to the table cell.
*
* Here's an example for $rows:
* @verbatim
* $rows = array(
* // Simple row
* array(
* 'Cell 1', 'Cell 2', 'Cell 3'
* ),
* // Row with attributes on the row and some of its cells.
* array(
* 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => 'funky'
* )
* );
* @endverbatim
*
* @param $attributes
* An array of HTML attributes to apply to the table tag.
* @param $caption
* A localized string to use for the
tag.
* @param $cols
* An array of table colum groups. Every column group is an array of columns,
* or an associative array with the following keys:
* - "data": an array of cells
* - Any HTML attributes, such as "class", to apply to the table column group.
*
* Each column can be either an empty array or associative array with the following keys:
* - Any HTML attributes, such as "class", to apply to the table column group.
*
* Here's an example for $cols:
* @verbatim
* $cols = array(
* // Simple colgroup.
* array(),
* // Simple colgroup with attributes.
* array(
* 'data' => array(), 'colspan' => 2, 'style' => 'color: green;',
* ),
* // Simple colgroup with one col.
* array(
* array(),
* ),
* // Colgroup with attributes on the colgroup and some of its cols.
* array(
* 'data' => array(array('class' => 'diff-marker'), array('colspan' => 2)), 'class' => 'funky',
* ),
* );
* @endverbatim
*
* The HTML will look as follows:
* @verbatim
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* ...
*
* @endverbatim
*
* @return
* An HTML string representing the table.
*/
function theme_diff_table($header, $rows, $attributes = array(), $caption = NULL, $cols = array()) {
$output = '
\n";
if (isset($caption)) {
$output .= '
'. $caption ."
\n";
}
// Format the table columns:
if (count($cols)) {
foreach ($cols as $number => $col) {
$attributes = array();
// Check if we're dealing with a simple or complex column
if (isset($col['data'])) {
foreach ($col as $key => $value) {
if ($key == 'data') {
$cells = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$cells = $col;
}
// Build colgroup
if (is_array($cells) && count($cells)) {
$output .= '
\n";
return $output;
}
/**
* Theme function for a header line in the diff.
*/
function theme_diff_header_line($lineno) {
return ''. t('Line %lineno', array('%lineno' => $lineno)) .'';
}
/**
* Theme function for a content line in the diff.
*/
function theme_diff_content_line($line) {
return '
'. $line .'
';
}
/**
* Theme function for an empty line in the diff.
*/
function theme_diff_empty_line($line) {
return $line;
}
/**
* Simple inline controls and legend.
*/
function theme_diff_inline_controls($node) {
drupal_add_css(drupal_get_path('module', 'diff') .'/diff.css', 'module', 'all', FALSE);
$output = "