init commit2

This commit is contained in:
zino
2021-02-16 23:13:27 +01:00
parent 12b4ef5db4
commit 1011e8b282
815 changed files with 365513 additions and 0 deletions

View File

@@ -0,0 +1,259 @@
/*****************************************************************************************************
* jquery.themepunch.revmigrate.js - jQuery Plugin for Revolution Slider Migration from 4.x to 5.0
* @version: 1.0.1 (18.08.2015)
* @requires jQuery v1.7 or later (tested on 1.9)
* @author ThemePunch
*****************************************************************************************************/
(function($) {
var _R = jQuery.fn.revolution;
///////////////////////////////////////////
// EXTENDED FUNCTIONS AVAILABLE GLOBAL //
///////////////////////////////////////////
jQuery.extend(true,_R, {
// OUR PLUGIN HERE :)
migration: function(container,options) {
// PREPARE THE NEW OPTIONS
options = prepOptions(options);
// PREPARE LAYER ANIMATIONS
prepLayerAnimations(container,options);
return options;
}
});
var prepOptions = function(o) {
// PARALLAX FALLBACKS
if (o.parallaxLevels || o.parallaxBgFreeze) {
var p = new Object();
p.type = o.parallax
p.levels = o.parallaxLevels;
p.bgparallax = o.parallaxBgFreeze == "on" ? "off" : "on";
p.disable_onmobile = o.parallaxDisableOnMobile;
o.parallax = p;
}
if (o.disableProgressBar === undefined)
o.disableProgressBar = o.hideTimerBar || "off";
// BASIC FALLBACKS
if (o.startwidth || o.startheight) {
o.gridwidth = o.startwidth;
o.gridheight = o.startheight;
}
if (o.sliderType===undefined)
o.sliderType = "standard";
if (o.fullScreen==="on")
o.sliderLayout = "fullscreen";
if (o.fullWidth==="on")
o.sliderLayout = "fullwidth";
if (o.sliderLayout===undefined)
o.sliderLayout = "auto";
// NAVIGATION ARROW FALLBACKS
if (o.navigation===undefined) {
var n = new Object();
if (o.navigationArrows=="solo" || o.navigationArrows=="nextto") {
var a = new Object();
a.enable = true;
a.style = o.navigationStyle || "";
a.hide_onmobile = o.hideArrowsOnMobile==="on" ? true : false;
a.hide_onleave = o.hideThumbs >0 ? true : false;
a.hide_delay = o.hideThumbs>0 ? o.hideThumbs : 200;
a.hide_delay_mobile = o.hideNavDelayOnMobile || 1500;
a.hide_under = 0;
a.tmp = '';
a.left = {
h_align:o.soloArrowLeftHalign,
v_align:o.soloArrowLeftValign,
h_offset:o.soloArrowLeftHOffset,
v_offset:o.soloArrowLeftVOffset
};
a.right = {
h_align:o.soloArrowRightHalign,
v_align:o.soloArrowRightValign,
h_offset:o.soloArrowRightHOffset,
v_offset:o.soloArrowRightVOffset
};
n.arrows = a;
}
if (o.navigationType=="bullet") {
var b = new Object();
b.style = o.navigationStyle || "";
b.enable=true;
b.hide_onmobile = o.hideArrowsOnMobile==="on" ? true : false;
b.hide_onleave = o.hideThumbs >0 ? true : false;
b.hide_delay = o.hideThumbs>0 ? o.hideThumbs : 200;
b.hide_delay_mobile = o.hideNavDelayOnMobile || 1500;
b.hide_under = 0;
b.direction="horizontal";
b.h_align=o.navigationHAlign || "center";
b.v_align=o.navigationVAlign || "bottom";
b.space=5;
b.h_offset=o.navigationHOffset || 0;
b.v_offset=o.navigationVOffset || 20;
b.tmp='<span class="tp-bullet-image"></span><span class="tp-bullet-title"></span>';
n.bullets = b;
}
if (o.navigationType=="thumb") {
var t = new Object();
t.style=o.navigationStyle || "";
t.enable=true;
t.width=o.thumbWidth || 100;
t.height=o.thumbHeight || 50;
t.min_width=o.thumbWidth || 100;
t.wrapper_padding=2;
t.wrapper_color="#f5f5f5";
t.wrapper_opacity=1;
t.visibleAmount=o.thumbAmount || 3;
t.hide_onmobile = o.hideArrowsOnMobile==="on" ? true : false;
t.hide_onleave = o.hideThumbs >0 ? true : false;
t.hide_delay = o.hideThumbs>0 ? o.hideThumbs : 200;
t.hide_delay_mobile = o.hideNavDelayOnMobile || 1500;
t.hide_under = 0;
t.direction="horizontal";
t.span=false;
t.position="inner";
t.space=2;
t.h_align=o.navigationHAlign || "center";
t.v_align=o.navigationVAlign || "bottom";
t.h_offset=o.navigationHOffset || 0;
t.v_offset=o.navigationVOffset || 20;
t.tmp='<span class="tp-thumb-image"></span><span class="tp-thumb-title"></span>';
n.thumbnails = t;
}
o.navigation = n;
o.navigation.keyboardNavigation=o.keyboardNavigation || "on";
o.navigation.onHoverStop=o.onHoverStop || "on";
o.navigation.touch = {
touchenabled:o.touchenabled || "on",
swipe_treshold : o.swipe_treshold ||75,
swipe_min_touches : o.swipe_min_touches || 1,
drag_block_vertical:o.drag_block_vertical || false
};
}
o.fallbacks = {
isJoomla:o.isJoomla || false,
panZoomDisableOnMobile: o.parallaxDisableOnMobile || "off",
simplifyAll:o.simplifyAll || "on",
nextSlideOnWindowFocus:o.nextSlideOnWindowFocus || "off",
disableFocusListener:o.disableFocusListener || true
};
return o;
}
var prepLayerAnimations = function(container,opt) {
var c = new Object(),
cw = container.width(),
ch = container.height();
c.skewfromleftshort = "x:-50;skX:85;o:0";
c.skewfromrightshort = "x:50;skX:-85;o:0";
c.sfl = "x:-50;o:0";
c.sfr = "x:50;o:0";
c.sft = "y:-50;o:0";
c.sfb = "y:50;o:0";
c.skewfromleft = "x:top;skX:85;o:0";
c.skewfromright = "x:bottom;skX:-85;o:0";
c.lfl = "x:top;o:0";
c.lfr = "x:bottom;o:0";
c.lft = "y:left;o:0";
c.lfb = "y:right;o:0";
c.fade = "o:0";
var src = (Math.random()*720-360)
container.find('.tp-caption').each(function() {
var cp = jQuery(this),
rw = Math.random()*(cw*2)-cw,
rh = Math.random()*(ch*2)-ch,
rs = Math.random()*3,
rz = Math.random()*720-360,
rx = Math.random()*70-35,
ry = Math.random()*70-35,
ncc = cp.attr('class');
c.randomrotate = "x:{-400,400};y:{-400,400};sX:{0,2};sY:{0,2};rZ:{-180,180};rX:{-180,180};rY:{-180,180};o:0;";
if (ncc.match("randomrotate")) cp.data('transform_in',c.randomrotate)
else
if (ncc.match(/\blfl\b/)) cp.data('transform_in',c.lfl)
else
if (ncc.match(/\blfr\b/)) cp.data('transform_in',c.lfr)
else
if (ncc.match(/\blft\b/)) cp.data('transform_in',c.lft)
else
if (ncc.match(/\blfb\b/)) cp.data('transform_in',c.lfb)
else
if (ncc.match(/\bsfl\b/)) cp.data('transform_in',c.sfl)
else
if (ncc.match(/\bsfr\b/)) cp.data('transform_in',c.sfr)
else
if (ncc.match(/\bsft\b/)) cp.data('transform_in',c.sft)
else
if (ncc.match(/\bsfb\b/)) cp.data('transform_in',c.sfb)
else
if (ncc.match(/\bskewfromleftshort\b/)) cp.data('transform_in',c.skewfromleftshort)
else
if (ncc.match(/\bskewfromrightshort\b/)) cp.data('transform_in',c.skewfromrightshort)
else
if (ncc.match(/\bskewfromleft\b/)) cp.data('transform_in',c.skewfromleft)
else
if (ncc.match(/\bskewfromright\b/)) cp.data('transform_in',c.skewfromright)
else
if (ncc.match(/\bfade\b/)) cp.data('transform_in',c.fade);
if (ncc.match(/\brandomrotateout\b/)) cp.data('transform_out',c.randomrotate)
else
if (ncc.match(/\bltl\b/)) cp.data('transform_out',c.lfl)
else
if (ncc.match(/\bltr\b/)) cp.data('transform_out',c.lfr)
else
if (ncc.match(/\bltt\b/)) cp.data('transform_out',c.lft)
else
if (ncc.match(/\bltb\b/)) cp.data('transform_out',c.lfb)
else
if (ncc.match(/\bstl\b/)) cp.data('transform_out',c.sfl)
else
if (ncc.match(/\bstr\b/)) cp.data('transform_out',c.sfr)
else
if (ncc.match(/\bstt\b/)) cp.data('transform_out',c.sft)
else
if (ncc.match(/\bstb\b/)) cp.data('transform_out',c.sfb)
else
if (ncc.match(/\bskewtoleftshortout\b/)) cp.data('transform_out',c.skewfromleftshort)
else
if (ncc.match(/\bskewtorightshortout\b/)) cp.data('transform_out',c.skewfromrightshort)
else
if (ncc.match(/\bskewtoleftout\b/)) cp.data('transform_out',c.skewfromleft)
else
if (ncc.match(/\bskewtorightout\b/)) cp.data('transform_out',c.skewfromright)
else
if (ncc.match(/\bfadeout\b/)) cp.data('transform_out',c.fade);
if (cp.data('customin')!=undefined) cp.data('transform_in',cp.data('customin'));
if (cp.data('customout')!=undefined) cp.data('transform_out',cp.data('customout'));
})
}
})(jQuery);

