Initial revision

This commit is contained in:
Robert Gaggl 2001-06-18 08:57:33 +00:00
parent 1ba4e8011b
commit bbfcb3d4f4
104 changed files with 3100 additions and 0 deletions

14
code/ImageMgr/create.hac Normal file
View file

@ -0,0 +1,14 @@
// check if user is logged in and is the owner of this weblog
this.checkPermissions();
if (req.data.submit == "cancel")
res.redirect(this.href());
newImg = this.evalNewImg();
res.skin = "main";
res.title = "Antville - " + this.__parent__.title;
res.head = this.__parent__.renderSkinAsString("style");
res.body = this.__parent__.renderSkinAsString("header");
res.body += newImg.renderSkinAsString("new");

21
code/ImageMgr/macros.js Normal file
View file

@ -0,0 +1,21 @@
/**
* macro renders imagepool as list
*/
function images_macro(param) {
renderPrefix(param);
for (var i=0;i<this.size();i++) {
this.get(i).renderSkin("preview");
}
renderSuffix(param);
}
/**
* macro renders editor for chosen image
*/
function imageeditor_macro(param) {
renderPrefix(param);
renderSuffix(param);
}

9
code/ImageMgr/main.hac Normal file
View file

@ -0,0 +1,9 @@
// check if user is logged in and is the owner of this weblog
this.checkPermissions();
res.skin = "main";
res.title = "Antville - " + this.__parent__.title;
res.head = this.__parent__.renderSkinAsString("style");
res.body = this.__parent__.renderSkinAsString("header");
res.body += this.renderSkinAsString("main");

2
code/ImageMgr/main.skin Normal file
View file

@ -0,0 +1,2 @@
<P><% this.images %></P>
<P><% this.link to="create" text="add new image" %></P>

View file

@ -0,0 +1,96 @@
/**
* function checks if image fits to the minimal needs
*/
function evalNewImg() {
var newImg = new image();
var rawimage = req.get("rawimage");
if (req.get("uploadError")) {
// looks like the file uploaded has exceeded uploadLimit ...
res.message = "File too big to handle!";
} else if (rawimage) {
if (rawimage.contentLength == 0) {
// looks like nothing was uploaded ...
res.message = "Please upload an image and fill out the form ...";
} else {
// first, check if alias already exists
if (!req.data.alias)
res.message = "You must enter an alias for this image!";
else if (this.get(req.data.alias))
res.message = "There is already an image with this alias!";
else {
newImg.filename = req.data.alias;
newImg.cache.saveTo = getProperty("imgPath") + this.__parent__.alias + "/";
// check if user wants to resize width
if (req.data.maxWidth)
newImg.cache.maxWidth = parseInt(req.data.maxWidth,10);
// check if user wants to resize height
if (req.data.maxHeight)
newImg.cache.maxHeight = parseInt(req.data.maxHeight,10);
// save/resize the image
newImg.saveImg(rawimage);
// any errors?
if (!newImg.cache.error) {
// the image is on disk, so we add the image-object
this.addImg(newImg);
res.redirect(this.href());
}
}
}
}
return (newImg);
}
/**
* function adds an image to pool
*/
function addImg(newImg) {
newImg.alias = req.data.alias;
newImg.alttext = req.data.alttext;
newImg.creator = user;
newImg.createtime = new Date();
if (this.add(newImg))
res.message = "The image " + newImg.alias + " was added successfully!";
else
res.message = "Ooops! Adding the image " + newImg.alias + " failed!";
return;
}
/**
* alias of image has changed, so we remove it and add it again with it's new alias
*/
function changeAlias(currImg) {
// var oldAlias = currImg.alias;
currImg.setParent(this);
this.remove(currImg);
this.set(currImg.alias,null);
currImg.alias = req.data.alias;
this.add(currImg);
return;
}
/**
* delete an image
*/
function deleteImage(currImg) {
currImg.setParent(this);
// first we try to remove the image from disk
var f = new File(getProperty("imgPath") + currImg.weblog.alias, currImg.filename + "." + currImg.fileext);
if (f.remove()) {
if (this.remove(currImg))
res.message = "The image was deleted successfully!";
else
res.message = "Ooops! Couldn't delete the image!";
} else
res.message = "Ooops! Couldn't remove the image from disk!";
res.redirect(this.href("main"));
}

View file

@ -0,0 +1,14 @@
/**
* function checks if user is allowed to add/edit images of this weblog
*/
function checkPermissions() {
if (!user.uid) {
res.message = "Please login before!";
user.cache.referer = this.href();
res.redirect(this.__parent__.members.href("login"));
} else if (this.__parent__.owner != user) {
res.message = "Sorry, you're not allowed to edit images";
res.redirect(this.href());
}
}

View file

@ -0,0 +1,5 @@
_subnodes=<image.WEBLOG_ID
_properties=image.ALIAS
_properties.aresubnodes=true
_subnodes.order=CREATETIME desc
_subnodes.loadmode=aggressive