gallery settings, defining scan root and shor order
This commit is contained in:
parent
ee01d1a81d
commit
8df0650658
6 changed files with 119 additions and 11 deletions
|
@ -54,9 +54,11 @@ function handleGalleryScanning() {
|
|||
OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('/')));
|
||||
}
|
||||
|
||||
function handleFilescan() {
|
||||
function handleFilescan($cleanup) {
|
||||
OC_JSON::checkLoggedIn();
|
||||
$pathlist = OC_Gallery_Scanner::find_paths('/');
|
||||
if ($cleanup) OC_Gallery_Album::cleanup();
|
||||
$root = OC_Appconfig::getValue('gallery', 'root', '').'/';
|
||||
$pathlist = OC_Gallery_Scanner::find_paths($root);
|
||||
sort($pathlist);
|
||||
OC_JSON::success(array('paths' => $pathlist));
|
||||
}
|
||||
|
@ -72,6 +74,25 @@ function handlePartialCreate($path) {
|
|||
OC_JSON::success(array('album_details' => $albums));
|
||||
}
|
||||
|
||||
function handleStoreSettings($root, $order) {
|
||||
OC_JSON::checkLoggedIn();
|
||||
if (!OC_Filesystem::file_exists($root)) {
|
||||
OC_JSON::error(array('cause' => 'No such file or directory'));
|
||||
return;
|
||||
}
|
||||
if (!OC_Filesystem::is_dir($root)) {
|
||||
OC_JSON::error(array('cause' => $root . ' is not a directory'));
|
||||
return;
|
||||
}
|
||||
|
||||
$current_root = OC_Appconfig::getValue('gallery', 'root', '/');
|
||||
$root = trim(rtrim($root, '/'));
|
||||
$rescan = $current_root==$root?'no':'yes';
|
||||
OC_Appconfig::setValue('gallery', 'root', $root);
|
||||
OC_Appconfig::setValue('gallery', 'order', $order);
|
||||
OC_JSON::success(array('rescan' => $rescan));
|
||||
}
|
||||
|
||||
if ($_GET['operation']) {
|
||||
switch($_GET['operation']) {
|
||||
case 'rename':
|
||||
|
@ -89,11 +110,14 @@ if ($_GET['operation']) {
|
|||
handleGalleryScanning();
|
||||
break;
|
||||
case 'filescan':
|
||||
handleFilescan();
|
||||
handleFilescan($_GET['cleanup']);
|
||||
break;
|
||||
case 'partial_create':
|
||||
handlePartialCreate($_GET['path']);
|
||||
break;
|
||||
case 'store_settings':
|
||||
handleStoreSettings($_GET['root'], $_GET['order']);
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('cause' => 'Unknown operation'));
|
||||
}
|
||||
|
|
|
@ -12,3 +12,6 @@ div.gallery_control_overlay a { color:white; }
|
|||
#gallery_images.rightcontent { padding:10px 5px; bottom: 0px; overflow: auto; right:0px}
|
||||
#scan { position:absolute; right:13.5em; top:0em; }
|
||||
#scan #scanprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; }
|
||||
#g-settings {position: absolute; left 13.5em; top: 0;}
|
||||
input[type=button] { -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; opacity: 1}
|
||||
input[type=button]:disabled { opacity: 0.5 }
|
||||
|
|
|
@ -38,10 +38,12 @@ function createNewAlbum() {
|
|||
var albumCounter = 0;
|
||||
var totalAlbums = 0;
|
||||
|
||||
function scanForAlbums() {
|
||||
function scanForAlbums(cleanup) {
|
||||
cleanup = cleanup?true:false;
|
||||
var albumCounter = 0;
|
||||
var totalAlbums = 0;
|
||||
$.getJSON('ajax/galleryOp.php?operation=filescan', function(r) {
|
||||
$('#g-scan-button').attr('disabled', 'true');
|
||||
$.getJSON('ajax/galleryOp.php?operation=filescan', {cleanup: cleanup}, function(r) {
|
||||
|
||||
if (r.status == 'success') {
|
||||
totalAlbums = r.paths.length;
|
||||
|
@ -68,6 +70,7 @@ function scanForAlbums() {
|
|||
} else {
|
||||
alert('Error occured: no such layer `gallery_list`');
|
||||
}
|
||||
$('#g-scan-button').attr('disabled', null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -125,13 +128,13 @@ function galleryRename(name) {
|
|||
$(this).dialog("close");
|
||||
return;
|
||||
}
|
||||
$.getJSON("ajax/galleryOp.php", {operation: "rename", oldname: name, newname: newname}, function(r) {
|
||||
$.getJSON('ajax/galleryOp.php', {operation: 'rename', oldname: name, newname: newname}, function(r) {
|
||||
if (r.status == "success") {
|
||||
Albums.rename($(".gallery_album_box").filterAttr('data-album',name), newname);
|
||||
} else {
|
||||
alert("Error: " + r.cause);
|
||||
}
|
||||
$('#dialog-form').dialog("close");
|
||||
$('#dialog-form').dialog('close');
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -139,10 +142,49 @@ function galleryRename(name) {
|
|||
{
|
||||
text: t('gallery', 'Cancel'),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
$( this ).dialog('close');
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
function settings() {
|
||||
$( '#g-dialog-settings' ).dialog({
|
||||
height: 180,
|
||||
width: 350,
|
||||
modal: false,
|
||||
buttons: [{
|
||||
text: t('gallery', 'Apply'),
|
||||
click: function() {
|
||||
var scanning_root = $('#g-scanning-root').val();
|
||||
var disp_order = $('#g-display-order option:selected').val();
|
||||
if (scanning_root == '') {
|
||||
alert('Scanning root cannot be empty');
|
||||
return;
|
||||
}
|
||||
$.getJSON('ajax/galleryOp.php', {operation: 'store_settings', root: scanning_root, order: disp_order}, function(r) {
|
||||
if (r.status == 'success') {
|
||||
if (r.rescan == 'yes') {
|
||||
$('#g-dialog-settings').dialog('close');
|
||||
Albums.clear(document.getElementById('gallery_list'));
|
||||
scanForAlbums(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
alert('Error: ' + r.cause);
|
||||
return;
|
||||
}
|
||||
$('#g-dialog-settings').dialog('close');
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('gallery', 'Cancel'),
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ Albums={
|
|||
});
|
||||
$(".gallery_album_decoration a.remove", local).bind('click', {name: a.name},function(event){
|
||||
event.preventDefault();
|
||||
galleryRemove(a.data.name);
|
||||
galleryRemove(event.data.name);
|
||||
});
|
||||
$("a.view", local).attr('href','?view='+a.name);
|
||||
$('h1',local).text(a.name);
|
||||
|
@ -80,6 +80,10 @@ Albums={
|
|||
$("a.view", element).attr("href", "?view="+new_name);
|
||||
$("h1", element).text(new_name);
|
||||
}
|
||||
},
|
||||
clear: function(element) {
|
||||
Albums.albums = new Array();
|
||||
element.innerHTML = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,14 @@ class OC_Gallery_Album {
|
|||
$stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_albums SET album_name=? WHERE uid_owner=? AND album_name=?');
|
||||
$stmt->execute(array($newname, $owner, $oldname));
|
||||
}
|
||||
|
||||
public static function cleanup() {
|
||||
$albums = self::find(OC_User::getUser());
|
||||
while ($r = $albums->fetchRow()) {
|
||||
OC_Gallery_Photo::removeByAlbumId($r['album_id']);
|
||||
self::remove(OC_User::getUser(), $r['album_name']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function remove($owner, $name=null) {
|
||||
$sql = 'DELETE FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
|
||||
|
@ -69,7 +77,8 @@ class OC_Gallery_Album {
|
|||
$sql .= ' AND album_path = ?';
|
||||
$args[] = $path;
|
||||
}
|
||||
$sql .= ' ORDER BY album_name ASC';
|
||||
$order = OC_Appconfig::getValue('gallery', 'order', 'ASC');
|
||||
$sql .= ' ORDER BY album_name ' . $order;
|
||||
|
||||
$stmt = OC_DB::prepare($sql);
|
||||
return $stmt->execute($args);
|
||||
|
|
|
@ -9,7 +9,10 @@ $l = new OC_L10N('gallery');
|
|||
<div id="controls">
|
||||
<div id="scan">
|
||||
<div id="scanprogressbar"></div>
|
||||
<input type="button" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" />
|
||||
<input type="button" id="g-scan-button" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" />
|
||||
</div>
|
||||
<div id="g-settings">
|
||||
<input type="button" id="g-settings-button" value="<?php echo $l->t('Settings');?>" onclick="javascript:settings();"/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallery_list">
|
||||
|
@ -28,3 +31,26 @@ $l = new OC_L10N('gallery');
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<div id="g-dialog-settings" title="<?php echo $l->t('Settings');?>" style="display:none">
|
||||
<form>
|
||||
<fieldset><?php $root = OC_Appconfig::getValue('gallery', 'root', '/'); $order = OC_Appconfig::getValue('gallery', 'order', 'ASC');?>
|
||||
<label for="name"><?php echo $l->t('Scanning root');?></label>
|
||||
<input type="text" name="g-scanning-root" id="g-scanning-root" class="text ui-widget-content ui-corner-all" value="<?php echo $root;?>" /><br/>
|
||||
|
||||
<label for="sort"><?php echo $l->t('Default sorting'); ?></label>
|
||||
<select id="g-display-order">
|
||||
<option value="ASC"<?php echo $order=='ASC'?'selected':'';?>><?php echo $l->t('Ascending'); ?></option>
|
||||
<option value="DESC"<?php echo $order=='DESC'?'selected':'';?>><?php echo $l->t('Descending'); ?></option>
|
||||
</select><br/>
|
||||
<!--
|
||||
<label for="sort"><?php echo $l->t('Thumbnails size'); ?></label>
|
||||
<select>
|
||||
<option value="100">100px</option>
|
||||
<option value="150">150px</option>
|
||||
<option value="200">200px</option>
|
||||
</select>
|
||||
-->
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue