* Fixed and finalized Layout.reset_action() as well as Layout.remove() and Skin.remove() methods
* Completely render skin outline and drop down menu from application directory * Moved remaining skins into protected (ie. non-customizable) skin files * Removed obsolete skin files * Removed obsolete code
This commit is contained in:
parent
dff39778a6
commit
75ff272950
9 changed files with 232 additions and 461 deletions
|
@ -534,3 +534,27 @@ default front page.</span></td>
|
|||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<%
|
||||
////////////////////// Notification skins
|
||||
%>
|
||||
|
||||
<% #block %>
|
||||
(You're receiving this mail because you are Administrator of <% param.site %>).
|
||||
|
||||
<% param.site %> (<% param.url %>) has been private for more than <% param.privatetime %> days. Due to policy reasons your site will be blocked in <% param.daysleft %> days if you keep it private. This does *not* mean that your site will be removed, but neither you nor other members of it will have access to <% param.site %> unless one of the system administrators decides to unblock your site.
|
||||
|
||||
So please either change the preferences of your site (select the checkbox "public") or send a mail to <% param.contact %> containing reasons why your site should stay private.
|
||||
|
||||
---------------------------------------
|
||||
<% root.title %> - <% root.url %>
|
||||
---------------------------------------
|
||||
|
||||
<& #delete %>
|
||||
(You're receiving this mail because you are Administrator of <% param.site %>).
|
||||
|
||||
<% param.site %> (<% param.url %>) was inactive for more than <% param.inactivity %> days. You have <% param.daysleft %> days time to reactivate your site, otherwise it will be deleted. Please note that the removal of <% param.site %> is an irreversible process!
|
||||
|
||||
---------------------------------------
|
||||
<% root.title %> - <% root.url %>
|
||||
---------------------------------------
|
|
@ -540,12 +540,12 @@ Admin.prototype.deleteInactiveSites = function() {
|
|||
if (site.trusted)
|
||||
continue;
|
||||
|
||||
var idleFor = new Date() - site.lastupdate;
|
||||
var idleFor = new Date() - site.modified;
|
||||
var timeSinceWarning = new Date() - site.lastdelwarn;
|
||||
if (idleFor >= warnThreshold) {
|
||||
// check if site-admins have been warned already
|
||||
var alreadyWarned = false;
|
||||
if (site.lastdelwarn > site.lastupdate)
|
||||
if (site.lastdelwarn > site.modified)
|
||||
alreadyWarned = true;
|
||||
// check whether warn admins or block site
|
||||
if (!alreadyWarned) {
|
||||
|
|
|
@ -32,7 +32,6 @@ sites.accessname = name
|
|||
sites.order = created desc
|
||||
|
||||
privateSites = collection(Site)
|
||||
#privateSites.order = SITE_LASTOFFLINE asc
|
||||
privateSites.filter = mode = 'private' and status <> 'blocked'
|
||||
|
||||
users = collection(User)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<% #block %>
|
||||
(You're receiving this mail because you are Administrator of <% param.site %>).
|
||||
|
||||
<% param.site %> (<% param.url %>) has been private for more than <% param.privatetime %> days. Due to policy reasons your site will be blocked in <% param.daysleft %> days if you keep it private. This does *not* mean that your site will be removed, but neither you nor other members of it will have access to <% param.site %> unless one of the system administrators decides to unblock your site.
|
||||
|
||||
So please either change the preferences of your site (select the checkbox "public") or send a mail to <% param.contact %> containing reasons why your site should stay private.
|
||||
|
||||
---------------------------------------
|
||||
<% root.title %> - <% root.url %>
|
||||
---------------------------------------
|
||||
|
||||
<& #delete %>
|
||||
(You're receiving this mail because you are Administrator of <% param.site %>).
|
||||
|
||||
<% param.site %> (<% param.url %>) was inactive for more than <% param.inactivity %> days. You have <% param.daysleft %> days time to reactivate your site, otherwise it will be deleted. Please note that the removal of <% param.site %> is an irreversible process!
|
||||
|
||||
---------------------------------------
|
||||
<% root.title %> - <% root.url %>
|
||||
---------------------------------------
|
|
@ -22,6 +22,32 @@
|
|||
// $URL$
|
||||
//
|
||||
|
||||
Layout.VALUES = [
|
||||
"background color",
|
||||
"link color",
|
||||
"active link color",
|
||||
"visited link color",
|
||||
"big font",
|
||||
"big font size",
|
||||
"big font color",
|
||||
"base font",
|
||||
"base font size",
|
||||
"base font color",
|
||||
"small font",
|
||||
"small font size",
|
||||
"small font color"
|
||||
];
|
||||
|
||||
Layout.remove = function(layout) {
|
||||
layout || (layout = this);
|
||||
if (layout.constructor === Layout) {
|
||||
Skins.remove.call(layout.skins);
|
||||
Images.remove.call(layout.images);
|
||||
layout.getFile().removeDirectory();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Layout.getModes = defineConstants(Layout, "default", "shared");
|
||||
|
||||
this.handleMetadata("title");
|
||||
|
@ -118,18 +144,22 @@ Layout.prototype.update = function(data) {
|
|||
return;
|
||||
}
|
||||
|
||||
Layout.remove = function() {
|
||||
Skins.remove.call(this.skins);
|
||||
this.getFile().removeDirectory();
|
||||
Images.remove.call(this.images);
|
||||
return;
|
||||
}
|
||||
|
||||
Layout.prototype.reset_action = function() {
|
||||
if (req.postParams.proceed) {
|
||||
if (req.data.proceed) {
|
||||
try {
|
||||
Skins.remove.call(this.skins);
|
||||
this.getFile().removeDirectory();
|
||||
Layout.remove.call(this);
|
||||
var skinFiles = app.getSkinfilesInPath(res.skinpath);
|
||||
var content, file;
|
||||
for (var name in skinFiles) {
|
||||
if (content = skinFiles[name][name]) {
|
||||
var dir = this.getFile(name);
|
||||
var file = new helma.File(dir, name + ".skin");
|
||||
dir.makeDirectory();
|
||||
file.open();
|
||||
file.write(content);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
res.message = gettext("The layout was successfully reset.");
|
||||
res.redirect(this.href());
|
||||
} catch(ex) {
|
||||
|
@ -207,42 +237,8 @@ Layout.prototype.import_action = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
Layout.prototype.getMacroHandler = function(name) {
|
||||
switch (name) {
|
||||
case "skins":
|
||||
return this[name];
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Layout.prototype.image_macro = function(param, name, mode) {
|
||||
name || (name = param.name);
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
var image = this.getImage(name, param.fallback);
|
||||
if (!image) {
|
||||
return;
|
||||
}
|
||||
|
||||
mode || (mode = param.as);
|
||||
var action = param.linkto;
|
||||
delete(param.name);
|
||||
delete(param.as);
|
||||
delete(param.linkto);
|
||||
|
||||
switch (mode) {
|
||||
case "url" :
|
||||
return res.write(image.getUrl());
|
||||
case "thumbnail" :
|
||||
action || (action = image.getUrl());
|
||||
return image.thumbnail_macro(param);
|
||||
}
|
||||
image.render_macro(param);
|
||||
return;
|
||||
Layout.prototype.getTitle = function() {
|
||||
return "Layout";
|
||||
}
|
||||
|
||||
Layout.prototype.getImage = function(name, fallback) {
|
||||
|
@ -269,14 +265,9 @@ Layout.prototype.getSkinPath = function() {
|
|||
return null;
|
||||
}
|
||||
var skinPath = [this.getFile().toString()];
|
||||
//this.parent && (skinPath.push(this.parent.getFile().toString()));
|
||||
return skinPath;
|
||||
}
|
||||
|
||||
Layout.prototype.getTitle = function() {
|
||||
return "Layout";
|
||||
}
|
||||
|
||||
Layout.prototype.getArchive = function(skinpath) {
|
||||
var zip = new helma.Zip();
|
||||
for each (var fpath in skinpath) {
|
||||
|
@ -316,15 +307,46 @@ Layout.prototype.getArchive = function(skinpath) {
|
|||
return zip;
|
||||
}
|
||||
|
||||
Layout.prototype.getMacroHandler = function(name) {
|
||||
switch (name) {
|
||||
case "skins":
|
||||
return this[name];
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Layout.prototype.image_macro = function(param, name, mode) {
|
||||
name || (name = param.name);
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
var image = this.getImage(name, param.fallback);
|
||||
if (!image) {
|
||||
return;
|
||||
}
|
||||
|
||||
mode || (mode = param.as);
|
||||
var action = param.linkto;
|
||||
delete(param.name);
|
||||
delete(param.as);
|
||||
delete(param.linkto);
|
||||
|
||||
switch (mode) {
|
||||
case "url" :
|
||||
return res.write(image.getUrl());
|
||||
case "thumbnail" :
|
||||
action || (action = image.getUrl());
|
||||
return image.thumbnail_macro(param);
|
||||
}
|
||||
image.render_macro(param);
|
||||
return;
|
||||
}
|
||||
|
||||
Layout.prototype.values_macro = function() {
|
||||
/* FIXME: should be enough to render res.meta.values in HopObject.onRequest
|
||||
res.push();
|
||||
var skin = new Skin("Site", "values");
|
||||
skin.render();
|
||||
res.pop();
|
||||
*/
|
||||
var values = [];
|
||||
//for each (var key in Layout.VALUES) {
|
||||
for (var key in res.meta.values) {
|
||||
values.push({key: key, value: res.meta.values[key]});
|
||||
}
|
||||
|
@ -337,19 +359,3 @@ Layout.prototype.values_macro = function() {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Layout.VALUES = [
|
||||
"background color",
|
||||
"link color",
|
||||
"active link color",
|
||||
"visited link color",
|
||||
"big font",
|
||||
"big font size",
|
||||
"big font color",
|
||||
"base font",
|
||||
"base font size",
|
||||
"base font color",
|
||||
"small font",
|
||||
"small font size",
|
||||
"small font color"
|
||||
]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<p class="storyTitle"><% response.title %></p>
|
||||
<% response.message prefix='<div class="message">' suffix="</div>" %>
|
||||
<form method="post" action="<% response.action %>">
|
||||
<% if <% skin.name %> is null then
|
||||
<% if <% skin.name %> is "" then
|
||||
<% skin.select prototype prefix=<% gettext Prototype suffix=": " %>
|
||||
suffix=<% skin.input name prefix=<% gettext Name suffix=": " %> %> %>
|
||||
else
|
||||
|
@ -12,7 +12,7 @@ else
|
|||
<tr>
|
||||
<td valign="top" nowrap="nowrap">
|
||||
<textarea name="source" cols="50" rows="23" wrap="virtual"
|
||||
class="formWide"><% skin.source encoding="form" %></textarea>
|
||||
class="formWide"><% skin.content encoding="form" %></textarea>
|
||||
<p>
|
||||
<button type="submit" name="save" value="2">
|
||||
<% gettext "Save and close" %>
|
||||
|
@ -28,7 +28,7 @@ else
|
|||
<% #listItem %>
|
||||
<li>
|
||||
<% skin.link edit <% skin.name prefix=<% skin.prototype suffix="." %> %> %>
|
||||
<% if <% skin.status %> is modified then
|
||||
<% if <% skin.created %> is null then "" else
|
||||
<% skin.skin $Skin#status prefix="<div>" suffix="</div>" %>
|
||||
%>
|
||||
<% // skin.summary prefix="<div>" suffix="</div>" %>
|
||||
|
@ -36,11 +36,9 @@ else
|
|||
|
||||
<% #status %>
|
||||
<span class="small">
|
||||
(<% gettext "Modified by {0}" <% skin.creator %> %><% if <% skin.custom %> is false then
|
||||
<% skin.link compare prefix=" ... " suffix=<% skin.link reset prefix=" ... " %> %>
|
||||
else
|
||||
<% skin.link restore prefix=" ... " %>
|
||||
%>)<br />
|
||||
(<% gettext "Modified by {0}" <% skin.creator %> %>
|
||||
<% skin.link compare prefix=" ... " %>
|
||||
<% skin.link reset prefix=" ... " %>)<br />
|
||||
<strong><% gettext Macro suffix=: %></strong>
|
||||
<% <% skin.prototype suffix="." | lowercase %>skin <% skin.name %> %>
|
||||
</span>
|
||||
|
|
|
@ -21,17 +21,42 @@
|
|||
// $URL$
|
||||
//
|
||||
|
||||
Skin.CUSTOMIZABLE_PROTOTYPES = ["Archive", "Choice", "Comment", "File",
|
||||
"Global", "Image", "Membership", "Poll", "Site", "Story", "Tag"];
|
||||
Skin.remove = function(skin) {
|
||||
skin || (skin = this);
|
||||
if (skin.constructor === Skin) {
|
||||
if (skin.source) {
|
||||
skin.setSource(skin.source);
|
||||
}
|
||||
skin.source = null;
|
||||
skin.remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Skin.getPrototypeOptions = function() {
|
||||
var prototypes = [];
|
||||
var content, file;
|
||||
var skinFiles = app.getSkinfilesInPath(res.skinpath);
|
||||
for (var name in skinFiles) {
|
||||
if (skinFiles[name][name]) {
|
||||
prototypes.push({value: name, display: name});
|
||||
}
|
||||
}
|
||||
return prototypes.sort(new String.Sorter("display"));
|
||||
}
|
||||
|
||||
Skin.prototype.constructor = function(prototype, name) {
|
||||
this.prototype = prototype;
|
||||
this.name = name;
|
||||
this.prototype = prototype || String.EMPTY;
|
||||
this.name = name || String.EMPTY;
|
||||
this.creator = this.modifier = session.user;
|
||||
this.created = this.modified = new Date;
|
||||
return this;
|
||||
}
|
||||
|
||||
Skin.prototype.getPermission = function(action) {
|
||||
return res.handlers.skins.getPermission("main");
|
||||
}
|
||||
|
||||
Skin.prototype.href = function(action) {
|
||||
res.push();
|
||||
res.write(res.handlers.layout.skins.href());
|
||||
|
@ -43,10 +68,6 @@ Skin.prototype.href = function(action) {
|
|||
return res.pop();
|
||||
}
|
||||
|
||||
Skin.prototype.getPermission = function(action) {
|
||||
return res.handlers.skins.getPermission("main");
|
||||
}
|
||||
|
||||
Skin.prototype.main_action = function() {
|
||||
return res.redirect(this.href("edit"));
|
||||
}
|
||||
|
@ -56,15 +77,6 @@ Skin.prototype.edit_action = function() {
|
|||
try {
|
||||
var url = this.href(req.action);
|
||||
this.update(req.postParams);
|
||||
/*
|
||||
// FIXME:
|
||||
if (false && this.equals(req.postParams.source)) {
|
||||
Skin.remove.call(this);
|
||||
url = Skins.getRedirectUrl(req.postParams);
|
||||
} else {
|
||||
this.setSource(req.postParams.source);
|
||||
}
|
||||
*/
|
||||
res.message = gettext("The changes were saved successfully.");
|
||||
if (req.postParams.save == 1) {
|
||||
res.redirect(url);
|
||||
|
@ -84,48 +96,22 @@ Skin.prototype.edit_action = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
Skin.prototype.getFormOptions = function(name) {
|
||||
switch (name) {
|
||||
case "prototype":
|
||||
return Skin.getPrototypeOptions();
|
||||
}
|
||||
}
|
||||
|
||||
Skin.getPrototypeOptions = function() {
|
||||
var prototypes = [];
|
||||
for each (var name in Skin.CUSTOMIZABLE_PROTOTYPES) {
|
||||
prototypes.push({value: name, display: name});
|
||||
}
|
||||
return prototypes.sort(new String.Sorter("display"));
|
||||
}
|
||||
|
||||
Skin.prototype.update = function(data) {
|
||||
if (this.isTransient()) {
|
||||
this.source = this.getSource();
|
||||
res.handlers.layout.skins.add(this);
|
||||
this.source = this.getSource();
|
||||
}
|
||||
this.setSource(data.source);
|
||||
this.touch();
|
||||
return;
|
||||
}
|
||||
|
||||
Skin.remove = function() {
|
||||
if (this.source) {
|
||||
this.setSource(this.source);
|
||||
delete this.source;
|
||||
} else {
|
||||
this.setSource();
|
||||
}
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
Skin.prototype.reset_action = function() {
|
||||
if (req.postParams.proceed) {
|
||||
try {
|
||||
var str = this.toString();
|
||||
this.setSource(this.source);
|
||||
this.remove();
|
||||
res.debug(this.source);
|
||||
Skin.remove(this);
|
||||
res.message = gettext("{0} was successfully reset.", str);
|
||||
res.redirect(res.handlers.layout.skins.href("modified"));
|
||||
} catch(ex) {
|
||||
|
@ -139,17 +125,12 @@ Skin.prototype.reset_action = function() {
|
|||
res.data.body = this.renderSkinAsString("$HopObject#confirm", {
|
||||
text: gettext('You are about to reset {0}.', this)
|
||||
});
|
||||
res.handlers.site.renderSkin("Site#page");
|
||||
res.handlers.skins.renderSkin("$Skins#page");
|
||||
return;
|
||||
}
|
||||
|
||||
Skin.prototype.compare_action = function() {
|
||||
// get the modified and original skins
|
||||
var originalSkin = this.source;
|
||||
|
||||
if (!originalSkin) {
|
||||
res.data.status = gettext("This is a custom skin, therefor no differences can be displayed");
|
||||
} else {
|
||||
var originalSkin = this.source || "";
|
||||
var diff = originalSkin.diff(this.getSource());
|
||||
if (!diff) {
|
||||
res.data.status = gettext("No differences were found");
|
||||
|
@ -186,7 +167,6 @@ Skin.prototype.compare_action = function() {
|
|||
}
|
||||
res.data.diff = res.pop();
|
||||
}
|
||||
}
|
||||
res.data.title = gettext("Compare versions of skin {0}.{1}",
|
||||
this.prototype, this.name);
|
||||
res.data.body = this.renderSkinAsString("$Skin#compare");
|
||||
|
@ -194,32 +174,25 @@ Skin.prototype.compare_action = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
Skin.prototype.status_macro = function() {
|
||||
return this.isTransient() ? "inherited" : "modified";
|
||||
}
|
||||
|
||||
Skin.prototype.summary_macro = function() {
|
||||
return Skins.getSummary("skin", this.prototype, this.name);
|
||||
}
|
||||
|
||||
Skin.prototype.source_macro = function() {
|
||||
return res.write(this.getSource());
|
||||
Skin.prototype.getFormOptions = function(name) {
|
||||
switch (name) {
|
||||
case "prototype":
|
||||
return Skin.getPrototypeOptions();
|
||||
}
|
||||
}
|
||||
|
||||
Skin.prototype.getSource = function() {
|
||||
var skinFiles = app.getSkinfilesInPath(res.skinpath)[this.prototype];
|
||||
if (!skinFiles) {
|
||||
return String.EMPTY;
|
||||
var skinSet = app.getSkinfilesInPath(res.skinpath)[this.prototype];
|
||||
if (skinSet) {
|
||||
var mainSkin = skinSet[this.prototype];
|
||||
if (mainSkin) {
|
||||
var skin = createSkin(mainSkin).getSubskin(this.name);
|
||||
if (skin) {
|
||||
return skin.getSource();
|
||||
}
|
||||
var source = skinFiles[this.name];
|
||||
if (!source) {
|
||||
// FIXME: Strange, the subskin can be rendered but it's not found
|
||||
// in app.getSkinFilesInPath() ...
|
||||
//global[this.prototype].prototype.renderSkin(this.prototype + "#" + this.name);
|
||||
skin = createSkin(skinFiles[this.prototype]).getSubskin(this.name);
|
||||
source = skin && skin.getSource();
|
||||
}
|
||||
return source || String.EMPTY;
|
||||
}
|
||||
return null; //String.EMPTY;
|
||||
}
|
||||
|
||||
Skin.prototype.setSource = function(source) {
|
||||
|
@ -272,11 +245,6 @@ Skin.prototype.getMainSkin = function() {
|
|||
return null;
|
||||
}
|
||||
|
||||
Skin.prototype.custom_macro = function() {
|
||||
// FIXME:
|
||||
return false;
|
||||
}
|
||||
|
||||
Skin.prototype.render = function() {
|
||||
return renderSkin(createSkin(this.getSource()));
|
||||
}
|
||||
|
@ -293,3 +261,11 @@ Skin.prototype.equals = function(source) {
|
|||
Skin.prototype.toString = function() {
|
||||
return "Skin #" + this._id + ": " + this.prototype + "." + this.name;
|
||||
}
|
||||
|
||||
Skin.prototype.status_macro = function() {
|
||||
return this.isTransient() ? "inherited" : "modified";
|
||||
}
|
||||
|
||||
Skin.prototype.content_macro = function() {
|
||||
return res.write(this.getSource());
|
||||
}
|
||||
|
|
|
@ -34,34 +34,18 @@ Skins.prototype.getPermission = function(action) {
|
|||
|
||||
Skins.prototype.getChildElement = function(name) {
|
||||
if (this.parent) {
|
||||
var groupName = path[path.length - 1].name;
|
||||
var group = this.parent.get(groupName);
|
||||
if (group) {
|
||||
var skin = group.get(name);
|
||||
var group = path[path.length - 1].name;
|
||||
var skin = this.getSkin(group, name);
|
||||
if (skin) {
|
||||
return skin;
|
||||
}
|
||||
}
|
||||
if (global[groupName] || groupName === "Global") {
|
||||
return new Skin(groupName, name);
|
||||
if (global[group] || group === "Global") {
|
||||
return this.getSkin(group, name);
|
||||
}
|
||||
}
|
||||
return new Skins(name, this);
|
||||
}
|
||||
|
||||
// FIXME: It's not totally clear why this is necessary;
|
||||
// but somehow Helma does not provide the correct path...
|
||||
// FIXME 2: Probably obsolete thanks to a custom Layout.href() method
|
||||
/*
|
||||
Skins.prototype.href = function(action) {
|
||||
res.push();
|
||||
res.write(res.handlers.site.href());
|
||||
res.write("layout/skins/");
|
||||
action && (res.write(action));
|
||||
return res.pop();
|
||||
}
|
||||
*/
|
||||
|
||||
Skins.prototype.main_action = function() {
|
||||
if (!this._parent) {
|
||||
res.redirect(res.handlers.layout.skins.href());
|
||||
|
@ -112,8 +96,7 @@ Skins.prototype.getOutline = function(type) {
|
|||
html.closeTag("a");
|
||||
html.openTag("ul");
|
||||
for each (var name in skin) {
|
||||
subskin = this.getSkin(prototype, name) ||
|
||||
new Skin(prototype, name);
|
||||
subskin = this.getSkin(prototype, name);
|
||||
subskin.renderSkin("$Skin#listItem");
|
||||
}
|
||||
html.closeTag("ul");
|
||||
|
@ -124,13 +107,13 @@ Skins.prototype.getOutline = function(type) {
|
|||
};
|
||||
|
||||
Skins.prototype.create_action = function() {
|
||||
var skin = new Skin(req.data.prototype, req.data.name);
|
||||
var skin = this.getSkin(req.postParams.prototype, req.postParams.name);
|
||||
if (req.postParams.save) {
|
||||
try {
|
||||
if (!skin.equals(req.postParams.source)) {
|
||||
skin.setSource(req.postParams.source);
|
||||
this.add(skin);
|
||||
if (!req.postParams.prototype || !req.postParams.name) {
|
||||
throw Error("Please choose a prototype and enter a skin name");
|
||||
}
|
||||
skin.update(req.postParams);
|
||||
res.message = gettext("The changes were saved successfully.");
|
||||
if (req.postParams.save == 1) {
|
||||
res.redirect(skin.href("edit"));
|
||||
|
@ -141,7 +124,7 @@ Skins.prototype.create_action = function() {
|
|||
res.message = ex;
|
||||
app.log(ex);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (skin.getSource()) {
|
||||
res.data.title = gettext("Edit skin {0}.{1} of {2}",
|
||||
skin.prototype, skin.name, res.handlers.site.title);
|
||||
|
@ -149,7 +132,6 @@ Skins.prototype.create_action = function() {
|
|||
res.data.title = gettext('Create a custom skin of {0}',
|
||||
res.handlers.site.title);
|
||||
}
|
||||
}
|
||||
res.data.action = this.href(req.action);
|
||||
res.data.body = skin.renderSkinAsString("$Skin#edit");
|
||||
this.renderSkin("$Skins#page");
|
||||
|
@ -192,218 +174,23 @@ Skins.prototype.safe_action = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
Skins.prototype.getSkin = function(prototype, name) {
|
||||
var skinset = this.get(prototype);
|
||||
return skinset ? skinset.get(name) : null;
|
||||
}
|
||||
|
||||
Skins.prototype.getSkinSource = function(proto, name) {
|
||||
var skin;
|
||||
if (skin = this.getSkin(proto, name)) {
|
||||
return skin.getSource();
|
||||
}
|
||||
if (app.skinfiles[proto]) {
|
||||
return app.skinfiles[proto][name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Skins.prototype.getOriginalSkin = function(proto, name) {
|
||||
var skin;
|
||||
var layout = this._parent;
|
||||
while (layout = layout.parent) {
|
||||
if (skin = layout.skins.getSkin(proto, name)) {
|
||||
Skins.prototype.getSkin = function(group, name) {
|
||||
var skinSet = path.layout.skins.get(group);
|
||||
if (skinSet) {
|
||||
var skin = skinSet.get(name);
|
||||
if (skin) {
|
||||
return skin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new Skin(group, name);
|
||||
}
|
||||
|
||||
Skins.prototype.getOriginalSkinSource = function(proto, name) {
|
||||
var skin;
|
||||
if (skin = this.getOriginalSkin(proto, name)) {
|
||||
return skin.getSource();
|
||||
Skins.remove = function(skins) {
|
||||
skins || (skins = this);
|
||||
if (skins.constructor === Skins) {
|
||||
while (skins.size() > 0) {
|
||||
HopObject.remove(skins.get(0));
|
||||
}
|
||||
if (app.skinfiles[proto]) {
|
||||
return app.skinfiles[proto][name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Skins.prototype.getCustomSkins = function() {
|
||||
var coll = [];
|
||||
// object to store the already added skin keys
|
||||
// used to avoid duplicate skins in the list
|
||||
var keys = {};
|
||||
|
||||
// private method to add a custom skin
|
||||
var addSkins = function(mgr) {
|
||||
var size = mgr.custom.size();
|
||||
for (var i=0;i<size;i++) {
|
||||
var s = mgr.custom.get(i);
|
||||
var key = s.proto + ":" + s.name;
|
||||
if (!keys[key]) {
|
||||
keys[key] = s;
|
||||
coll.push(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
var handler = this._parent;
|
||||
while (handler) {
|
||||
addSkins(handler.skins);
|
||||
handler = handler.parent;
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
|
||||
Skins.getSummary = function(prefix, prototype, name) {
|
||||
return gettext("Description of skin {0}", prototype + "." + name);
|
||||
var key = prefix + "." + prototype;
|
||||
name && (key += "." + name);
|
||||
var languages = new Array("en");
|
||||
var syslang;
|
||||
if ((syslang = root.getLocale().getLanguage()) != "en")
|
||||
languages.unshift(syslang);
|
||||
if (res.handlers.site) {
|
||||
var lang = res.handlers.site.getLocale().getLanguage();
|
||||
if (lang != "en" && lang != syslang)
|
||||
languages.unshift(lang);
|
||||
}
|
||||
var lang;
|
||||
for (var i=0; i<languages.length; i+=1) {
|
||||
if (!(lang = app.data[languages[i]])) {
|
||||
continue;
|
||||
}
|
||||
if (lang.getProperty(key)) {
|
||||
return lang.getProperty(key).split("|");
|
||||
}
|
||||
}
|
||||
return [prototype + "." + name];
|
||||
}
|
||||
|
||||
Skins.Skinset = function(key, skins, context) {
|
||||
this.key = key;
|
||||
this.skins = skins;
|
||||
this.context = context;
|
||||
this.children = [];
|
||||
this.add = function(obj) {
|
||||
this.children.push(obj);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Skins.SKINSETS = [];
|
||||
|
||||
new function() {
|
||||
var newSet = new Skins.Skinset("Root", ["Root.page", "Root.main", "Root.style", "Root.javascript", "Root.sysmgrnavigation", "Root.new"], "Root");
|
||||
newSet.add(new Skins.Skinset("Root.scripts", ["Root.systemscripts", "Global.colorpickerScripts"]));
|
||||
newSet.add(new Skins.Skinset("Root.sitelist", ["Site.preview", "Root.list"]));
|
||||
newSet.add(new Skins.Skinset("Root.rss", ["Root.rss", "Site.rssItem", "Site.rssResource", "Global.rssImage"]));
|
||||
newSet.add(new Skins.Skinset("Root.colorpicker", ["Global.colorpicker", "Global.colorpickerExt", "Global.colorpickerWidget", "Global.colorpickerScripts"]));
|
||||
newSet.add(new Skins.Skinset("Root.welcome", ["Site.welcome", "Site.welcomeowner", "Site.welcomesysadmin", "Root.welcome"]));
|
||||
newSet.add(new Skins.Skinset("Root.various", ["Root.blocked", "Root.notfound", "Root.sysError"]));
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("Site", ["Site.page", "Site.style", "Site.javascript", "Site.main", "Day.main", "Story.dayheader"]);
|
||||
newSet.add(new Skins.Skinset("Site.navigation", ["Site.contribnavigation", "Site.adminnavigation", "Global.nextpagelink", "Global.prevpagelink", "Global.pagenavigation", "Global.pagenavigationitem", "Members.statusloggedin", "Members.statusloggedout"]));
|
||||
newSet.add(new Skins.Skinset("Site.topics", ["TopicMgr.main", "Topic.main"]));
|
||||
newSet.add(new Skins.Skinset("Site.calendar", ["Site.calendar", "Site.calendardayheader", "Site.calendarweek", "Site.calendarday", "Site.calendarselday"]));
|
||||
newSet.add(new Skins.Skinset("Site.rss", ["Site.rss", "Story.rssItem", "Story.rssResource"]));
|
||||
newSet.add(new Skins.Skinset("Site.search", ["Site.searchresult", "Site.searchbox", "Story.searchview"]));
|
||||
newSet.add(new Skins.Skinset("Site.referrers", ["Site.referrers", "Site.referrerItem"]));
|
||||
newSet.add(new Skins.Skinset("Site.mostread", ["Site.mostread", "Story.mostread"]));
|
||||
newSet.add(new Skins.Skinset("Site.mails", ["Members.mailregconfirm", "Members.mailpassword", "Members.mailnewmember", "Membership.mailstatuschange", "Membership.mailmessage", "Site.notificationMail"], "Root"));
|
||||
newSet.add(new Skins.Skinset("Site.preferences", ["Site.edit", "Site.notification"], "Root"));
|
||||
newSet.add(new Skins.Skinset("Site.user", ["Members.login", "Members.register", "Members.sendpwd", "User.edit", "User.sitelist", "User.subscriptions", "Membership.subscriptionlistitem"], "Root"));
|
||||
newSet.add(new Skins.Skinset("Site.members", ["Members.main", "Members.new", "Members.membergroup", "Members.searchresult", "Members.searchresultitem", "Membership.mgrlistitem", "Membership.edit"], "Root"));
|
||||
newSet.add(new Skins.Skinset("Site.various", ["Site.robots"]));
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("Story", ["Story.display", "Story.main", "Story.preview", "Story.comment", "Story.historyview", "Story.embed", "Story.edit"]);
|
||||
newSet.add(new Skins.Skinset("Story.backlinks", ["Story.backlinks", "Story.backlinkItem"]));
|
||||
newSet.add(new Skins.Skinset("Story.list", ["StoryMgr.main", "Story.mgrlistitem"]));
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("Comment", ["Comment.toplevel", "Comment.reply", "Comment.edit"]);
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("Image", ["Image.main", "Image.edit", "ImageMgr.new", "LayoutImage.edit", "ImageMgr.main", "Image.mgrlistitem"]);
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("File", ["File.main", "File.edit", "FileMgr.new", "FileMgr.main", "File.mgrlistitem"]);
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("Poll", ["Poll.main", "Poll.results", "Choice.main", "Choice.result", "Choice.graph"]);
|
||||
newSet.add(new Skins.Skinset("Poll.editor", ["Poll.edit", "Choice.edit"]));
|
||||
newSet.add(new Skins.Skinset("Poll.list", ["PollMgr.main", "Poll.mgrlistitem"]));
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("SysMgr", ["SysMgr.status", "SysMgr.list", "Site.sysmgr_listitem", "Site.sysmgr_edit", "Site.sysmgr_delete", "User.sysmgr_listitem", "User.sysmgr_edit", "SysLog.sysmgr_listitem"], "Root");
|
||||
newSet.add(new Skins.Skinset("SysMgr.forms", ["SysMgr.setup", "SysMgr.sitesearchform", "SysMgr.usersearchform", "SysMgr.syslogsearchform"]));
|
||||
newSet.add(new Skins.Skinset("SysMgr.mails", ["SysMgr.blockwarnmail", "SysMgr.deletewarnmail"]));
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("SkinMgr", ["SkinMgr.main", "SkinMgr.page", "SkinMgr.edit", "SkinMgr.treebranch", "SkinMgr.treeleaf", "Skin.status", "Skin.statuscustom", "SkinMgr.new", "Skin.diff", "Skin.diffline"], "Root");
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("LayoutMgr", ["LayoutMgr.main", "LayoutMgr.new", "LayoutMgr.import"], "Root");
|
||||
newSet.add(new Skins.Skinset("LayoutMgr.layout", ["Layout.mgrlistitem", "Layout.main", "Layout.edit", "Layout.download", "Layout.chooserlistitem", "Layout.testdrive"]));
|
||||
newSet.add(new Skins.Skinset("LayoutMgr.images", ["LayoutImageMgr.main", "LayoutImageMgr.navigation", "LayoutImageMgr.new"]));
|
||||
Skins.SKINSETS.push(newSet);
|
||||
|
||||
newSet = new Skins.Skinset("various", ["HopObject.delete"], "Root");
|
||||
Skins.SKINSETS.push(newSet);
|
||||
}
|
||||
|
||||
Skins.buildMacroHelp = function() {
|
||||
var sorter = function(a, b) {
|
||||
var str1 = a.name.toLowerCase();
|
||||
var str2 = b.name.toLowerCase();
|
||||
if (str1 > str2)
|
||||
return 1;
|
||||
else if (str1 < str2)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
var macroHelp = {};
|
||||
var ref = macroHelp.Global = [];
|
||||
var macrolist = HELP.macros.Global;
|
||||
for (var i in macrolist)
|
||||
ref.push({name: i, storyid: macrolist[i]});
|
||||
ref.sort(sorter);
|
||||
|
||||
var ref = macroHelp.HopObject = [];
|
||||
var macrolist = HELP.macros.HopObject;
|
||||
for (var i in macrolist)
|
||||
ref.push({name: i, storyid: macrolist[i]});
|
||||
ref.sort(sorter);
|
||||
|
||||
for (var proto in HELP.macros) {
|
||||
if (proto.indexOf("_") == 0 || proto == "Global" || proto == "HopObject")
|
||||
continue;
|
||||
var macrolist = HELP.macros[proto];
|
||||
var ref = macroHelp[proto] = [];
|
||||
var keys = "";
|
||||
for (var i in macrolist) {
|
||||
ref.push({name: i, storyid: macrolist[i]});
|
||||
keys += i + ",";
|
||||
}
|
||||
for (var n in macroHelp.HopObject) {
|
||||
var shared = macroHelp.HopObject[n];
|
||||
if (keys.indexOf(shared.name + ",") < 0)
|
||||
ref.push(shared);
|
||||
}
|
||||
ref.sort(sorter);
|
||||
}
|
||||
return macroHelp;
|
||||
}
|
||||
|
||||
Skins.remove = function() {
|
||||
if (this.constructor === Skins) {
|
||||
this.forEach(function() {
|
||||
HopObject.remove(this);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue