moving gallery op to one file, migrate gallery dialogs to oc dialogs
This commit is contained in:
parent
f06858689f
commit
c411826fe5
|
@ -88,6 +88,22 @@ function handleStoreSettings($root, $order) {
|
|||
OC_JSON::success(array('rescan' => $rescan));
|
||||
}
|
||||
|
||||
|
||||
function handleGetGalleries() {
|
||||
$a = array();
|
||||
|
||||
$result = OC_Gallery_Album::find(OC_User::getUser());
|
||||
|
||||
while ($r = $result->fetchRow()) {
|
||||
$album_name = $r['album_name'];
|
||||
$tmp_res = OC_Gallery_Photo::find($r['album_id']);
|
||||
|
||||
$a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png');
|
||||
}
|
||||
|
||||
OC_JSON::success(array('albums'=>$a));
|
||||
}
|
||||
|
||||
if ($_GET['operation']) {
|
||||
switch($_GET['operation']) {
|
||||
case 'rename':
|
||||
|
@ -113,6 +129,9 @@ if ($_GET['operation']) {
|
|||
case 'store_settings':
|
||||
handleStoreSettings($_GET['root'], $_GET['order']);
|
||||
break;
|
||||
case 'get_galleries':
|
||||
handleGetGalleries();
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('cause' => 'Unknown operation'));
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - gallery application
|
||||
*
|
||||
* @author Bartek Przybylski
|
||||
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('gallery');
|
||||
|
||||
$a = array();
|
||||
|
||||
$result = OC_Gallery_Album::find(OC_User::getUser());
|
||||
|
||||
while ($r = $result->fetchRow()) {
|
||||
$album_name = $r['album_name'];
|
||||
$tmp_res = OC_Gallery_Photo::find($r['album_id']);
|
||||
|
||||
$a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png');
|
||||
}
|
||||
|
||||
OC_JSON::success(array('albums'=>$a));
|
||||
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
var actual_cover;
|
||||
$(document).ready(function() {
|
||||
$.getJSON('ajax/getAlbums.php', function(r) {
|
||||
$.getJSON('ajax/galleryOp.php', {operation: 'get_galleries'}, function(r) {
|
||||
if (r.status == 'success') {
|
||||
for (var i in r.albums) {
|
||||
var a = r.albums[i];
|
||||
|
@ -81,71 +81,39 @@ function scanForAlbums(cleanup) {
|
|||
}
|
||||
|
||||
function galleryRemove(albumName) {
|
||||
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
|
||||
$( "#dialog:ui-dialog" ).dialog( "destroy" );
|
||||
$('#albumName', $("#dialog-confirm")).text(albumName);
|
||||
|
||||
$( '#dialog-confirm' ).dialog({
|
||||
resizable: false,
|
||||
height:150,
|
||||
buttons: [{
|
||||
text: t('gallery', 'OK'),
|
||||
click: function() {
|
||||
$.getJSON("ajax/galleryOp.php", {operation: "remove", name: albumName}, function(r) {
|
||||
if (r.status == "success") {
|
||||
$(".gallery_album_box").filterAttr('data-album',albumName).remove();
|
||||
Albums.remove(albumName);
|
||||
} else {
|
||||
alert("Error: " + r.cause);
|
||||
}
|
||||
$('#dialog-confirm').dialog('close');
|
||||
});
|
||||
}},
|
||||
{
|
||||
text: t('gallery', 'Cancel'),
|
||||
click: function() {
|
||||
$( this ).dialog( 'close' );
|
||||
}}]
|
||||
OC.dialogs.confirm(t('gallery', 'Do you want to remove album ') + decodeURIComponent(escape(albumName)),
|
||||
t('gallery', 'Remove confirmation'),
|
||||
function(decision) {
|
||||
if (decision) {
|
||||
$.getJSON("ajax/galleryOp.php", {operation: "remove", name: decodeURIComponent(escape(albumName))}, function(r) {
|
||||
if (r.status == "success") {
|
||||
$(".gallery_album_box").filterAttr('data-album',albumName).remove();
|
||||
Albums.remove(albumName);
|
||||
} else {
|
||||
OC.dialogs.alert(r.cause, "Error");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function galleryRename(name) {
|
||||
$('#name', $('#dialog-form')).val(name);
|
||||
$( "#dialog-form" ).dialog({
|
||||
height: 140,
|
||||
width: 350,
|
||||
modal: false,
|
||||
buttons: [{
|
||||
text: t('gallery', 'Change name'),
|
||||
click: function() {
|
||||
var newname = $('#name', $('#dialog-form')).val();
|
||||
if (newname == name || newname == '') {
|
||||
$(this).dialog("close");
|
||||
return;
|
||||
}
|
||||
if (Albums.find(newname)) {
|
||||
alert("Album ", newname, " exists");
|
||||
$(this).dialog("close");
|
||||
return;
|
||||
}
|
||||
$.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');
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('gallery', 'Cancel'),
|
||||
click: function() {
|
||||
$( this ).dialog('close');
|
||||
}
|
||||
}
|
||||
],
|
||||
OC.dialogs.prompt(t('gallery', 'New album name'),
|
||||
t('gallery', 'Change name'),
|
||||
name,
|
||||
function(newname) {
|
||||
if (newname == name || newname == '') return;
|
||||
if (Albums.find(newname)) {
|
||||
OC.dialogs.alert('Album ' + newname + ' exists', 'Alert');
|
||||
return;
|
||||
}
|
||||
$.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 {
|
||||
OC.dialogs.alert('Error: ' + r.cause, 'Error');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class OC_Gallery_Scanner {
|
|||
}
|
||||
$current_album['imagesCount'] = count($current_album['images']);
|
||||
$albums['imagesCount'] = $current_album['imagesCount'];
|
||||
$albums['albumName'] = $current_album['name'];
|
||||
$albums['albumName'] = utf8_encode($current_album['name']);
|
||||
|
||||
$result = OC_Gallery_Album::find(OC_User::getUser(), /*$current_album['name']*/ null, $path);
|
||||
// don't duplicate galleries with same path (bug oc-33)
|
||||
|
|
|
@ -52,7 +52,7 @@ OCdialogs = {
|
|||
*/
|
||||
confirm:function(text, title, callback) {
|
||||
var content = '<p><span class="ui-icon ui-icon-notice"></span>'+text+'</p>';
|
||||
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTON, callback);
|
||||
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback);
|
||||
},
|
||||
/**
|
||||
* prompt for user input
|
||||
|
@ -60,8 +60,8 @@ OCdialogs = {
|
|||
* @param title dialog title
|
||||
* @param callback which will be triggered when user press OK (input text will be passed to callback)
|
||||
*/
|
||||
prompt:function(text, title, callback) {
|
||||
var content = '<p><span class="ui-icon ui-icon-pencil"></span>'+text+':<br/><input type="text" id="oc-dialog-prompt-input" style="width:90%"></p>';
|
||||
prompt:function(text, title, default_value, callback) {
|
||||
var content = '<p><span class="ui-icon ui-icon-pencil"></span>'+text+':<br/><input type="text" id="oc-dialog-prompt-input" value="'+default_value+'" style="width:90%"></p>';
|
||||
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback);
|
||||
},
|
||||
/**
|
||||
|
@ -131,15 +131,19 @@ OCdialogs = {
|
|||
}
|
||||
return $(element).val();
|
||||
},
|
||||
prompt_ok_handler: function(callback, c_id){callback(true, $(c_id + " input#oc-dialog-prompt-input").val()); $(c_id).dialog('close');},
|
||||
prompt_ok_handler: function(callback, c_id) { $(c_id).dialog('close'); if (callback != undefined) callback($(c_id + " input#oc-dialog-prompt-input").val()); },
|
||||
form_ok_handler: function(callback, c_id) {
|
||||
var r = [];
|
||||
var c = 0;
|
||||
$(c_id + ' input').each(function(i, elem) {
|
||||
r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)};
|
||||
c++;
|
||||
});
|
||||
$(c_id).dialog('close');
|
||||
callback(r);
|
||||
if (callback != undefined) {
|
||||
var r = [];
|
||||
var c = 0;
|
||||
$(c_id + ' input').each(function(i, elem) {
|
||||
r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)};
|
||||
c++;
|
||||
});
|
||||
$(c_id).dialog('close');
|
||||
callback(r);
|
||||
} else {
|
||||
$(c_id).dialog('close');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue