Skip to content

Commit

Permalink
maj du 22.12.2012
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Dec 23, 2012
1 parent 3bf3378 commit de5611a
Show file tree
Hide file tree
Showing 8 changed files with 485 additions and 83 deletions.
21 changes: 17 additions & 4 deletions oc454/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ Tested for OC4.5.4 Install instructions And Now also for OC4.5

That's all and now when you sharing a folder of images with subfolders you have a nice webwidget gallery.

[UPDATE]
If you have another apps directory as default (apps) where files_sharing_widget would be installed than you have to change the appspath
in the widgetloader.php

[NEW Features]
Now you can use The Gallery Widget in an other apps folder (e.g. apps2) if this is in config.php iconfigurated
Now you can create your own Watermark text to the pictures (Copyright Hint)
New Js Engine in the widget.js
New Js Engine in the widget.js

[DEMOS]
On the right side the pics direct loaded from Owncloud Share Widget
http://www.coding-schmiede.de/

http://showcase.libasys.de/widget/

Click on the Button the widget will be shown
http://showcase.libasys.de/widgetdemo/

Integration the Widget on Facebook [password protected]
Pass:facebook
http://www.facebook.com/pages/Libasys/212217432121922?sk=app_390630084348208

Shared by a Link direct
https://ssl.webpack.de/demo.libasyscloud.de/widget.php?action=real&iToken=ZI5%2BKcT%2FIF5CQUeEOk2%2F%2B2UPO6EEAMULrGyHGLSctBM%3D
44 changes: 35 additions & 9 deletions oc454/apps/files_sharing_widget/js/widget.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if (window.jQuery === undefined || window.jQuery.fn.jquery !== "1.8.2") {
var script_tag = document.createElement("script");
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",ownWidgetOptions.appspath+ "/js/jquery-pack.min.js");
script_tag.setAttribute("src",ownWidgetOptions.path + ownWidgetOptions.appspath+ "/files_sharing_widget/js/jquery-pack.min.js");
if (script_tag.readyState) {

script_tag.onreadystatechange = function() {
Expand Down Expand Up @@ -50,7 +50,11 @@
// if($.browser.msie && $.browser.version<9){
//widgetContainer.css('opacity',0.3);
// }
OwnWidget.init(ownWidgetOptions);
if(ownWidgetOptions.showButtonLink!=undefined){
OwnWidget.prepareExternLink(ownWidgetOptions);
}else{
if($("#ownWidget-container").length>0) OwnWidget.init(ownWidgetOptions);
}
});
}