View File

@@ -0,0 +1,392 @@
/********************************************
* REVOLUTION 5.1.6 EXTENSION - PARALLAX
* @version: 1.2 (04.01.2016)
* @requires jquery.themepunch.revolution.js
* @author ThemePunch
*********************************************/
(function($) {
var _R = jQuery.fn.revolution,
_ISM = _R.is_mobile();
jQuery.extend(true,_R, {
/*callStaticDDDParallax: function(container,opt,li) {
// STATIC 3D PARALLAX MOVEMENTS
if (opt.parallax && (opt.parallax.ddd_path=="static" || opt.parallax.ddd_path=="both")) {
var coo = {},
path = li.data('3dpath');
coo.li = li;
if (path.split(',').length>1) {
coo.h = parseInt(path.split(',')[0],0);
coo.v = parseInt(path.split(',')[1],0);
container.trigger('trigger3dpath',coo);
}
}
},*/
checkForParallax : function(container,opt) {
var _ = opt.parallax;
if (_ISM && _.disable_onmobile=="on") return false;
if (_.type=="3D" || _.type=="3d") {
punchgs.TweenLite.set(opt.c,{overflow:_.ddd_overflow});
punchgs.TweenLite.set(opt.ul,{overflow:_.ddd_overflow});
if (opt.sliderType!="carousel" && _.ddd_shadow=="on") {
opt.c.prepend('<div class="dddwrappershadow"></div>')
punchgs.TweenLite.set(opt.c.find('.dddwrappershadow'),{force3D:"auto",transformPerspective:1600,transformOrigin:"50% 50%", width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:0});
}
}
opt.li.each(function() {
var li = jQuery(this);
if (_.type=="3D" || _.type=="3d") {
li.find('.slotholder').wrapAll('<div class="dddwrapper" style="width:100%;height:100%;position:absolute;top:0px;left:0px;overflow:hidden"></div>');
li.find('.tp-parallax-wrap').wrapAll('<div class="dddwrapper-layer" style="width:100%;height:100%;position:absolute;top:0px;left:0px;z-index:5;overflow:'+_.ddd_layer_overflow+';"></div>');
// MOVE THE REMOVED 3D LAYERS OUT OF THE PARALLAX GROUP
li.find('.rs-parallaxlevel-tobggroup').closest('.tp-parallax-wrap').wrapAll('<div class="dddwrapper-layertobggroup" style="position:absolute;top:0px;left:0px;z-index:50;width:100%;height:100%"></div>');
var dddw = li.find('.dddwrapper'),
dddwl = li.find('.dddwrapper-layer'),
dddwlbg = li.find('.dddwrapper-layertobggroup');
dddwlbg.appendTo(dddw);
if (opt.sliderType=="carousel") {
if (_.ddd_shadow=="on") dddw.addClass("dddwrappershadow");
punchgs.TweenLite.set(dddw,{borderRadius:opt.carousel.border_radius});
}
punchgs.TweenLite.set(li,{overflow:"visible",transformStyle:"preserve-3d",perspective:1600});
punchgs.TweenLite.set(dddw,{force3D:"auto",transformOrigin:"50% 50%"});
punchgs.TweenLite.set(dddwl,{force3D:"auto",transformOrigin:"50% 50%",zIndex:5});
punchgs.TweenLite.set(opt.ul,{transformStyle:"preserve-3d",transformPerspective:1600});
}
});
for (var i = 1; i<=_.levels.length;i++)
opt.c.find('.rs-parallaxlevel-'+i).each(function() {
var pw = jQuery(this),
tpw = pw.closest('.tp-parallax-wrap');
tpw.data('parallaxlevel',_.levels[i-1])
tpw.addClass("tp-parallax-container");
});
if (_.type=="mouse" || _.type=="scroll+mouse" || _.type=="mouse+scroll" || _.type=="3D" || _.type=="3d") {
container.mouseenter(function(event) {
var currslide = container.find('.active-revslide'),
t = container.offset().top,
l = container.offset().left,
ex = (event.pageX-l),
ey = (event.pageY-t);
currslide.data("enterx",ex);
currslide.data("entery",ey);
});
container.on('mousemove.hoverdir, mouseleave.hoverdir, trigger3dpath',function(event,data) {
var currslide = data && data.li ? data.li : container.find('.active-revslide');
// CALCULATE DISTANCES
if (_.origo=="enterpoint") {
var t = container.offset().top,
l = container.offset().left;
if (currslide.data("enterx")==undefined) currslide.data("enterx",(event.pageX-l));
if (currslide.data("entery")==undefined) currslide.data("entery",(event.pageY-t));
var mh = currslide.data("enterx") || (event.pageX-l),
mv = currslide.data("entery") || (event.pageY-t),
diffh = (mh - (event.pageX - l)),
diffv = (mv - (event.pageY - t)),
s = _.speed/1000 || 0.4;
} else {
var t = container.offset().top,
l = container.offset().left,
diffh = (opt.conw/2 - (event.pageX-l)),
diffv = (opt.conh/2 - (event.pageY-t)),
s = _.speed/1000 || 3;
}
/*if (event.type=="trigger3dpath") {
diffh = data.h;
diffv = data.v;
_.ddd_lasth = diffh;
_.ddd_lastv = diffv;
}*/
if (event.type=="mouseleave") {
diffh = _.ddd_lasth || 0;
diffv = _.ddd_lastv || 0;
s = 1.5;
}
/*if (_.ddd_path=="static") {
diffh = _.ddd_lasth || 0;
diffv = _.ddd_lastv || 0;
}*/
var pcnts = [];
currslide.find(".tp-parallax-container").each(function(i){
pcnts.push(jQuery(this));
});
container.find('.tp-static-layers .tp-parallax-container').each(function(){
pcnts.push(jQuery(this));
});
jQuery.each(pcnts, function() {
var pc = jQuery(this),
bl = parseInt(pc.data('parallaxlevel'),0),
pl = _.type=="3D" || _.type=="3d" ? bl/200 : bl/100,
offsh = diffh * pl,
offsv = diffv * pl;
if (_.type=="scroll+mouse" || _.type=="mouse+scroll" )
punchgs.TweenLite.to(pc,s,{force3D:"auto",x:offsh,ease:punchgs.Power3.easeOut,overwrite:"all"});
else
punchgs.TweenLite.to(pc,s,{force3D:"auto",x:offsh,y:offsv,ease:punchgs.Power3.easeOut,overwrite:"all"});
});
if (_.type=="3D" || _.type=="3d") {
var sctor = '.tp-revslider-slidesli .dddwrapper, .dddwrappershadow, .tp-revslider-slidesli .dddwrapper-layer';
if (opt.sliderType==="carousel") sctor = ".tp-revslider-slidesli .dddwrapper, .tp-revslider-slidesli .dddwrapper-layer";
opt.c.find(sctor).each(function() {
var t = jQuery(this),
pl = _.levels[_.levels.length-1]/200,
offsh = diffh * pl,
offsv = diffv * pl,
offrv = opt.conw == 0 ? 0 : Math.round((diffh / opt.conw * pl)*100) || 0,
offrh = opt.conh == 0 ? 0 : Math.round((diffv / opt.conh * pl)*100) || 0,
li = t.closest('li'),
zz = 0,
itslayer = false;
if (t.hasClass("dddwrapper-layer")) {
zz = _.ddd_z_correction || 65;
itslayer = true;
}
if (t.hasClass("dddwrapper-layer")) {
offsh=0;
offsv=0;
}
if (li.hasClass("active-revslide") || opt.sliderType!="carousel")
if (_.ddd_bgfreeze!="on" || (itslayer))
punchgs.TweenLite.to(t,s,{rotationX:offrh, rotationY:-offrv, x:offsh, z:zz,y:offsv,ease:punchgs.Power3.easeOut,overwrite:"all"});
else
punchgs.TweenLite.to(t,0.5,{force3D:"auto",rotationY:0, rotationX:0, z:0,ease:punchgs.Power3.easeOut,overwrite:"all"});
else
punchgs.TweenLite.to(t,0.5,{force3D:"auto",rotationY:0,z:0,x:0,y:0, rotationX:0, z:0,ease:punchgs.Power3.easeOut,overwrite:"all"});
if (event.type=="mouseleave")
punchgs.TweenLite.to(jQuery(this),3.8,{z:0, ease:punchgs.Power3.easeOut});
});
}
});
if (_ISM)
window.ondeviceorientation = function(event) {
var y = Math.round(event.beta || 0)-70,
x = Math.round(event.gamma || 0);
var currslide = container.find('.active-revslide');
if (jQuery(window).width() > jQuery(window).height()){
var xx = x;
x = y;
y = xx;
}
var cw = container.width(),
ch = container.height(),
diffh = (360/cw * x),
diffv = (180/ch * y),
s = _.speed/1000 || 3,
pcnts = [];
currslide.find(".tp-parallax-container").each(function(i){
pcnts.push(jQuery(this));
});
container.find('.tp-static-layers .tp-parallax-container').each(function(){
pcnts.push(jQuery(this));
});
jQuery.each(pcnts, function() {
var pc = jQuery(this),
bl = parseInt(pc.data('parallaxlevel'),0),
pl = bl/100,
offsh = diffh * pl*2,
offsv = diffv * pl*4;
punchgs.TweenLite.to(pc,s,{force3D:"auto",x:offsh,y:offsv,ease:punchgs.Power3.easeOut,overwrite:"all"});
});
if (_.type=="3D" || _.type=="3d") {
var sctor = '.tp-revslider-slidesli .dddwrapper, .dddwrappershadow, .tp-revslider-slidesli .dddwrapper-layer';
if (opt.sliderType==="carousel") sctor = ".tp-revslider-slidesli .dddwrapper, .tp-revslider-slidesli .dddwrapper-layer";
opt.c.find(sctor).each(function() {
var t = jQuery(this),
pl = _.levels[_.levels.length-1]/200
offsh = diffh * pl,
offsv = diffv * pl*3,
offrv = opt.conw == 0 ? 0 : Math.round((diffh / opt.conw * pl)*500) || 0,
offrh = opt.conh == 0 ? 0 : Math.round((diffv / opt.conh * pl)*700) || 0,
li = t.closest('li'),
zz = 0,
itslayer = false;
if (t.hasClass("dddwrapper-layer")) {
zz = _.ddd_z_correction || 65;
itslayer = true;
}
if (t.hasClass("dddwrapper-layer")) {
offsh=0;
offsv=0;
}
if (li.hasClass("active-revslide") || opt.sliderType!="carousel")
if (_.ddd_bgfreeze!="on" || (itslayer))
punchgs.TweenLite.to(t,s,{rotationX:offrh, rotationY:-offrv, x:offsh, z:zz,y:offsv,ease:punchgs.Power3.easeOut,overwrite:"all"});
else
punchgs.TweenLite.to(t,0.5,{force3D:"auto",rotationY:0, rotationX:0, z:0,ease:punchgs.Power3.easeOut,overwrite:"all"});
else
punchgs.TweenLite.to(t,0.5,{force3D:"auto",rotationY:0,z:0,x:0,y:0, rotationX:0, z:0,ease:punchgs.Power3.easeOut,overwrite:"all"});
if (event.type=="mouseleave")
punchgs.TweenLite.to(jQuery(this),3.8,{z:0, ease:punchgs.Power3.easeOut});
});
}
}
}
_R.scrollTicker(opt,container);
},
scrollTicker : function(opt,container) {
var faut;
if (opt.scrollTicker!=true) {
opt.scrollTicker = true;
if (_ISM) {
punchgs.TweenLite.ticker.fps(150);
punchgs.TweenLite.ticker.addEventListener("tick",function() {_R.scrollHandling(opt);},container,false,1);
} else {
jQuery(window).on('scroll mousewheel DOMMouseScroll', function() {
_R.scrollHandling(opt,true);
});
}
}
_R.scrollHandling(opt, true);
},
// - SET POST OF SCROLL PARALLAX -
scrollHandling : function(opt,fromMouse) {
opt.lastwindowheight = opt.lastwindowheight || jQuery(window).height();
var t = opt.c.offset().top,
st = jQuery(window).scrollTop(),
b = new Object(),
_v = opt.viewPort,
_ = opt.parallax;
if (opt.lastscrolltop==st && !opt.duringslidechange && !fromMouse) return false;
//if (opt.lastscrolltop==st) return false;
function saveLastScroll(opt,st) {
opt.lastscrolltop = st;
}
punchgs.TweenLite.delayedCall(0.2,saveLastScroll,[opt,st]);
b.top = (t-st);
b.h = opt.conh==0 ? opt.c.height() : opt.conh;
b.bottom = (t-st) + b.h;
var proc = b.top<0 ? b.top / b.h : b.bottom>opt.lastwindowheight ? (b.bottom-opt.lastwindowheight) / b.h : 0;
opt.scrollproc = proc;
if (_R.callBackHandling)
_R.callBackHandling(opt,"parallax","start");
if (_v.enable) {
var area = 1-Math.abs(proc);
area = area<0 ? 0 : area;
// To Make sure it is not any more in %
if (!jQuery.isNumeric(_v.visible_area))
if (_v.visible_area.indexOf('%')!==-1)
_v.visible_area = parseInt(_v.visible_area)/100;
if (1-_v.visible_area<=area) {
if (!opt.inviewport) {
opt.inviewport = true;
_R.enterInViewPort(opt);
}
} else {
if (opt.inviewport) {
opt.inviewport = false;
_R.leaveViewPort(opt);
}
}
}
// SCROLL BASED PARALLAX EFFECT
if (_ISM && opt.parallax.disable_onmobile=="on") return false;
var pt = new punchgs.TimelineLite();
pt.pause();
if (_.type!="3d" && _.type!="3D") {
if (_.type=="scroll" || _.type=="scroll+mouse" || _.type=="mouse+scroll")
opt.c.find(".tp-parallax-container").each(function(i) {
var pc = jQuery(this),
pl = parseInt(pc.data('parallaxlevel'),0)/100,
offsv = proc * -(pl*opt.conh) || 0;
pc.data('parallaxoffset',offsv);
pt.add(punchgs.TweenLite.set(pc,{force3D:"auto",y:offsv}),0);
});
opt.c.find('.tp-revslider-slidesli .slotholder, .tp-revslider-slidesli .rs-background-video-layer').each(function() {
var t = jQuery(this),
l = t.data('bgparallax') || opt.parallax.bgparallax;
l = l == "on" ? 1 : l;
if (l!== undefined || l !== "off") {
var pl = opt.parallax.levels[parseInt(l,0)-1]/100,
offsv = proc * -(pl*opt.conh) || 0;
if (jQuery.isNumeric(offsv))
pt.add(punchgs.TweenLite.set(t,{position:"absolute",top:"0px",left:"0px",backfaceVisibility:"hidden",force3D:"true",y:offsv+"px"}),0);
}
});
}
if (_R.callBackHandling)
_R.callBackHandling(opt,"parallax","end");
pt.play(0);
}
});
//// END OF PARALLAX EFFECT
})(jQuery);

