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