Code
function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null) {
static $button_counter = 1;
$types = array('submit', 'button', 'reset');
if ( !isset($params['type']) ) {
$params['type'] = 'submit';
}
if ( !in_array($params['type'], $types) ) {
$params['type'] = 'submit';
}
if ( ($params['type'] == 'submit') && isset($link)) {
$params['type'] = 'button';
}
if (!isset($priority)) {
$priority = 'secondary';
}
// modification : attribution d'un id dans le tableau $params
if (!isset($params['id'])){
$idbutton = "tdb" . $button_counter . "";
}else{
$idbutton = $params['id'];
$button_counter -= 1;
}
$button = '<span class="tdbLink">';
if ( ($params['type'] == 'button') && isset($link)) {
$button .= '<a id="' . $idbutton . '" href="' . $link . '"';
if ( isset($params['newwindow']) ) {
$button .= ' target="_blank"';
}
} else {
$button .= '<button id="' . $idbutton . '" type="' . tep_output_string($params['type']) . '"';
if ( isset($params['params']) ) {
$button .= ' ' . $params['params'];
}
}
$button .= '>' . $title;
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '</a>';
} else {
$button .= '</button>';
}
$button .= '</span><script type="text/javascript">$("#' . $idbutton . '").button(';
$args = array();
if ( isset($icon) ) {
if ( !isset($params['iconpos']) ) {
$params['iconpos'] = 'left';
}
if ( $params['iconpos'] == 'left' ) {
$args[] = 'icons:{primary:"ui-icon-' . $icon . '"}';
} else {
$args[] = 'icons:{secondary:"ui-icon-' . $icon . '"}';
}
}
if (empty($title)) {
$args[] = 'text:false';
}
// modification : desactivation d'un bouton
if ( isset($params['disabled']) ) {
$args[] = 'disabled: true';
$activate = 'false';
}
if (!empty($args)) {
$button .= '{' . implode(',', $args) . '}';
}
$button .= ').addClass("ui-priority-' . $priority . '").click(function() {return ' . $activate . ';}).parent().removeClass("tdbLink");</script>';
$button_counter++;
return $button;
}
static $button_counter = 1;
$types = array('submit', 'button', 'reset');
if ( !isset($params['type']) ) {
$params['type'] = 'submit';
}
if ( !in_array($params['type'], $types) ) {
$params['type'] = 'submit';
}
if ( ($params['type'] == 'submit') && isset($link)) {
$params['type'] = 'button';
}
if (!isset($priority)) {
$priority = 'secondary';
}
// modification : attribution d'un id dans le tableau $params
if (!isset($params['id'])){
$idbutton = "tdb" . $button_counter . "";
}else{
$idbutton = $params['id'];
$button_counter -= 1;
}
$button = '<span class="tdbLink">';
if ( ($params['type'] == 'button') && isset($link)) {
$button .= '<a id="' . $idbutton . '" href="' . $link . '"';
if ( isset($params['newwindow']) ) {
$button .= ' target="_blank"';
}
} else {
$button .= '<button id="' . $idbutton . '" type="' . tep_output_string($params['type']) . '"';
if ( isset($params['params']) ) {
$button .= ' ' . $params['params'];
}
}
$button .= '>' . $title;
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '</a>';
} else {
$button .= '</button>';
}
$button .= '</span><script type="text/javascript">$("#' . $idbutton . '").button(';
$args = array();
if ( isset($icon) ) {
if ( !isset($params['iconpos']) ) {
$params['iconpos'] = 'left';
}
if ( $params['iconpos'] == 'left' ) {
$args[] = 'icons:{primary:"ui-icon-' . $icon . '"}';
} else {
$args[] = 'icons:{secondary:"ui-icon-' . $icon . '"}';
}
}
if (empty($title)) {
$args[] = 'text:false';
}
// modification : desactivation d'un bouton
if ( isset($params['disabled']) ) {
$args[] = 'disabled: true';
$activate = 'false';
}
if (!empty($args)) {
$button .= '{' . implode(',', $args) . '}';
}
$button .= ').addClass("ui-priority-' . $priority . '").click(function() {return ' . $activate . ';}).parent().removeClass("tdbLink");</script>';
$button_counter++;
return $button;
}
fait suite à ce sujet : http://www.oscommerce-fr.info/forum/index....showtopic=67822
seul le passage des données diffère, puisqu'on se sert uniquement du tableau $params
exemple :
tep_draw_button('NOM_DU_BOUTON', 'nom_de_licone*', 'lien ou pas', 'priorité -> par défaut : secondary, le tableau de paramêtres : array('id' => 'id_du_bouton', 'disabled' => 'true'))
le paramêtre 'disbled' permet de désactiver un bouton. ne fonctionne pas avec un bouton type lien, d'où l'ajout : .click(function() {return ' . $activate . ';})
* pour rappel, sur le net, il existe des @connes célèbres. par exemple, une ancienne ministre qui pensait qu'open-office etait un parefeu (et dire qu'aujourd'hui, il me semble, elle taffe à versailles, confonds elle le roi soleil avec nainbo 1er ?)