View File

@@ -0,0 +1 @@
window.tplogs = true;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
window.tplogs = true;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,89 @@
<?php
/**
* Facebook
*
* with help of the API this class delivers album images from Facebook
*
* @package socialstreams
* @subpackage socialstreams/facebook
* @author ThemePunch <info@themepunch.com>
*/
class TP_facebook {
/**
* Get User ID from its URL
*
* @since 1.0.0
* @param string $user_url URL of the Page
*/
public function get_user_from_url($user_url){
$theid = str_replace("https", "", $user_url);
$theid = str_replace("http", "", $theid);
$theid = str_replace("://", "", $theid);
$theid = str_replace("www.", "", $theid);
$theid = str_replace("facebook", "", $theid);
$theid = str_replace(".com", "", $theid);
$theid = str_replace("/", "", $theid);
$theid = explode("?", $theid);
return $theid[0];
}
/**
* Get Photosets List from User
*
* @since 1.0.0
* @param string $user_id Facebook User id (not name)
* @param int $item_count number of photos to pull
*/
public function get_photo_sets($user_id,$item_count=10){
//photoset params
$url = "https://graph.facebook.com/$user_id/albums";
$photo_sets_list = json_decode(file_get_contents($url));
return $photo_sets_list->data;
}
/**
* Get Photoset Photos
*
* @since 1.0.0
* @param string $photo_set_id Photoset ID
* @param int $item_count number of photos to pull
*/
public function get_photo_set_photos($photo_set_id,$item_count=10){
$url = "https://graph.facebook.com/v2.0/$photo_set_id?fields=photos";
$photo_set_photos = json_decode(file_get_contents($url));
return $photo_set_photos->photos->data;
}
/**
* Get Feed
*
* @since 1.0.0
* @param string $user User ID
* @param int $item_count number of itmes to pull
*/
public function get_post_feed($user,$app_id,$app_secret,$item_count=10){
$oauth = file_get_contents("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=".$app_id."&client_secret=".$app_secret);
$url = "https://graph.facebook.com/$user/feed?".$oauth."&fields=id,from,message,picture,link,name,icon,privacy,type,status_type,object_id,application,created_time,updated_time,is_hidden,is_expired,likes,comments";
$feed = json_decode(file_get_contents($url));
return $feed->data;
}
/**
* Decode URL from feed
*
* @since 1.0.0
* @param string $url facebook Output Data
*/
public static function decode_facebook_url($url) {
$url = str_replace('u00253A',':',$url);
$url = str_replace('\u00255C\u00252F','/',$url);
$url = str_replace('u00252F','/',$url);
$url = str_replace('u00253F','?',$url);
$url = str_replace('u00253D','=',$url);
$url = str_replace('u002526','&',$url);
return $url;
}
}
?>