Expand All @@ -60,7 +64,10 @@ var OwnWidget={
var defaults={
crypt:'',
path:'',
appspath:'', //<?php echo OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath("files_sharing_widget")); ?>
appspath:'apps',
showButtonLink:'',
customThumbHeight:'',
customThumbpPage:'',
display:'',
fbAppid:'',
modal:true,
Expand All @@ -83,12 +90,24 @@ var OwnWidget={
} else {
this.showWidget();
}
this.initSupersized()
this.initSupersized();

},
prepareExternLink:function(options){
var self=this;

if(options.showButtonLink!=''){
jQuery('#'+options.showButtonLink).click(function(){
clearTimeout(timeout);
var timeout=setTimeout(function(){self.init(options);}, 500);


});
}
},

loadCssFile:function(){
if(jQuery('#ownWidgetCss').length<1){
jQuery("<link>", {id:'ownWidgetCss',rel : "stylesheet",type : "text/css",href :this.options.appspath + "/css/widget.css"}).appendTo("head");
jQuery("<link>", {id:'ownWidgetCss',rel : "stylesheet",type : "text/css",href :this.options.path + this.options.appspath+ "/files_sharing_widget/css/widget.css"}).appendTo("head");
}
},

Expand Down Expand Up @@ -206,10 +225,16 @@ var OwnWidget={

loadData:function() {
var self = this;
var addCustomThumbSize='';
if(this.options.customThumbHeight!='') addCustomThumbSize='&cTh='+this.options.customThumbHeight;

var addCustomThumbPage='';
if(this.options.customThumbpPage!='') addCustomThumbPage='&cTpP='+this.options.customThumbpPage;
//customThumbpPage
jQuery.ajax({
dataType : "jsonp",
jsonp : "jsonp_callback",
url : self.options.path + "/public.php?service=pics&iToken=" + rawurlencode(self.options.crypt) + self.loadPage,
url : self.options.path + "widget.php?iToken=" + rawurlencode(self.options.crypt) + self.loadPage+addCustomThumbSize+addCustomThumbPage,

success : function(data) {

Expand Down Expand Up @@ -241,6 +266,7 @@ var OwnWidget={
self.widgetContainer.css(self.options.cssAddWidget);

if (!self.options.cssAddWidget.top && !self.options.cssAddWidget.left) {

self.widgetContainer.css({
top : (jQuery(window).height() / 2) - (self.widgetContainer.height() / 2),
left : (jQuery(window).width() / 2) - (self.widgetContainer.width() / 2)
Expand Down Expand Up @@ -289,7 +315,7 @@ var OwnWidget={
progress_delay : false,
thumb_page : false,
thumb_interval : false,
image_path : this.options.appspath+ "/img/",
image_path : this.options.path + this.options.appspath+ "/files_sharing_widget/img/",
play_button : "#pauseplay",
next_slide : "#nextslide",
prev_slide : "#prevslide",
Expand All @@ -310,7 +336,7 @@ var OwnWidget={
},
initSupersized:function() {
var self=this;
var htmlString = '<div id="slideshow-content" style="display:none;z-index:201;"><div id="closeSlideShow">X</div><div id="prevthumb"></div><div id="nextthumb"></div> <a id="prevslide" class="load-item"></a> <a id="nextslide" class="load-item"></a> <div id="thumb-tray" class="load-item"><div id="thumb-back"></div><div id="thumb-forward"></div></div> <div id="progress-back" class="load-item"><div id="progress-bar"></div></div><div id="controls-wrapper" class="load-item"><div id="controls"><a id="play-button"><img id="pauseplay" src="'+ this.options.appspath + '/img/pause.png" /></a><div id="slidecounter"><span class="slidenumber"></span><span class="totalslides"></span></div><div id="slidecaption"></div><a id="tray-button"><img id="tray-arrow" src="' + this.options.appspath + '/img/button-tray-up.png" /></a><ul id="slide-list"></ul></div></div></div>';
var htmlString = '<div id="slideshow-content" style="display:none;z-index:201;"><div id="closeSlideShow">X</div><div id="prevthumb"></div><div id="nextthumb"></div> <a id="prevslide" class="load-item"></a> <a id="nextslide" class="load-item"></a> <div id="thumb-tray" class="load-item"><div id="thumb-back"></div><div id="thumb-forward"></div></div> <div id="progress-back" class="load-item"><div id="progress-bar"></div></div><div id="controls-wrapper" class="load-item"><div id="controls"><a id="play-button"><img id="pauseplay" src="'+ this.options.path + this.options.appspath + '/files_sharing_widget/img/pause.png" /></a><div id="slidecounter"><span class="slidenumber"></span><span class="totalslides"></span></div><div id="slidecaption"></div><a id="tray-button"><img id="tray-arrow" src="' + this.options.path + this.options.appspath + '/files_sharing_widget/img/button-tray-up.png" /></a><ul id="slide-list"></ul></div></div></div>';
jQuery(htmlString).appendTo("body");
jQuery("#closeSlideShow").click(function() {
if (jQuery.supersized.vars.slideshow_interval) {
Expand Down
2 changes: 1 addition & 1 deletion oc454/apps/files_sharing_widget/js/widget.js

Large diffs are not rendered by default.

54 changes: 19 additions & 35 deletions oc454/apps/files_sharing_widget/lib/widgethelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OC_Widget_Helper {
* Returns a absolute url to the given service.
*/
public static function linkToWidget($service, $add_slash = false) {
return OC_Helper::linkToAbsolute( '', 'public.php') . '?service=pics&action=' . $service . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
return OC_Helper::linkToAbsolute( '', 'widget.php') . '?action=' . $service . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
}


Expand Down Expand Up @@ -73,15 +73,15 @@ public static function makeNormPic($path,$bWatermark=true,$sWatermarkTxt='(c) ze
$image -> show();
}
}

/**
* @load Template for real view
* @param int width of the widget
* @param int height of the widget
* @return return the template
*
*/
/* public static function getRelativeAppWebPath() {
public static function getRelativeAppWebPath() {

foreach(OC::$APPSROOTS as $dir) {
if(file_exists($dir['path'].'/files_sharing_widget')) {
Expand All @@ -90,16 +90,25 @@ public static function makeNormPic($path,$bWatermark=true,$sWatermarkTxt='(c) ze
}
return false;
}
*/

public static function loadTemplateReal($WIDTH="770",$HEIGHT="570",$TITLE='Zeus-Cloud Picture Widget') {


$getRelativeAppsPath=OC_Widget_Helper::getRelativeAppWebPath();
if(strripos(OC::$WEBROOT,'/')) $getRelativeAppsPath=substr($getRelativeAppsPath,1,strlen($getRelativeAppsPath)-1);

$addcustomThumbHeight='';
if(isset($_GET['cTh']) && intval($_GET['cTh'])>0) $addcustomThumbHeight=intval($_GET['cTh']);

$addcustomThumbperPage='';
if(isset($_GET['cTpP']) && intval($_GET['cTpP'])>0) $addcustomThumbperPage=intval($_GET['cTpP']);

$tpl="<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de-DE\" lang=\"de-DE\">\n<head>\n<title>".htmlentities(utf8_decode($TITLE))."</title>
\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><meta content=\"yes\" name=\"apple-mobile-web-app-capable\" />
\n<meta content=\"minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no\" name=\"viewport\" />
\n<link href=\"".OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath('files_sharing_widget'))."/img/startup.png\" rel=\"apple-touch-startup-image\" />
\n<link href=\"".OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath('files_sharing_widget'))."/img/homescreen.png\" rel=\"apple-touch-icon\" />
\n<script>var ownWidgetOptions = {crypt:'".$_GET['iToken']."',path:'".OC_HELPER::makeURLAbsolute(OC::$WEBROOT)."',appspath:'".OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath('files_sharing_widget'))."',cssAddWidget:{'width':'".$WIDTH."','height':'".$HEIGHT."'}};</script>
\n<script src=\"".OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath('files_sharing_widget'))."/js/widget.full.js\" type=\"text/javascript\"></script>\n
\n<link rel=\"shortcut icon\" href=\"".OC_HELPER::makeURLAbsolute(OC::$WEBROOT)."/core/img/favicon.png\" /><link href=\"".OC_HELPER::makeURLAbsolute(OC::$WEBROOT).$getRelativeAppsPath."/files_sharing_widget/img/startup.png\" rel=\"apple-touch-startup-image\" />
\n<link href=\"".OC_HELPER::makeURLAbsolute(OC::$WEBROOT).$getRelativeAppsPath."/files_sharing_widget/img/homescreen.png\" rel=\"apple-touch-icon\" />
\n<script>var ownWidgetOptions = {crypt:'".$_GET['iToken']."',path:'".OC_HELPER::makeURLAbsolute(OC::$WEBROOT)."',appspath:'".$getRelativeAppsPath."',customThumbHeight:'".$addcustomThumbHeight."',customThumbpPage:'".$addcustomThumbperPage."',cssAddWidget:{'width':'".$WIDTH."','height':'".$HEIGHT."'}};</script>
\n<script src=\"".OC_HELPER::makeURLAbsolute(OC::$WEBROOT).$getRelativeAppsPath."/files_sharing_widget/js/widget.js\" type=\"text/javascript\"></script>\n
\n</head>
\n<body class=\"widgetbg\">
\n<div id=\"ownWidget-container\"></div>
Expand Down Expand Up @@ -135,31 +144,7 @@ public static function encrypt($sValue, $sSecretKey) {
)
,"\0\3");
}
/**
* @decrypt string
* @param string Value to decrypt
* @param string Secret Key
* @return decrypted string
*
*/

public static function decrypt($sValue, $sSecretKey) {
return rtrim(
mcrypt_decrypt(
MCRYPT_RIJNDAEL_256,
$sSecretKey,
base64_decode($sValue),
MCRYPT_MODE_ECB,
mcrypt_create_iv(
mcrypt_get_iv_size(
MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB
),
MCRYPT_RAND
)
)
,"\0\3");
}

/**
* @get Count Pics of Directory and one image for Preview
Expand Down Expand Up @@ -213,7 +198,7 @@ public static function getAllSharesUser($SECRET){
if($share['item_type']=='folder') $itemTypeChoose='dir';
$expDate = new \DateTime($share['expiration'], new \DateTimeZone($tz));
$EXPDATE=$expDate->format('d.m.Y H:i');
/*

if($share['share_type']==0){
$output[]=array(
'id'=>$share['id'],
Expand All @@ -236,7 +221,6 @@ public static function getAllSharesUser($SECRET){
'iToken'=>''
);
}
*/
if($share['share_type']==3){
$addPassImg='';
$tokenLink='&'.$itemTypeChoose.'='.$share['path'];
Expand Down
34 changes: 14 additions & 20 deletions oc454/apps/files_sharing_widget/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,13 @@
*
*
*/

OC::$CLASSPATH['OC_Share_Backend_File'] = "files_sharing/lib/share/file.php";
OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'files_sharing/lib/share/folder.php';
OC::$CLASSPATH['OC_Filestorage_Shared'] = "files_sharing/lib/sharedstorage.php";
OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC_Filestorage_Shared', 'setup');
//OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
//OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');

//
$SESSIONPREFIX = OC_Config::getValue('SESSIONPREFIX');

$shareSecret=OCP\Config::getSystemValue('secretword');
if($shareSecret=='') $shareSecret='mySecretWord';
$getSchluessel= OC_Widget_Helper::decrypt(rawurldecode($_GET['iToken']),$shareSecret);

$_GET['dir']=$getSchluessel;
//$_GET['service']='pics';
//
OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');

$bReal=false;
if (isset($_GET['action']) && $_GET['action']=='real') {
Expand Down Expand Up @@ -66,7 +56,7 @@
$ObjParamter['imgheight']=150;
$ObjParamter['width']=750;
$ObjParamter['height']=550;
$ObjParamter['watermark']=1;
$ObjParamter['watermark']=0;
$ObjParamter['watermarktxt']='';
$ObjParamter['title']='';
}
Expand Down Expand Up @@ -129,7 +119,9 @@

if (isset($_GET['dir'])) {
if (isset($_GET['path']) && $_GET['path'] != '') {
OC_Widget_Helper::makeThumb($path,$ObjParamter['imgheight'],$ObjParamter['watermark'],$ObjParamter['watermarktxt']);
$addThumbHeight=$ObjParamter['imgheight'];
if(isset($_GET['cTh']) && (intval($_GET['cTh']) > 49 && intval($_GET['cTh']) < 151)) $addThumbHeight=intval($_GET['cTh']);
OC_Widget_Helper::makeThumb($path,$addThumbHeight,$ObjParamter['watermark'],$ObjParamter['watermarktxt']);
}
}
}else{
Expand All @@ -145,14 +137,14 @@
$rootLength = strlen($baseDir) + 1;
$counter = 0;
$maxNeben = $ObjParamter['maxpicsperpage'];
if ($maxNeben)
$maxNeben = ((int)$maxNeben - 1);
if(isset($_GET['cTpP']) && (intval($_GET['cTpP']) > 2 && intval($_GET['cTpP']) < 31)) $maxNeben=intval($_GET['cTpP']);
if ($maxNeben) $maxNeben = ((int)$maxNeben - 1);
if (!$maxNeben) $maxNeben = 5;

$mySecret=OCP\Config::getSystemValue('secretword');
if($mySecret=='') $mySecret='mySecretWord';
$thumbSize=$ObjParamter['imgheight'];

if(isset($_GET['cTh']) && (intval($_GET['cTh']) > 49 && intval($_GET['cTh']) < 151)) $thumbSize=intval($_GET['cTh']);
//$aFilesArray=[];

foreach (OC_Files::getDirectoryContent($path) as $i) {
Expand Down Expand Up @@ -194,9 +186,11 @@
$ouputAlbumThumb='<div class="rotate"><div style="width:100px;height:75px;">&nbsp;</div ><span>'.$i['name'].' ('.$AlbumData['ANZAHLPICS'].')</span></div>';
if($AlbumData['path']){
$relPath=substr($AlbumData['path'], $rootLength);
if($thumbSize>66) $albumThSize=65;
else $albumThSize=$thumbSize;

$ShowAlbumThumb = OC_Widget_Helper::linkToWidget('thumb') . '&path=/'.$relPath.'&iToken='.rawurlencode($_GET['iToken']);
$ouputAlbumThumb='<div class="rotate"><img class="imgAlbumshow" src="' . $ShowAlbumThumb . '" width="100" style="width:100px;height:65px;" /><br /> <span>'.$i['name'].' ('.$AlbumData['ANZAHLPICS'].')</span></div>';
$ouputAlbumThumb='<div class="rotate"><img class="imgAlbumshow" src="' . $ShowAlbumThumb . '" height="'.$albumThSize.'" style="height:'.$albumThSize.'px;" /><br /> <span>'.$i['name'].' ('.$AlbumData['ANZAHLPICS'].')</span></div>';
}

$dataFolder.= '<a class="loadAlbum" href="javascript:;" title="'.$i['directory'].'/'.$i['name'].'">'.$ouputAlbumThumb.'</a> ';
Expand Down Expand Up @@ -253,7 +247,7 @@
$dataOutput='<div style="text-align:center;margin-top:40px;"><form id="loginForm" action=" " method="post">
Password:
<input type="password" name="password" id="password" value="" />
<input type="submit" value="Go" id="iSubmit" />
<input type="submit" value="Los" id="iSubmit" />
</form>
</div>';
}
Expand Down
21 changes: 7 additions & 14 deletions oc454/apps/files_sharing_widget/templates/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
?>
<fieldset class="personalblock">
<legend>Shared files and folders with link</legend>
<legend>Shared Files and Folders</legend>
<ul class="shareSettings">
<li class="shareHeading">
<span style="width:10%; float:left;display:block;">ShareType </span>
Expand All @@ -27,8 +27,10 @@
<span style="width:15%;float:left;display:block;"><?php echo $shareInfo['shareName']; ?></span>
<span style="width:15%;float:left;display:block;"><a href="<?php echo $shareInfo['link']; ?>" target="_blank"><?php echo $shareInfo['name']; ?></a></span>
<span style="width:20%;float:left;display:block;"><?php echo $shareInfo['date']; ?></span>
<span style="width:38%;display:block;float:left;"><a id="widgetlink-<?php echo $shareInfo['id'] ?>" href="<?php echo OC_HELPER::makeURLAbsolute(OC::$WEBROOT); ?>/public.php?service=pics&action=real&iToken=<?php echo $shareInfo['iToken']; ?>" target="_blank"><?php echo $shareInfo['iToken']; ?></a></span><br style="clear:both;" /></li>
<span style="width:38%;display:block;float:left;"><a id="widgetlink-<?php echo $shareInfo['id'] ?>" href="<?php echo OC_HELPER::makeURLAbsolute(OC::$WEBROOT); ?>/widget.php?action=real&iToken=<?php echo $shareInfo['iToken']; ?>" target="_blank"><?php echo $shareInfo['iToken']; ?></a></span><br style="clear:both;" /></li>
<?php endforeach;}
$getRelativeAppsPath=OC_Widget_Helper::getRelativeAppWebPath();
$getRelativeAppsPath=substr($getRelativeAppsPath,1,strlen($getRelativeAppsPath)-1);
?>
</ul><br />
<b>Configurationparameters:</b><br />
Expand All @@ -45,24 +47,15 @@
<br /><br />
Use as Widget: (For Integration Homepage, Facebook)<br />
<textarea style="width:60%;height:120px;" readonly>
<!DOCTYPE html>
<html>
<head>
<title>Galerie Widget by Libasys</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
var ownWidgetOptions = {
crypt:'thecryptoken', //e.g.os3Nz8rhqNnV1cfUotvc2M3H0w==
path:'<?php echo OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/'); ?>',
appspath:'<?php echo OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath('files_sharing_widget')); ?>',
appspath:'<?php echo $getRelativeAppsPath; ?>',
cssAddWidget:{'width':670,'height':400}
};
}
</script>
<script src="<?php echo OC_HELPER::makeURLAbsolute(OC_App::getAppWebPath('files_sharing_widget')); ?>/js/widget.full.js" type="text/javascript"></script>
</head>
<body class="widgetbg"><div id="ownWidget-container"></div></body>
</html>
</textarea>
<script src="<?php echo OC_HELPER::makeURLAbsolute(OC::$WEBROOT).'/'.$getRelativeAppsPath; ?>/files_sharing_widget/js/widget.js" type="text/javascript"></script></textarea>

</fieldset>
<!-- Dialogs -->
Expand Down
Loading

0 comments on commit de5611a

Please sign in to comment.