From af1ee60b62c1c5301eae9b97c32bad8c1d22c24d Mon Sep 17 00:00:00 2001
From: Ghislain Loas <ghislo@sandbox.pergame.net>
Date: Mon, 7 Sep 2015 16:36:14 +0200
Subject: [PATCH] hotline #29103 word "Portail" is now set with  translator
 function

---
 VERSIONS_HOTLINE/#29103                       |  1 +
 .../admin/views/scripts/index/index.phtml     |  2 +-
 .../admin/views/scripts/users/index.phtml     | 12 ++---
 .../views/scripts/bib/_articles_by_bib.phtml  |  6 +--
 library/Class/Bib.php                         |  5 +-
 .../View/Helper/Admin/ProfileSelect.php       | 50 +++++++++----------
 6 files changed, 40 insertions(+), 36 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/#29103

diff --git a/VERSIONS_HOTLINE/#29103 b/VERSIONS_HOTLINE/#29103
new file mode 100644
index 00000000000..8fbfe7483b7
--- /dev/null
+++ b/VERSIONS_HOTLINE/#29103
@@ -0,0 +1 @@
+ - ticket #29103 : Le terme 'Portail' est maintenant traductible et peut être remplacé via la variable TEXT_REPLACEMENTS
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/index/index.phtml b/application/modules/admin/views/scripts/index/index.phtml
index b8def5c897d..4846df71ac9 100644
--- a/application/modules/admin/views/scripts/index/index.phtml
+++ b/application/modules/admin/views/scripts/index/index.phtml
@@ -36,7 +36,7 @@ echo $this->ligneInfos($this->traduire("Utilisateur"), $this->user->getLogin());
 echo $this->ligneInfos("Pseudo", $this->user->getNomAff());
 echo $this->ligneInfos("Rôle", $acl->getLibelleRole($this->user->getRoleLevel()));
 $bib = $this->user->getBib();
-$bib = (!$bib) ? 'Portail' : $bib->getLibelle();
+$bib = (!$bib) ? $this->_('Portail') : $bib->getLibelle();
 echo $this->ligneInfos("Bibliothèque", $bib);
 ?>
 
diff --git a/application/modules/admin/views/scripts/users/index.phtml b/application/modules/admin/views/scripts/users/index.phtml
index 9b3f48174ba..8c3ef56a05b 100644
--- a/application/modules/admin/views/scripts/users/index.phtml
+++ b/application/modules/admin/views/scripts/users/index.phtml
@@ -1,4 +1,4 @@
-<?php 
+<?php
 echo $this->profileSelect('users',$this->id_zone,$this->id_bib,'zb',0,true,true,true);
 
 
@@ -23,7 +23,7 @@ else
   <tr>
     <td colspan="10"  class="separ"></td>
   </tr>
-<?php 
+<?php
 
 $acl = new  ZendAfi_Acl_AdminControllerRoles();
 
@@ -31,8 +31,8 @@ $ligne=0;
 foreach($this->users as $user)
 {
     $ligne ++ ;
-    if ($ligne & 1) $class="first"; else $class="second"; 
-    if ($user["ID_SITE"] =="0") $nom_bib="Portail"; 
+    if ($ligne & 1) $class="first"; else $class="second";
+    if ($user["ID_SITE"] =="0") $nom_bib = $this->_('Portail');
     else $nom_bib=fetchOne("select nom_court from int_bib where id_bib=".$user["ID_SITE"]);
     if (strlen($user["LOGIN"])>=15) $login= substr($user["LOGIN"],0,15).'...'; else $login=$user["LOGIN"];
     if (strlen($nom_bib)>=40) $nom_bib_r= substr($nom_bib,0,40).'...'; else $nom_bib_r=$nom_bib;
@@ -45,11 +45,11 @@ foreach($this->users as $user)
     if (Class_Users::getIdentity()->isAdmin()) {
       echo('<a href="'.BASE_URL.'/admin/users/edit/id/'.$user["ID_USER"].'">'.$this->boutonIco("type=edit").'</a>&nbsp;&nbsp; <a href="'.BASE_URL.'/admin/users/delete/id/'.$user["ID_USER"].'">');
       if ($user["ID_USER"] != '1') echo $this->boutonIco("type=del");
-    
+
     echo('</a>');
     }
     echo('</td></tr>');
-    
+
 }
 echo ('</table>');
 echo BR.'<div align="center" style="width:100%">'.$this->pager($this->nombre,$this->nb_par_page,$this->page,$this->url).'</div>';