View File

@@ -0,0 +1,265 @@
<?php
/**
* Flickr
*
* with help of the API this class delivers all kind of Images from flickr
*
* @package socialstreams
* @subpackage socialstreams/flickr
* @author ThemePunch <info@themepunch.com>
*/
class TP_flickr {
/**
* API key
*
* @since 1.0.0
* @access private
* @var string $api_key flickr API key
*/
private $api_key;
/**
* API params
*
* @since 1.0.0
* @access private
* @var array $api_param_defaults Basic params to call with API
*/
private $api_param_defaults;
/**
* Basic URL
*
* @since 1.0.0
* @access private
* @var string $url Url to fetch user from
*/
private $flickr_url;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $api_key flickr API key.
*/
public function __construct($api_key) {
$this->api_key = $api_key;
$this->api_param_defaults = array(
'api_key' => $this->api_key,
'format' => 'json',
'nojsoncallback' => 1,
);
}
/**
* Calls Flicker API with set of params, returns json
*
* @since 1.0.0
* @param array $params Parameter build for API request
*/
private function call_flickr_api($params){
//build url
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = urlencode($k).'='.urlencode($v);
}
//call the API and decode the response
$url = "https://api.flickr.com/services/rest/?".implode('&', $encoded_params);
$rsp = json_decode(file_get_contents($url));
return $rsp;
}
/**
* Get User ID from its URL
*
* @since 1.0.0
* @param string $user_url URL of the Gallery
*/
public function get_user_from_url($user_url){
//gallery params
$user_params = $this->api_param_defaults + array(
'method' => 'flickr.urls.lookupUser',
'url' => $user_url,
);
//set User Url
$this->flickr_url = $user_url;
//get gallery info
$user_info = $this->call_flickr_api($user_params);
return $user_info->user->id;
}
/**
* Get Group ID from its URL
*
* @since 1.0.0
* @param string $group_url URL of the Gallery
*/
public function get_group_from_url($group_url){
//gallery params
$group_params = $this->api_param_defaults + array(
'method' => 'flickr.urls.lookupGroup',
'url' => $group_url,
);
//set User Url
$this->flickr_url = $group_url;
//get gallery info
$group_info = $this->call_flickr_api($group_params);
return $group_info->group->id;
}
/**
* Get Public Photos
*
* @since 1.0.0
* @param string $user_id flicker User id (not name)
* @param int $item_count number of photos to pull
*/
public function get_public_photos($user_id,$item_count=10){
//public photos params
$public_photo_params = $this->api_param_defaults + array(
'method' => 'flickr.people.getPublicPhotos',
'user_id' => $user_id,
'extras' => 'description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o',
'per_page'=> $item_count,
'page' => 1
);
//get photo list
$public_photos_list = $this->call_flickr_api($public_photo_params);
return $public_photos_list->photos->photo;
}
/**
* Get Photosets List from User
*
* @since 1.0.0
* @param string $user_id flicker User id (not name)
* @param int $item_count number of photos to pull
*/
public function get_photo_sets($user_id,$item_count=10){
//photoset params
$photo_set_params = $this->api_param_defaults + array(
'method' => 'flickr.photosets.getList',
'user_id' => $user_id,
'per_page'=> $item_count,
'page' => 1
);
//get photoset list
$photo_sets_list = $this->call_flickr_api($photo_set_params);
return $photo_sets_list->photosets->photoset;
}
/**
* Get Photoset Photos
*
* @since 1.0.0
* @param string $photo_set_id Photoset ID
* @param int $item_count number of photos to pull
*/
public function get_photo_set_photos($photo_set_id,$item_count=10){
//photoset photos params
$photo_set_params = $this->api_param_defaults + array(
'method' => 'flickr.photosets.getPhotos',
'photoset_id' => $photo_set_id,
'per_page' => $item_count,
'page' => 1,
'extras' => 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o'
);
//get photo list
$photo_set_photos = $this->call_flickr_api($photo_set_params);
return $photo_set_photos->photoset->photo;
}
/**
* Get Groop Pool Photos
*
* @since 1.0.0
* @param string $group_id Photoset ID
* @param int $item_count number of photos to pull
*/
public function get_group_photos($group_id,$item_count=10){
//photoset photos params
$group_pool_params = $this->api_param_defaults + array(
'method' => 'flickr.groups.pools.getPhotos',
'group_id' => $group_id,
'per_page' => $item_count,
'page' => 1,
'extras' => 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o'
);
//get photo list
$group_pool_photos = $this->call_flickr_api($group_pool_params);
return $group_pool_photos->photos->photo;
}
/**
* Get Gallery ID from its URL
*
* @since 1.0.0
* @param string $gallery_url URL of the Gallery
* @param int $item_count number of photos to pull
*/
public function get_gallery_from_url($gallery_url){
//gallery params
$gallery_params = $this->api_param_defaults + array(
'method' => 'flickr.urls.lookupGallery',
'url' => $gallery_url,
);
//get gallery info
$gallery_info = $this->call_flickr_api($gallery_params);
return $gallery_info->gallery->id;
}
/**
* Get Gallery Photos
*
* @since 1.0.0
* @param string $gallery_id flicker Gallery id (not name)
* @param int $item_count number of photos to pull
*/
public function get_gallery_photos($gallery_id,$item_count=10){
//gallery photos params
$gallery_photo_params = $this->api_param_defaults + array(
'method' => 'flickr.galleries.getPhotos',
'gallery_id' => $gallery_id,
'extras' => 'description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o',
'per_page'=> $item_count,
'page' => 1
);
//get photo list
$gallery_photos_list = $this->call_flickr_api($gallery_photo_params);
return $gallery_photos_list->photos->photo;
}
/**
* Encode the flickr ID for URL (base58)
*
* @since 1.0.0
* @param string $num flickr photo id
*/
public static function base_encode($num, $alphabet='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ') {
$base_count = strlen($alphabet);
$encoded = '';
while ($num >= $base_count) {
$div = $num/$base_count;
$mod = ($num-($base_count*intval($div)));
$encoded = $alphabet[$mod] . $encoded;
$num = intval($div);
}
if ($num) $encoded = $alphabet[$num] . $encoded;
return $encoded;
}
}
?>

