File indexing completed on 2025-05-04 05:29:02
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 ?> 0023 <?php if($this->step ==0) {?> 0024 <h3>Number of all not yet importetd projects: <?= $this->coutAll ?></h3> 0025 0026 0027 <form action="/backend/hive"> 0028 <input type="hidden" name="step" value="10"> 0029 <button>Go to next step</button> 0030 </form> 0031 0032 <br/><br/><br/><br/> 0033 <p>Info: <?= $this->info ?></p> 0034 0035 0036 <?php } else if($this->step ==10) {?> 0037 0038 0039 <h3>Step 1 - Hive-Categories: </h3> 0040 0041 <form action="/backend/hive"> 0042 <input type="hidden" name="step" value="20"> 0043 <input type="text" name="cat_ids" value="" size="100"> 0044 <button>Next</button> 0045 </form> 0046 0047 0048 <br/><br/><br/><br/> 0049 <p><a href="/backend/hive">Back to Start</a></p> 0050 <p>Info: <?= $this->info ?></p> 0051 <?php } else if($this->step ==20) {?> 0052 0053 0054 <h3>Step 2 - Overview Import: </h3> 0055 0056 <p><b>- Hive-Categories: <?= $this->cat_ids?></b></p> 0057 0058 <ul> 0059 0060 <?php 0061 $catArray = $this->categories; 0062 foreach ($catArray as $cat) { 0063 echo '<li>Hive-Cat-Id: '.$cat['id'].' - '.$cat['desc'].' - Ocs-Cat-Id: '.$cat['pling_cat_id'].'</li>'; 0064 } 0065 ?> 0066 </ul> 0067 0068 <form action="/backend/hive"> 0069 <input type="hidden" name="step" value="30"> 0070 <input type="hidden" name="cat_ids" value="<?= $this->cat_ids ?>"> 0071 <p><input type="checkbox" name="import_previews"> Import Gallery-Pics?</p> 0072 <p><input type="checkbox" name="import_files"> Import Files?</p> 0073 0074 <button>Start Import</button> 0075 </form> 0076 0077 0078 <br/><br/><br/><br/> 0079 <p><a href="/backend/hive">Back to Start</a></p> 0080 <p>Info: <?= $this->info ?></p> 0081 0082 <?php } else if($this->step ==30) {?> 0083 0084 0085 <h3>Step 3 - Import...</h3> 0086 <h4><span id="info_text"></span></h4> 0087 <p><span id="info"></span></p> 0088 <br/><br/><br/><br/> 0089 <p>Info: <?= $this->info ?></p> 0090 0091 0092 <script type="text/javascript"> 0093 catIds = '<?= $this->cat_ids ?>'; 0094 catList = catIds.split(','); 0095 startImport(catList,0,5,0,2000); 0096 0097 0098 var importCounter = 0; 0099 var errorCounter = 0; 0100 function startImport(cat_ids, index, limit, sum_now, sum_all) { 0101 if(index>=cat_ids.length) { 0102 $('#info_text').html('<b>Import Done! Imported ' + importCounter + ' projects. <p><a href="/backend/hive">Back to Start</a></p></b>'); 0103 return false; 0104 } 0105 cat_id = cat_ids[index]; 0106 0107 if(null != cat_id) { 0108 0109 var url_string = '/backend/hive/start-import-all-ajax?cat_id='+cat_id+'&limit='+limit+'&import_files=<?= $this->import_files ?>&import_previews=<?= $this->import_previews ?>'; 0110 0111 jQuery.ajax({ 0112 url: url_string, 0113 type: 'get', 0114 error: function () { 0115 errorCounter++; 0116 if(errorCounter<100) { 0117 startImport(cat_ids,index,limit, sum_now, sum_all); 0118 } else { 0119 //alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0120 index++; 0121 startImport(cat_ids,index,limit, 0, sum_all); 0122 } 0123 return false; 0124 }, 0125 success: function (results) { 0126 0127 sum_now = sum_now + limit; 0128 0129 0130 is_done = results['IsImportDone']; 0131 newOffset = results['offset']; 0132 newLimit = results['limit']; 0133 counter = results['ImportCounter']; 0134 totalCounter = results['TotalCounter']; 0135 importCounter = importCounter + counter; 0136 0137 if(sum_all == 0) { 0138 sum_all = totalCounter; 0139 } 0140 0141 //$('#info_text').html('<b>' + results['ImportCounter'] + ' projects with ' + results['ImportFileCounter'] + ' files imported!</b>'); 0142 $('#info_text').html('<b>Imported ' + importCounter + ' projects. ' + totalCounter + ' projects left.</b>'); 0143 if(is_done && counter>0 && sum_now<sum_all) { 0144 0145 //abortTimer(); 0146 //alert('Done'); 0147 $('#info').html(results['Message']); 0148 //startImport(0,25); 0149 startImport(cat_ids,index,limit, sum_now, sum_all); 0150 0151 } else { 0152 index++; 0153 startImport(cat_ids,index,limit, 0, sum_all); 0154 } 0155 return false; 0156 } 0157 }); 0158 } 0159 } 0160 </script> 0161 0162 <?php } else if($this->step ==1) {?> 0163 0164 0165 <h3>Step 1: Hive-Category</h3> 0166 0167 <form action="/backend/hive"> 0168 <input type="hidden" name="step" value="2"> 0169 <p>Please select hive category:</p> 0170 <select id="cat_id" name="cat_id" style="height: 25px;"> 0171 <option></option> 0172 <?php 0173 $catArray = $this->categories; 0174 foreach ($catArray as $cat) { 0175 echo '<option value="'.$cat['id'].'">'.$cat['desc'].'</option>'; 0176 } 0177 ?> 0178 </select> 0179 <button>Next</button> 0180 </form> 0181 <br/><br/> 0182 <span id="info_text"></span> 0183 0184 <br/><br/><br/><br/> 0185 <p><a href="/backend/hive">Back to Start</a></p> 0186 <p>Info: <?= $this->info ?></p> 0187 <script type="text/javascript"> 0188 $('body').on("change", 'select', function (event) { 0189 event.preventDefault(); 0190 event.stopImmediatePropagation(); 0191 0192 var url_string = '/backend/hive/count?cat_id=' + $('#cat_id').val(); 0193 0194 jQuery.ajax({ 0195 url: url_string, 0196 type: 'get', 0197 error: function () { 0198 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0199 return false; 0200 }, 0201 success: function (results) { 0202 $('#info_text').html('<b>' + results['TotalRecordCount'] + ' projects</b>'); 0203 return false; 0204 } 0205 }); 0206 0207 return false; 0208 }); 0209 0210 </script> 0211 <?php } else if($this->step ==2) {?> 0212 0213 0214 <h3>Step 2 - OCS-Category: </h3> 0215 0216 <form action="/backend/hive"> 0217 <input type="hidden" name="step" value="3"> 0218 <input type="hidden" name="cat_id" value="<?= $this->cat_id ?>"> 0219 <p>Please select the target ocs category for hive-category <?= $this->cat_desc ?></p> 0220 <select name="ocs_cat_id" style="height: 25px;"> 0221 <?php 0222 $catArray = $this->categories; 0223 foreach ($catArray as $cat) { 0224 echo '<option value="'.$cat['id'].'">'.$cat['desc'].'</option>'; 0225 } 0226 ?> 0227 </select> 0228 <button>Next</button> 0229 </form> 0230 0231 0232 <br/><br/><br/><br/> 0233 <p><a href="/backend/hive">Back to Start</a></p> 0234 <p>Info: <?= $this->info ?></p> 0235 <?php } else if($this->step ==3) {?> 0236 0237 0238 <h3>Step 3 - Summary</h3> 0239 0240 <p><b>- Hive-Category: <?= $this->cat_desc ?> (id = <?= $this->cat_id ?>)</b></p> 0241 <p><b>- OCS-Category: <?= $this->ocs_cat_desc ?> (id = <?= $this->ocs_cat_id ?>)</b></p> 0242 <p><b>- We will import files from <?= $this->count?> Hive-Projects</b></p> 0243 0244 <form action="/backend/hive"> 0245 <input type="hidden" name="step" value="4"> 0246 <input type="hidden" name="cat_id" value="<?= $this->cat_id ?>"> 0247 <input type="hidden" name="ocs_cat_id" value="<?= $this->ocs_cat_id ?>"> 0248 0249 <p><input type="checkbox" name="import_previews"> Import Gallery-Pics?</p> 0250 <p><input type="checkbox" name="import_files"> Import Files?</p> 0251 0252 <button>Start Import</button> 0253 </form> 0254 0255 0256 <br/><br/><br/><br/> 0257 <p><a href="/backend/hive">Back to Start</a></p> 0258 <p>Info: <?= $this->info ?></p> 0259 <?php } else if($this->step ==4) {?> 0260 0261 0262 <h3>Step 4 - Import...</h3> 0263 <h4><span id="info_text"></span></h4> 0264 <p><span id="info"></span></p> 0265 <br/><br/><br/><br/> 0266 <p>Info: <?= $this->info ?></p> 0267 0268 0269 <script type="text/javascript"> 0270 startImport(0,25); 0271 var importCounter = 0; 0272 var errorCounter = 0; 0273 function startImport(offset, limit) { 0274 0275 var url_string = '/backend/hive/start-import-ajax?cat_id=<?= $this->cat_id ?>&ocs_cat_id=<?= $this->ocs_cat_id ?>&import_files=<?= $this->import_files ?>&import_previews=<?= $this->import_previews ?>&limit='+limit+'&offset='+offset; 0276 0277 jQuery.ajax({ 0278 url: url_string, 0279 type: 'get', 0280 error: function () { 0281 //alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0282 //$('#info_text').html('<b>Status: ERROR ' + results['Message'] + '</b>'); 0283 //abortTimer(); 0284 errorCounter++; 0285 if(errorCounter<100) { 0286 startImport(0,25); 0287 } else { 0288 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0289 } 0290 return false; 0291 }, 0292 success: function (results) { 0293 0294 is_done = results['IsImportDone']; 0295 newOffset = results['offset']; 0296 newLimit = results['limit']; 0297 counter = results['ImportCounter']; 0298 totalCounter = results['TotalCounter']; 0299 importCounter = importCounter + counter; 0300 //$('#info_text').html('<b>' + results['ImportCounter'] + ' projects with ' + results['ImportFileCounter'] + ' files imported!</b>'); 0301 $('#info_text').html('<b>Imported ' + importCounter + ' projects. ' + totalCounter + ' projects left.</b>'); 0302 if(is_done && counter>0) { 0303 0304 //abortTimer(); 0305 //alert('Done'); 0306 $('#info').html(results['Message']); 0307 startImport(0,25); 0308 } else if(is_done && counter==0) { 0309 $('#info_text').html('<b>Import Done! Imported ' + importCounter + ' projects. <p><a href="/backend/hive">Back to Start</a></p></b>'); 0310 } 0311 return false; 0312 } 0313 }); 0314 } 0315 0316 // set timeout 0317 //var tid = setTimeout(getStatus, 2000); 0318 function getStatus() { 0319 // do some stuff... 0320 var url_string = '/backend/hive/import-status-ajax'; 0321 var is_done = false; 0322 jQuery.ajax({ 0323 url: url_string, 0324 type: 'get', 0325 error: function () { 0326 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0327 abortTimer(); 0328 $('#info_text').html('<b>Status: ERROR ' + results['Message'] + '</b>'); 0329 return false; 0330 }, 0331 success: function (results) { 0332 $('#info_text').html('<b>Status: import project ' + results['ImportCounter'] + ' of ' + results['ProjectCounter'] + ' projects</b>'); 0333 is_done = results['IsImportDone']; 0334 } 0335 }); 0336 0337 if(is_done) { 0338 abortTimer(); 0339 } else { 0340 tid = setTimeout(getStatus, 2000); // repeat myself 0341 } 0342 0343 } 0344 function abortTimer() { // to be called when you want to stop the timer 0345 clearTimeout(tid); 0346 } 0347 0348 0349 </script> 0350 0351 <?php }?> 0352