Example #1
0
 function rate($data)
 {
     $row = $this->getTable('phocadownloadfilevotes');
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $row->date = gmdate('Y-m-d H:i:s');
     $row->published = 1;
     if (!$row->id) {
         $where = 'fileid = ' . (int) $row->fileid;
         $row->ordering = $row->getNextOrder($where);
     }
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Update the Vote Statistics
     if (!PhocaDownloadRate::updateVoteStatisticsFile($data['fileid'])) {
         return false;
     }
     return true;
 }
Example #2
0
				if ($this->t['display_mirror_links'] == 4 || $this->t['display_mirror_links'] == 6) {
					$classMirror = 'pd-button-mirror2';
					$mirrorOutput2 = str_replace('class=""', 'class="btn btn-primary "', $mirrorOutput2);
				} else {
					$classMirror = 'pd-mirror-bp';
				}
			
				$pdMirrorLink2 = '<div class="'.$classMirror.'">'.$mirrorOutput2.'</div>';
			}
			
			// pdreportlink
			$pdReportLink = PhocaDownloadRenderFront::displayReportLink(1, $v->title);

			
			// pdrating
			$pdRating 	= PhocaDownloadRate::renderRateFile($v->id, $this->t['display_rating_file']);
			
			// pdtags
			$pdTags = '';
			if ($this->t['display_tags_links'] == 2 || $this->t['display_tags_links'] == 3) {
				$tags2 = $l->displayTags($v->id);
				if ($tags2 != '') {
					$pdTags .= '<div class="pd-float">'.$tags2.'</div>';
				}
			}

			// RENDER	
			echo '<div class="pd-filebox">';
			echo '<div class="row ">';
			echo '<div class="col-sm-12 col-md-12">';
			echo $pdTitle;