View File

@@ -0,0 +1,48 @@
<?php
/**
* Instagram
*
* with help of the API this class delivers all kind of Images from instagram
*
* @package socialstreams
* @subpackage socialstreams/instagram
* @author ThemePunch <info@themepunch.com>
*/
class TP_instagram {
/**
* API key
*
* @since 1.0.0
* @access private
* @var string $api_key Instagram API key
*/
private $api_key;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $api_key Instagram API key.
*/
public function __construct($api_key) {
$this->api_key = $api_key;
}
/**
* Get Instagram Pictures
*
* @since 1.0.0
* @param string $user_id Instagram User id (not name)
*/
public function get_public_photos($search_user_id){
//call the API and decode the response
$url = "https://api.instagram.com/v1/users/".$search_user_id."/media/recent?access_token=".$this->api_key."&client_id=".$search_user_id;
$rsp = json_decode(file_get_contents($url));
return $rsp->data;
}
}
?>

View File

@@ -0,0 +1,93 @@
<?php
/**
* @author Albert Kozlowski <vojant@gmail.com>
* @license MIT License
* @link https://github.com/vojant/Twitter-php
*/
namespace TwitterPhp;
use \TwitterPhp\Connection\Application;
use \TwitterPhp\Connection\User;
require_once 'connection/ConnectionAbstract.php';
require_once 'connection/Application.php';
require_once 'connection/User.php';
/**
* Class TwitterRestApiException
*/
class RestApiException extends \Exception {};
/**
* Class RestApi
* @package TwitterPhp
*/
class RestApi
{
/**
* @var string
*/
private $_consumerKey;
/**
* @var string
*/
private $_consumerSecret;
/**
* @var string
*/
private $_accessToken;
/**
* @var string
*/
private $_accessTokenSecret;
/**
* @param string $consumerKey
* @param string $consumerSecret
* @param null|string $accessToken
* @param null|string $accessTokenSecret
* @throws TwitterRestApiException
*/
public function __construct($consumerKey,$consumerSecret,$accessToken = null,$accessTokenSecret = null)
{
if (!function_exists('curl_init')) {
throw new TwitterRestApiException('You must have the cURL extension enabled to use this library');
}
$this->_consumerKey = $consumerKey;
$this->_consumerSecret = $consumerSecret;
$this->_accessToken = $accessToken;
$this->_accessTokenSecret = $accessTokenSecret;
}
/**
* Connect to Twitter API as application.
* @link https://dev.twitter.com/docs/auth/application-only-auth
*
* @return \TwitterPhp\Connection\Application
*/
public function connectAsApplication()
{
return new Application($this->_consumerKey,$this->_consumerSecret);
}
/**
* Connect to Twitter API as user.
* @link https://dev.twitter.com/docs/auth/oauth/single-user-with-examples
*
* @return \TwitterPhp\Connection\User
* @throws TwitterRestApiException
*/
public function connectAsUser()
{
if (!$this->_accessToken || !$this->_accessTokenSecret) {
throw new TwitterRestApiException('Missing ACCESS_TOKEN OR ACCESS_TOKEN_SECRET');
}
return new User($this->_consumerKey,$this->_consumerSecret,$this->_accessToken,$this->_accessTokenSecret);
}
}

