0
&& $horizontal_count > $GLOBALS['cfg']['RepeatCells']
) {
$output .= $header;
$horizontal_count = 0;
$odd_row = true;
}
// key names and descriptions for the left section,
// sorted by key names
$leftKeyname = $keys[$indexByKeyname];
list(
$leftDescription,
$leftDescriptionTitle
) = PMA_getDescriptionAndTitle($descriptions[$indexByKeyname]);
// key names and descriptions for the right section,
// sorted by descriptions
$rightKeyname = $keys[$indexByDescription];
list(
$rightDescription,
$rightDescriptionTitle
) = PMA_getDescriptionAndTitle($descriptions[$indexByDescription]);
$indexByDescription++;
if (! empty($current_value)) {
$rightKeynameIsSelected = $rightKeyname == $current_value;
$leftKeynameIsSelected = $leftKeyname == $current_value;
}
$output .= '
';
$odd_row = ! $odd_row;
$output .= PMA_getHtmlForColumnElement(
'class="nowrap"', $leftKeynameIsSelected,
$leftKeyname, $leftDescription,
$leftDescriptionTitle
);
$output .= PMA_getHtmlForColumnElement(
'', $leftKeynameIsSelected, $leftKeyname,
$leftDescription, $leftDescriptionTitle
);
$output .= ''
. ' | ';
$output .= PMA_getHtmlForColumnElement(
'', $rightKeynameIsSelected, $rightKeyname,
$rightDescription, $rightDescriptionTitle
);
$output .= PMA_getHtmlForColumnElement(
'class="nowrap"', $rightKeynameIsSelected,
$rightKeyname, $rightDescription,
$rightDescriptionTitle
);
$output .= '
';
return array($output, $horizontal_count, $odd_row, $indexByDescription);
}
/**
* Function to get html for relational field selection
*
* @param string $db current database
* @param string $table current table
* @param string $field field
* @param array $foreignData foreign column data
* @param string $fieldkey field key
* @param string $current_value current columns's value
*
* @return string
*/
function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignData,
$fieldkey, $current_value
) {
$gotopage = PMA_getHtmlForGotoPage($foreignData);
$showall = PMA_getHtmlForShowAll($foreignData);
$output = '';
$output .= '';
if (!is_array($foreignData['disp_row'])) {
$output .= ''
. '
';
return $output;
}
$header = '
' . __('Keyname') . ' |
' . __('Description') . ' |
|
' . __('Description') . ' |
' . __('Keyname') . ' |
';
$output .= '' . $header . '' . "\n"
. '' . $header . '' . "\n"
. '' . "\n";
$descriptions = array();
$keys = array();
foreach ($foreignData['disp_row'] as $relrow) {
if ($foreignData['foreign_display'] != false) {
$descriptions[] = $relrow[$foreignData['foreign_display']];
} else {
$descriptions[] = '';
}
$keys[] = $relrow[$foreignData['foreign_field']];
}
asort($keys);
$horizontal_count = 0;
$odd_row = true;
$indexByDescription = 0;
foreach ($keys as $indexByKeyname => $value) {
list(
$html,
$horizontal_count,
$odd_row,
$indexByDescription
) = PMA_getHtmlForOneKey(
$horizontal_count, $header, $odd_row, $keys, $indexByKeyname,
$descriptions, $indexByDescription, $current_value
);
$output .= $html;
}
$output .= ''
. '';
return $output;
}
/**
* Get the description (possibly truncated) and the title
*
* @param string $description the key name's description
*
* @return array the new description and title
*/
function PMA_getDescriptionAndTitle($description)
{
$limitChars = $GLOBALS['cfg']['LimitChars'];
if (mb_strlen($description) <= $limitChars) {
$description = htmlspecialchars(
$description
);
$descriptionTitle = '';
} else {
$descriptionTitle = htmlspecialchars(
$description
);
$description = htmlspecialchars(
mb_substr(
$description, 0, $limitChars
)
. '...'
);
}
return array($description, $descriptionTitle);
}
/**
* Function to get html for each column element
*
* @param string $cssClass class="nowrap" or ''
* @param bool $isSelected whether current equals form's value
* @param string $keyname current key
* @param string $description current value
* @param string $title current title
*
* @return string
*/
function PMA_getHtmlForColumnElement($cssClass, $isSelected, $keyname,
$description, $title
) {
$keyname = htmlspecialchars($keyname);
$output = '' : '')
. '';
if ($cssClass !== '') {
$output .= $keyname;
} else {
$output .= $description;
}
$output .= '' . ($isSelected ? '' : '') . ' | ';
return $output;
}
/**
* Function to get html for show all case
*
* @param array $foreignData foreign data
*
* @return string
*/
function PMA_getHtmlForShowAll($foreignData)
{
$showall = '';
if (is_array($foreignData['disp_row'])) {
if ($GLOBALS['cfg']['ShowAll']
&& ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows'])
) {
$showall = '';
}
}
return $showall;
}
/**
* Function to get html for the goto page option
*
* @param array $foreignData foreign data
*
* @return string
*/
function PMA_getHtmlForGotoPage($foreignData)
{
$gotopage = '';
isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
if (!is_array($foreignData['disp_row'])) {
return $gotopage;
}
$session_max_rows = $GLOBALS['cfg']['MaxRows'];
$pageNow = @floor($pos / $session_max_rows) + 1;
$nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);
if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) {
$gotopage = PMA\libraries\Util::pageselector(
'pos',
$session_max_rows,
$pageNow,
$nbTotalPage,
200,
5,
5,
20,
10,
__('Page number:')
);
}
return $gotopage;
}
/**
* Function to get foreign limit
*
* @param string $foreign_showAll foreign navigation
*
* @return string
*/
function PMA_getForeignLimit($foreign_showAll)
{
if (isset($foreign_showAll) && $foreign_showAll == __('Show all')) {
return null;
}
isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
return 'LIMIT ' . $pos . ', ' . $GLOBALS['cfg']['MaxRows'] . ' ';
}