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 
0023 $catTagGropuModel  = new Default_Model_TagGroup();
0024 $tagGroups = $catTagGropuModel->fetchTagGroupsForCategory($this->product->project_category_id);
0025 $tagsForGroupHelper = new Default_View_Helper_FetchTagsForTagGroup();
0026 
0027 ?>
0028 
0029 <style type="text/css">
0030   .pploadajax .btn{
0031     padding: 3px 5px;
0032   }
0033   .pploadajax td{
0034     padding: 3px;
0035   }
0036 
0037 </style>
0038 
0039   <!-- ppload -->
0040          <?php if ($this->product->ppload_collection_id): ?>
0041              <?php
0042              $helperCatXdgType = new Default_View_Helper_CatXdgType();
0043              $xdgType = $helperCatXdgType->catXdgType($this->product->project_category_id);
0044              ?>
0045 
0046              <article>
0047                 <div style="border: 1px solid #ddd; height: 300px; width: 100%; display: flex; align-items: center;">
0048                       <h1 style="flex:1; text-align: center;   ">  Welcome to download !</h1>
0049                 </div>
0050              </article>
0051 
0052                  <article style="font-size: smaller;" class="pploadajax">
0053                      <div data-ppload-api-uri="<?= PPLOAD_API_URI ?>"
0054                           data-ppload-collection-id="<?= $this->product->ppload_collection_id ?>"
0055                           data-xdg-type="<?= $xdgType ?>">
0056 
0057                          <!--table-bordered-->
0058                          <table class="table table-ocs-file" data-ppload-files-ajax="" style="width: 1200px; ">
0059                              <thead>
0060                                 <tr>
0061                                  <th><?= $this->translate('File (click to download)'); ?></th>
0062                                  <th><?= $this->translate('Version'); ?></th>
0063                                  <th><?= $this->translate('Description'); ?></th>
0064 
0065                                  
0066                                  <?php
0067                                     //Show all Tag-Groups for this Category and show them as Dropdowns
0068                                     if(!empty($tagGroups)) {
0069                                         foreach ($tagGroups as $tagGroup) {
0070                                             echo "<th>" . $tagGroup['group_display_name'] . "</th>";
0071                                         }
0072                                     }
0073                                 ?>
0074                                  <th style="text-align: right"><?= $this->translate('Downloads'); ?></th>
0075                                  <th><?= $this->translate('Date'); ?></th>
0076 
0077                                  <th style="text-align: right"><?= $this->translate('Filesize'); ?></th>
0078 
0079                                  <th style="text-align: right">DL</th>
0080                                   <th style="text-align: right;white-space:nowrap"><?= $this->translate('OCS-Install'); ?>
0081                                      <a href="#modal-installation-instructions" role="button" data-toggle="modal"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a>
0082                                  </th>
0083                                  <?php if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) : ?>
0084                                  <th>Compatible</th>
0085                                  <?php endif; ?>
0086                                 </tr>
0087                              </thead>
0088                              <tbody></tbody>
0089                              <tfoot>
0090                              </tfoot>
0091                          </table>
0092 
0093 
0094                      </div>
0095                  </article>
0096 
0097 
0098 
0099 
0100 
0101              <script type="text/javascript">
0102 
0103                  $(function () {
0104                      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}};
0105 
0106                      var $pploadCollection = $('div[data-ppload-collection-id]');
0107                      var pploadApiUri = $pploadCollection.attr('data-ppload-api-uri');
0108                      var hasFilesPanelOpened = false;
0109 
0110                      function keysrt(key, asc) {
0111                          if(asc) {
0112                               return function(a,b){
0113                                if (a[key] > b[key]) return 1;
0114                                if (a[key] < b[key]) return -1;
0115                                return 0;
0116                               }
0117                          } else {
0118                              return function(a,b){
0119                                    if (a[key] < b[key]) return 1;
0120                                    if (a[key] > b[key]) return -1;
0121                                    return 0;
0122                              }
0123                          }
0124                     }
0125 
0126 
0127 
0128 
0129                      function getPploadFiles(page) {
0130 
0131                          var collectionId = $pploadCollection.attr('data-ppload-collection-id');
0132                          if (!page) {
0133                              page = 1;
0134                          }
0135                          $.ajax({
0136                              url: pploadApiUri + 'files/index',
0137                              type: 'GET',
0138                              data: {
0139                                  format: 'json',
0140                                  ignore_status_code: 1,
0141                                  status: 'all',
0142                                  collection_id: collectionId,
0143                                  perpage: 1000,
0144                                  page: page
0145                              },
0146                              dataType: 'json',
0147                              success: function (data, textStatus, jqXHR) {
0148                                  var isPlayable = false;
0149                                  var fileSizeSum = 0;
0150 
0151                                  var downloaded_count_total = 0;
0152                                  var firstRow = true;
0153 
0154                                 var myArray = $.map(data.files, function(entry) {
0155                                     return entry;
0156                                 });
0157 
0158                                 //myArray = myArray.sortOn('active');
0159                                 myArray.sort(keysrt('active'), false);
0160                                 myArrayActive = [];
0161                                 myArrayInactive = [];
0162                                 $.each(myArray, function () {
0163                                         if(this.active == '1') {
0164                                                 myArrayActive.push(this);
0165                                         } else {
0166                                                 myArrayInactive.push(this);
0167                                         }
0168                                 });
0169 
0170                                 //sort
0171                                 myArrayActive.sort(keysrt('created_timestamp'), false);
0172                                 myArrayInactive.sort(keysrt('created_timestamp'), false);
0173 
0174                                 var oldestFileId = null;
0175                                 //Active Files
0176                                  $.each(myArrayActive, function () {
0177                                     if(firstRow) {
0178                                         //this.downloaded_count = parseInt(this.downloaded_count) + parseInt(<?= $this->product->count_downloads_hive?>);
0179                                         oldestFileId = this.id;
0180                                         firstRow = false;
0181                                     }
0182 
0183                                     if(this.id < oldestFileId) {
0184                                             oldestFileId = this.id;
0185                                     }
0186 
0187                                     count_downloads = this.downloaded_count || 0;
0188                                     downloaded_count_total = downloaded_count_total+parseInt(count_downloads);
0189 
0190                                     //downloadlink is now: domain/api/files/download/id/ID/s/TOKEN/t/TIMESTAMP/u/USERID/FILE_NAME
0191                                     var hash = '<?= $this->download_hash ?>';
0192                                     var timetamp = '<?= $this->download_timestamp ?>';
0193                                     var userid = '<?= $this->product->member_id?>';
0194 
0195                                     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);
0196                                     var downloadLink = '<a href="' + downloadUrl + '" id="data-link-ajax' + this.id + '">' + this.name + '</a>';
0197 
0198                                     /*
0199                                     var fileNameBtnLink = this.name;
0200                                     if(fileNameBtnLink.length > 25) {
0201                                         fileNameBtnLink = fileNameBtnLink.substring(0,22) + '...';
0202                                     }*/
0203                                     var downloadBtnLink = downloadUrl;
0204                                     var downloadLinkFilename = shortFilename(this.name);
0205 
0206                                     var link = '';
0207 
0208                                     var fileDescription = '';
0209                                     if (this.description) {
0210                                         fileDescription = this.description;
0211                                     }
0212                                      var licenseId = '';
0213                                      var license = '';
0214                                      var packagetypeId = '';
0215                                      if (this.tags) {
0216                                          fileTags = this.tags;
0217 
0218                                          $.each(fileTags.split(','), function () {
0219 
0220                                              if(this.indexOf("##")==-1) {
0221                                               var tagStr = this.split('-');
0222                                               if (tagStr.length == 2 && tagStr[0] == 'os') {
0223                                                   osId = tagStr[1];
0224                                               } else if (tagStr.length == 2 && tagStr[0] == 'licensetype') {
0225                                                   licenseId = tagStr[1];
0226                                               } else if (tagStr.length == 2 && tagStr[0] == 'packagetypeid') {
0227                                                   packagetypeId = tagStr[1];
0228                                               }
0229                                              } else {
0230                                               var tagStr = this.split('##');
0231                                               if (tagStr.length == 2 && tagStr[0] == 'link') {
0232                                                   link = tagStr[1];
0233                                               } else if (tagStr.length == 2 && tagStr[0] == 'license') {
0234                                                   license = tagStr[1];
0235                                                   license = Base64.decode(license);
0236                                               } else if (tagStr.length == 2 && tagStr[0] == 'packagetypeid') {
0237                                                   packagetypeId = tagStr[1];
0238                                               }
0239                                              }
0240 
0241                                          });
0242                                      }
0243 
0244                                      var ocsUrl = '';
0245                                      if (typeof link !== 'undefined' && link) {
0246                                          ocsUrl = generateOcsUrl(
0247                                              decodeURIComponent(link),
0248                                              $pploadCollection.attr('data-xdg-type')
0249                                          );
0250                                      } else if (!link) {
0251                                          ocsUrl = generateOcsUrl(
0252                                              downloadUrl,
0253                                              $pploadCollection.attr('data-xdg-type'),
0254                                              this.name
0255                                          );
0256                                      }
0257 
0258                                      var installButton = '';
0259                                      var installLink = '';
0260                                      var installLinkFilename = '';
0261 
0262                                      if ( ocsUrl) {
0263                                             if(this.active && this.ocs_compatible == 1){
0264                                                 installButton = '<a href="' + ocsUrl + '" class="btn btn-native btn-min-width">Install</a>';
0265                                                 installLink = ocsUrl;
0266                                                 installLinkFilename = shortFilename(this.name);
0267 
0268                                             } else {
0269                                                 installButton = '<a href="#" class="btn btn-min-width disabled">INCOMPATIBLE</a>';
0270                                                 installLink = '';
0271                                                 installLinkFilename = '';
0272                                             }
0273                                      }
0274 
0275                                     //if(this.active == '1') {
0276                                     var greyText = ' class="activerows"';
0277                                     if(this.active == '0') {
0278                                            greyText = ' style="color: #ccc;"';
0279                                     }
0280 
0281                                     var downloadButton = '';
0282                                     var username = '<?= $this->product->username?>';
0283                                     downloadButton = '<a href="'+downloadUrl+'" data-username="'+username+'" class="btn btn-native btn-min-width opendownloadfile" ><img src="/images/system/download.svg" alt="download" style="width:20px; height:20px"></a>' ;
0284 
0285                                     if(this.version==null) {version = '';} else{version = this.version;}
0286                                     var isExternLink = false;
0287                                     if ((typeof link != 'undefined') && (link != "")) {
0288                                        isExternLink = true;
0289                                     }
0290 
0291 
0292 
0293                                     var mnt = moment(this.created_timestamp);
0294 
0295                                         $pploadCollection.find('table[data-ppload-files-ajax] tbody').append(
0296                                             '<tr data-ppload-file-id="' + this.id + '"' + greyText + '>'
0297                                             + '<td>' + downloadLink + '</td>'
0298                                             + '<td>' + version + '</td>'
0299                                             + '<td>' + fileDescription + '</td>'
0300                                             + '<td>'
0301                                             + '<select id="data-select-packagetype-ajax' + this.id + '" data-packagetype-id="" name="packagetype" class="form-control input-sm" style="width: 200px;">'
0302                                             + '<option value=\"\"></option>'
0303                                             + '<option value=\"2\">Android (APK)</option>'
0304                                             + '<option value=\"1\">AppImage</option>'
0305                                             + '<option value=\"9\">Arch</option>'
0306                                             + '<option value=\"5\">Debian</option>'
0307                                             + '<option value=\"8\">Electron-Webapp</option>'
0308                                             + '<option value=\"7\">Flatpak</option>'
0309                                             + '<option value=\"10\">open/Suse</option>'
0310                                             + '<option value=\"3\">OS X compatible</option>'
0311                                             + '<option value=\"11\">Redhat</option>'
0312                                             + '<option value=\"6\">Snappy</option>'
0313                                             + '<option value=\"12\">Source Code</option>'
0314                                             + '<option value=\"4\">Windows executable</option>'
0315                                             + '</select><span id="file-tag-packagetype-ajax'+this.id+'">'
0316                                             + '</td>'
0317 
0318                                             + '<td style="text-align: right"><span id="download_counter_' + this.id + '">' + count_downloads + '</td>'
0319                                             + '<td>' +mnt.format('YYYY-MM-DD') + '</td>'
0320                                             + '<td style="text-align: right">' + humanFileSize(this.size,false) + '</td>'
0321                                             + '<td style="text-align: right; ">' + downloadButton+ '</td>'
0322                                             + '<td style="text-align: right; ">' + installButton + '</td>'
0323 
0324                                             + '</tr>'
0325                                         );
0326 
0327 
0328 
0329                                         if ((typeof osId != 'undefined') && (osId != "")) {
0330                                             $("#data-updatepploadfile" + this.id + " option[value='" + osId + "']").attr('selected', 'selected');
0331                                             $os = $("#data-updatepploadfile" + this.id + " option[value='" + osId + "']").text();
0332                                             //alert("Text: " + $os);
0333                                             $("#data-updatepploadfile" + this.id).hide();
0334                                             $("#file-tag-os" + this.id).text($os);
0335                                         }
0336 
0337                                         if ((typeof licenseId != 'undefined') && (licenseId != "")) {
0338                                             $("#data-select-license" + this.id + " option[value='" + licenseId + "']").attr('selected', 'selected');
0339                                             $licenseIdText = $("#data-select-license" + this.id + " option[value='" + licenseId + "']").text();
0340                                             $("#data-select-license" + this.id).hide();
0341                                             $("#file-tag-license" + this.id).text($licenseIdText);
0342                                         } else {
0343                                          $("#data-select-license" + this.id).hide();
0344                                         }
0345 
0346                                         if ((typeof license != 'undefined') && (license != "")) {
0347                                             $("#file-tag-license-text" + this.id).text(license);
0348                                         }
0349 
0350                                         $("#data-select-license" + this.id).hide();
0351 
0352                                         if ((typeof packagetypeId != 'undefined') && (packagetypeId != "")) {
0353                                             $("#data-select-packagetype-ajax" + this.id + " option[value='" + packagetypeId + "']").attr('selected', 'selected');
0354                                             $packagetypeIdText = $("#data-select-packagetype-ajax" + this.id + " option[value='" + packagetypeId + "']").text();
0355                                             $("#data-select-packagetype-ajax" + this.id).hide();
0356                                             $("#file-tag-packagetype-ajax" + this.id).text($packagetypeIdText);
0357 
0358                                         } else {
0359                                          $("#data-select-packagetype-ajax" + this.id).hide();
0360                                         }
0361 
0362                                         console.log($("#data-select-packagetype-ajax" + this.id));
0363                                         $("#data-select-packagetype-ajax" + this.id).hide();
0364 
0365                                         if ((typeof this.ocs_compatible != 'undefined') && (this.ocs_compatible != "") && this.ocs_compatible == 1) {
0366                                             $("#data-checkbox-compatible-" + this.id).attr('checked', 'checked');
0367                                         }
0368 
0369 
0370                                         if (isExternLink) {
0371                                             $fileserverLink = $("#data-link-ajax" + this.id).attr('href');
0372                                             $("#data-link-ajax" + this.id).attr('href', decodeURIComponent(link));
0373                                             $("#data-link-ajax" + this.id).attr('data-link-ajax-org', $fileserverLink);
0374 
0375                                             $("#data-link-ajax" + this.id).attr('target','_blank');
0376                                             $("#data-link-ajax" + this.id).html($("#data-link-ajax" + this.id).html() + " (External Link)");
0377 
0378                                             $("#data-link-ajax" + this.id).click(function (event) {
0379                                                 event.preventDefault();
0380                                                 $fileserverLink = $(this).attr('data-link-ajax-org');
0381                                                 window.open($fileserverLink, '_blank');
0382                                             });
0383 
0384 
0385                                             $fileserverLink = $("#data-link-ajax-dl" + this.id).attr('href');
0386                                             $("#data-link-ajax-dl" + this.id).attr('href', decodeURIComponent(link));
0387                                             $("#data-link-ajax-dl" + this.id).attr('data-link-ajax-org', $fileserverLink);
0388 
0389                                             $("#data-link-ajax-dl" + this.id).attr('target','_blank');
0390 
0391                                             $("#download-link-filename" + this.id).html($("#download-link-filename" + this.id).html() + " (External Link)");
0392 
0393                                             $("#data-link-ajax-dl" + this.id).click(function (event) {
0394                                                 event.preventDefault();
0395                                                 $fileserverLink = $(this).attr('data-link-ajax-org');
0396                                                 window.open($fileserverLink, '_blank');
0397                                             });
0398 
0399                                             $("#install-link-filename" + this.id).html($("#install-link-filename" + this.id).html() + " (External Link)");
0400                                         }
0401 
0402 
0403                                         $compatibleCheckbox = $("#data-checkbox-compatible-" + this.id);
0404 
0405                                         if(this.active == '0') {
0406                                             $compatibleCheckbox.prop('disabled', 'disabled');
0407                                         }
0408 
0409 
0410 
0411                                         //fileSizeSum += parseInt(this.size);
0412                                         if(parseInt(this.size)>0) {
0413                                             fileSizeSum += roundFileSizeInMB(parseInt(this.size));
0414                                         }
0415 
0416                                     //if (!isExternLink)
0417                                     //{
0418                                        //fileSizeSum += roundFileSizeInMB(parseInt(this.size));
0419                                     //}
0420 
0421 
0422                                     if (this.type == 'audio/mpeg' || this.type == 'application/ogg') {
0423                                         isPlayable = true;
0424                                     }
0425 
0426                                     //}
0427 
0428                                  });
0429 
0430                                  //
0431                                  //Inactive Fiels
0432                                  //
0433                                  $.each(myArrayInactive, function () {
0434                                     if(null == oldestFileId) {
0435                                             oldestFileId = this.id;
0436                                     }
0437 
0438                                     if(this.id < oldestFileId) {
0439                                             oldestFileId = this.id;
0440                                     }
0441 
0442                                     cout_downloads = this.downloaded_count || 0;
0443 
0444                                     downloaded_count_total = downloaded_count_total+parseInt(cout_downloads);
0445 
0446                                     downloadLink = this.name;
0447 
0448                                      var fileDescription = '';
0449                                      if (this.description) {
0450                                          fileDescription = this.description;
0451                                      }
0452 
0453                                      var licenseId = '';
0454                                      var license = '';
0455                                      if (this.tags) {
0456                                          fileTags = this.tags;
0457                                          $.each(fileTags.split(','), function () {
0458 
0459                                              if(this.indexOf("##")==-1) {
0460                                               var tagStr = this.split('-');
0461                                               if (tagStr.length == 2 && tagStr[0] == 'os') {
0462                                                   osId = tagStr[1];
0463                                               } else if (tagStr.length == 2 && tagStr[0] == 'licensetype') {
0464                                                   licenseId = tagStr[1];
0465                                               } else if (tagStr.length == 2 && tagStr[0] == 'packagetypeid') {
0466                                                   packagetypeId = tagStr[1];
0467                                               }
0468                                              } else {
0469                                               var tagStr = this.split('##');
0470                                               if (tagStr.length == 2 && tagStr[0] == 'link') {
0471                                                   link = tagStr[1];
0472                                               } else if (tagStr.length == 2 && tagStr[0] == 'license') {
0473                                                   license = tagStr[1];
0474                                                   license = Base64.decode(license);
0475                                               } else if (tagStr.length == 2 && tagStr[0] == 'packagetypeid') {
0476                                                   packagetypeId = tagStr[1];
0477                                               }
0478                                              }
0479                                              /*else if (tagStr.length == 2 && tagStr[0] == 'package') {
0480                                               packageId = tagStr[1];
0481                                               }
0482                                               else if (tagStr.length == 2 && tagStr[0] == 'arch') {
0483                                               archId = tagStr[1];
0484                                               }
0485                                               else if (tagStr.length == 2 && tagStr[0] == 'device') {
0486                                               deviceId = tagStr[1];
0487                                               }*/
0488                                          });
0489                                      }
0490 
0491                                      //if(this.active == '1') {
0492                                        var greyText = ' class="inactiverows" style="color: #ccc; display:none;"';
0493 
0494                                        if(this.version==null) {version = '';} else{version = this.version;}
0495 
0496                                          var isExternLink = false;
0497                                          if ((typeof link != 'undefined') && (link != "")) {
0498                                             isExternLink = true;
0499                                             downloadLink = '<a href="' + decodeURIComponent(link) + '" id="data-link-ajax' + this.id + '" style="color: #ccc;">' + this.name + '</a>';
0500                                          }
0501                                          var mnt = moment(this.created_timestamp);
0502                                          $pploadCollection.find('table[data-ppload-files-ajax] tbody').append(
0503                                             '<tr' + greyText + '>'
0504                                             + '<td>' + downloadLink + '</td>'
0505                                                 + '<td>' + version + '</td>'
0506                                             + '<td>' + fileDescription + '</td>'
0507                                                 + '<td>'
0508                                                 + '<select id="data-select-packagetype-ajax' + this.id + '" data-packagetype-id=" name="packagetype" class="form-control input-sm" style="width: 200px;">'
0509                                                 + '<option value=\"\"></option>'
0510                                                 + '<option value=\"2\">Android (APK)</option>'
0511                                                 + '<option value=\"1\">AppImage</option>'
0512                                                 + '<option value=\"9\">Arch</option>'
0513                                                 + '<option value=\"5\">Debian</option>'
0514                                                 + '<option value=\"8\">Electron-Webapp</option>'
0515                                                 + '<option value=\"7\">Flatpak</option>'
0516                                                 + '<option value=\"10\">open/Suse</option>'
0517                                                 + '<option value=\"3\">OS X compatible</option>'
0518                                                 + '<option value=\"11\">Redhat</option>'
0519                                                 + '<option value=\"6\">Snappy</option>'
0520                                                 + '<option value=\"12\">Source Code</option>'
0521                                                 + '<option value=\"4\">Windows executable</option>'
0522                                                 + '</select><span id="file-tag-packagetype-ajax'+this.id+'">'
0523                                                 + '</td>'
0524 
0525                                             + '<td style="text-align: right"><span id="download_counter_' + this.id + '">' + cout_downloads + '</td>'
0526                                             + '<td>' +mnt.format('YYYY-MM-DD')  + '</td>'
0527                                             + '<td style="text-align: right">' + humanFileSize(this.size,false) + '</td>'
0528                                                 + '<td></td>'
0529                                                 + '<td></td>'
0530                                             + '</tr>'
0531                                          );
0532 
0533                                          if ((typeof osId != 'undefined') && (osId != "")) {
0534                                              $("#data-updatepploadfile" + this.id + " option[value='" + osId + "']").attr('selected', 'selected');
0535                                              $os = $("#data-updatepploadfile" + this.id + " option[value='" + osId + "']").text();
0536                                              //alert("Text: " + $os);
0537                                              $("#data-updatepploadfile" + this.id).hide();
0538                                              $("#file-tag-os" + this.id).text($os);
0539                                          }
0540 
0541                                          if ((typeof licenseId != 'undefined') && (licenseId != "")) {
0542                                              $("#data-select-license" + this.id + " option[value='" + licenseId + "']").attr('selected', 'selected');
0543                                              $licenseIdText = $("#data-select-license" + this.id + " option[value='" + licenseId + "']").text();
0544                                              $("#data-select-license" + this.id).hide();
0545                                              $("#file-tag-license" + this.id).text($licenseIdText);
0546                                          } else {
0547                                           $("#data-select-license" + this.id).hide();
0548                                          }
0549 
0550                                          $("#data-select-license" + this.id).hide();
0551 
0552                                          if ((typeof license != 'undefined') && (license != "")) {
0553                                              $("#file-tag-license-text" + this.id).text(license);
0554                                          }
0555 
0556                                              if ((typeof packagetypeId != 'undefined') && (packagetypeId != "")) {
0557                                              $("#data-select-packagetype-ajax" + this.id + " option[value='" + packagetypeId + "']").attr('selected', 'selected');
0558                                              $packagetypeIdText = $("#data-select-packagetype-ajax" + this.id + " option[value='" + packagetypeId + "']").text();
0559                                              $("#data-select-packagetype-ajax" + this.id).hide();
0560                                              $("#file-tag-packagetype-ajax" + this.id).text($packagetypeIdText);
0561                                          } else {
0562                                           $("#data-select-packagetype-ajax" + this.id).hide();
0563                                          }
0564 
0565                                          $("#data-select-packagetype-ajax" + this.id).hide();
0566 
0567 
0568 
0569                                          if (isExternLink) {
0570                                             //$("#data-link-ajax" + this.id).attr('href', decodeURIComponent(link));
0571                                                 $("#data-link-ajax" + this.id).attr('target','_blank');
0572                                             $("#data-link-ajax" + this.id).html($("#data-link-ajax" + this.id).html() + " (External Link)");
0573                                          }
0574 
0575 
0576 
0577                                         //fileSizeSum += parseInt(this.size);
0578                                             if(parseInt(this.size)>0) {
0579                                                 fileSizeSum += roundFileSizeInMB(parseInt(this.size));
0580                                             }
0581                                          //if (!isExternLink)
0582                                          //{
0583                                             //fileSizeSum += roundFileSizeInMB(parseInt(this.size));
0584                                          //}
0585 
0586 
0587                                          if (this.type == 'audio/mpeg' || this.type == 'application/ogg') {
0588                                              isPlayable = true;
0589                                          }
0590 
0591                                      //}
0592 
0593                                  });
0594 
0595 
0596                                  //add old download counter
0597                                  downloaded_count_total += parseInt(<?= $this->product->count_downloads_hive?>);
0598 
0599                                  //add old download counter to oldest file
0600                                  var fileCount = $('#download_counter_'+ oldestFileId).html();
0601                                  var oldNewCounter = parseInt(fileCount) + parseInt(<?= $this->product->count_downloads_hive?>);
0602                                  $('#download_counter_'+ oldestFileId).html(oldNewCounter);
0603 
0604 
0605 
0606                                 //$('#downloadscnt').html(downloaded_count_total);
0607 
0608                                  $pploadCollection.find('table[data-ppload-files-ajax] tfoot').append(
0609                                      '<tr>'
0610                                      + '<th colspan="4">' + myArrayActive.length + ' <?= $this->translate("files")?> (<span style="color: #ccc;" ><a style="cursor:pointer" onclick="fnToggleInactiveFiles();return false;">'+myArrayInactive.length+' archived</a></span>)</th>'
0611                                      + '<th style="text-align: right">' + downloaded_count_total + '</th>'
0612                                      + '<th></th>'
0613                                     + '<th style="text-align: right">' + fileSizeSum.toFixed(2) + ' MB</th>'
0614                                      //+ '<th style="text-align: right">' + humanFileSize(fileSizeSum) + '</th>'
0615                                      + '<th></th>'
0616                                        + '<th></th>'
0617                                      + '</tr>'
0618                                  );
0619 
0620                                  $pploadCollection.find('a[data-ppload-download-link]').attr(
0621                                      'href',
0622                                      pploadApiUri + 'collections/download/id/' + collectionId
0623                                  );
0624 
0625 
0626 
0627 
0628                                 /*if (data.pagination !== 'undefined' && data.pagination.next) {
0629                                     getPploadFiles(data.pagination.next);
0630                                 }*/
0631 
0632                              },
0633                              error: function (jqXHR, textStatus, errorThrown) {
0634 
0635 
0636 
0637                              }
0638                          });
0639                      }
0640 
0641                      function generateOcsUrl(url, type, filename) {
0642                          if (!url || !type) {
0643                              return '';
0644                          }
0645                          if (!filename) {
0646                              filename = url.split('/').pop().split('?').shift();
0647                          }
0648                          return 'ocs://install'
0649                             + '?url=' + encodeURIComponent(url)
0650                             + '&type=' + encodeURIComponent(type)
0651                             + '&filename=' + encodeURIComponent(filename);
0652                      }
0653 
0654 
0655 
0656 
0657                     function shortFilename(filename) {
0658                         var returnString = filename;
0659                         if(filename.length > 25) {
0660                             var name = filename.substring(0,22);
0661                             var fileExt = filename.split('.').pop();
0662                             if(fileExt.length>3) {
0663                                 name = name.substring(0,(25-fileExt.length));
0664                             }
0665                             returnString = name + '...' + fileExt;
0666                         }
0667                         return returnString;
0668                     }
0669 
0670 
0671                      function roundFileSizeInMB(bytes)
0672                      {
0673                         // min size 0.01MB
0674                         if(bytes>0)
0675                         {
0676                             var size = (bytes / 1048576).toFixed(2);
0677                             if(size == '0.00')
0678                             {
0679                                 return Number('0.01');
0680                             }else
0681                             {
0682                                 return Number(size);
0683                             }
0684                         }
0685                      }
0686 
0687 
0688 
0689                       fnToggleInactiveFiles = function(){
0690                            $('.inactiverows').toggle();
0691                       };
0692 
0693 
0694 
0695                      function humanFileSize(bytes,isExternLink) {
0696                          if(isExternLink) return '----';
0697                          if(bytes>0)
0698                          {
0699                              var size = '';
0700                              size = (bytes / 1048576).toFixed(2);
0701                              if(size == '0.00')
0702                              {
0703                                 return '0.01 MB';
0704                              }else
0705                              {
0706                                 return size+' MB';
0707                              }
0708                          }
0709                          else
0710                          {
0711                             return '0.00 MB';
0712                          }
0713                      }
0714 
0715                      function humanFileSize_(bytes) {
0716                          if(bytes>0)
0717                          {
0718                              var size = '';
0719                              size = (bytes / 1048576).toFixed(2);
0720 
0721 
0722                              if(size == '0.00')
0723                              {
0724                                 return '0.01 MB';
0725                              }else
0726                              {
0727                                 return size+' MB';
0728                              }
0729                          }
0730                          else
0731                          {
0732                             return '0.00 MB';
0733                          }
0734                      }
0735 
0736                      //$('a[href="#files-panel"][data-toggle="tab"]').on('click', function () {
0737                      if (!hasFilesPanelOpened) {
0738                          getPploadFiles();
0739                          hasFilesPanelOpened = true;
0740 
0741 
0742                      }
0743                      //});
0744 
0745                  });
0746 
0747                 $(function() {
0748                     $('#modal-installation-instructions').on('hidden.bs.modal', function (e) {
0749                               var iframe = document.getElementById('iframeInstallInstruction');
0750                               var leg=$(iframe).attr("src");
0751                               $(iframe).attr("src","");
0752                         });
0753 
0754                     $('#modal-installation-instructions').on('show.bs.modal', function (e) {
0755                               var iframe = document.getElementById('iframeInstallInstruction');
0756                               var leg=$(iframe).attr("src");
0757                               $(iframe).attr("src","https://opendesktop.github.io/ocs-url/opendesktoporg-help.html");
0758                         });
0759 
0760                 });
0761              </script>
0762          <?php endif; ?>
0763          <!-- /ppload -->