From 8a9734cb5417b5f2b3988142c530e4032b6fb9e5 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Wed, 10 May 2017 10:45:12 +0200
Subject: [PATCH] dev #59734 rt

---
 VERSIONS_WIP/59734                            |   3 +-
 .../admin/controllers/ProfilController.php    |   1 +
 .../admin/views/scripts/profil/accueil.phtml  | 144 --------
 public/admin/js/config_accueil.js             | 349 ------------------
 4 files changed, 3 insertions(+), 494 deletions(-)
 delete mode 100644 public/admin/js/config_accueil.js

diff --git a/VERSIONS_WIP/59734 b/VERSIONS_WIP/59734
index 4ada07b0633..79e8b903b4b 100644
--- a/VERSIONS_WIP/59734
+++ b/VERSIONS_WIP/59734
@@ -1 +1,2 @@
- - ticket #59734 : ZendAfi_Form Profil & page
\ No newline at end of file
+ - ticket #59734 : Administration ;: migration des formulaires d'édition de profil et de page vers le mode onglet
+ 
\ No newline at end of file
diff --git a/application/modules/admin/controllers/ProfilController.php b/application/modules/admin/controllers/ProfilController.php
index 414f64fab14..8cd587825d1 100644
--- a/application/modules/admin/controllers/ProfilController.php
+++ b/application/modules/admin/controllers/ProfilController.php
@@ -184,6 +184,7 @@ class Admin_ProfilController extends ZendAfi_Controller_Action {
   protected function _parseSaveContentString() {
     $modules = ['modules' => []];
     $profil = Class_Profil::find($this->id_profil);
+
     for($division = 1; $division <= Class_Profil::DIV_FLOTANTTE; $division++) {
 
       if(!$widgets = $this->_getParam('division' . $division))
diff --git a/application/modules/admin/views/scripts/profil/accueil.phtml b/application/modules/admin/views/scripts/profil/accueil.phtml
index 6b975c6a6c9..20a1932d3a9 100644
--- a/application/modules/admin/views/scripts/profil/accueil.phtml
+++ b/application/modules/admin/views/scripts/profil/accueil.phtml
@@ -2,148 +2,4 @@
 echo $this->partial('profil/_profil_panel.phtml',
                     ['profil' => $this->profil]);
 echo $this->renderForm($this->form);
-return;
 ?>
-
-<script type="text/javascript" src="<?php echo URL_ADMIN_JS?>common.js"> </script>
-<script type="text/javascript" src="<?php echo URL_ADMIN_JS?>config_accueil.js"> </script>
-<script type="text/javascript" src="<?php echo URL_ADMIN_JS?>controle_maj.js"> </script>
-<link rel="stylesheet" type="text/css" media="screen" href="<?php echo URL_ADMIN_CSS?>config_accueil.css" />
-
-<?php echo $this->partial('profil/_profil_panel.phtml',
-                          array('profil' => $this->profil)); ?>
-
-
-
-<div class="form">
-  <form name="form" action="<?php echo BASE_URL.'/admin/profil/accueil/id_profil/'.$this->profil->getid() ?>#drag_and_drop_modules" method="post">
-      <?php
-      if($this->profil->hasErrors())  {
-        echo '<ul class="errors">';
-        foreach($this->profil->getErrors() as $erreur)
-          echo '<li>'.$erreur.'</li>';
-        echo '</ul>';
-      }
-      ?>
-      <fieldset>
-        <legend>Page</legend>
-        <table border="0" cellpadding="5" cellspacing="0">
-          <tr>
-            <td class="droite"><?php echo $this->traduire('Libelle'); ?></td>
-            <td class="gauche"><input type="text" name="libelle" value="<?php echo $this->escape(trim($this->profil->getLibelle()));?>" maxlength="50"/></td>
-          </tr>
-          <tr>
-   <td class="droite"><?php echo $this->_("Utiliser le css du profil");echo "</br>". basename($this->profil->getHeaderCss()); ?></td>
-            <td class="gauche">
-              <?php echo $this->formCheckbox('use_parent_css',
-                                             $this->profil->getUseParentCss(),
-                                             null,
-                                             array('1', '0')) ?>
-            </td>
-          </tr>
-          <tr>
-            <td class="droite">
-              <?php echo $this->_("Ajouter au plan du site"); ?>
-            </td>
-            <td class="gauche">
-              <?php echo $this->formCheckbox('sitemap',
-                                             $this->profil->getCfgAccueilParam('sitemap'),
-                                             null,
-                                             array('1', '0')) ?>
-            </td>
-          </tr>
-          <tr>
-            <td class="droite"><?php echo $this->traduire('Page css:'); ?></td>
-            <td class="gauche" style="padding-left:5px">
-<?php echo $this->coreFiveFileInput('page_css', $this->profil->getPageCss(), 'css', 'File') ?>
-            </td>
-          </tr>
-        <tr>
-          <td class="droite"><?php echo $this->traduire('URL de la page'); ?></td>
-          <td class="gauche"><input type="text" style="width:100%" name="rewrite_url" value="<?php echo $this->escape(trim($this->profil->getRewriteUrl()));?>" maxlength="150"/></td>
-        </tr>
-        </table>
-      </fieldset>
-      <a name="drag_and_drop_modules"></a>
-      <fieldset><legend>Modules</legend>
-        <div>Modules disponibles</div>
-        <div id="dhtmlgoodies_dragDropContainer">
-          <div id="dhtmlgoodies_listOfItems">
-            <table>
-              <tr>
-                <td style="width:25%;"><?php echo $this->module_info; ?></td>
-                <td style="width:25%;"><?php echo $this->module_rech; ?></td>
-                <td style="width:25%;"><?php echo $this->module_site; ?></td>
-                <td style="width:25%;"><?php echo $this->module_abonne; ?></td>
-              </tr>
-            </table>
-          </div>
-
-          <br/>
-
-          <div>Modules installés</div>
-          <div id="dhtmlgoodies_mainContainer">
-            <table>
-              <?php
-              $width_col = "98%";
-              if($this->nb_divisions == 2) $width_col = "48%";
-              if($this->nb_divisions == 3) $width_col = "33%";
-
-              echo('<tr><td style="width:'.$width_col.';">
-                        <div style="width:100%;background-color:#E2EBED">
-                        <p>1ere division</p>
-                        <ul id="box1">'.$this->box1.'</ul>
-                </div></td>');
-              if($this->nb_divisions > 1)
-              {
-                echo('<td style="width:'.$width_col.'"><div style="width:100%;background-color:#E2EBED">
-                <p>2eme division</p>
-                <ul id="box2">'.$this->box2.'</ul>
-                </div></td>');
-              }
-              if($this->nb_divisions > 2)
-              {
-                echo('<td style="width:'.$width_col.'">
-                <div style="width:100%;background-color:#E2EBED">
-                <p>3eme division</p>
-                <ul id="box3">'.$this->box3.'</ul>
-                </div></td>');
-              }
-              ?>
-            </tr>
-            <?php if (Class_AdminVar::isMenuBoiteEnabled()) { ?>
-            <tr>
-               <td colspan="<?php echo $this->nb_divisions ?>">
-                 <div style="width:100%;background-color:#E2EBED">
-                   <p>Bannière</p>
-                   <ul id="box4"><?php echo $this->box4 ?></ul>
-                 </div>
-               </td>
-             </tr>
-             <?php } ?>
-             <tr>
-               <td colspan="<?php echo $this->nb_divisions ?>">
-                 <div style="width:100%;background-color:#E2EBED">
-                   <p>Flottant</p>
-                   <ul id="box5"><?php echo $this->box5 ?></ul>
-                 </div>
-               </td>
-             </tr>
-            </table>
-          </div>
-        </div>
-      </fieldset>
-
-      <ul id="dragContent"></ul>
-      <div id="dragDropIndicator"><img src="<?php echo URL_ADMIN_IMG; ?>insert.gif" alt='insérer' /></div>
-      <textarea id="saveContent" name="saveContent" style="display:none;" rows="30" cols="10"></textarea>
-      <br/>
-      <div  align="center" style="width:100%">
-        <?php
-        echo $this->Button_Submit();
-        echo $this->Button_Back((new Class_Entity())
-                                ->setUrl($this->url(['action' => 'edit'])));
-        ?>
-      </div>
-    </form>
-  </div>
diff --git a/public/admin/js/config_accueil.js b/public/admin/js/config_accueil.js
deleted file mode 100644
index a66be391d92..00000000000
--- a/public/admin/js/config_accueil.js
+++ /dev/null
@@ -1,349 +0,0 @@
-// VARIABLES YOU COULD MODIFY
-var boxSizeArray = [12,12,12,12,12,12,12,12];	// Array indicating how many items there is rooom for in the right column ULs
-
-var arrow_offsetX = -5;	// Offset X - position of small arrow
-var arrow_offsetY = 0;	// Offset Y - position of small arrow
-
-var arrow_offsetX_firefox = -6;	// Firefox - offset X small arrow
-var arrow_offsetY_firefox = -13; // Firefox - offset Y small arrow
-
-var verticalSpaceBetweenListItems = 3;	// Pixels space between one <li> and next
-var indicateDestionationByUseOfArrow = true;	// Display arrow to indicate where object will be dropped(false = use rectangle)
-
-var cloneSourceItems = true;	// Items picked from main container will be cloned(i.e. "copy" instead of "cut").
-var cloneAllowDuplicates = true;	// Allow multiple instances of an item inside a small box(example: drag Student 1 to team A twice
-var indicateDestinationBox = false; // La petite fleche 
-var nIdModuleMax=0  // Indice max pour affecter un id_module aux nouveaux objets
-
-// VARIABLES YOU SHOULD NOT MODIFY
-var dragDropTopContainer = false;
-var dragTimer = -1;
-var dragContentObj = false;
-var contentToBeDragged = false;	// Reference to dragged <li>
-var contentToBeDragged_src = false;	// Reference to parent of <li> before drag started
-var contentToBeDragged_next = false; 	// Reference to next sibling of <li> to be dragged
-var destinationObj = false;	// Reference to <UL> or <LI> where element is dropped.
-var dragDropIndicator = false;	// Reference to small arrow indicating where items will be dropped
-var ulPositionArray = new Array();
-var mouseoverObj = false;	// Reference to highlighted DIV
-var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
-var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;
-
-function getTopPos(inputObj)
-{		
-  var returnValue = inputObj.offsetTop;
-  while((inputObj = inputObj.offsetParent) != null){
-    if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
-  }
-  return returnValue;
-}
-
-function getLeftPos(inputObj)
-{
-  var returnValue = inputObj.offsetLeft;
-  while((inputObj = inputObj.offsetParent) != null){
-    if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
-  }
-  return returnValue;
-}
-
-function cancelEvent()
-{
-  return false;
-}
-
-//--------------------------------------------------------------------------	
-// Debut du drag
-//--------------------------------------------------------------------------	
-function initDrag(e)
-{
-  // Si click sur le bouton proprietes on laisse faire le onclick
-  if(e.target.src)
-  { 
-    return false;
-  }
-  if(document.all)e = event;
-  var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
-  var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
-  dragTimer = 0;
-  dragContentObj.style.left = e.clientX + sl + 'px';
-  dragContentObj.style.top = e.clientY + st + 'px';
-  contentToBeDragged = this;
-  contentToBeDragged_src = this.parentNode;
-  contentToBeDragged_next = false;
-  if(this.nextSibling)
-  {
-    contentToBeDragged_next = this.nextSibling;
-    if(!this.tagName && contentToBeDragged_next.nextSibling)contentToBeDragged_next = contentToBeDragged_next.nextSibling;
-  }
-  timerDrag();
-  return false;
-}
-
-function timerDrag()
-{
-  if(dragTimer>=0 && dragTimer<10){
-    dragTimer++;
-    setTimeout('timerDrag()',10);
-    return;
-  }
-  if(dragTimer==10){
-
-    if(cloneSourceItems && contentToBeDragged.parentNode.id=='allItems'){
-      newItem = contentToBeDragged.cloneNode(true);
-      newItem.onmousedown = contentToBeDragged.onmousedown;
-      contentToBeDragged = newItem;
-    }
-    dragContentObj.style.display='block';
-    dragContentObj.appendChild(contentToBeDragged);
-  }
-}
-
-function moveDragContent(e)
-{
-  if(dragTimer<10)
-  {
-    if(contentToBeDragged)
-    {
-      if(contentToBeDragged_next) contentToBeDragged_src.insertBefore(contentToBeDragged,contentToBeDragged_next);
-      else contentToBeDragged_src.appendChild(contentToBeDragged);
-    }
-    return;
-  }
-  if(document.all)e = event;
-  var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
-  var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
-
-  dragContentObj.style.left = e.clientX + sl + 'px';
-  dragContentObj.style.top = e.clientY + st + 'px';
-
-  if(mouseoverObj) mouseoverObj.className='';
-  destinationObj = false;
-  dragDropIndicator.style.display='none';
-  if(indicateDestinationBox)indicateDestinationBox.style.display='none';
-  var x = e.clientX + sl;
-  var y = e.clientY + st;
-  var width = dragContentObj.offsetWidth;
-  var height = dragContentObj.offsetHeight;
-
-  var tmpOffsetX = arrow_offsetX;
-  var tmpOffsetY = arrow_offsetY;
-  if(!document.all){
-    tmpOffsetX = arrow_offsetX_firefox;
-    tmpOffsetY = arrow_offsetY_firefox;
-  }
-
-  for(var no=0;no<ulPositionArray.length;no++){
-    var ul_leftPos = ulPositionArray[no]['left'];
-    var ul_topPos = ulPositionArray[no]['top'];
-    var ul_height = ulPositionArray[no]['height'];
-    var ul_width = ulPositionArray[no]['width'];
-
-    if((x+width) > ul_leftPos && x<(ul_leftPos + ul_width) && (y+height)> ul_topPos && y<(ul_topPos + ul_height)){
-      var noExisting = ulPositionArray[no]['obj'].getElementsByTagName('LI').length;
-      if(indicateDestinationBox && indicateDestinationBox.parentNode==ulPositionArray[no]['obj'])noExisting--;
-      if(noExisting<boxSizeArray[no-1] || no==0){
-	dragDropIndicator.style.left = ul_leftPos + tmpOffsetX + 'px';
-	var subLi = ulPositionArray[no]['obj'].getElementsByTagName('LI');
-
-	var clonedItemAllreadyAdded = false;
-	if(cloneSourceItems && !cloneAllowDuplicates){
-	  for(var liIndex=0;liIndex<subLi.length;liIndex++){
-	    if(contentToBeDragged.id == subLi[liIndex].id)clonedItemAllreadyAdded = true;
-	  }
-	  if(clonedItemAllreadyAdded)continue;
-	}
-
-	for(var liIndex=0;liIndex<subLi.length;liIndex++){
-	  var tmpTop = getTopPos(subLi[liIndex]);
-	  if(!indicateDestionationByUseOfArrow){
-	    if(y<tmpTop){
-	      destinationObj = subLi[liIndex];
-	      indicateDestinationBox.style.display='block';
-	      subLi[liIndex].parentNode.insertBefore(indicateDestinationBox,subLi[liIndex]);
-	      break;
-	    }
-	  }else{
-	    if(y<tmpTop){
-	      destinationObj = subLi[liIndex];
-	      dragDropIndicator.style.top = tmpTop + tmpOffsetY - Math.round(dragDropIndicator.clientHeight/2) + 'px';
-	      dragDropIndicator.style.display='block';
-	      break;
-	    }
-	  }
-	}
-
-	if(!indicateDestionationByUseOfArrow){
-	  if(indicateDestinationBox.style.display=='none'){
-	    indicateDestinationBox.style.display='block';
-	    ulPositionArray[no]['obj'].appendChild(indicateDestinationBox);
-	  }
-
-	}else{
-	  if(subLi.length>0 && dragDropIndicator.style.display=='none'){
-	    dragDropIndicator.style.top = getTopPos(subLi[subLi.length-1]) + subLi[subLi.length-1].offsetHeight + tmpOffsetY + 'px';
-	    dragDropIndicator.style.display='block';
-	  }
-	  if(subLi.length==0){
-	    dragDropIndicator.style.top = ul_topPos + arrow_offsetY + 'px'
-	    dragDropIndicator.style.display='block';
-	  }
-	}
-
-	if(!destinationObj)destinationObj = ulPositionArray[no]['obj'];
-	mouseoverObj = ulPositionArray[no]['obj'].parentNode;
-	mouseoverObj.className='mouseover';
-	return;
-      }
-    }
-  }
-}
-
-//--------------------------------------------------------------------------
-// Drop element ou retour a l'envoyeur
-//--------------------------------------------------------------------------	
-function dragDropEnd(e)
-{
-  if(dragTimer==-1)return;
-  if(dragTimer<10)
-  {
-    dragTimer = -1;
-    return;
-  }
-  dragTimer = -1;
-  if(document.all)e = event;
-  if(cloneSourceItems && !destinationObj && contentToBeDragged_src.id.substr(0,3)!="box" || (destinationObj && destinationObj.id=='allItems') || (destinationObj && destinationObj.parentNode.id=='allItems'))
-  {
-    contentToBeDragged.parentNode.removeChild(contentToBeDragged);
-  }
-  else
-  {
-    if(destinationObj)
-    {
-      setFlagMaj(true);
-      // Affecter un identifiant si nouvel element
-      if(contentToBeDragged_src.id == "allItems")
-      {
-	nIdModuleMax++;
-	contentToBeDragged.setAttribute("id_module",nIdModuleMax);
-	contentToBeDragged.setAttribute("new_module",true);
-        $(contentToBeDragged).mousedown(initDrag);
-	
-	// Afficher le picto pour les proprietes
-	oImg=contentToBeDragged;
-	while(true)
-	{
-	  oImg=oImg.lastChild;
-	  if(!oImg) { alert("Erreur javascript : config_accueil - Fonction : dragDropEnd"); return; }
-	  if(oImg.nodeName == "IMG") break;
-	}
-	oImg.style.display="block";
-      }
-      if(destinationObj.tagName=='UL') destinationObj.appendChild(contentToBeDragged);
-      else destinationObj.parentNode.insertBefore(contentToBeDragged,destinationObj);
-      mouseoverObj.className='';
-      destinationObj = false;
-      dragDropIndicator.style.display='none';
-      if(indicateDestinationBox)
-      {
-	indicateDestinationBox.style.display='none';
-	document.body.appendChild(indicateDestinationBox);
-      }
-      contentToBeDragged = false;
-      setFlagMaj(false);saveDragDropNodes();var form=$('[id*=dragDrop]').closest('form');form.submit();
-      return;
-    }
-    if(contentToBeDragged_next) contentToBeDragged_src.insertBefore(contentToBeDragged,contentToBeDragged_next);
-    else contentToBeDragged_src.appendChild(contentToBeDragged);
-    setFlagMaj(false);saveDragDropNodes();var form=$('[id*=dragDrop]').closest('form');form.submit();
-  }
-  contentToBeDragged = false;
-  dragDropIndicator.style.display='none';
-  if(indicateDestinationBox)
-  {
-    indicateDestinationBox.style.display='none';
-    document.body.appendChild(indicateDestinationBox);
-  }
-  setFlagMaj(false);saveDragDropNodes();var form=$('[id*=dragDrop]').closest('form');form.submit();
-  mouseoverObj = false;
-}
-
-//--------------------------------------------------------------------------
-// Recup des donnees (bas�e sur la balise UL)
-//--------------------------------------------------------------------------
-function saveDragDropNodes()
-{
-  var saveString = "";
-  var uls = dragDropTopContainer.getElementsByTagName('UL');
-  for(var no=0;no<uls.length;no++)
-  {
-    var lis = uls[no].getElementsByTagName('LI');
-    for(var no2=0;no2<lis.length;no2++)
-    {
-      if(saveString.length>0)saveString = saveString + ";";
-      if(uls[no].id !="allItems") {
-	var id_module = lis[no2].getAttribute("id_module");
-	if (lis[no2].getAttribute("new_module") == 'true') id_module = 'new';
-	saveString = saveString + uls[no].id + '|' + id_module + "|" + lis[no2].id + "|" + lis[no2].getAttribute('proprietes');
-      }
-    }
-  }
-  document.getElementById('saveContent').innerHTML = saveString;
-}
-
-//--------------------------------------------------------------------------
-// Initialisation des evenements 
-//--------------------------------------------------------------------------	
-function initDragDropScript()
-{
-  dragContentObj = document.getElementById('dragContent');
-  dragDropIndicator = document.getElementById('dragDropIndicator');
-  dragDropTopContainer = document.getElementById('dhtmlgoodies_dragDropContainer');
-  document.documentElement.onselectstart = cancelEvent;
-  
-  // Get objets <li>
-  var listItems = dragDropTopContainer.getElementsByTagName('LI');	
-  var itemHeight = false;
-
-  //pour bug IE 7 & 8
-  $('#dhtmlgoodies_dragDropContainer LI').mousedown(initDrag);
-
-  for(var no=0;no<listItems.length;no++)
-  {
-    //		listItems[no].onmousedown = initDrag;
-    listItems[no].onselectstart = cancelEvent;
-    if(!itemHeight) itemHeight = listItems[no].offsetHeight;
-    if(MSIE && navigatorVersion/1<6) listItems[no].style.cursor='hand';
-    // Indice max
-    if(listItems[no].getAttribute("id_module") > nIdModuleMax) nIdModuleMax=listItems[no].getAttribute("id_module");
-  }
-  var mainContainer = document.getElementById('dhtmlgoodies_mainContainer');
-  var uls = mainContainer.getElementsByTagName('UL');
-  var leftContainer = document.getElementById('dhtmlgoodies_listOfItems');
-  var itemBox = leftContainer.getElementsByTagName('UL')[0];
-
-  document.documentElement.onmousemove = moveDragContent;	// Mouse move event - moving draggable div
-  document.documentElement.onmouseup = dragDropEnd;	// Mouse move event - moving draggable div
-
-  var ulArray = dragDropTopContainer.getElementsByTagName('UL');
-  for(var no=0;no<ulArray.length;no++)
-  {
-    ulPositionArray[no] = new Array();
-    ulPositionArray[no]['left'] = getLeftPos(ulArray[no]);
-    ulPositionArray[no]['top'] = getTopPos(ulArray[no]);
-    ulPositionArray[no]['width'] = ulArray[no].offsetWidth;
-    ulPositionArray[no]['height'] = ulArray[no].clientHeight;
-    ulPositionArray[no]['obj'] = ulArray[no];
-  }
-  if(!indicateDestionationByUseOfArrow)
-  {
-    indicateDestinationBox = document.createElement('LI');
-    indicateDestinationBox.id = 'indicateDestination';
-    indicateDestinationBox.style.display='none';
-    document.body.appendChild(indicateDestinationBox);
-  }
-}
-
-// Initialiser les objets au form load
-$(document).ready(initDragDropScript);
-
-- 
GitLab