diff --git a/application/modules/opac/views/scripts/bib/_articles_by_bib.phtml b/application/modules/opac/views/scripts/bib/_articles_by_bib.phtml
index 7fe328befe3..7a8a46c34c4 100644
--- a/application/modules/opac/views/scripts/bib/_articles_by_bib.phtml
+++ b/application/modules/opac/views/scripts/bib/_articles_by_bib.phtml
@@ -8,8 +8,8 @@
     // Nom de la ville
     if ($bib = $article->getBib())
       $ville = $bib->getVille();
-    else 
-      $ville = "Portail";
+    else
+      $ville = $this->_('Portail');
 
     if (!array_key_exists($ville, $news_bib))
       $news_bib[$ville] = array();
@@ -28,4 +28,4 @@
     }
     echo('</ul>');
   }
-}?>
\ No newline at end of file
+}?>
diff --git a/library/Class/Bib.php b/library/Class/Bib.php
index 42dc7452532..807544f2863 100644
--- a/library/Class/Bib.php
+++ b/library/Class/Bib.php
@@ -32,6 +32,9 @@ class BibCSite extends Zend_Db_Table_Abstract {
 
 
 class BibLoader extends Storm_Model_Loader {
+  use Trait_Translator;
+
+
   protected $_portail;
 
   public function findAllWithPortail() {
@@ -68,7 +71,7 @@ class BibLoader extends Storm_Model_Loader {
 
   public function getPortail() {
     if (!isset($this->_portail))
-      $this->_portail = $this->newInstanceWithId(0)->setLibelle('Portail');
+      $this->_portail = $this->newInstanceWithId(0)->setLibelle($this->_('Portail'));
     return $this->_portail;
   }
 
diff --git a/library/ZendAfi/View/Helper/Admin/ProfileSelect.php b/library/ZendAfi/View/Helper/Admin/ProfileSelect.php
index 444566d715e..a863ed28330 100644
--- a/library/ZendAfi/View/Helper/Admin/ProfileSelect.php
+++ b/library/ZendAfi/View/Helper/Admin/ProfileSelect.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 ////////////////////////////////////////////////////////////////////////////////
 // OPAC3 : FILTRE DE SELECTION : ZONE / BIBLIOTHEQUE / PROFIL
@@ -25,13 +25,13 @@
 //           b -> rend combo bib
 //           p -> rend combo profil
 ////////////////////////////////////////////////////////////////////////////////
- 
+
 class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHelper
 {
   public $user;                // User identifié
-  
+
 //-----------------------------------------------------------------------------------------------
-// Main routine 
+// Main routine
 //-----------------------------------------------------------------------------------------------
   public function profileSelect($url,$id_zone=0, $id_bib=0,$combo="zb", $id_profil=0,$portail=false,$all=true,$champ_nom=false)
   {
@@ -39,7 +39,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
     if($id_profil) $titre.=$this->translate()->_(" et profil");
     $this->user = ZendAfi_Auth::getInstance()->getIdentity();
     $html = '<div class="form" style="font-size:10pt">'.$titre.'<br/><table cellpadding="3" cellspacing="1" border="0">';
-  
+
     // Combo des zones
     if(preg_match("^z^",$combo))
     {
@@ -48,7 +48,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
       <td>'.$this->getZoneSelect($id_zone,$portail,$all,$url).'</td>
       </tr>';
     }
-  
+
     // Combo des bibliotheques
     if(preg_match("^b^",$combo))
     {
@@ -57,7 +57,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
       <td>'.$this->getBibSelect($id_zone,$id_bib,$portail,$all,$url).'</td>
       </tr>';
     }
-    
+
     // Combo des profils
     if(preg_match("^p^",$combo))
     {
@@ -67,7 +67,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
       </tr>';
     }
     $html.='</table>';
-    
+
     // Recherche d'abonnés
     if($champ_nom==true)
     {
@@ -76,9 +76,9 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
       $html.='<table cellpadding="3" cellspacing="1" border="0">';
       $rech_user = isset($_SESSION["admin"]["rech_user"]) ? $_SESSION["admin"]["rech_user"] : array('role' => 0, 'login' => '', 'nom' => '');
       $cls=new ZendAfi_Acl_AdminControllerRoles();
-      
-      
-      $combo_roles= Class_Users::getIdentity()->isAdmin() ? $cls->rendCombo($rech_user["role"],$this->user->ROLE_LEVEL,true) : $cls->rendCombo('2','2',false); 
+
+
+      $combo_roles= Class_Users::getIdentity()->isAdmin() ? $cls->rendCombo($rech_user["role"],$this->user->ROLE_LEVEL,true) : $cls->rendCombo('2','2',false);
 
       $html.='
       <tr>
@@ -101,7 +101,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
       </table>
       </form>';
     }
-    
+
     $html.='</div>';
     return $html;
   }
@@ -114,22 +114,22 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
     $class_zone = new Class_Zone();
     $zone_array = $class_zone->getAllZone();
     $redirect = "location='".BASE_URL."/admin/".$url."?z='+ this.value + '&amp;b=ALL'";
-    
+
     // Si l'user est minimum modo_portail
     if ($this->user->ROLE_LEVEL > 4)
     {
       $html[]='<select name="zone" id="zone" onchange="'.$redirect.'">';
       if($all == true) $html[]='<option value="ALL" >** tous **</option>';
-      if($portail == true) 
+      if($portail == true)
       {
         if($id_zone_selected=="PORTAIL" or !$id_zone_selected) $sel = ' selected="selected"'; else $sel = "";
-        $html[]='<option value="PORTAIL"'.$sel.'>Portail</option>';
+        $html[]='<option value="PORTAIL"'.$sel.'>' . $this->_('Portail') . '</option>';
       }
     }
-    
+
     // Si l'user est admin_bib
     else $html[]='<select name="zone" id="zone" disabled="disabled">';
-  
+
     foreach ($zone_array as $zone) {
       if($id_zone_selected == $zone->ID_ZONE and $id_zone_selected !="PORTAIL") $sel = 'selected="selected"'; else $sel="";
 
@@ -149,7 +149,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
     $html[]='</select>';
     return (implode('',$html));
   }
-    
+
 //----------------------------------------------------------------------------------
 // Combo des bibliotheques
 //----------------------------------------------------------------------------------
@@ -158,23 +158,23 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
     $class_bib = new Class_Bib();
     $bib_array = $class_bib->getBibs($id_zone);
     $redirect = "location='".BASE_URL."/admin/".$url."?z=".$id_zone."&amp;b='+ this.value";
-  
+
     if ($this->user->ROLE_LEVEL > 4) // Si l'user est minimum modo_portail
     {
       $html[]='<select name="bib" id="bib" onchange="'.$redirect.'">';
       if($id_zone != "PORTAIL")
-      { 
+      {
         if($id_bib == "ALL") $sel = 'selected="selected"'; else $sel="";
         if($all == true) $html[]='<option value="ALL" '.$sel.'>** '.$this->translate()->_('toutes').' **</option>';
       }
-      if($portail == true and (!$id_zone or $id_zone=="PORTAIL" or $id_zone=="ALL")) 
+      if($portail == true and (!$id_zone or $id_zone=="PORTAIL" or $id_zone=="ALL"))
       {
         if($id_bib == "PORTAIL") $sel = 'selected="selected"'; else $sel="";
         $html[]='<option value="PORTAIL" '.$sel.'>'.$this->translate()->_('Portail').'</option>';
       }
     }
     else $html[]='<select name="bib" id="bib" style="width:100%" disabled="disabled">';
-  
+
     if($bib_array)
     {
       foreach ($bib_array as $bib)
@@ -194,7 +194,7 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
     $html[]='</select>';
     return implode('',$html);
   }
-    
+
 //----------------------------------------------------------------------------------
 // Combo des profils
 //----------------------------------------------------------------------------------
@@ -205,8 +205,8 @@ class ZendAfi_View_Helper_Admin_ProfileSelect extends ZendAfi_View_Helper_BaseHe
     $html[]='<select name="id_profil" id="id_profil" onchange="'.$redirect.'">';
     foreach ($profil_array as $profil) {
       if ($id_profil == $profil->getId())
-        $selected='selected="selected"'; 
-      else 
+        $selected='selected="selected"';
+      else
         $selected='';
       $html[]='<option value="'.$profil->getId().'" '.$selected.'>'.$profil->getLibelle().'</option>';
     }
-- 
GitLab