| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Copyright (c) STMicroelectronics, 2007. All Rights Reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Originally written by Manuel Vacelet, 2007 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * This file is a part of Codendi. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * Codendi is free software; you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * it under the terms of the GNU General Public License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * the Free Software Foundation; either version 2 of the License, or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * Codendi is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * along with Codendi. If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | require_once('Docman_MetadataFactory.class.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | class Docman_MetadataComparator { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     var $docmanIcons; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     var $srcGo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     var $dstGo; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     function Docman_MetadataComparator($srcGroupId, $dstGroupId, $themePath) { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         $this->docmanIcons = new Docman_Icons($themePath.'/images/ic/'); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         $pm = ProjectManager::instance(); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         $this->srcGo = $pm->getProject($srcGroupId); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $this->dstGo = $pm->getProject($dstGroupId); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * For a five object iterator, return an array of object indexed by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * $func applied on object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     function getArrayFromIterator($iter, $func) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $a = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         while($iter->valid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             $e = $iter->current(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             $a[$e->$func()] = $e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             $iter->next(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         return $a; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     function checkMdDifferences($srcMd, $dstMd, $loveMap) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $diffArray = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         if(!$dstMd->sameDescription($srcMd)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             $diffArray[] = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_desc'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         if(!$dstMd->sameIsEmptyAllowed($srcMd)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             $diffArray[] = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_allowempty', array($GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_'.$srcMd->getIsEmptyAllowed()))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         if(!$dstMd->sameIsMultipleValuesAllowed($srcMd)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             $diffArray[] = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_allowmultiplevalue', array($GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_'.$srcMd->getIsMultipleValuesAllowed()))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         if(!$dstMd->sameUseIt($srcMd)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             $diffArray[] = $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_useit', array($GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_param_'.$srcMd->getUseIt()))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         return $diffArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * Same algo used in Docman_View_ItemDetailsSectionPaste::_checkLoveToImport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     function getLoveCompareTable($srcMd, $dstMd, $mdMap, &$sthToImport) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $html = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         if($srcMd->getLabel() == 'status') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             // No differences possible with status. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             return $html; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         // Get list of ListOfValues elements from dst project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $srcLoveFactory = new Docman_MetadataListOfValuesElementFactory($srcMd->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $srcLoveIter = $srcLoveFactory->getIteratorByFieldId($srcMd->getId(), $srcMd->getLabel(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         // Get list of ListOfValues elements from dst project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $dstLoveFactory = new Docman_MetadataListOfValuesElementFactory($dstMd->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $dstLoveIter = $dstLoveFactory->getIteratorByFieldId($dstMd->getId(), $dstMd->getLabel(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $dstLoveArray = $this->getArrayFromIterator($dstLoveIter, 'getId'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $maxRow = max($srcLoveIter->count(), $dstLoveIter->count()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         // Keep a trace of matching love | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $matchingLove = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         while($srcLoveIter->valid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             $srcLove = $srcLoveIter->current(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             $rowStyle = 'missing'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             // Compute the differences | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             $dstLove = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             if(isset($mdMap['love'][$srcLove->getId()])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                 $dstLove = $dstLoveArray[$mdMap['love'][$srcLove->getId()]]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 $matchingLove[$dstLove->getId()] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 $rowStyle = 'equals'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                 $sthToImport = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             $html .= "<tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             // Name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             $html .= "<td style=\"padding-left: 2em;\"></td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             $html .= "<td>".Docman_MetadataHtmlList::_getElementName($srcLove)."</td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             // Presence in source project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             $html .= '<td align="center"><img src="'.$this->docmanIcons->getThemeIcon('tick.png').'" /></td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             // Presence in destination project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |             $html .= "<td align=\"center\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             switch($rowStyle) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             case 'equals': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                 $html .= '<img src="'.$this->docmanIcons->getThemeIcon('tick.png').'" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             $html .= "</td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             // Differences | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             $html .= "<td class=\"docman_md_".$rowStyle."\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             switch($rowStyle) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             case 'missing': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_status_'.$rowStyle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             $html .= "</td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             // Action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $html .= "<td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             switch($rowStyle) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             case 'missing': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_act_import_love', array($srcLove->getName())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             $html .= "</td\n>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             $html .= "</tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             $srcLoveIter->next(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         // Append to the table the list of values elements in the dst project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         // that where not present in the src project. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         foreach($dstLoveArray as $love) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             if(!isset($matchingLove[$love->getId()])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                 $html .= "<tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 // Name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 $html .= "<td> </td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 $html .= "<td>".$love->getName()."</td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 // Presence in source project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 $html .= "<td></td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 // Presence in destination project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                 $html .= '<td align="center"><img src="'.$this->docmanIcons->getThemeIcon('tick.png').'" /></td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 // Differences | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                 $html .= "<td></td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                 // Action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                 $html .= "<td></td>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                 $html .= "</tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         return $html; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     function getMetadataCompareTable(&$sthToImport) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         $html = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         // True if there is sth to import in dst project. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         $sthToImport = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         // For source project, only get the 'Used' metadata. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $srcMdFactory = new Docman_MetadataFactory($this->srcGo->getGroupId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $srcMdIter = $srcMdFactory->getMetadataForGroup(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         // For destination (current) project, get all metadata. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         $dstMdFactory = new Docman_MetadataFactory($this->dstGo->getGroupId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $dstMdIter = $dstMdFactory->getMetadataForGroup(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $dstMdArray = $this->getArrayFromIterator($dstMdIter, 'getLabel'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         // Get mapping between the 2 definitions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $mdMap = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $srcMdFactory->getMetadataMapping($this->dstGo->getGroupId(), $mdMap); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_desc', array($this->dstGo->getPublicName(), $this->srcGo->getPublicName())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         // Table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         $html .= "<table border=\"1\">\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $html .= "<tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         $html .= "<th colspan=\"2\">".$GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_prop')."</th>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $html .= "<th>".$this->srcGo->getPublicName()."</th>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         $html .= "<th>".$this->dstGo->getPublicName()."</th>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $html .= "<th>".$GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_diff', array($this->dstGo->getPublicName(), $this->srcGo->getPublicName()))."</th>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         $html .= "<th>".$GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_action', array($this->dstGo->getPublicName()))."</th>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $html .= "</tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         // Keep a trace of metadata that matched in the dst metadata list. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $matchingMd = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $srcMdIter->rewind(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         while($srcMdIter->valid()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             $srcMd = $srcMdIter->current(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             $dstMd = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             // Compute the differences between the 2 projects | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             $dstMdStatus = 'missing'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             $dstMdLabel = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             if($srcMdFactory->isRealMetadata($srcMd->getLabel())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                 if(isset($mdMap['md'][$srcMd->getId()])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                     $dstMdLabel = $srcMdFactory->getLabelFromId($mdMap['md'][$srcMd->getId()]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                 $dstMdLabel = $srcMd->getLabel(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             if(isset($dstMdArray[$dstMdLabel])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                 $dstMd = $dstMdArray[$dstMdLabel]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 if($dstMd !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                     $matchingMd[$dstMdLabel] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                     $dstMdStatus = 'equivalent'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |                     if($dstMd->equals($srcMd)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                         $dstMdStatus = 'equals'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |                         $sthToImport = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                     $sthToImport = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                 // The metadata is not in the metadata map list, check if it's | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                 // not a name conflict | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |                 $dstMdi = $dstMdFactory->findByName($srcMd->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                 if ($dstMdi->count() == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |                     $dstMdStatus = 'conflict'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |                     $sthToImport = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |             // Display result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             $html .= "<tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             // Property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             $html .= "<td colspan=\"2\" style=\"font-weight: bold;\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             $html .= $srcMd->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |             // Presence in source project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             $html .= "<td align=\"center\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $html .= '<img src="'.$this->docmanIcons->getThemeIcon('tick.png').'" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |             $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             // Presence in destination project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             $html .= "<td align=\"center\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             switch($dstMdStatus) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             case 'equals': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             case 'equivalent': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |                 $html .= '<img src="'.$this->docmanIcons->getThemeIcon('tick.png').'" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             // Differences | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             $html .= "<td class=\"docman_md_".$dstMdStatus."\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             switch($dstMdStatus) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             case 'equivalent': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             case 'missing': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             case 'conflict': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_status_'.$dstMdStatus); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |             $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             // Action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             $html .= "<td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             switch($dstMdStatus) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             case 'equals': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                 // Nothing to do | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             case 'equivalent': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                 $diffArray = $this->checkMdDifferences($srcMd, $dstMd, $mdMap['love']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                 $diffStr = '<ul style="padding:0;padding-left:1.5em;margin:0;"><li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |                 $diffStr .= implode('</li><li>', $diffArray); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |                 $diffStr .= '</li></ul>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_act_update_md', array($srcMd->getName(), $this->dstGo->getPublicName(), $diffStr));                 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             case 'missing': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_act_import_md', array($srcMd->getName())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             case 'conflict': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                 $html .= $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_tbl_act_conflict'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |             $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |             $html .= "</tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |             // List of values | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |             if($srcMd->getType() == PLUGIN_DOCMAN_METADATA_TYPE_LIST) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |                 if($dstMd !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |                     $html .= $this->getLoveCompareTable($srcMd, $dstMd, $mdMap, $sthToImport); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |             unset($dstMd); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |             $srcMdIter->next(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         // Append to the table the metadata in the dst project that where not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |         // present in the src project. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         foreach($dstMdArray as $md) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             if(!isset($matchingMd[$md->getLabel()])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |                 $html .= "<tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |                 // Name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |                 $html .= "<td colspan=\"2\" style=\"font-weight: bold;\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |                 $html .= $md->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |                 $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |                 // Presence in source project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |                 $html .= "<td></td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |                 // Presence in destination project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |                 $html .= "<td align=\"center\">"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |                 $html .= '<img src="'.$this->docmanIcons->getThemeIcon('tick.png').'" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |                 $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |                 // Differences | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |                 $html .= "<td></td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |                 // Action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |                 $html .= "<td></td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |                 $html .= "</td>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |                 $html .= "</tr>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |         $html .= "</table>\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         return $html; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 359 |  |  | ?> | 
            
                                                        
            
                                    
            
            
                | 360 |  |  |  |