File indexing completed on 2024-12-29 05:24:38
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 $catTagGropuModel = new Default_Model_TagGroup(); 0023 $tagGroups = $catTagGropuModel->fetchTagGroupsForCategory($this->product->project_category_id); 0024 $tagsForGroupHelper = new Default_View_Helper_FetchTagsForTagGroup(); 0025 ?> 0026 0027 <style> 0028 0029 #product-page-content #product-panels #files-panel table.table-ocs-file td { 0030 vertical-align: top !important; 0031 } 0032 0033 </style> 0034 0035 <!-- ppload --> 0036 <?php if ($this->product->ppload_collection_id): ?> 0037 <?php 0038 $helperCatXdgType = new Default_View_Helper_CatXdgType(); 0039 $xdgType = $helperCatXdgType->catXdgType($this->product->project_category_id); 0040 0041 $helperUserRole = new Backend_View_Helper_UserRole(); 0042 $userRoleName = $helperUserRole->userRole(); 0043 0044 ?> 0045 <article> 0046 <div id="modal-installation-instructions" 0047 class="modal fade" 0048 role="dialog" 0049 aria-labelledby="modal-installation-instructions-label"> 0050 <div class="modal-dialog content-modal" style="width: 640px; font-size: 12pt;"> 0051 <div class="modal-content"> 0052 <div class="modal-header"> 0053 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 0054 <h3 id="modal-installation-instructions-label"><?= $this->translate('Installation Instructions') ?></h3> 0055 </div> 0056 <div class="modal-body"> 0057 <?php /* 0058 <iframe src="https://opendesktop.github.io/ocs-url/opendesktoporg-help.html" width="100%" height="500" frameborder="0" seamless id="iframeInstallInstruction"></iframe> 0059 */ 0060 ?> 0061 0062 </div> 0063 </div> 0064 </div> 0065 </div> 0066 0067 <div data-ppload-api-uri="<?= PPLOAD_API_URI ?>" 0068 data-ppload-collection-id="<?= $this->product->ppload_collection_id ?>" 0069 data-xdg-type="<?= $xdgType ?>" 0070 style="overflow-x: auto;"> 0071 0072 <!-- 0073 <iframe src="" width="0" height="0" frameborder="0" 0074 data-pling-music-uri="/pling-music-html5/embed.html" 0075 seamless></iframe> 0076 --> 0077 0078 <!--table-bordered--> 0079 <table class="table table-ocs-file" data-ppload-files=""> 0080 <thead> 0081 <tr> 0082 <th><?= $this->translate('File (click to download)'); ?></th> 0083 <th><?= $this->translate('Version'); ?></th> 0084 <th><?= $this->translate('Description'); ?></th> 0085 0086 0087 <?php 0088 //Show all Tag-Groups for this Category and show them as Dropdowns 0089 if(!empty($tagGroups)) { 0090 foreach ($tagGroups as $tagGroup) { 0091 echo "<th>" . $tagGroup['group_display_name'] . "</th>"; 0092 } 0093 } 0094 ?> 0095 <th style="text-align: right"><?= $this->translate('Downloads'); ?></th> 0096 <th><?= $this->translate('Date'); ?></th> 0097 0098 <th style="text-align: right"><?= $this->translate('Filesize'); ?></th> 0099 0100 <th style="text-align: right">DL</th> 0101 <th style="text-align: right;white-space:nowrap"><?= $this->translate('OCS-Install'); ?> 0102 <a href="#modal-installation-instructions" role="button" data-toggle="modal"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> 0103 </th> 0104 <?php if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) : ?> 0105 <th>Compatible</th> 0106 <?php endif; ?> 0107 </tr> 0108 </thead> 0109 <tbody></tbody> 0110 <tfoot> 0111 </tfoot> 0112 </table> 0113 0114 0115 </div> 0116 </article> 0117 0118 0119 <?php /* 0120 <div class="item active" style="max-width: 800px; max-height: 550px; margin:0 auto; display: none" id="carouselPPlay"> 0121 <div data-ppload-api-uri="<?= PPLOAD_API_URI ?>" 0122 data-ppload-collection-id="<?= $this->product->ppload_collection_id ?>"> 0123 0124 <iframe src="" width="0" height="0" frameborder="0" id="pplayiframe" 0125 data-pling-music-uri="/pling-music-html5/embed.html" 0126 seamless></iframe> 0127 </div> 0128 </div> 0129 */?> 0130 0131 0132 <script type="text/javascript"> 0133 0134 $(function () { 0135 var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}; 0136 0137 var $pploadCollection = $('div[data-ppload-collection-id]'); 0138 var $plingMusic = $pploadCollection.find('iframe[data-pling-music-uri]'); 0139 var pploadApiUri = $pploadCollection.attr('data-ppload-api-uri'); 0140 var hasFilesPanelOpened = false; 0141 var externalIcon = ' <i class="fa fa-external-link"></i>'; 0142 function keysrt(key, asc) { 0143 if(asc) { 0144 return function(a,b){ 0145 if (a[key] > b[key]) return 1; 0146 if (a[key] < b[key]) return -1; 0147 return 0; 0148 } 0149 } else { 0150 return function(a,b){ 0151 if (a[key] < b[key]) return 1; 0152 if (a[key] > b[key]) return -1; 0153 return 0; 0154 } 0155 } 0156 } 0157 0158 function activeCarouselFirstImg() 0159 { 0160 $('.carousel-inner .item').first().addClass('active'); 0161 $('.carousel-indicators > li').first().addClass('active'); 0162 $( '.carousel-indicators > li').each(function( index ) { 0163 $( this ).attr("data-slide-to",index); 0164 }); 0165 } 0166 0167 0168 function getPploadFiles(page) { 0169 activeCarouselFirstImg(); 0170 0171 var collectionId = $pploadCollection.attr('data-ppload-collection-id'); 0172 if (!page) { 0173 page = 1; 0174 } 0175 $.ajax({ 0176 //url: pploadApiUri + 'files/index', 0177 url: '/p/<?= $this->product->project_id ?>/getfilesajax', 0178 type: 'GET', 0179 data: { 0180 format: 'json', 0181 ignore_status_code: 1, 0182 status: 'all', 0183 collection_id: collectionId, 0184 perpage: 1000, 0185 page: page 0186 }, 0187 dataType: 'json', 0188 success: function (data, textStatus, jqXHR) { 0189 if (data.status != 'success') { 0190 activeCarouselFirstImg(); 0191 return; 0192 } 0193 0194 var isPlayable = false; 0195 var fileSizeSum = 0; 0196 0197 var downloaded_count_total = 0; 0198 var firstRow = true; 0199 0200 var myArray = $.map(data.files, function(entry) { 0201 return entry; 0202 }); 0203 0204 //myArray = myArray.sortOn('active'); 0205 myArray.sort(keysrt('active'), false); 0206 myArrayActive = []; 0207 myArrayInactive = []; 0208 $.each(myArray, function () { 0209 if(this.active == '1') { 0210 myArrayActive.push(this); 0211 } else { 0212 myArrayInactive.push(this); 0213 } 0214 }); 0215 0216 //sort 0217 myArrayActive.sort(keysrt('created_timestamp'), false); 0218 myArrayInactive.sort(keysrt('created_timestamp'), false); 0219 0220 var oldestFileId = null; 0221 //Active Files 0222 $.each(myArrayActive, function () { 0223 if(firstRow) { 0224 //this.downloaded_count = parseInt(this.downloaded_count) + parseInt(<?= $this->product->count_downloads_hive?>); 0225 oldestFileId = this.id; 0226 firstRow = false; 0227 } 0228 0229 if(this.id < oldestFileId) { 0230 oldestFileId = this.id; 0231 } 0232 0233 count_downloads = this.downloaded_count || 0; 0234 downloaded_count_total = downloaded_count_total+parseInt(count_downloads); 0235 0236 var link = ''; 0237 0238 if (this.tags) { 0239 fileTags = this.tags; 0240 0241 $.each(fileTags.split(','), function () { 0242 var tagStr = this.split('##'); 0243 if (tagStr.length == 2 && tagStr[0] == 'link') { 0244 link = tagStr[1]; 0245 } 0246 }); 0247 } 0248 var isExternLink = false; 0249 if ((typeof link != 'undefined') && (link != "")) { 0250 isExternLink = true; 0251 } 0252 0253 //downloadlink is now: domain/api/files/download/id/ID/s/TOKEN/t/TIMESTAMP/u/USERID/FILE_NAME 0254 var downloadUrl = "https://<?= $_SERVER["SERVER_NAME"]?>/p/<?= $this->product->project_id ?>/startdownload?file_id=" + this.id + "&file_name=" + this.name + "&file_type=" + this.type + "&file_size=" + this.size; 0255 var downloadLink = '<a href="' + downloadUrl + '" id="data-link' + this.id + '" class="opendownloadfile" data-file_id="' + this.id + '" data-file_name="' + this.name + '" data-file_type="' + this.type + '" data-file_size="' + this.size + '" data-has_torrent="' + this.has_torrent + '" data-project_id="<?= $this->product->project_id ?>" data-link_type="download" data-is-external-link="'+isExternLink+'">' + this.name + '</a>'; 0256 0257 /* 0258 var fileNameBtnLink = this.name; 0259 if(fileNameBtnLink.length > 25) { 0260 fileNameBtnLink = fileNameBtnLink.substring(0,22) + '...'; 0261 }*/ 0262 var downloadBtnLink = downloadUrl; 0263 var downloadLinkFilename = shortFilename(this.name); 0264 0265 0266 0267 var fileDescription = ''; 0268 if (this.description) { 0269 fileDescription = this.description; 0270 } 0271 var ocsUrl = ''; 0272 if (typeof link !== 'undefined' && link) { 0273 ocsUrl = generateOcsUrl( 0274 decodeURIComponent(link), 0275 $pploadCollection.attr('data-xdg-type') 0276 ); 0277 } else if (!link) { 0278 ocsUrl = generateOcsUrl( 0279 downloadUrl, 0280 $pploadCollection.attr('data-xdg-type'), 0281 this.name 0282 ); 0283 } 0284 0285 var installButton = ''; 0286 var installLink = ''; 0287 var installLinkFilename = ''; 0288 0289 if ( ocsUrl) { 0290 if(this.active && this.ocs_compatible == 1){ 0291 installButton = '<a href="' + downloadUrl + '" class="opendownloadfile btn btn-native btn-min-width" data-file_id="' + this.id + '" data-file_name="' + this.name + '" data-file_type="' + this.type + '" data-file_size="' + this.size + '" data-has_torrent="' + this.has_torrent + '" data-project_id="<?= $this->product->project_id ?>" data-link_type="install" data-is-external-link="'+isExternLink+'">Install</a>'; 0292 installLink = downloadUrl; 0293 installLinkFilename = shortFilename(this.name); 0294 0295 } else { 0296 installButton = '<a href="#" class="btn btn-min-width disabled">INCOMPATIBLE</a>'; 0297 installLink = ''; 0298 installLinkFilename = ''; 0299 } 0300 } 0301 0302 //if(this.active == '1') { 0303 var greyText = ' class="activerows"'; 0304 if(this.active == '0') { 0305 greyText = ' style="color: #ccc;"'; 0306 } 0307 0308 var downloadButton = ''; 0309 downloadButton = '<a href="'+downloadUrl+'" data-username="'+username+'" data-file_id="' + this.id + '" data-file_name="' + this.name + '" data-file_type="' + this.type + '" data-file_size="' + this.size + '" data-has_torrent="' + this.has_torrent + '" data-project_id="<?= $this->product->project_id ?>" data-link_type="download" data-is-external-link="'+isExternLink+'" class="btn btn-native btn-min-width opendownloadfile" ><img src="/images/system/download.svg" alt="download" style="width:20px; height:20px"></a>' ; 0310 0311 0312 if(this.version==null) {version = '';} else{version = this.version;} 0313 0314 0315 0316 0317 var mnt = moment(this.created_timestamp); 0318 0319 var tableString = ""; 0320 tableString += '<tr data-ppload-file-id="' + this.id + '"' + greyText + '>'; 0321 tableString += '<td>' + downloadLink + '</td>'; 0322 tableString += '<td>' + version + '</td>'; 0323 tableString += '<td>' + fileDescription + '</td>'; 0324 0325 <?php 0326 //Show all Tag-Groups for this Category and show them as Dropdowns 0327 if(!empty($tagGroups)) { 0328 0329 ?> 0330 var tagGroups = null; 0331 //get cat-tag-groups 0332 $.ajax({ 0333 url: '/p/<?= $this->product->project_id ?>/gettaggroupsforcatajax', 0334 type: 'GET', 0335 async: false, 0336 cache: false, 0337 timeout: 30000, 0338 data: {project_cat_id: <?= $this->product->project_category_id ?>, file_id: this.id, test: false}, 0339 dataType: 'json', 0340 success: function (data, textStatus, jqXHR) { 0341 if (data.status != 'success') { 0342 tagGroups = data.tag_groups; 0343 var fileId = this.id; 0344 $.each(tagGroups, function() { 0345 tableString += '<td>'; 0346 for(key in this.tag_list){ 0347 if(null != this.selected_tags) { 0348 $tag_name = this.tag_list[key]; 0349 $.each(this.selected_tags, function() { 0350 if(key == this.tag_id) { 0351 tableString += '<span>'+$tag_name+'</span>'; 0352 if($tag_name.toUpperCase() == 'APPIMAGE'){ 0353 tableString += ' <i class="fa fa-question-circle appimagequestion" style="cursor: pointer;"></i>'; 0354 } 0355 tableString += '<br>'; 0356 } 0357 }) 0358 } 0359 /* 0360 if(null != this.selected_tag && key == this.selected_tag) { 0361 tableString += '<span>'+this.tag_list[key]+'</span>'; 0362 if(this.tag_list[key].toUpperCase() == 'APPIMAGE'){ 0363 tableString += ' <i class="fa fa-question-circle appimagequestion" style="cursor: pointer;"></i>'; 0364 } 0365 }*/ 0366 0367 } 0368 }); 0369 return; 0370 } 0371 }, 0372 error: function (jqXHR, textStatus, errorThrown) { 0373 return; 0374 } 0375 }); 0376 0377 <?php 0378 } 0379 ?> 0380 0381 0382 tableString += '<td style="text-align: right"><span id="download_counter_' + this.id + '">' + count_downloads + '</td>'; 0383 tableString += '<td>' +mnt.format('YYYY-MM-DD') + '</td>'; 0384 tableString += '<td style="text-align: right">' + humanFileSize(this.size,false) + '</td>'; 0385 tableString += '<td style="text-align: right; ">' + downloadButton+ '</td>'; 0386 tableString += '<td style="text-align: right; ">' + installButton + '</td>'; 0387 <?php if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) : ?> 0388 tableString += '<td style="text-align: center; "><input type="checkbox" id="data-checkbox-compatible-'+this.id+'" data-is-compatible="" ></td>'; 0389 <?php endif; ?> 0390 tableString += '</tr>'; 0391 $pploadCollection.find('table[data-ppload-files] tbody').append(tableString); 0392 0393 <?php /* download/install dropdown btn */ 0394 ?> 0395 var username = '<?= $this->product->username?>'; 0396 $('#dropdown_downloads').append( 0397 '<li><a data-username="' + username + '" href="' + downloadBtnLink + '" style="white-space: normal; color: #23527c;" class="opendownloadfile" id="data-link-dl' + this.id + '" data-file_id="' + this.id + '" data-file_name="' + this.name + '" data-file_type="' + this.type + '" data-file_size="' + this.size + '" data-has_torrent="' + this.has_torrent + '" data-project_id="<?= $this->product->project_id ?>" data-link_type="download" data-is-external-link="'+isExternLink+'"><span id="download-link-filename' + this.id + '" style="white-space: normal; color: #23527c;">' + downloadLinkFilename + '</span><span class="right"> ' + humanFileSize(this.size,false) + ' </span></a></li>' 0398 ); 0399 $('#dropdown_downloads').addClass("active"); 0400 $('#dropdown_downloads').removeClass('hide'); 0401 $('#project_btn_download').enable(); 0402 $('#project_btn_download').removeClass('disabled'); 0403 $('#project_btn_download').addClass("active"); 0404 $('#project_btn_download').addClass("btn-primary"); 0405 0406 if(ocsUrl && this.active && this.ocs_compatible == 1){ 0407 $('#dropdown_installs').addClass("active"); 0408 $('#dropdown_installs').removeClass('hide'); 0409 $('#project_btn_install').enable(); 0410 $('#project_btn_install').removeClass('disabled'); 0411 $('#project_btn_install').removeClass('hide'); 0412 $('#project_btn_install').addClass("active"); 0413 $('#project_btn_grp_install').removeClass("hide"); 0414 0415 $('#dropdown_installs').append( 0416 '<li><a href="' + downloadBtnLink + '" style="white-space: normal; color: #23527c;" class="opendownloadfile" data-file_id="' + this.id + '" data-file_name="' + this.name + '" data-file_type="' + this.type + '" data-file_size="' + this.size + '" data-has_torrent="' + this.has_torrent + '" data-project_id="<?= $this->product->project_id ?>" data-link_type="install" data-is-external-link="'+isExternLink+'"><span id="install-link-filename' + this.id + '" style="white-space: normal; color: #23527c;">' + installLinkFilename + '</span><span class="right"> ' + humanFileSize(this.size,false) + ' </span></a></li>' 0417 0418 ); 0419 } 0420 0421 0422 if ((typeof osId != 'undefined') && (osId != "")) { 0423 $("#data-updatepploadfile" + this.id + " option[value='" + osId + "']").attr('selected', 'selected'); 0424 $os = $("#data-updatepploadfile" + this.id + " option[value='" + osId + "']").text(); 0425 //alert("Text: " + $os); 0426 $("#data-updatepploadfile" + this.id).hide(); 0427 $("#file-tag-os" + this.id).text($os); 0428 } 0429 0430 0431 0432 0433 if (isExternLink) { 0434 0435 $fileserverLink = $("#data-link" + this.id).attr('href'); 0436 $("#data-link" + this.id).attr('href', decodeURIComponent(link)); 0437 $("#data-link" + this.id).attr('data-link-org', $fileserverLink); 0438 $("#data-link" + this.id).attr('data-is-external-link', isExternLink); 0439 0440 $("#data-link" + this.id).attr('target','_blank'); 0441 $("#data-link" + this.id).html($("#data-link" + this.id).html()+ externalIcon ); 0442 0443 /* 0444 $("#data-link" + this.id).click(function (event) { 0445 event.preventDefault(); 0446 $fileserverLink = $(this).attr('data-link-org'); 0447 window.open($fileserverLink, '_blank'); 0448 }); 0449 */ 0450 0451 $fileserverLink = $("#data-link-dl" + this.id).attr('href'); 0452 $("#data-link-dl" + this.id).attr('href', decodeURIComponent(link)); 0453 $("#data-link-dl" + this.id).attr('data-link-org', $fileserverLink); 0454 $("#data-link" + this.id).attr('data-is-external-link', isExternLink); 0455 0456 $("#data-link-dl" + this.id).attr('target','_blank'); 0457 0458 $("#download-link-filename" + this.id).html($("#download-link-filename" + this.id).html()+ externalIcon ); 0459 0460 /* 0461 $("#data-link-dl" + this.id).click(function (event) { 0462 event.preventDefault(); 0463 $fileserverLink = $(this).attr('data-link-org'); 0464 window.open($fileserverLink, '_blank'); 0465 }); 0466 */ 0467 0468 $("#install-link-filename" + this.id).html($("#install-link-filename" + this.id).html() + externalIcon ); 0469 } 0470 0471 0472 $compatibleCheckbox = $("#data-checkbox-compatible-" + this.id); 0473 0474 if(this.active == '0') { 0475 $compatibleCheckbox.prop('disabled', 'disabled'); 0476 } 0477 0478 $compatibleCheckbox.click(function (event) { 0479 event.preventDefault(); 0480 $fileId = $(this).closest('tr[data-ppload-file-id]').attr('data-ppload-file-id'); 0481 $isCompatible = this.checked; 0482 updateOcsCompatible($fileId, $isCompatible); 0483 }); 0484 0485 0486 //fileSizeSum += parseInt(this.size); 0487 if(parseInt(this.size)>0) { 0488 fileSizeSum += roundFileSizeInMB(parseInt(this.size)); 0489 } 0490 0491 //if (!isExternLink) 0492 //{ 0493 //fileSizeSum += roundFileSizeInMB(parseInt(this.size)); 0494 //} 0495 0496 0497 if (this.type == 'audio/mpeg' || this.type == 'application/ogg') { 0498 isPlayable = true; 0499 } 0500 0501 //} 0502 0503 }); 0504 0505 // 0506 //Inactive Fiels 0507 // 0508 $.each(myArrayInactive, function () { 0509 if(null == oldestFileId) { 0510 oldestFileId = this.id; 0511 } 0512 0513 if(this.id < oldestFileId) { 0514 oldestFileId = this.id; 0515 } 0516 0517 var count_downloads = this.downloaded_count || 0; 0518 0519 downloaded_count_total = downloaded_count_total+parseInt(count_downloads); 0520 0521 var link = ''; 0522 0523 if (this.tags) { 0524 fileTags = this.tags; 0525 0526 $.each(fileTags.split(','), function () { 0527 var tagStr = this.split('##'); 0528 if (tagStr.length == 2 && tagStr[0] == 'link') { 0529 link = tagStr[1]; 0530 } 0531 }); 0532 } 0533 var isExternLink = false; 0534 if ((typeof link != 'undefined') && (link != "")) { 0535 isExternLink = true; 0536 downloadLink = '<a href="' + decodeURIComponent(link) + '" id="data-link' + this.id + '" style="color: #ccc;">' + this.name + '</a>'; 0537 } 0538 0539 var hash = '<?= $this->download_hash ?>'; 0540 var timetamp = '<?= $this->download_timestamp ?>'; 0541 var userid = '<?= $this->product->member_id?>'; 0542 var downloadUrl = "https://<?= $_SERVER["SERVER_NAME"]?>/p/<?= $this->product->project_id ?>/startdownload?file_id=" + this.id + "&file_name=" + this.name + "&file_type=" + this.type + "&file_size=" + this.size + "&url=" + encodeURIComponent(pploadApiUri + 'files/download/id/' + this.id + '/s/' + hash + '/t/' + timetamp + '/u/' + userid + '/' + this.name); 0543 //var downloadLink = '<a class="inactiverows" style="color: #ccc; display:none;" href="' + downloadUrl + '" id="data-link' + this.id + '">' + this.name + '</a>'; 0544 var downloadLink = '<a class="inactiverows opendownloadfile" style="color: #ccc; display:none;" href="' + downloadUrl + '" id="data-link' + this.id + '" data-file_id="' + this.id + '" data-file_name="' + this.name + '" data-file_type="' + this.type + '" data-file_size="' + this.size + '" data-has_torrent="' + this.has_torrent + '" data-project_id="<?= $this->product->project_id ?>" data-link_type="download" data-is-external-link="'+isExternLink+'">' + this.name + '</a>'; 0545 0546 0547 var fileDescription = ''; 0548 if (this.description) { 0549 fileDescription = this.description; 0550 } 0551 0552 0553 0554 0555 //if(this.active == '1') { 0556 var greyText = ' class="inactiverows" style="color: #ccc; display:none;"'; 0557 0558 if(this.version==null) {version = '';} else{version = this.version;} 0559 var mnt = moment(this.created_timestamp); 0560 0561 var tableString = ""; 0562 tableString += '<tr data-ppload-file-id="' + this.id + '"' + greyText + '>'; 0563 tableString += '<td>' + downloadLink + '</td>'; 0564 tableString += '<td>' + version + '</td>'; 0565 tableString += '<td>' + fileDescription + '</td>'; 0566 0567 <?php 0568 //Show all Tag-Groups for this Category and show them as Dropdowns 0569 if(!empty($tagGroups)) { 0570 0571 ?> 0572 var tagGroups = null; 0573 //get cat-tag-groups 0574 $.ajax({ 0575 url: '/p/<?= $this->product->project_id ?>/gettaggroupsforcatajax', 0576 type: 'GET', 0577 async: false, 0578 cache: false, 0579 timeout: 30000, 0580 data: {project_cat_id: <?= $this->product->project_category_id ?>, file_id: this.id, test: false}, 0581 dataType: 'json', 0582 success: function (data, textStatus, jqXHR) { 0583 if (data.status != 'success') { 0584 tagGroups = data.tag_groups; 0585 var fileId = this.id; 0586 $.each(tagGroups, function() { 0587 tableString += '<td>'; 0588 for(key in this.tag_list){ 0589 if(null != this.selected_tags) { 0590 $tag_name = this.tag_list[key]; 0591 $.each(this.selected_tags, function() { 0592 if(key == this.tag_id) { 0593 tableString += '<span>'+$tag_name+'</span>'; 0594 if($tag_name.toUpperCase() == 'APPIMAGE'){ 0595 tableString += ' <i class="fa fa-question-circle appimagequestion" style="cursor: pointer;"></i>'; 0596 } 0597 tableString += '<br>'; 0598 } 0599 }) 0600 } 0601 /* 0602 if(null != this.selected_tag && key == this.selected_tag) { 0603 tableString += '<span>'+this.tag_list[key]+'</span>'; 0604 }*/ 0605 } 0606 }); 0607 return; 0608 } 0609 }, 0610 error: function (jqXHR, textStatus, errorThrown) { 0611 return; 0612 } 0613 }); 0614 0615 <?php 0616 } 0617 ?> 0618 0619 0620 tableString += '<td style="text-align: right"><span id="download_counter_' + this.id + '">' + count_downloads + '</td>'; 0621 tableString += '<td>' +mnt.format('YYYY-MM-DD') + '</td>'; 0622 tableString += '<td style="text-align: right">' + humanFileSize(this.size,false) + '</td>'; 0623 tableString += '<td style="text-align: right; "></td>'; 0624 tableString += '<td style="text-align: right; "></td>'; 0625 tableString += '</tr>'; 0626 $pploadCollection.find('table[data-ppload-files] tbody').append(tableString); 0627 0628 if (isExternLink) { 0629 //$("#data-link" + this.id).attr('href', decodeURIComponent(link)); 0630 $("#data-link" + this.id).attr('target','_blank'); 0631 $("#data-link" + this.id).html($("#data-link" + this.id).html() + externalIcon ); 0632 } 0633 0634 0635 0636 //fileSizeSum += parseInt(this.size); 0637 if(parseInt(this.size)>0) { 0638 fileSizeSum += roundFileSizeInMB(parseInt(this.size)); 0639 } 0640 //if (!isExternLink) 0641 //{ 0642 //fileSizeSum += roundFileSizeInMB(parseInt(this.size)); 0643 //} 0644 0645 0646 if (this.type == 'audio/mpeg' || this.type == 'application/ogg') { 0647 isPlayable = true; 0648 } 0649 0650 //} 0651 0652 }); 0653 0654 0655 //add old download counter 0656 downloaded_count_total += parseInt(<?= $this->product->count_downloads_hive?>); 0657 0658 //add old download counter to oldest file 0659 var fileCount = $('#download_counter_'+ oldestFileId).html(); 0660 var oldNewCounter = parseInt(fileCount) + parseInt(<?= $this->product->count_downloads_hive?>); 0661 $('#download_counter_'+ oldestFileId).html(oldNewCounter); 0662 0663 0664 0665 //$('#downloadscnt').html(downloaded_count_total); 0666 var colsStart = 3; 0667 <?php 0668 //Show all Tag-Groups for this Category and show the saved values 0669 if(!empty($tagGroups)) { 0670 echo "colsStart += " . count($tagGroups) . ";"; 0671 } 0672 0673 ?> 0674 0675 0676 $pploadCollection.find('table[data-ppload-files] tfoot').append( 0677 '<tr>' 0678 + '<th colspan="' + colsStart + '">' + myArrayActive.length + ' <?= $this->translate("files")?> (<span style="color: #ccc;" ><a style="cursor:pointer" onclick="fnToggleInactiveFiles();return false;">'+myArrayInactive.length+' archived</a></span>)</th>' 0679 0680 + '<th style="text-align: right">' + downloaded_count_total + '</th>' 0681 + '<th></th>' 0682 + '<th style="text-align: right">' + fileSizeSum.toFixed(2) + ' MB</th>' 0683 //+ '<th style="text-align: right">' + humanFileSize(fileSizeSum) + '</th>' 0684 + '<th></th>' 0685 + '<th></th>' 0686 + '</tr>' 0687 ); 0688 0689 $pploadCollection.find('a[data-ppload-download-link]').attr( 0690 'href', 0691 pploadApiUri + 'collections/download/id/' + collectionId 0692 ); 0693 0694 0695 /* 0696 var b= false; 0697 if (isPlayable && !$plingMusic.attr('src')) { 0698 $plingMusic.attr({ 0699 src: $plingMusic.attr('data-pling-music-uri') 0700 + '?play_collection=' + collectionId, 0701 width: '100%', 0702 height: '550' 0703 }); 0704 0705 $('.carousel-inner').prepend($('#carouselPPlay').show()); 0706 $('.carousel-indicators').prepend('<li data-target="#myCarousel" data-slide-to="0"></li>'); 0707 $('.carousel-indicators > li').first().addClass('active'); 0708 b = true; 0709 } 0710 0711 if(!b){ 0712 activeCarouselFirstImg(); 0713 } 0714 */ 0715 0716 0717 /*if (data.pagination !== 'undefined' && data.pagination.next) { 0718 getPploadFiles(data.pagination.next); 0719 }*/ 0720 0721 }, 0722 error: function (jqXHR, textStatus, errorThrown) { 0723 0724 activeCarouselFirstImg(); 0725 0726 0727 } 0728 }); 0729 } 0730 0731 function generateOcsUrl(url, type, filename) { 0732 if (!url || !type) { 0733 return ''; 0734 } 0735 if (!filename) { 0736 filename = url.split('/').pop().split('?').shift(); 0737 } 0738 return 'ocs://install' 0739 + '?url=' + encodeURIComponent(url) 0740 + '&type=' + encodeURIComponent(type) 0741 + '&filename=' + encodeURIComponent(filename); 0742 } 0743 0744 0745 function updateOcsCompatible(fileId, isCompatible) { 0746 var $url = "/p/<?= $this->product->project_id ?>/updatepploadfile"; 0747 0748 if(fileId != 'undefined' && fileId != null) { 0749 0750 $.ajax({ 0751 url: $url, 0752 type: 'POST', 0753 data: { 0754 file_id: fileId, 0755 ocs_compatible: (isCompatible==true?1:0) 0756 }, 0757 dataType: 'json', 0758 success: function (data, textStatus, jqXHR) { 0759 if (data.status == 'ok') { 0760 $("#files-panel").find('table[data-ppload-files] tbody').html(''); 0761 $('#dropdown_downloads').html(''); 0762 $("#files-panel").find('table[data-ppload-files] tfoot').html(''); 0763 getPploadFiles(); 0764 0765 } 0766 0767 }, 0768 error: function (jqXHR, textStatus, errorThrown) { 0769 alert("Error: " + textStatus + ", " + errorThrown); 0770 0771 } 0772 }); 0773 } 0774 } 0775 0776 function shortFilename(filename) { 0777 var returnString = filename; 0778 if(filename.length > 25) { 0779 var name = filename.substring(0,22); 0780 var fileExt = filename.split('.').pop(); 0781 if(fileExt.length>3) { 0782 name = name.substring(0,(25-fileExt.length)); 0783 } 0784 returnString = name + '...' + fileExt; 0785 } 0786 return returnString; 0787 } 0788 0789 0790 function roundFileSizeInMB(bytes) 0791 { 0792 // min size 0.01MB 0793 if(bytes>0) 0794 { 0795 var size = (bytes / 1048576).toFixed(2); 0796 if(size == '0.00') 0797 { 0798 return Number('0.01'); 0799 }else 0800 { 0801 return Number(size); 0802 } 0803 } 0804 } 0805 0806 0807 0808 fnToggleInactiveFiles = function(){ 0809 $('.inactiverows').toggle(); 0810 }; 0811 0812 0813 0814 function humanFileSize(bytes,isExternLink) { 0815 if(isExternLink) return '----'; 0816 if(bytes>0) 0817 { 0818 var size = ''; 0819 size = (bytes / 1048576).toFixed(2); 0820 if(size == '0.00') 0821 { 0822 return '0.01 MB'; 0823 }else 0824 { 0825 return size+' MB'; 0826 } 0827 } 0828 else 0829 { 0830 return '0.00 MB'; 0831 } 0832 } 0833 0834 function humanFileSize_(bytes) { 0835 if(bytes>0) 0836 { 0837 var size = ''; 0838 size = (bytes / 1048576).toFixed(2); 0839 /* 0840 if (bytes >= 1073741824) { 0841 size = (bytes / 1073741824).toFixed(2) + 'GB'; 0842 } 0843 else if (bytes >= 1048576) { 0844 size = (bytes / 1048576).toFixed(2) + 'MB'; 0845 } 0846 else if (bytes >= 1024) { 0847 size = (bytes / 1024).toFixed(2) + 'KB'; 0848 } 0849 else { 0850 size = bytes + 'bytes'; 0851 }*/ 0852 0853 if(size == '0.00') 0854 { 0855 return '0.01 MB'; 0856 }else 0857 { 0858 return size+' MB'; 0859 } 0860 } 0861 else 0862 { 0863 return '0.00 MB'; 0864 } 0865 } 0866 0867 //$('a[href="#files-panel"][data-toggle="tab"]').on('click', function () { 0868 if (!hasFilesPanelOpened) { 0869 getPploadFiles(); 0870 hasFilesPanelOpened = true; 0871 0872 0873 } 0874 //}); 0875 0876 }); 0877 0878 $(function() { 0879 0880 $('#modal-installation-instructions').on('show.bs.modal', function (e) { 0881 $.ajax({ 0882 url: '/p/<?= $this->product->project_id?>/loadinstallinstruction', 0883 type: 'html', 0884 success: function (results) { 0885 var text = results.data; 0886 $('#modal-installation-instructions').find('.modal-body').html(text); 0887 } 0888 }); 0889 }); 0890 0891 }); 0892 </script> 0893 <?php endif; ?> 0894 <!-- /ppload -->