View File

@@ -0,0 +1,122 @@
<?php
include 'RestApi.php';
/**
* Twitter
*
* with help of the API this class delivers all kind of tweeted images from twitter
*
* @package socialstreams
* @subpackage socialstreams/twitter
* @author ThemePunch <info@themepunch.com>
*/
class TP_twitter {
/**
* Consumer Key
*
* @since 1.0.0
* @access private
* @var string $consumer_key Consumer Key
*/
private $consumer_key;
/**
* Consumer Secret
*
* @since 1.0.0
* @access private
* @var string $consumer_secret Consumer Secret
*/
private $consumer_secret;
/**
* Access Token
*
* @since 1.0.0
* @access private
* @var string $access_token Access Token
*/
private $access_token;
/**
* Access Token Secret
*
* @since 1.0.0
* @access private
* @var string $access_token_secret Access Token Secret
*/
private $access_token_secret;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $api_key flickr API key.
*/
public function __construct($consumer_key,$consumer_secret,$access_token,$access_token_secret) {
$this->consumer_key = $consumer_key;
$this->consumer_secret = $consumer_secret;
$this->access_token = $access_token;
$this->access_token_secret = $access_token_secret;
}
/**
* Get Tweets
*
* @since 1.0.0
* @param string $twitter_account Twitter account without trailing @ char
*/
public function get_public_photos($twitter_account){
$twitter = new \TwitterPhp\RestApi($this->consumer_key,$this->consumer_secret,$this->access_token,$this->access_token_secret);
/*
* Connect as application
* https://dev.twitter.com/docs/auth/application-only-auth
*/
$connection = $twitter->connectAsApplication();
/*
* Collection of the most recent Tweets posted by the user indicated by the screen_name, without replies
* https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
*/
$tweets = $connection->get('/statuses/user_timeline',array('screen_name' => $twitter_account, 'entities' => 1, 'trim_user' => 0 , 'exclude_replies' => 'true'));
//var_dump($tweets);
return $tweets;
}
/**
* Find Key in array and return value (multidim array possible)
*
* @since 1.0.0
* @param string $key Needle
* @param array $form Haystack
*/
public static function array_find_element_by_key($key, $form) {
if (array_key_exists($key, $form)) {
$ret =& $form[$key];
return $ret;
}
foreach ($form as $k => $v) {
if (is_array($v)) {
$ret =TP_twitter::array_find_element_by_key($key, $form[$k]);
if ($ret) {
return $ret;
}
}
}
return FALSE;
}
/**
* Prepare output array $stream
*
* @since 1.0.0
* @param string $tweets Twitter Output Data
*/
public static function makeClickableLinks($s) {
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
}
}
?>

