Skip to content
Snippets Groups Projects
Commit 9ff8b6f7 authored by Jaime Pérez's avatar Jaime Pérez
Browse files

Fix for compatibility with PHP 5.3.

PHP 5.3 does not allow the use of $this inside closures. This is a temporary fix for compatibility with 5.3, while we are still supporting it. We will drop this when updating the minimum requirements to PHP 5.4.
parent 542354d8
No related branches found
No related tags found
No related merge requests found
...@@ -33,10 +33,21 @@ foreach ($this->data['idplist'] as $idpentry) { ...@@ -33,10 +33,21 @@ foreach ($this->data['idplist'] as $idpentry) {
value="<?php echo htmlspecialchars($this->data['returnIDParam']); ?>"/> value="<?php echo htmlspecialchars($this->data['returnIDParam']); ?>"/>
<select id="dropdownlist" name="idpentityid"> <select id="dropdownlist" name="idpentityid">
<?php <?php
/*
* TODO: change this to use $this instead when PHP 5.4 is the minimum requirement.
*
* This is a dirty hack because PHP 5.3 does not allow the use of $this inside closures. Therefore, the
* translation function must be passed somehow inside the closure. PHP 5.4 allows using $this, so we can
* then go back to the previous behaviour.
*/
$GLOBALS['__t'] = $this;
usort($this->data['idplist'], function ($idpentry1, $idpentry2) { usort($this->data['idplist'], function ($idpentry1, $idpentry2) {
// TODO: this is only compatible with PHP >= 5.4, fix compat with 5.3! return strcmp(
return strcmp($this->t('idpname_'.$idpentry1['entityid']), $this->t('idpname_'.$idpentry2['entityid'])); $GLOBALS['__t']->t('idpname_'.$idpentry1['entityid']),
$GLOBALS['__t']->t('idpname_'.$idpentry2['entityid'])
);
}); });
unset($GLOBALS['__t']);
foreach ($this->data['idplist'] as $idpentry) { foreach ($this->data['idplist'] as $idpentry) {
echo '<option value="'.htmlspecialchars($idpentry['entityid']).'"'; echo '<option value="'.htmlspecialchars($idpentry['entityid']).'"';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment