first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* WP File Download
|
||||
*
|
||||
* @package WP File Download
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wpfdViewCategories extends View {
|
||||
|
||||
public function render($tpl = null) {
|
||||
$modelCats = $this->getModel('categories');
|
||||
$modelCat = $this->getModel('category');
|
||||
|
||||
$content = new stdClass();
|
||||
$content->categories = $modelCats->getCategories(Utilities::getInt('id'));
|
||||
$content->category = $modelCat->getCategory(Utilities::getInt('id'));
|
||||
|
||||
if(Utilities::getInt('id') == Utilities::getInt('top') ) {
|
||||
$content->category->parent = false;
|
||||
}
|
||||
|
||||
echo json_encode($content);
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* WP File Download
|
||||
*
|
||||
* @package WP File Download
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wpfdViewCategory extends View {
|
||||
|
||||
public function render($tpl = null) {
|
||||
|
||||
$modelCat = $this->getModel('category');
|
||||
|
||||
$content = new stdClass();
|
||||
$content->category = $modelCat->getCategory(Utilities::getInt('id'));
|
||||
echo json_encode($content);
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* WP File Download
|
||||
*
|
||||
* @package WP File Download
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wpfdViewFile extends View {
|
||||
public function render($tpl = null) {
|
||||
|
||||
$categoryid = Utilities::getInput('categoryid','GET','none');
|
||||
$idFile = Utilities::getInput('id','GET','none');
|
||||
|
||||
$modelTokens = $this->getModel('tokens');
|
||||
$sessionToken = isset($_SESSION['wpfdToken']) ? $_SESSION['wpfdToken'] : null ;
|
||||
if($sessionToken===null){
|
||||
$token = $modelTokens->createToken();
|
||||
$_SESSION['wpfdToken'] = $token;
|
||||
}else{
|
||||
$tokenId = $modelTokens->tokenExists($sessionToken);
|
||||
if($tokenId){
|
||||
$modelTokens->updateToken($tokenId);
|
||||
$token = $sessionToken;
|
||||
}else{
|
||||
$token = $modelTokens->createToken();
|
||||
$_SESSION['wpfdToken'] = $token;
|
||||
}
|
||||
}
|
||||
|
||||
if(apply_filters('wpfdAddonCategoryFrom', $categoryid) == 'googleDrive'){
|
||||
$file = apply_filters('wpfdAddonGetGoogleDriveFile',$idFile,$categoryid,$token);
|
||||
}elseif(apply_filters('wpfdAddonCategoryFrom', $categoryid) == 'dropbox'){
|
||||
$file = apply_filters('wpfdAddonGetDropboxFile',$idFile,$categoryid, $token);
|
||||
}
|
||||
if(!$file || ($file == $idFile) ){
|
||||
$model = $this->getModel('file');
|
||||
$file = $model->getFile(Utilities::getInt('id'),Utilities::getInt('rootcat'));
|
||||
}
|
||||
|
||||
//crop file titles
|
||||
$rootcat = Utilities::getInt('rootcat');
|
||||
$modelCat = $this->getModel('category');
|
||||
$categorys = $modelCat->getCategory($categoryid);
|
||||
$rootcategory = $modelCat->getCategory($rootcat);
|
||||
$file = (object)($file);
|
||||
if ($rootcat){
|
||||
$file->crop_title = wpfdBase::cropTitle($rootcategory->params,$rootcategory->params['theme'], $file->post_title);
|
||||
}else{
|
||||
$file->crop_title = wpfdBase::cropTitle($categorys->params,$categorys->params['theme'], $file->post_title);
|
||||
}
|
||||
if (!$file || ($file == $idFile) ) {
|
||||
return json_encode(new stdClass());
|
||||
}
|
||||
|
||||
//fix : access check
|
||||
$content = new stdClass();
|
||||
$content->file = $file;
|
||||
|
||||
echo json_encode($content);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* WP File Download
|
||||
*
|
||||
* @package WP File Download
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wpfdViewFiles extends View {
|
||||
|
||||
public function render($tpl = null) {
|
||||
|
||||
|
||||
$id_category = Utilities::getInt('id');
|
||||
$root_category = Utilities::getInt('rootcat');
|
||||
$modelCat = $this->getModel('category');
|
||||
$category = $modelCat->getCategory($id_category);
|
||||
$rootcategory = $modelCat->getCategory($root_category);
|
||||
|
||||
$modelTokens = Model::getInstance('tokens');
|
||||
$sessionToken = isset($_SESSION['wpfdToken']) ? $_SESSION['wpfdToken'] : null ;
|
||||
if($sessionToken===null){
|
||||
$token = $modelTokens->createToken();
|
||||
$_SESSION['wpfdToken'] = $token;
|
||||
}else{
|
||||
$tokenId = $modelTokens->tokenExists($sessionToken);
|
||||
if($tokenId){
|
||||
$modelTokens->updateToken($tokenId);
|
||||
$token = $sessionToken;
|
||||
}else{
|
||||
$token = $modelTokens->createToken();
|
||||
$_SESSION['wpfdToken'] = $token;
|
||||
}
|
||||
}
|
||||
|
||||
if (apply_filters('wpfdAddonCategoryFrom', $id_category) == 'googleDrive') {
|
||||
|
||||
$ordering = Utilities::getInput('orderCol','GET','none') != null ? Utilities::getInput('orderCol','GET','none') : $category->ordering;
|
||||
$orderingdir = Utilities::getInput('orderDir','GET','none') != null ? Utilities::getInput('orderDir','GET','none') : $category->orderingdir;
|
||||
$files = apply_filters('wpfdAddonGetListGoogleDriveFile', $id_category, $ordering, $orderingdir,$category->slug,$token);
|
||||
|
||||
$content = new stdClass();
|
||||
$content->files = $files;
|
||||
$content->category = $category;
|
||||
}elseif(apply_filters('wpfdAddonCategoryFrom', $id_category) == 'dropbox'){
|
||||
$ordering = Utilities::getInput('orderCol','GET','none') != null ? Utilities::getInput('orderCol','GET','none') : $category->ordering;
|
||||
$orderingdir = Utilities::getInput('orderDir','GET','none') != null ? Utilities::getInput('orderDir','GET','none') : $category->orderingdir;
|
||||
$files = apply_filters('wpfdAddonGetListDropboxFile', $id_category, $ordering, $orderingdir,$category->slug,$token);
|
||||
|
||||
$content = new stdClass();
|
||||
$content->files = $files;
|
||||
$content->category = $category;
|
||||
} else {
|
||||
$modelFiles = $this->getModel('files');
|
||||
$ordering = Utilities::getInput('orderCol','GET','none') != null ? Utilities::getInput('orderCol','GET','none') : $category->ordering;
|
||||
$orderingdir = Utilities::getInput('orderDir','GET','none') != null ? Utilities::getInput('orderDir','GET','none') : $category->orderingdir;
|
||||
|
||||
$content = new stdClass();
|
||||
$content->files = $modelFiles->getFiles($id_category, $ordering, $orderingdir);
|
||||
$content->category = $category;
|
||||
}
|
||||
|
||||
$modelConfig = Model::getInstance('config');
|
||||
$global_settings = $modelConfig->getGlobalConfig();
|
||||
$limit = $global_settings['paginationnunber'];
|
||||
$page = Utilities::getInt('page');
|
||||
|
||||
$total = ceil(count($content->files) / $limit);
|
||||
$page = (int)$page ? $page : 1;
|
||||
$offset = ($page - 1) * $limit;
|
||||
if( $offset < 0 ) $offset = 0;
|
||||
|
||||
if ($rootcategory->params['theme'] != 'tree') {
|
||||
$content->files = array_slice( $content->files, $offset, $limit );
|
||||
}
|
||||
//crop file titles
|
||||
foreach ($content->files as $i => $file) {
|
||||
$content->files[$i]->crop_title = $file->post_title;
|
||||
if ($root_category){
|
||||
$content->files[$i]->crop_title = wpfdBase::cropTitle($rootcategory->params,$rootcategory->params['theme'], $file->post_title);
|
||||
}else{
|
||||
$content->files[$i]->crop_title = wpfdBase::cropTitle($category->params,$category->params['theme'], $file->post_title);
|
||||
}
|
||||
}
|
||||
|
||||
$content->pagination = wpfd_category_pagination(array(
|
||||
'base' => '',
|
||||
'format' => '',
|
||||
'current' => max( 1, $page),
|
||||
'total' => $total
|
||||
)
|
||||
);
|
||||
|
||||
echo json_encode($content);
|
||||
die();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* WP File Download
|
||||
*
|
||||
* @package WP File Download
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
// No direct access.
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
?>
|
||||
|
||||
<div id="wpfdViewer">
|
||||
<?php if($mediaType=='image') { ?>
|
||||
<img src="<?php echo $downloadLink;?>" alt="" title="" />
|
||||
<?php } else if($mediaType=='video') { ?>
|
||||
<video width="100%" height="100%" src="<?php echo $downloadLink;?>" type="<?php echo $mineType;?>" class="mejs-player" data-mejsoptions='{"alwaysShowControls": true}'
|
||||
id="playerVid" controls="controls" preload="auto" autoplay="true">
|
||||
<source type="<?php echo $mineType;?>" src="<?php echo $downloadLink;?>"/>
|
||||
Your browser does not support the <code>video</code> element.
|
||||
</video>
|
||||
<?php } else if($mediaType=='audio') { ?>
|
||||
<audio src="<?php echo $downloadLink;?>" type="<?php echo $mineType;?>"
|
||||
id="playerAud" controls="controls" preload="auto" autoplay="true"></audio>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
var w = $('#wpfdViewer').width();
|
||||
var h = $('#wpfdViewer').height();
|
||||
var vid = document.getElementById("playerVid");
|
||||
var aud = document.getElementById("playerAud");
|
||||
if(vid !== null) {
|
||||
vid.onloadeddata = function() {
|
||||
// Browser has loaded the current frame
|
||||
var vW = $(vid).width();
|
||||
var vH = $(vid).height();
|
||||
|
||||
if(vH > h ) {
|
||||
newH = h - 10;
|
||||
newW = newH/vH* vW ;
|
||||
$(vid).attr('width', newW).attr('height',newH);
|
||||
$(vid).width( newW);
|
||||
$(vid).height(newH);
|
||||
|
||||
$(".mejs-video").width(newW);
|
||||
$(".mejs-video").height(newH);
|
||||
|
||||
var barW = newW - 150;
|
||||
$(".mejs-time-rail").width(barW).css('padding-right','5px');
|
||||
$(".mejs-time-total").width(barW);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
$('video,audio').mediaelementplayer(/* Options */);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.wpfdviewer::before {
|
||||
content: none;
|
||||
}
|
||||
#wpfdViewer {
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 100%;
|
||||
}
|
||||
#wpfdViewer img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
}
|
||||
#wpfdViewer audio, #wpfdViewer video {
|
||||
display: inline-block;
|
||||
}
|
||||
#wpfdViewer .mejs-container {
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
#wpfdViewer video {
|
||||
width: 100% !important;
|
||||
max-width: 100%;
|
||||
height: auto !important;
|
||||
max-height: 100% !important;
|
||||
}
|
||||
#wpfdViewer .mejs-container.mejs-video {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#wpfdViewer .mejs-container.mejs-audio{
|
||||
top: 50%;
|
||||
margin-top: -15px;
|
||||
}
|
||||
.wpfdviewer #wpadminbar {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* WP File Download
|
||||
*
|
||||
* @package WP File Download
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
use Joomunited\WPFramework\v1_0_4\Factory;
|
||||
use Joomunited\WPFramework\v1_0_4\Form;
|
||||
use Joomunited\WPFramework\v1_0_4\Application;
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wpfdViewFrontviewer extends View {
|
||||
public function render($tpl = null) {
|
||||
|
||||
$model = $this->getModel('file');
|
||||
$id = Utilities::getInt('id');
|
||||
$catid = Utilities::getInt('catid');
|
||||
$ext = Utilities::getInput('ext','GET','string');
|
||||
$this->mediaType = Utilities::getInput('type','GET','string');
|
||||
|
||||
$app = Application::getInstance('wpfd') ;
|
||||
$this->downloadLink= $app->getAjaxUrl().'&task=file.download&wpfd_file_id='.$id.'&wpfd_category_id='.$catid.'&preview=1';
|
||||
$this->mineType = wpfdHelperFile::mime_type($ext);
|
||||
|
||||
wp_enqueue_style('wpfd-mediaelementplayer', plugins_url( 'app/site/assets/css/mediaelementplayer.min.css' , WPFDL_PLUGIN_FILE ),array(),WPFDL_VERSION);
|
||||
wp_enqueue_script('wpfd-mediaelementplayer', plugins_url( 'app/site/assets/js/mediaelement-and-player.js' , WPFDL_PLUGIN_FILE ),array(),WPFDL_VERSION);
|
||||
|
||||
parent::render($tpl); die();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user