本文整理汇总了PHP中tablesort_cell函数的典型用法代码示例。如果您正苦于以下问题:PHP tablesort_cell函数的具体用法?PHP tablesort_cell怎么用?PHP tablesort_cell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tablesort_cell函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cells = $row;
}
if (count($cells)) {
// Add odd/even class
if (empty($row['no_striping'])) {
$class = $flip[$class];
$attributes['class'][] = $class;
}
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
}
$output .= " </tr>\n";
}
}
$output .= "</tbody>\n";
}
$output .= "</table>\n";
print $output;
示例2: phptemplate_table
function phptemplate_table($header, $rows, $attributes = array(), $caption = NULL)
{
$output = '<div class="tablewrapper">';
$output .= '<table' . drupal_attributes($attributes) . " class=\"tableclass\">\n";
if (isset($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
$output .= ' <thead><tr>';
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
$output .= " </tr></thead>\n";
}
// Format the table rows:
$output .= "<tbody>\n";
if (count($rows)) {
$flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even';
foreach ($rows as $number => $row) {
$attributes = array();
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cells = $row;
}
// Add odd/even class
$class = $flip[$class];
if (isset($attributes['class'])) {
$attributes['class'] .= ' ' . $class;
} else {
$attributes['class'] = $class;
}
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
}
$output .= " </tr>\n";
}
}
$output .= "</tbody></table>\n";
$output .= "</div>\n";
return $output;
}
示例3: ec_resp_table
//.........这里部分代码省略.........
$output = '<table' . drupal_attributes($attributes) . ">\n";
if (isset($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
// Format the table columns:
if (count($colgroups)) {
foreach ($colgroups as $number => $colgroup) {
$attributes = array();
// Check if we're dealing with a simple or complex column.
if (isset($colgroup['data'])) {
foreach ($colgroup as $key => $value) {
if ($key == 'data') {
$cols = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cols = $colgroup;
}
// Build colgroup.
if (is_array($cols) && count($cols)) {
$output .= ' <colgroup' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cols as $col) {
$output .= ' <col' . drupal_attributes($col) . ' />';
}
$output .= " </colgroup>\n";
} else {
$output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
}
}
}
// Add the 'empty' row message if available.
if (!count($rows) && $empty) {
$header_count = 0;
foreach ($header as $header_cell) {
if (is_array($header_cell)) {
$header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
} else {
$header_count++;
}
}
$rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
// HTML requires that the thead tag has tr tags in it followed by tbody
// tags. Using ternary operator to check and see if we have any rows.
$output .= count($rows) ? ' <thead><tr>' : ' <tr>';
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
// Using ternary operator to close the tags based on whether
// or not there are rows.
$output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
} else {
$ts = array();
}
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
$flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even';
foreach ($rows as $number => $row) {
// Check if we're dealing with a simple or complex row.
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cells = $row;
}
if (count($cells)) {
// Add odd/even class.
if (empty($row['no_striping'])) {
$class = $flip[$class];
$attributes['class'][] = $class;
}
// Build row.
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
}
$output .= " </tr>\n";
}
}
$output .= "</tbody>\n";
}
$output .= "</table>\n";
return $output;
}
示例4: mothership_table
function mothership_table($header, $rows, $attributes = array(), $caption = NULL)
{
// Add sticky headers, if applicable.
if (count($header)) {
drupal_add_js('misc/tableheader.js');
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
$attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : $attributes['class'] . ' sticky-enabled';
}
$output = '<table' . drupal_attributes($attributes) . ">\n";
if (isset($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
// HTML requires that the thead tag has tr tags in it follwed by tbody
// tags. Using ternary operator to check and see if we have any rows.
$output .= count($rows) ? ' <thead><tr>' : ' <tr>';
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
// Using ternary operator to close the tags based on whether or not there are rows
$output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
} else {
$ts = array();
}
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
$flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even';
foreach ($rows as $number => $row) {
$attributes = array();
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cells = $row;
}
if (count($cells)) {
// Add odd/even class
$class = $flip[$class];
if (isset($attributes['class'])) {
$attributes['class'] .= ' ' . $class;
} else {
$attributes['class'] = $class;
}
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
}
$output .= " </tr>\n";
}
}
$output .= "</tbody>\n";
}
$output .= "</table>\n";
return $output;
}
示例5: dynamo_table
/**
* Overrides table theme function with support for colgroups
* based on Drupal 7 theme function.
*/
function dynamo_table($header, $rows, $attributes = array(), $caption = NULL)
{
// Get colgroups out if attributes
$colgroups = $attributes['colgroups'];
if (!empty($attributes['colgroups'])) {
unset($attributes['colgroups']);
}
// Add sticky headers, if applicable.
if (count($header)) {
drupal_add_js('misc/tableheader.js');
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
array_push($attributes['class'], 'sticky-enabled');
}
$output = '<table' . drupal_attributes($attributes) . ">\n";
if (isset($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
// Format the table columns:
if (count($colgroups)) {
foreach ($colgroups as $number => $colgroup) {
$attributes = array();
// Check if we're dealing with a simple or complex column
if (isset($colgroup['data'])) {
foreach ($colgroup as $key => $value) {
if ($key == 'data') {
$cols = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cols = $colgroup;
}
// Build colgroup
if (is_array($cols) && count($cols)) {
$output .= ' <colgroup' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cols as $col) {
$output .= ' <col' . drupal_attributes($col) . ' />';
}
$output .= " </colgroup>\n";
} else {
$output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
}
}
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
// HTML requires that the thead tag has tr tags in it followed by tbody
// tags. Using ternary operator to check and see if we have any rows.
$output .= count($rows) ? ' <thead><tr>' : ' <tr>';
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
// Using ternary operator to close the tags based on whether or not there are rows
$output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
} else {
$ts = array();
}
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
$flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even';
foreach ($rows as $number => $row) {
$attributes = array();
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cells = $row;
}
if (count($cells)) {
// Add odd/even class
$class = $flip[$class];
// TODO: This code looks broken. I've added the is_array check
// to prevent errors, but I don't know if it'll ever be true.
// mikl, 2010-05-24
if (is_array($attributes['class'])) {
array_push($attributes['class'], $class);
}
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
//.........这里部分代码省略.........
示例6: badm_table
/**
* Overrides theme_table().
*/
function badm_table($variables)
{
$header = $variables['header'];
$rows = $variables['rows'];
$attributes = $variables['attributes'];
$caption = $variables['caption'];
$colgroups = $variables['colgroups'];
$empty = $variables['empty'];
$attributes['class'][] = 'table';
$attributes['class'][] = 'table-striped';
$output = '<table' . drupal_attributes($attributes) . ">\n";
if (isset($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
// Format the table columns:
if (count($colgroups)) {
foreach ($colgroups as $colgroup) {
$attributes = array();
// Check if we're dealing with a simple or complex column
if (isset($colgroup['data'])) {
foreach ($colgroup as $key => $value) {
if ($key == 'data') {
$cols = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cols = $colgroup;
}
// Build colgroup
if (is_array($cols) && count($cols)) {
$output .= ' <colgroup' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cols as $col) {
$output .= ' <col' . drupal_attributes($col) . ' />';
}
$output .= " </colgroup>\n";
} else {
$output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
}
}
}
// Add the 'empty' row message if available.
if (!count($rows) && $empty) {
$header_count = 0;
foreach ($header as $header_cell) {
if (is_array($header_cell)) {
$header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
} else {
$header_count++;
}
}
$rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
// HTML requires that the thead tag has tr tags in it followed by tbody
// tags. Using ternary operator to check and see if we have any rows.
$output .= count($rows) ? ' <thead><tr>' : ' <tr>';
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
// Using ternary operator to close the tags based on whether or not there are rows
$output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
} else {
$ts = array();
}
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
foreach ($rows as $row) {
$attributes = array();
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
} else {
$attributes[$key] = $value;
}
}
} else {
$cells = $row;
}
if (count($cells)) {
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
}
$output .= " </tr>\n";
}
//.........这里部分代码省略.........
示例7: badm_preprocess_table
/**
* Implements hook_preprocess_HOOK().
*/
function badm_preprocess_table(&$vars)
{
// Make it bootstrap yeah!
if (isset($vars['attributes']['class']) && is_string($vars['attributes']['class'])) {
$vars['attributes']['class'] = array($vars['attributes']['class']);
}
$vars['attributes']['class'][] = 'table';
if (empty($vars['attributes']['no_strip'])) {
$vars['attributes']['class'][] = 'table-striped';
}
$vars['attributes']['class'][] = 'table-condensed';
// Count header for later, better here than over there.
$header_count = 0;
if (!empty($vars['header'])) {
foreach ($vars['header'] as &$header_cell) {
if (is_array($header_cell)) {
$header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
} else {
$header_count++;
}
}
}
// Need this in template.
$vars['header_count'] = $header_count;
if ($header_count) {
$vars['sortheader'] = tablesort_init($vars['header']);
} else {
$vars['sortheader'] = [];
}
if (!empty($vars['header'])) {
foreach ($vars['header'] as &$header_cell) {
$header_cell = tablesort_header($header_cell, $vars['header'], $vars['sortheader']);
}
}
if (!empty($vars['rows'])) {
foreach ($vars['rows'] as &$row) {
$i = 0;
foreach ($row as &$cell) {
$cell = tablesort_cell($cell, $vars['header'], $vars['sortheader'], $i);
$i++;
}
}
}
// Add the 'empty' row message if available.
if ($vars['empty'] && empty($vars['rows'])) {
$vars['rows'][] = [['data' => $vars['empty'], 'colspan' => $header_count, 'class' => ['empty', 'message']]];
}
// Manage main attributes
if (isset($vars['colgroups'])) {
_badm_extract_data_from_attributes($vars, 'colgroups');
}
if (isset($vars['header'])) {
_badm_extract_data_from_attributes($vars, 'header');
}
if (isset($vars['rows'])) {
_badm_extract_data_from_attributes($vars, 'rows');
}
// Manage cells attributes, because they are deeper.
$vars['cells_attributes'] = [];
foreach ($vars['rows'] as $row_index => &$row) {
if (is_array($row)) {
foreach ($row as $cell_index => &$cell) {
$vars['cells_attributes'][$row_index][$cell_index] = [];
if (isset($cell['data']) || is_array($cell) && count(element_properties($cell)) == 0) {
$temp_real_value = '';
foreach ($cell as $key => $value) {
if ($key == 'data') {
$temp_real_value = $value;
} else {
$vars['cells_attributes'][$row_index][$cell_index][$key] = $value;
}
}
$cell = $temp_real_value;
}
}
}
}
$vars['theme_hook_suggestions'][] = 'table';
}