New function PMA_buttonOrImage to display button or image to submit form and not to duplicate code on all places.

This commit is contained in:
Michal Čihař
2004-10-21 11:59:21 +00:00
parent 3f258cfb45
commit 1eaea0fe95
4 changed files with 41 additions and 38 deletions

View File

@@ -11,6 +11,9 @@ $Source$
#1005511), navigation is reloaded once in header (I'm not sure whether I
choose correct version of reload code, we have several diferent, but it
seems to work well).
* tbl_properties_structure.php, libraries/common.lib.php,
libraries/display_tbl.lib.php: New function PMA_buttonOrImage to display
button or image to submit form and not to duplicate code on all places.
2004-10-20 Marc Delisle <lem9@users.sourceforge.net>
* libraries/common.lib.php: there was already a tip icon in our collection,

View File

@@ -2278,6 +2278,32 @@ if (typeof(document.getElementById) != 'undefined'
return preg_replace('|\s?AND$|', '', $uva_condition);
} // end function
/**
* Function to generate unique condition for specified row.
*
* @param string name of button element
* @param string class of button element
* @param string name of image element
* @param string text to display
* @param string image to display
*
* @access public
* @author Michal Cihar (michal@cihar.com)
*/
function PMA_buttonOrImage($button_name, $button_class, $image_name, $text, $image) {
global $pmaThemeImage, $propicon;
/* Opera has trouble with <input type="image"> */
/* IE has trouble with <button> */
if (PMA_USR_BROWSER_AGENT != 'IE') {
echo '<button class="' . $button_class . '" type="submit" name="' . $button_name . '" value="' . $text . '" title="' . $text . '">' . "\n"
. '<img src="' . $pmaThemeImage . $image . '" title="' . $text . '" alt="' . $text . '" width="16" height="16" />' . (($propicon == 'both') ? '&nbsp;' . $text : '') . "\n"
. '</button>' . "\n";
} else {
echo '<input type="image" name="' . $image_name . '" value="' .$text . '" title="' . $text . '" src="' . $pmaThemeImage . $image . '" />' . (($propicon == 'both') ? '&nbsp;' . $text : '') . "\n";
}
} // end function
} // end if: minimal common.lib needed?
?>

View File

@@ -1867,28 +1867,10 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
echo '&nbsp;&nbsp;<i>' . $GLOBALS['strWithChecked'] . '</i>'. "\n";
if ($cfg['PropertiesIconic']) {
/* Opera has trouble with <input type="image"> */
/* IE has trouble with <button> */
if (PMA_USR_BROWSER_AGENT != 'IE') {
echo ' <button class="mult_submit" type="submit" name="submit_mult" value="row_edit" title="' . $GLOBALS['strEdit'] . '">' . "\n"
. '<img src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" title="' . $GLOBALS['strEdit'] . '" alt="' . $GLOBALS['strEdit'] . '" width="16" height="16" align="middle" />' . (($propicon == 'both') ? '&nbsp;' . $GLOBALS['strEdit'] : '') . "\n"
. '</button>';
echo '&nbsp;<button class="mult_submit" type="submit" name="submit_mult" value="row_delete" title="' . $delete_text . '">' . "\n"
. '<img src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" title="' . $delete_text . '" alt="' . $delete_text . '" width="16" height="16" align="middle" />' . (($propicon == 'both') ? '&nbsp;' . $delete_text : '') . "\n"
. '</button>';
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submin_mult_change', $GLOBALS['strChange'], 'b_edit.png');
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submin_mult_change', $delete_text, 'b_drop.png');
if ($analyzed_sql[0]['querytype'] == 'SELECT') {
echo '&nbsp;<button class="mult_submit" type="submit" name="submit_mult" value="row_export" title="' . $GLOBALS['strExport'] . '">' . "\n"
. '<img src="' . $GLOBALS['pmaThemeImage'] . 'b_tblexport.png" title="' . $GLOBALS['strExport'] . '" alt="' . $GLOBALS['strExport'] . '" width="16" height="16" align="middle" />' . (($propicon == 'both') ? '&nbsp;' . $GLOBALS['strExport'] : '') . "\n"
. '</button>';
}
} else {
echo ' <input type="image" name="submit_mult_edit" value="row_edit" title="' . $GLOBALS['strEdit'] . '" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" />' . (($propicon == 'both') ? '&nbsp;' . $GLOBALS['strEdit'] : '');
echo '&nbsp;<input type="image" name="submit_mult" value="row_delete" title="' . $delete_text . '" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" />' . (($propicon == 'both') ? '&nbsp;' . $delete_text : '');
if ($analyzed_sql[0]['querytype'] == 'SELECT') {
echo '&nbsp;<input type="image" name="submit_mult_export" value="row_export" title="' . $GLOBALS['strExport'] . '" src="' . $GLOBALS['pmaThemeImage'] . 'b_tblexport.png" />' . (($propicon == 'both') ? '&nbsp;' . $GLOBALS['strExport'] : '');
}
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submin_mult_change', $GLOBALS['strExport'], 'b_tblexport.png');
}
echo "\n";
} else {

View File

@@ -411,25 +411,17 @@ $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db,$t
<td>
<?php
/*
$titles['Primary'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' . $pmaThemeImage . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" border="0" />';
$titles['Index'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' . $pmaThemeImage . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" border="0" />';
$titles['Unique'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' . $pmaThemeImage . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" border="0" />';
$titles['IdxFulltext'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' . $pmaThemeImage . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" border="0" />';
*/
if ($cfg['PropertiesIconic']) {
/* Opera has trouble with <input type="image"> */
/* IE has trouble with <button> */
if (PMA_USR_BROWSER_AGENT != 'IE') {
echo '<button class="mult_submit" type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '">' . "\n"
. '<img src="' . $pmaThemeImage . 'b_edit.png" title="' . $strChange . '" alt="' . $strChange . '" width="16" height="16" />' . (($propicon == 'both') ? '&nbsp;' . $strChange : '') . "\n"
. '</button>' . "\n";
} else {
echo ' <input type="image" name="submit_mult_change" value="' .$strChange . '" title="' . $strChange . '" src="' . $pmaThemeImage . 'b_edit.png" />' . (($propicon == 'both') ? '&nbsp;' . $strChange : '') . "\n";
}
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submin_mult_change', $strChange, 'b_edit.png');
// Drop button if there is at least two fields
if ($fields_cnt > 1) {
if (PMA_USR_BROWSER_AGENT != 'IE') {
echo ' <button class="mult_submit" type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '">' . "\n"
. '<img src="' . $pmaThemeImage . 'b_drop.png" title="' . $strDrop . '" alt="' . $strDrop . '" width="16" height="16" />' . (($propicon == 'both') ? '&nbsp;' . $strDrop : '') . "\n"
. '</button>' . "\n";
} else {
echo ' <input type="image" name="submit_mult_drop" value="' .$strDrop . '" title="' . $strDrop . '" src="' . $pmaThemeImage . 'b_drop.png" />' . (($propicon == 'both') ? '&nbsp;' . $strDrop : '') . "\n";
}
PMA_buttonOrImage('submit_mult', 'mult_submit', 'submin_mult_drop', $strDrop, 'b_drop.png');
}
} else {
echo ' <input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";