fix compatibility status

This commit is contained in:
John BOTELLA
2019-03-05 16:58:05 +01:00
parent 7a4540088a
commit 6b98eecd32
2 changed files with 55 additions and 29 deletions

View File

@@ -7981,14 +7981,15 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
/** /**
* @param string $statusLabel label of badge no html : use in alt attribute for accessibility * @param string $statusLabel label of badge no html : use in alt attribute for accessibility
* @param string $statusLabelShort short label of badge no html
* @param string $html optional : label of badge with html * @param string $html optional : label of badge with html
* @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name * @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name
* @param int $displayMode for retrocompatibility 0=label only, 1=label + Picto, 2=Picto, 3=Picto + label * @param int $displayMode for retrocompatibility 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @param string $url the url for link * @param string $url the url for link
* @param array $params various params for future : recommended rather than adding more function arguments * @param array $params various params for future : recommended rather than adding more function arguments
* @return string html status * @return string html status
*/ */
function dolGetStatus($statusLabel = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array()) function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array())
{ {
global $conf; global $conf;
@@ -8011,28 +8012,36 @@ function dolGetStatus($statusLabel = '', $html = '', $statusType = 'status0', $d
if($displayMode==0){ if($displayMode==0){
$return = !empty($html)?$html:$statusLabel; $return = !empty($html)?$html:$statusLabel;
} }
elseif($displayMode===1){
$return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel);
}
// use status with images // use status with images
elseif(empty($conf->global->MAIN_STATUS_USES_CSS)){ elseif(empty($conf->global->MAIN_STATUS_USES_CSS)){
$return = ''; $return = '';
$htmlLabel = '<span class="hideonsmartphone">'.(!empty($html)?$html:$statusLabel).'</span>'; $htmlLabel = '<span class="hideonsmartphone">'.(!empty($html)?$html:$statusLabel).'</span>';
$htmlLabelShort = '<span class="hideonsmartphone">'.(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).'</span>';
if(!empty($statusImg[$statusType])){ if(!empty($statusImg[$statusType])){
$htmlImg = img_picto($statusLabel, $statusImg[$statusType]); $htmlImg = img_picto($statusLabel, $statusImg[$statusType]);
}else{ }else{
$htmlImg = img_picto($statusLabel, $statusType); $htmlImg = img_picto($statusLabel, $statusType);
} }
if($displayMode === 1){
$return = $htmlLabel .' '. $htmlImg; if($displayMode === 2){
}
elseif($displayMode === 2){
$return = $htmlImg;
}
elseif($displayMode === 3){
$return = $htmlImg .' '. $htmlLabel; $return = $htmlImg .' '. $htmlLabel;
} }
else{ elseif($displayMode === 3){
$return = !empty($html)?$html:$statusLabel; $return = $htmlImg;
}
elseif($displayMode === 4){
$return = $htmlImg .' '. $htmlLabel;
}
elseif($displayMode === 5){
$return = $htmlLabelShort .' '. $htmlImg;
}
else{ // $displayMode >= 6
$return = $htmlLabel .' '. $htmlImg;
} }
} }
@@ -8040,10 +8049,19 @@ function dolGetStatus($statusLabel = '', $html = '', $statusType = 'status0', $d
// Use new badge // Use new badge
if(!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)){ if(!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)){
$mode = 'pill'; $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel;
if($displayMode == 2)$mode = 'dot';
$return = dolGetBadge($statusLabel, $html, $statusType, $mode); if($displayMode == 3){
$return = dolGetBadge($statusLabel, '', $statusType, 'dot');
}
elseif($displayMode === 5){
$return = dolGetBadge($statusLabelShort, $html, $statusType);
}
else{
$return = dolGetBadge($statusLabel, $html, $statusType);
}
} }
return $return; return $return;

View File

@@ -293,26 +293,34 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
$conf->global->MAIN_STATUS_USES_CSS = 1; $conf->global->MAIN_STATUS_USES_CSS = 1;
?> ?>
<h4>Using hidden global conf MAIN_STATUS_USES_CSS=1</h4> <h4>Using hidden global conf MAIN_STATUS_USES_CSS=1</h4>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4') ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4') ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4',1) ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',1) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4',2) ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',2) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4',3) ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',3) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',4) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',5) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',6) ?></p>
<?php $conf->global->MAIN_STATUS_USES_CSS = 0; ?> <?php $conf->global->MAIN_STATUS_USES_CSS = 0; ?>
<h4>Disabled hidden global conf : MAIN_STATUS_USES_CSS=0</h4> <h4>Disabled hidden global conf : MAIN_STATUS_USES_CSS=0</h4>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4') ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',1) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4',1) ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',2) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4',2) ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',3) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label <u>with</u> <em>html</em>', 'status4',3) ?></p> <p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',4) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',5) ?></p>
<p><?php print dolGetStatus('your label for accessibility', 'your label', 'your label <u>with</u> <em>html</em>', 'status4',6) ?></p>
<?php $conf->global->MAIN_STATUS_USES_CSS = $saveGlobalConf; ?> <?php $conf->global->MAIN_STATUS_USES_CSS = $saveGlobalConf; ?>
<figure class="highlight"><pre> <figure class="highlight"><pre>
&lt;?php print dolGetStatus('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4') ?&gt; &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4') ?&gt;
&lt;?php print dolGetStatus('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',1) ?&gt; &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',1) ?&gt;
&lt;?php print dolGetStatus('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',2) ?&gt; &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',2) ?&gt;
&lt;?php print dolGetStatus('your label for accessibility', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',3) ?&gt; &lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',3) ?&gt;
&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',4) ?&gt;
&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',5) ?&gt;
&lt;?php print dolGetStatus('your label for accessibility', 'your label', 'your label &lt;u&gt;with&lt;/u&gt; &lt;em&gt;html&lt;/em&gt;', 'status4',6) ?&gt;
</pre></figure> </pre></figure>