Example #3
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->t['p'] = $app->getParams();
     $this->t['user'] = JFactory::getUser();
     $uri = JFactory::getURI();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $fileId = $app->input->get('id', 0, 'int');
     $this->t['limitstart'] = $app->input->get('start', 0, 'int');
     // we need it for category back link
     $this->t['tmpl'] = $app->input->get('tmpl', '', 'string');
     $this->t['mediapath'] = PhocaDownloadPath::getPathMedia();
     $this->t['tmplr'] = 0;
     if ($this->t['tmpl'] == 'component') {
         $this->t['tmplr'] = 1;
     }
     if ($this->t['limitstart'] > 0) {
         $this->t['limitstarturl'] = '&start=' . $this->t['limitstart'];
     } else {
         $this->t['limitstarturl'] = '';
     }
     $this->category = $model->getCategory($fileId);
     $this->file = $model->getFile($fileId, $this->t['limitstarturl']);
     PhocaDownloadRenderFront::renderAllCSS();
     $document->addCustomTag('<script type="text/javascript" src="' . JURI::root() . 'components/com_phocadownload/assets/overlib/overlib_mini.js"></script>');
     $js = 'var enableDownloadButtonPD = 0;' . 'function enableDownloadPD() {' . ' if (enableDownloadButtonPD == 0) {' . '   document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=false;' . '   enableDownloadButtonPD = 1;' . ' } else {' . '   document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=true;' . '   enableDownloadButtonPD = 0;' . ' }' . '}';
     $document->addScriptDeclaration($js);
     // Params
     $this->t['licenseboxheight'] = $this->t['p']->get('license_box_height', 300);
     $this->t['filename_or_name'] = $this->t['p']->get('filename_or_name', 'filename');
     $this->t['display_up_icon'] = $this->t['p']->get('display_up_icon', 1);
     $this->t['allowed_file_types'] = $this->t['p']->get('allowed_file_types', '');
     $this->t['disallowed_file_types'] = $this->t['p']->get('disallowed_file_types', '');
     $this->t['enable_user_statistics'] = $this->t['p']->get('enable_user_statistics', 1);
     $this->t['display_file_comments'] = $this->t['p']->get('display_file_comments', 0);
     $this->t['file_icon_size'] = $this->t['p']->get('file_icon_size', 16);
     $this->t['display_file_view'] = $this->t['p']->get('display_file_view', 0);
     $this->t['download_metakey'] = $this->t['p']->get('download_metakey', '');
     $this->t['download_metadesc'] = $this->t['p']->get('download_metadesc', '');
     $this->t['display_downloads'] = $this->t['p']->get('display_downloads', 0);
     $this->t['display_date_type'] = $this->t['p']->get('display_date_type', 0);
     $this->t['displaynew'] = $this->t['p']->get('display_new', 0);
     $this->t['displayhot'] = $this->t['p']->get('display_hot', 0);
     $this->t['pw'] = PhocaDownloadRenderFront::renderPhocaDownload();
     $this->t['download_external_link'] = $this->t['p']->get('download_external_link', '_self');
     $this->t['display_report_link'] = $this->t['p']->get('display_report_link', 0);
     $this->t['send_mail_download'] = $this->t['p']->get('send_mail_download', 0);
     // not boolean but id of user
     //$this->t['send_mail_upload'] 		= $this->t['p']->get( 'send_mail_upload', 0 );
     $this->t['display_rating_file'] = $this->t['p']->get('display_rating_file', 0);
     $this->t['display_tags_links'] = $this->t['p']->get('display_tags_links', 0);
     $this->t['display_mirror_links'] = $this->t['p']->get('display_mirror_links', 0);
     $this->t['display_specific_layout'] = $this->t['p']->get('display_specific_layout', 0);
     $this->t['display_detail'] = $this->t['p']->get('display_detail', 1);
     $this->t['fb_comment_app_id'] = $this->t['p']->get('fb_comment_app_id', '');
     $this->t['fb_comment_width'] = $this->t['p']->get('fb_comment_width', '550');
     $this->t['fb_comment_lang'] = $this->t['p']->get('fb_comment_lang', 'en_US');
     $this->t['fb_comment_count'] = $this->t['p']->get('fb_comment_count', '');
     // Rating
     if ($this->t['display_rating_file'] == 2 || $this->t['display_rating_file'] == 3) {
         JHTML::_('behavior.framework', true);
         PhocaDownloadRate::renderRateFileJS(1);
         $this->t['display_rating_file'] = 1;
     } else {
         $this->t['display_rating_file'] = 0;
     }
     // DOWNLOAD
     // - - - - - - - - - - - - - - -
     $download = $app->input->get('download', array(0), 'array');
     $licenseAgree = $app->input->get('license_agree', '', 'string');
     $downloadId = (int) $download[0];
     if ($downloadId > 0) {
         if (isset($this->file[0]->id)) {
             $currentLink = 'index.php?option=com_phocadownload&view=file&id=' . $this->file[0]->id . ':' . $this->file[0]->alias . $this->t['limitstarturl'] . '&Itemid=' . $app->input->get('Itemid', 0, 'int');
         } else {
             $currentLink = 'index.php?option=com_phocadownload&view=categories&Itemid=' . $app->input->get('Itemid', 0, 'int');
         }
         // Check Token
         $token = JSession::getFormToken();
         if (!JRequest::getInt($token, 0, 'post')) {
             //JError::raiseError(403, 'Request Forbidden');
             $app->redirect(JRoute::_('index.php', false), JText::_('COM_PHOCADOWNLOAD_INVALID_TOKEN'));
             exit;
         }
         // Check License Agreement
         if (empty($licenseAgree)) {
             $app->redirect(JRoute::_($currentLink, false), JText::_('COM_PHOCADOWNLOAD_WARNING_AGREE_LICENSE_TERMS'));
             exit;
         }
         $fileData = PhocaDownloadDownload::getDownloadData($downloadId, $currentLink);
         PhocaDownloadDownload::download($fileData, $downloadId, $currentLink);
     }
     // - - - - - - - - - - - - - - -
     $imagePath = PhocaDownloadPath::getPathSet('icon');
     $this->t['cssimgpath'] = str_replace('../', JURI::base(true) . '/', $imagePath['orig_rel_ds']);
     $filePath = PhocaDownloadPath::getPathSet('file');
     $this->t['absfilepath'] = $filePath['orig_abs_ds'];
     $this->t['action'] = $uri->toString();
     if (isset($this->category[0]) && is_object($this->category[0]) && isset($this->file[0]) && is_object($this->file[0])) {
         $this->_prepareDocument($this->category[0], $this->file[0]);
     }
     parent::display($tpl);
 }