View File

@@ -0,0 +1,80 @@
<?php
namespace TwitterPhp\Connection;
use TwitterPhp\RestApiException;
class Application extends Base
{
/**
* @var string
*/
private $_consumerKey;
/**
* @var string
*/
private $_consumerSecret;
/**
* @var string
*/
private $_bearersToken = null;
/**
* @param string $consumerKey
* @param string $consumerSecret
*/
public function __construct($consumerKey,$consumerSecret)
{
$this->_consumerKey = $consumerKey;
$this->_consumerSecret = $consumerSecret;
}
/**
* @param string $url
* @param array $parameters
* @param $method
* @return array
*/
protected function _buildHeaders($url,array $parameters = null,$method)
{
return $headers = array(
"Authorization: Bearer " . $this->_getBearerToken()
);
}
/**
* Get Bearer token
*
* @link https://dev.twitter.com/docs/auth/application-only-auth
*
* @throws \TwitterPhp\RestApiException
* @return string
*/
private function _getBearerToken() {
if (!$this->_bearersToken) {
$token = urlencode($this->_consumerKey) . ':' . urlencode($this->_consumerSecret);
$token = base64_encode($token);
$headers = array(
"Authorization: Basic " . $token
);
$options = array (
CURLOPT_URL => self::TWITTER_API_AUTH_URL,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => "grant_type=client_credentials"
);
$response = $this->_callApi($options);
if (isset($response["token_type"]) && $response["token_type"] == 'bearer') {
$this->_bearersToken = $response["access_token"];
} else {
throw new RestApiException('Error while getting access token');
}
}
return $this->_bearersToken;
}
}

View File

@@ -0,0 +1,120 @@
<?php
namespace TwitterPhp\Connection;
/**
* Class Base
* @package TwitterPhp
* @subpackage Connection
*/
abstract class Base
{
/**
* Url for Twitter api
*/
const TWITTER_API_URL = 'https://api.twitter.com';
/**
* Twitter URL that authenticates bearer tokens
*/
const TWITTER_API_AUTH_URL = 'https://api.twitter.com/oauth2/token/';
/**
* Version of Twitter api
*/
const TWITTER_API_VERSION = '1.1';
/**
* Timeout value for curl connections
*/
const DEFAULT_TIMEOUT = 10;
/**
* METHOD GET
*/
const METHOD_GET = 'GET';
/**
* METHOD POST
*/
const METHOD_POST = 'POST';
/**
* @param string $url
* @param array $parameters
* @param $method
* @return array
*/
abstract protected function _buildHeaders($url,array $parameters = null,$method);
/**
* Do GET request to Twitter api
*
* @link https://dev.twitter.com/docs/api/1.1
*
* @param $resource
* @param array $parameters
* @return mixed
*/
public function get($resource, array $parameters = array())
{
$url = $this->_prepareUrl($resource);
$headers = $this->_buildHeaders($url,$parameters,self::METHOD_GET);
$url = $url . '?' . http_build_query($parameters);
$curlParams = array (
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => $headers
);
return $this->_callApi($curlParams);
}
/**
* Do POST request to Twitter api
*
* @link https://dev.twitter.com/docs/api/1.1
*
* @param $resource
* @param array $parameters
* @return mixed
*/
public function post($resource, array $parameters = array())
{
$url = $this->_prepareUrl($resource);
$headers = $this->_buildHeaders($url,$parameters,self::METHOD_POST);
$curlParams = array (
CURLOPT_URL => $url,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $parameters,
CURLOPT_HTTPHEADER => $headers
);
return $this->_callApi($curlParams);
}
/**
* Call Twitter api
*
* @param array $params
* @return array
*/
protected function _callApi(array $params)
{
$curl = curl_init();
curl_setopt_array($curl,$params);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, self::DEFAULT_TIMEOUT);
$response = curl_exec($curl);
return json_decode($response,true);
}
/**
* @param string $resource
* @return string
*/
private function _prepareUrl($resource)
{
return self::TWITTER_API_URL . '/' . self::TWITTER_API_VERSION . '/' . ltrim($resource,'/') . '.json';
}
}

