PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_phocadownload/views/file/tmpl/default.php

https://github.com/wiktorm/projekt-awr
PHP | 213 lines | 163 code | 34 blank | 16 comment | 81 complexity | 0f713c0e41f9e6e8f732735eb7242fa2 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0, LGPL-2.1
  1. <?php
  2. defined('_JEXEC') or die('Restricted access');
  3. if ( $this->params->def( 'show_page_title', 1 ) ) {
  4. echo '<div class="componentheading'.$this->params->get( 'pageclass_sfx' ).'">'.$this->params->get('page_title').'</div>';
  5. }
  6. echo '<div id="phoca-dl-file-box">';
  7. if (!empty($this->category[0])) {
  8. echo '<div class="pd-file">';
  9. if ($this->tmpl['display_up_icon'] == 1) {
  10. //echo '<div class="pdtop"><a title="'.JText::_('Category').'" href="'. JRoute::_('index.php?option=com_phocadownload&view=category&id='.$this->category[0]->id.':'.$this->category[0]->alias. $this->tmpl['limitstarturl'] . '&Itemid='. JRequest::getVar('Itemid', 1, 'get', 'int')).'" >'.JHTML::_('image', 'components/com_phocadownload/assets/images/up.png', JText::_('Up')). '</a></div>';
  11. echo '<div class="pdtop"><a title="'.JText::_('Category').'" href="'. JRoute::_(PhocaDownloadHelperRoute::getCategoryRoute($this->category[0]->id, $this->category[0]->alias, $this->category[0]->sectionid). $this->tmpl['limitstarturl']).'" >'.JHTML::_('image', 'components/com_phocadownload/assets/images/up.png', JText::_('Up')). '</a></div>';
  12. }
  13. } else {
  14. echo '<div class="pd-file"><div class="pdtop"></div>';
  15. }
  16. if (!empty($this->file[0])) {
  17. $valueDoc = $this->file[0];
  18. // USER RIGHT - Access of categories (if file is included in some not accessed category) - - - - -
  19. // ACCESS is handled in SQL query, ACCESS USER ID is handled here (specific users)
  20. $rightDisplay = 0;
  21. if (!empty($this->category[0])) {
  22. $rightDisplay = PhocaDownloadHelper::getUserRight('accessuserid', $valueDoc->cataccessuserid, $valueDoc->cataccess, $this->tmpl['user']->get('aid', 0), $this->tmpl['user']->get('id', 0), 0);
  23. }
  24. // - - - - - - - - - - - - - - - - - - - - - -
  25. if ($rightDisplay == 1) {
  26. // Title or name
  27. if ($this->tmpl['filename_or_name'] == 'title') {
  28. $displayName = $valueDoc->title;
  29. } else if ($this->tmpl['filename_or_name'] == 'filename'){
  30. $displayName = PhocaDownloadHelper::getTitleFromFilenameWithExt( $valueDoc->filename );
  31. } else if ($this->tmpl['filename_or_name'] == 'filenametitle'){
  32. $displayName = $valueDoc->title . ' - '.PhocaDownloadHelper::getTitleFromFilenameWithExt( $valueDoc->filename );
  33. }
  34. echo '<h3>'.$displayName. '</h3>';
  35. if ((int)$this->tmpl['display_file_view'] == 1) {
  36. $details = '';
  37. if ($valueDoc->title != '') {
  38. $details .= '<h4>'.$valueDoc->title.'</h4>';
  39. }
  40. $details = '<table class="pd-file-details" border="0">';
  41. if ($valueDoc->filename != '') {
  42. // IMAGE FILENAME
  43. $imageFileName = '';
  44. $imageFileNameThumbnail = '';
  45. if ($valueDoc->image_filename !='') {
  46. $thumbnail = false;
  47. $thumbnail = preg_match("/phocathumbnail/i", $valueDoc->image_filename);
  48. if ($thumbnail) {
  49. $imageFileNameThumbnail = '<div style="margin-top:5px;margin-bottom:5px" ><img src="'.$this->cssimagepath.$valueDoc->image_filename.'" alt="" /></div>';
  50. $imageFileName = '';
  51. } else {
  52. $imageFileNameThumbnail = '';
  53. $imageFileName = 'style="background: url(\''.$this->cssimagepath.$valueDoc->image_filename.'\') 0 center no-repeat;"';
  54. }
  55. }
  56. $details .= '<tr><td><strong>'.JText::_('File Name').'</strong>:</td>';
  57. $details .= '<td class="pdfile">'. $imageFileNameThumbnail.'<div class="pd-document'.$this->tmpl['file_icon_size'].'" '.$imageFileName.'><div class="pd-float">';
  58. $details .= PhocaDownloadHelper::getTitleFromFilenameWithExt( $valueDoc->filename );
  59. //if ($fileSize !='') {
  60. // $details .= ' <small style="color:#ccc">('.$fileSize.')</small>';
  61. //}
  62. $details .= '</div>';
  63. $details .= PhocaDownloadHelper::displayNewIcon($valueDoc->date, $this->tmpl['displaynew']);
  64. $details .= PhocaDownloadHelper::displayHotIcon($valueDoc->hits, $this->tmpl['displayhot']);
  65. //Specific icons
  66. if (isset($valueDoc->image_filename_spec1) && $valueDoc->image_filename_spec1 != '') {
  67. $iconPath = PhocaDownloadHelper::getPathSet('icon');
  68. $iconPath = str_replace ( '../', JURI::base(true).'/', $iconPath['orig_rel_ds']);
  69. $details .= '<div class="pd-float"><img src="'.$iconPath . $valueDoc->image_filename_spec1.'" alt="" /></div>';
  70. }
  71. if (isset($valueDoc->image_filename_spec2) && $valueDoc->image_filename_spec2 != '') {
  72. $iconPath = PhocaDownloadHelper::getPathSet('icon');
  73. $iconPath = str_replace ( '../', JURI::base(true).'/', $iconPath['orig_rel_ds']);
  74. $details .= '<div class="pd-float"><img src="'.$iconPath . $valueDoc->image_filename_spec2.'" alt="" /></div>';
  75. }
  76. $details .= '</div></td></tr>' . "\n";
  77. }
  78. // FILESIZE
  79. if ($valueDoc->filename !='') {
  80. $absFile = str_replace('/', DS, JPath::clean($this->absfilepath . $valueDoc->filename));
  81. if (JFile::exists($absFile))
  82. {
  83. $fileSize = PhocaDownloadHelper::getFileSizeReadable(filesize($absFile));
  84. } else {
  85. $fileSize = '';
  86. }
  87. }
  88. if ($fileSize != '') {
  89. $details .= '<tr><td><strong>'.JText::_('File Size').'</strong>:</td><td>'.$fileSize.'</td></tr>';
  90. }
  91. if ($valueDoc->version != '') {
  92. $details .= '<tr><td><strong>'.JText::_('Version').'</strong>:</td><td>'.$valueDoc->version.'</td></tr>';
  93. }
  94. if ($valueDoc->license != '') {
  95. if ($valueDoc->license_url != '') {
  96. $details .= '<tr><td><strong>'.JText::_('License').'</strong>:</td><td>'.'<a href="'.$valueDoc->license_url.'" target="_blank">'.$valueDoc->license.'</a></td></tr>';
  97. } else {
  98. $details .= '<tr><td><strong>'.JText::_('License').'</strong>:</td><td>'.$valueDoc->license.'</td></tr>';
  99. }
  100. }
  101. if ($valueDoc->author != '') {
  102. if ($valueDoc->author_url != '') {
  103. $details .= '<tr><td><strong>'.JText::_('Author').'</strong>:</td><td>'.'<a href="'.$valueDoc->author_url.'" target="_blank">'.$valueDoc->author.'</a></td></tr>';
  104. } else {
  105. $details .= '<tr><td><strong>'.JText::_('Author').'</strong>:</td><td>'.$valueDoc->author.'</td></tr>';
  106. }
  107. }
  108. if ($valueDoc->author_email != '') {
  109. //$details .= '<tr><td><strong>'.JText::_('Email').'</strong>:</td><td>'. JHTML::_( 'email.cloak', $valueDoc->author_email).'</td></tr>';
  110. $protectMail = str_replace('@', '['.JText::_('at').']', $valueDoc->author_email);
  111. $protectMail = str_replace('.', '['.JText::_('dot').']', $protectMail);
  112. $details .= '<tr><td><strong>'.JText::_('Email').'</strong>:</td><td>'. $protectMail.'</td></tr>';
  113. }
  114. // FILEDATE
  115. $fileDate = '';
  116. if ((int)$this->tmpl['display_date_type'] > 0) {
  117. if ($valueDoc->filename !='') {
  118. $fileDate = PhocaDownloadHelper::getFileTime($valueDoc->filename, $this->tmpl['display_date_type']);
  119. }
  120. } else {
  121. $fileDate = JHTML::Date($valueDoc->date, "%d. %B %Y");
  122. }
  123. if ($fileDate != '') {
  124. $details .= '<tr><td><strong>'.JText::_('Date').'</strong>:</td><td>'.$fileDate.'</td></tr>';
  125. }
  126. if ($valueDoc->description != '' && $valueDoc->description != '<p>&#160;</p>' && $valueDoc->description != '<p>&nbsp;</p>' && $valueDoc->description != '<p></p>' && $valueDoc->description != '<br />') {
  127. $details .= '<tr><td colspan="2">'.$valueDoc->description.'</td></tr>';
  128. }
  129. if ($this->tmpl['display_downloads'] == 1) {
  130. $details .= '<tr><td><strong>'.JText::_('Downloads').'</strong>:</td><td>'.$valueDoc->hits.' x</td></tr>';
  131. }
  132. $details .='</table><p>&nbsp;</p>';
  133. echo $details;
  134. }
  135. if ((int)$valueDoc->confirm_license > 0) {
  136. echo '<h4>'.JText::_('License Agreement').'</h4>';
  137. echo '<div id="phoca-dl-license" style="height:'.(int)$this->tmpl['licenseboxheight'].'px">'.$valueDoc->licensetext.'</div>';
  138. // External link
  139. if ($valueDoc->link_external != '') {
  140. echo '<form action="" name="phocaDownloadForm" id="phocadownloadform" target="'.$this->tmpl['download_external_link'].'">';
  141. echo '<input type="checkbox" name="license_agree" onclick="enableDownloadPD()" /> <span>'.JText::_('I agree to the terms listed above').'</span> ';
  142. echo '<input type="button" name="submit" onClick="location.href=\''.$valueDoc->link_external.'\';" id="pdlicensesubmit" value="'.JText::_('Download').'" />';
  143. } else {
  144. echo '<form action="'.$this->request_url.'" method="post" name="phocaDownloadForm" id="phocadownloadform">';
  145. echo '<input type="checkbox" name="license_agree" onclick="enableDownloadPD()" /> <span>'.JText::_('I agree to the terms listed above').'</span> ';
  146. echo '<input type="submit" name="submit" id="pdlicensesubmit" value="'.JText::_('Download').'" />';
  147. echo '<input type="hidden" name="download" value="'.$valueDoc->id.'" />';
  148. echo '<input type="hidden" name="'. JUtility::getToken().'" value="1" />';
  149. }
  150. echo '</form>';
  151. // For users who have disabled Javascript
  152. echo '<script type=\'text/javascript\'>document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=true</script>';
  153. } else {
  154. // External link
  155. if ($valueDoc->link_external != '') {
  156. echo '<form action="" name="phocaDownloadForm" id="phocadownloadform" target="'.$this->tmpl['download_external_link'].'">';
  157. echo '<input type="button" name="submit" onClick="location.href=\''.$valueDoc->link_external.'\';" id="pdlicensesubmit" value="'.JText::_('Download').'" />';
  158. } else {
  159. echo '<form action="'.$this->request_url.'" method="post" name="phocaDownloadForm" id="phocadownloadform">';
  160. echo '<input type="submit" name="submit" id="pdlicensesubmit" value="'.JText::_('Download').'" />';
  161. echo '<input type="hidden" name="license_agree" value="1" />';
  162. echo '<input type="hidden" name="download" value="'.$valueDoc->id.'" />';
  163. echo '<input type="hidden" name="'. JUtility::getToken().'" value="1" />';
  164. }
  165. echo '</form>';
  166. }
  167. if (JComponentHelper::isEnabled('com_jcomments', true) && $this->tmpl['display_file_comments'] == 1) {
  168. include_once(JPATH_BASE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php');
  169. echo JComments::showComments($valueDoc->id, 'com_phocadownload_files', JText::_('PHOCADOWNLOAD_FILE') .' '. $valueDoc->title);
  170. }
  171. } else {
  172. echo '<h3>'.JText::_('File') .'</h3>';
  173. echo '<div class="pd-error">'.JText::_('PHOCADOWNLOAD_NO_RIGHTS_ACCESS_CATEGORY').'</div>';
  174. }
  175. } else {
  176. echo '<h3>&nbsp;</h3>';
  177. }
  178. echo '</div></div>'. $this->tmpl['phoca_dwnld'];
  179. ?>