Example #4
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->t['p'] = $app->getParams();
     $this->t['user'] = JFactory::getUser();
     $uri = JFactory::getURI();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $this->t['categoryid'] = $app->input->get('id', 0, 'int');
     $this->t['tagid'] = $app->input->get('tagid', 0, 'int');
     $limitStart = $app->input->get('limitstart', 0, 'int');
     $this->t['mediapath'] = PhocaDownloadPath::getPathMedia();
     $this->category = $model->getCategory($this->t['categoryid']);
     $this->subcategories = $model->getSubcategories($this->t['categoryid']);
     $this->files = $model->getFileList($this->t['categoryid'], $this->t['tagid']);
     $this->t['pagination'] = $model->getPagination($this->t['categoryid'], $this->t['tagid']);
     PhocaDownloadRenderFront::renderAllCSS();
     $document->addCustomTag('<script type="text/javascript" src="' . JURI::root() . 'components/com_phocadownload/assets/overlib/overlib_mini.js"></script>');
     if ($limitStart > 0) {
         $this->t['limitstarturl'] = '&start=' . $limitStart;
     } else {
         $this->t['limitstarturl'] = '';
     }
     $this->t['download_external_link'] = $this->t['p']->get('download_external_link', '_self');
     $this->t['filename_or_name'] = $this->t['p']->get('filename_or_name', 'filenametitle');
     $this->t['display_downloads'] = $this->t['p']->get('display_downloads', 0);
     $this->t['display_description'] = $this->t['p']->get('display_description', 3);
     $this->t['display_detail'] = $this->t['p']->get('display_detail', 1);
     $this->t['display_play'] = $this->t['p']->get('display_play', 0);
     $this->t['playerwidth'] = $this->t['p']->get('player_width', 328);
     $this->t['playerheight'] = $this->t['p']->get('player_height', 200);
     $this->t['playermp3height'] = $this->t['p']->get('player_mp3_height', 30);
     $this->t['previewwidth'] = $this->t['p']->get('preview_width', 640);
     $this->t['previewheight'] = $this->t['p']->get('preview_height', 480);
     $this->t['display_preview'] = $this->t['p']->get('display_preview', 0);
     $this->t['play_popup_window'] = $this->t['p']->get('play_popup_window', 0);
     $this->t['preview_popup_window'] = $this->t['p']->get('preview_popup_window', 0);
     $this->t['file_icon_size'] = $this->t['p']->get('file_icon_size', 16);
     $this->t['displaynew'] = $this->t['p']->get('display_new', 0);
     $this->t['displayhot'] = $this->t['p']->get('display_hot', 0);
     $this->t['display_up_icon'] = $this->t['p']->get('display_up_icon', 1);
     $this->t['allowed_file_types'] = $this->t['p']->get('allowed_file_types', '');
     $this->t['disallowed_file_types'] = $this->t['p']->get('disallowed_file_types', '');
     $this->t['enable_user_statistics'] = $this->t['p']->get('enable_user_statistics', 1);
     $this->t['display_category_comments'] = $this->t['p']->get('display_category_comments', 0);
     $this->t['display_date_type'] = $this->t['p']->get('display_date_type', 0);
     $this->t['display_file_view'] = $this->t['p']->get('display_file_view', 0);
     $this->t['download_metakey'] = $this->t['p']->get('download_metakey', '');
     $this->t['download_metadesc'] = $this->t['p']->get('download_metadesc', '');
     $this->t['display_rating_file'] = $this->t['p']->get('display_rating_file', 0);
     $this->t['display_mirror_links'] = $this->t['p']->get('display_mirror_links', 0);
     $this->t['display_report_link'] = $this->t['p']->get('display_report_link', 0);
     $this->t['send_mail_download'] = $this->t['p']->get('send_mail_download', 0);
     // not boolean but id of user
     //$this->t['send_mail_upload'] 		= $this->t['p']->get( 'send_mail_upload', 0 );
     $this->t['display_tags_links'] = $this->t['p']->get('display_tags_links', 0);
     $this->t['display_specific_layout'] = $this->t['p']->get('display_specific_layout', 0);
     $this->t['fb_comment_app_id'] = $this->t['p']->get('fb_comment_app_id', '');
     $this->t['fb_comment_width'] = $this->t['p']->get('fb_comment_width', '550');
     $this->t['fb_comment_lang'] = $this->t['p']->get('fb_comment_lang', 'en_US');
     $this->t['fb_comment_count'] = $this->t['p']->get('fb_comment_count', '');
     $this->t['html5_play'] = $this->t['p']->get('html5_play', 0);
     // Rating
     if ($this->t['display_rating_file'] == 1 || $this->t['display_rating_file'] == 3) {
         JHTML::_('behavior.framework', true);
         PhocaDownloadRate::renderRateFileJS(1);
         $this->t['display_rating_file'] = 1;
     } else {
         $this->t['display_rating_file'] = 0;
     }
     $this->t['dg'] = PhocaDownloadRenderFront::renderPhocaDownload();
     // DOWNLOAD
     // - - - - - - - - - - - - - - -
     $download = $app->input->get('download', array(0), 'array');
     $downloadId = (int) $download[0];
     if ($downloadId > 0) {
         if (isset($this->category[0]->id) && (int) $this->category[0]->id > 0) {
             $currentLink = 'index.php?option=com_phocadownload&view=category&id=' . $this->category[0]->id . ':' . $this->category[0]->alias . $this->t['limitstarturl'] . '&Itemid=' . $app->input->get('Itemid', 0, 'int');
         } else {
             $currentLink = $uri;
         }
         $fileData = PhocaDownloadDownload::getDownloadData($downloadId, $currentLink);
         PhocaDownloadDownload::download($fileData, $downloadId, $currentLink);
     }
     // - - - - - - - - - - - - - - -
     // DETAIL
     // - - - - - - - - - - - - - - -
     if ($this->t['display_detail'] == 2) {
         $this->t['buttond'] = new JObject();
         $this->t['buttond']->set('methodname', 'modal-button');
         $this->t['buttond']->set('name', 'detail');
         $this->t['buttond']->set('modal', true);
         $this->t['buttond']->set('options', "{handler: 'iframe', size: {x: 600, y: 500}, overlayOpacity: 0.7, classWindow: 'phocadownloaddetailwindow', classOverlay: 'phocadownloaddetailoverlay'}");
     }
     JHTML::_('behavior.modal', 'a.pd-modal-button');
     // PLAY - - - - - - - - - - - -
     $windowWidthPl = (int) $this->t['playerwidth'] + 20;
     $windowHeightPl = (int) $this->t['playerheight'] + 20;
     if ($this->t['html5_play'] == 1) {
         $windowWidthPl = (int) $this->t['playerwidth'] + 40;
     } else {
         $windowWidthPl = (int) $this->t['playerwidth'] + 50;
     }
     $windowHeightPlMP3 = (int) $this->t['playermp3height'] + 20;
     if ($this->t['play_popup_window'] == 1) {
         $this->t['buttonpl'] = new JObject();
         $this->t['buttonpl']->set('methodname', 'js-button');
         $this->t['buttonpl']->set('options', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPl . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
         $this->t['buttonpl']->set('optionsmp3', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPlMP3 . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
     } else {
         $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadplaywindow   {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadplayoverlay  {background-color:#000;} \n" . " </style> \n");
         $this->t['buttonpl'] = new JObject();
         $this->t['buttonpl']->set('name', 'image');
         $this->t['buttonpl']->set('modal', true);
         $this->t['buttonpl']->set('methodname', 'modal-button');
         $this->t['buttonpl']->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPl . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}");
         $this->t['buttonpl']->set('optionsmp3', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPlMP3 . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}");
     }
     // - - - - - - - - - - - - - - -
     // PREVIEW - - - - - - - - - - - -
     $windowWidthPr = (int) $this->t['previewwidth'] + 20;
     $windowHeightPr = (int) $this->t['previewheight'] + 20;
     if ($this->t['preview_popup_window'] == 1) {
         $this->t['buttonpr'] = new JObject();
         $this->t['buttonpr']->set('methodname', 'js-button');
         $this->t['buttonpr']->set('options', "window.open(this.href,'win2','width=" . $windowWidthPr . ",height=" . $windowHeightPr . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
     } else {
         $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadpreviewwindow   {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadpreviewoverlay  {background-color:#000;} \n" . " </style> \n");
         $this->t['buttonpr'] = new JObject();
         $this->t['buttonpr']->set('name', 'image');
         $this->t['buttonpr']->set('modal', true);
         $this->t['buttonpr']->set('methodname', 'modal-button');
         $this->t['buttonpr']->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPr . ", y: " . $windowHeightPr . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}");
         $this->t['buttonpr']->set('optionsimg', "{handler: 'image', size: {x: 200, y: 150}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}");
     }
     // - - - - - - - - - - - - - - -
     $imagePath = PhocaDownloadPath::getPathSet('icon');
     $this->t['cssimgpath'] = str_replace('../', JURI::base(true) . '/', $imagePath['orig_rel_ds']);
     $filePath = PhocaDownloadPath::getPathSet('file');
     $this->t['absfilepath'] = $filePath['orig_abs_ds'];
     $this->t['action'] = $uri->toString();
     if (isset($this->category[0]) && is_object($this->category[0])) {
         $this->_prepareDocument($this->category[0]);
     }
     parent::display($tpl);
 }
Example #5
0
 function display($tpl = null)
 {
     if (!JRequest::checkToken('request')) {
         $response = array('status' => '0', 'error' => JText::_('JINVALID_TOKEN'));
         echo json_encode($response);
         return;
     }
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $ratingVote = $app->input->get('ratingVote', 0, 'post', 'int');
     $ratingId = $app->input->get('ratingId', 0, 'post', 'int');
     // ID of File
     $format = $app->input->get('format', '', 'post', 'string');
     $task = $app->input->get('task', '', 'get', 'string');
     $view = $app->input->get('view', '', 'get', 'string');
     $small = $app->input->get('small', 1, 'get', 'string');
     //small or large rating icons
     $paramsC = JComponentHelper::getParams('com_phocadownload');
     $param['displayratingfile'] = $paramsC->get('display_rating_file', 0);
     // Check if rating is enabled - if not then user should not be able to rate or to see updated reating
     if ($task == 'refreshrate' && (int) $param['displayratingfile'] > 0) {
         $ratingOutput = PhocaDownloadRate::renderRateFile((int) $ratingId, 1, $small, true);
         // ID of File
         $response = array('status' => '0', 'message' => $ratingOutput);
         echo json_encode($response);
         return;
         //return $ratingOutput;
     } else {
         if ($task == 'rate') {
             $user = JFactory::getUser();
             //$view 		= $app->input->get( 'view', '', 'get', '', JREQUEST_NOTRIM  );
             //$Itemid		= $app->input->get( 'Itemid', 0, 'int');
             $neededAccessLevels = PhocaDownloadAccess::getNeededAccessLevels();
             $access = PhocaDownloadAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels);
             $post['fileid'] = (int) $ratingId;
             $post['userid'] = $user->id;
             $post['rating'] = (int) $ratingVote;
             if ($format != 'json') {
                 $msg = JText::_('COM_PHOCADOWNLOAD_ERROR_WRONG_RATING');
                 $response = array('status' => '0', 'error' => $msg);
                 echo json_encode($response);
                 return;
             }
             if ((int) $post['fileid'] < 1) {
                 $msg = JText::_('COM_PHOCADOWNLOAD_ERROR_FILE_NOT_EXISTS');
                 $response = array('status' => '0', 'error' => $msg);
                 echo json_encode($response);
                 return;
             }
             $model = $this->getModel();
             $checkUserVote = PhocaDownloadRate::checkUserVoteFile($post['fileid'], $post['userid']);
             // User has already rated this category
             if ($checkUserVote) {
                 $msg = JText::_('COM_PHOCADOWNLOAD_RATING_ALREADY_RATED_FILE');
                 $response = array('status' => '0', 'error' => '', 'message' => $msg);
                 echo json_encode($response);
                 return;
             } else {
                 if ((int) $post['rating'] < 1 || (int) $post['rating'] > 5) {
                     $msg = JText::_('COM_PHOCADOWNLOAD_ERROR_WRONG_RATING');
                     $response = array('status' => '0', 'error' => $msg);
                     echo json_encode($response);
                     return;
                 }
                 if ($access > 0 && $user->id > 0) {
                     if (!$model->rate($post)) {
                         $msg = JText::_('COM_PHOCADOWNLOAD_ERROR_RATING_FILE');
                         $response = array('status' => '0', 'error' => $msg);
                         echo json_encode($response);
                         return;
                     } else {
                         $msg = JText::_('COM_PHOCADOWNLOAD_SUCCESS_RATING_FILE');
                         $response = array('status' => '1', 'error' => '', 'message' => $msg);
                         echo json_encode($response);
                         return;
                     }
                 } else {
                     $msg = JText::_('COM_PHOCADOWNLOAD_NOT_AUTHORISED_ACTION');
                     $response = array('status' => '0', 'error' => $msg);
                     echo json_encode($response);
                     return;
                 }
             }
         } else {
             $msg = JText::_('COM_PHOCADOWNLOAD_NOT_AUTHORISED_ACTION');
             $response = array('status' => '0', 'error' => $msg);
             echo json_encode($response);
             return;
         }
     }
 }