View File

@@ -0,0 +1,92 @@
<?php
namespace TwitterPhp\Connection;
class User extends Base
{
/**
* @var string
*/
private $_consumerKey;
/**
* @var string
*/
private $_consumerSecret;
/**
* @var string
*/
private $_accessToken;
/**
* @var string
*/
private $_accessTokenSecret;
/**
* @param string $consumerKey
* @param string $consumerSecret
* @param string $accessToken
* @param string $accessTokenSecret
*/
public function __construct($consumerKey,$consumerSecret,$accessToken,$accessTokenSecret)
{
$this->_consumerKey = $consumerKey;
$this->_consumerSecret = $consumerSecret;
$this->_accessToken = $accessToken;
$this->_accessTokenSecret = $accessTokenSecret;
}
/**
* @param string $url
* @param array $parameters
* @param $method
* @return array
*/
protected function _buildHeaders($url,array $parameters = null,$method)
{
$oauthHeaders = array(
'oauth_version' => '1.0',
'oauth_consumer_key' => $this->_consumerKey,
'oauth_nonce' => time(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_token' => $this->_accessToken,
'oauth_timestamp' => time()
);
$data = $oauthHeaders;
if ($method == self::METHOD_GET) {
$data = array_merge($oauthHeaders,$parameters);
}
$oauthHeaders['oauth_signature'] = $this->_buildOauthSignature($url,$data,$method);
ksort($oauthHeaders);
$oauthHeader = array();
foreach($oauthHeaders as $key => $value) {
$oauthHeader[] = $key . '="' . rawurlencode($value) . '"';
}
$headers[] = 'Authorization: OAuth ' . implode(', ', $oauthHeader);
return $headers;
}
/**
* @param $url
* @param array $params
* @param $method
* @return string
*/
private function _buildOauthSignature($url,array $params,$method)
{
ksort($params);
$sortedParams = array();
foreach($params as $key=>$value) {
$sortedParams[] = $key . '=' . $value;
}
$signatureBaseString = $method . "&" . rawurlencode($url) . '&' . rawurlencode(implode('&', $sortedParams));
$compositeKey = rawurlencode($this->_consumerSecret) . '&' . rawurlencode($this->_accessTokenSecret);
return base64_encode(hash_hmac('sha1', $signatureBaseString, $compositeKey, true));
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Vimeo
*
* with help of the API this class delivers all kind of Images/Videos from Vimeo
*
* @package socialstreams
* @subpackage socialstreams/vimeo
* @author ThemePunch <info@themepunch.com>
*/
class TP_vimeo {
/**
* Stream Array
*
* @since 1.0.0
* @access private
* @var array $stream Stream Data Array
*/
private $stream;
/**
* Get Vimeo User Videos
*
* @since 1.0.0
*/
public function get_vimeo_videos($type,$value){
//call the API and decode the response
if($type=="user"){
$url = "https://vimeo.com/api/v2/".$value."/videos.json";
}
else{
$url = "https://vimeo.com/api/v2/".$type."/".$value."/videos.json";
}
$rsp = json_decode(file_get_contents($url));
return $rsp;
}
/**
* Prepare output array $stream for Vimeo videos
*
* @since 1.0.0
* @param string $videos Vimeo Output Data
*/
private function vimeo_output_array($videos,$count){
foreach ($videos as $video) {
if($count-- == 0) break;
$stream = array();
$image_url = @array(
'thumbnail_small' => array($video->thumbnail_small),
'thumbnail_medium' => array($video->thumbnail_medium),
'thumbnail_large' => array($video->thumbnail_large),
);
$stream['custom-image-url'] = $image_url; //image for entry
$stream['custom-type'] = 'vimeo'; //image, vimeo, youtube, soundcloud, html
$stream['custom-vimeo'] = $video->id;
$stream['post_url'] = $video->url;
$stream['post_link'] = $video->url;
$stream['title'] = $video->title;
$stream['content'] = $video->description;
$stream['date_modified'] = $video->upload_date;
$stream['author_name'] = $video->user_name;
$this->stream[] = $stream;
}
}
}
?>

View File

@@ -0,0 +1,85 @@
<?php
/**
* Youtube
*
* with help of the API this class delivers all kind of Images/Videos from youtube
*
* @package socialstreams
* @subpackage socialstreams/youtube
* @author ThemePunch <info@themepunch.com>
*/
class TP_youtube {
/**
* API key
*
* @since 1.0.0
* @access private
* @var string $api_key Youtube API key
*/
private $api_key;
/**
* Channel ID
*
* @since 1.0.0
* @access private
* @var string $channel_id Youtube Channel ID
*/
private $channel_id;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $api_key Youtube API key.
*/
public function __construct($api_key,$channel_id) {
$this->api_key = $api_key;
$this->channel_id = $channel_id;
}
/**
* Get Youtube Playlists
*
* @since 1.0.0
*/
public function get_playlists(){
//call the API and decode the response
$url = "https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=".$this->channel_id."&key=".$this->api_key;
$rsp = json_decode(file_get_contents($url));
return $rsp->items;
}
/**
* Get Youtube Playlist Items
*
* @since 1.0.0
* @param string $playlist_id Youtube Playlist ID
* @param integer $count Max videos count
*/
public function show_playlist_videos($playlist_id,$count=50){
//call the API and decode the response
$url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=".$playlist_id."&maxResults=".$count."&fields=items%2Fsnippet&key=".$this->api_key;
$rsp = json_decode(file_get_contents($url));
return $rsp->items;
}
/**
* Get Youtube Channel Items
*
* @since 1.0.0
* @param integer $count Max videos count
*/
public function show_channel_videos($count=50){
//call the API and decode the response
$url = "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=".$this->channel_id."&maxResults=".$count."&key=".$this->api_key."&order=date";
echo $url;
$rsp = json_decode(file_get_contents($url));
return $rsp->items;
}
}
?>