Intermediate commit:

* Improved tag framework 
 * Added support for image tags
 * Moved most code of StoryMgr.evalNewStory to Story.evalStory to decrease redundancy
 * Added compatibility module (including drafts for database conversions)
 * Moved code for topics to compatibility module
 * Removed obsolete code
This commit is contained in:
Tobi Schäfer 2007-08-03 19:41:51 +00:00
parent d5c59cf2ec
commit 09b39b2af3
48 changed files with 872 additions and 494 deletions

View file

@ -314,6 +314,11 @@ Image.prototype.evalImg = function(param, modifier) {
this.alttext = param.alttext;
this.modifier = modifier;
this.modifytime = new Date();
param.tags = Story.prototype.setTopic.call(this,
param.topic || param.addToTopic);
Story.prototype.setTags.call(this, param.tags);
if (this.thumbnail) {
this.thumbnail.alttext = this.alttext;
this.thumbnail.modifytime = this.modifytime;

View file

@ -22,6 +22,20 @@
<% image.alttext as="editor" class="formText" %><br />
</td>
</tr>
<tr>
<td colspan="3">
Add this image to a topic<br />
<table style="margin-left:15px;">
<tr>
<td width="48%" class="small">Choose a topic...<br />
<% image.topicchooser firstOption="--- choose topic ---" %></td>
<td valign="top" width="4%">&nbsp;</td>
<td valign="top" width="48%" class="small">...or enter a new one<br />
<input type="text" name="topic" value="<% request.topic %>" /></td>
</tr>
</table>
</td>
</tr>
</table>
<div class="small"><% image.creator as="link" prefix="Created by " %><% image.createtime format="short" prefix=" on " suffix="." %></div><br />

View file

@ -61,6 +61,6 @@ modifier.foreign = USER_ID
tags = collection(TagHub)
tags.local.1 = $id
tags.foreign.1 = parent_id
tags.foreign.1 = tagged_id
tags.local.2 = $prototype
tags.foreign.2 = parent_type
tags.foreign.2 = tagged_type

View file

@ -39,9 +39,8 @@ tags = mountpoint(Tags)
allTags = collection(Tag)
allTags.local = site_id
allTags.foreign = site_id
allTags.filter = tag.type = 'Image'
allTags.group = tag.name
allTags.group.order = tag.name asc
allTags.filter = type = 'Image'
allTags.accessname = tag.name
alphabeticalTags = collection(Tag)
alphabeticalTags.accessname = name

View file

@ -516,7 +516,7 @@ Layout.prototype.evalLayout = function(param, modifier) {
this.title = param.title;
this.description = param.description;
// get preferences from param object
var prefs = this.preferences.getAll();
var prefs = this.preferences.get();
for (var i in param) {
if (i.startsWith("preferences_"))
prefs[i.substring(12)] = param[i];
@ -640,7 +640,7 @@ Layout.prototype.setParentLayout = function(parent) {
this.shareable = 0;
// copy relevant preferences from parent
var prefs = new HopObject();
var parentPrefs = parent.preferences.getAll();
var parentPrefs = parent.preferences.get();
prefs.bgcolor = parentPrefs.bgcolor;
prefs.textfont = parentPrefs.textfont;
prefs.textsize = parentPrefs.textsize;
@ -673,7 +673,7 @@ Layout.prototype.dumpToZip = function(z, fullExport) {
cl.title = this.title;
cl.alias = this.alias;
cl.description = this.description;
cl.preferences = this.preferences.getAll();
cl.preferences = this.preferences.get();
cl.creator = this.creator ? this.creator.name : null;
cl.createtime = this.creator ? this.createtime : null;
cl.exporttime = new Date();

View file

@ -22,30 +22,6 @@
// $URL$
//
//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
/**
* constructor function for site objects
* @param String Title

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View file

@ -43,14 +43,12 @@ trusted = SITE_ISTRUSTED
createtime = SITE_CREATETIME
modifytime = SITE_MODIFYTIME
topics = mountpoint(TopicMgr)
members = mountpoint(MemberMgr)
images = mountpoint(ImageMgr)
layouts = mountpoint(LayoutMgr)
files = mountpoint(FileMgr)
stories = mountpoint(StoryMgr)
polls = mountpoint(PollMgr)
tags = mountpoint(Tags)
preferences = mountpoint(Metadata)
preferences_data = SITE_PREFERENCES
@ -106,3 +104,10 @@ tags = collection(Tag)
tags.accessname = tag.name
tags.local = site_id
tags.foreign = site_id
tags.filter = type = 'Story'
slideshows = collection(Tag)
slideshows.accessname = tag.name
slideshows.local = site_id
slideshows.foreign = site_id
slideshows.filter = type = 'Image'

View file

@ -22,6 +22,20 @@
// $URL$
//
/**
* constructor function for story objects
*/
Story.prototype.constructor = function(creator, createtime, ipaddress) {
this.reads = 0;
this.ipaddress = ipaddress;
this.creator = creator;
this.modifier = creator;
this.editableby = EDITABLEBY_ADMINS;
this.createtime = new Date();
this.modifytime = this.createtime;
return this;
};
/**
* main action
*/
@ -197,23 +211,6 @@ Story.prototype.online_macro = function(param) {
return;
};
/**
* macro rendering the location of the story
*/
Story.prototype.location_macro = function(param) {
switch (this.online) {
case 1:
Html.link({href: this.site.topics.get(this.topic).href()}, "topic");
break;
case 2:
res.write("site");
break;
}
return;
};
/**
* macro rendering createtime of story, either as editor,
* plain text or as link to the frontpage of the day
@ -473,52 +470,6 @@ Story.prototype.discussions_macro = function(param) {
return;
};
/**
* macro renders a list of existing topics as dropdown
*/
Story.prototype.topicchooser_macro = function(param) {
var size = path.Site.topics.size();
var options = new Array();
for (var i=0;i<size;i++) {
var topic = path.Site.topics.get(i);
if (topic.size()) {
options[i] = {value: topic.groupname, display: topic.groupname};
if (req.data.addToTopic)
var selected = req.data.addToTopic;
else if (this.topic == topic.groupname)
var selected = topic.groupname;
}
}
Html.dropDown({name: "addToTopic"}, options, selected, param.firstOption);
return;
};
/**
* macro renders the name of the topic this story belongs to
* either as link, image (if an image entiteld by the
* topic name is available) or plain text
*/
Story.prototype.topic_macro = function(param) {
if (!this.topic || !this.online)
return;
if (!param.as || param.as == "text")
res.write(this.topic);
else if (param.as == "link") {
Html.link({href: path.Site.topics.href(this.topic)},
param.text ? param.text : this.topic);
} else if (param.as == "image") {
if (!param.imgprefix)
param.imgprefix = "topic_";
var img = getPoolObj(param.imgprefix + this.topic, "images");
if (!img)
return;
Html.openLink({href: path.Site.topics.href(this.topic)});
renderImage(img.obj, param)
Html.closeLink();
}
return;
};
/**
* macro returns a list of references linking to a story
* since referrers are asynchronously written to database by scheduler
@ -592,19 +543,6 @@ Story.prototype.addtofront_macro = function(param) {
}
return;
};
/**
* constructor function for story objects
*/
Story.prototype.constructor = function(creator, ipaddress) {
this.reads = 0;
this.ipaddress = ipaddress;
this.creator = creator;
this.editableby = EDITABLEBY_ADMINS;
this.createtime = new Date();
this.modifytime = new Date();
return this;
};
/**
* check if story is ok; if true, save changed story
@ -615,62 +553,66 @@ Story.prototype.constructor = function(creator, ipaddress) {
* - message (String): containing a message to user
*/
Story.prototype.evalStory = function(param, modifier) {
var site = this.site || res.handlers.site;
// collect content
var content = extractContent(param, this.content.get());
// if all story parts are null, return with error-message
if (!content.exists)
if (!content.exists) {
throw new Exception("textMissing");
}
// check if the createtime is set in param
if (param.createtime) {
try {
var ctime = param.createtime.toDate("yyyy-MM-dd HH:mm");
var ctime = param.createtime.toDate("yyyy-MM-dd HH:mm", site.getTimeZone());
} catch (err) {
throw new Exception("timestampParse", param.createtime);
}
}
// check name of topic (if specified)
var topicName = null;
if (param.topic) {
// FIXME: this should be solved more elegantly
if (String.URLPATTERN.test(param.topic))
throw new Exception("topicNoSpecialChars");
if (this.site.topics[param.topic] || this.site.topics[param.topic + "_action"])
throw new Exception("topicReservedWord");
topicName = param.topic;
} else if (param.addToTopic)
topicName = param.addToTopic;
// Update tags of the story
this.setTags(param.content_tags);
// store the new values of the story
if (param.publish) {
var newStatus = param.addToFront ? 2 : 1;
if (!this.online || content.isMajorUpdate)
this.site.lastupdate = new Date();
this.online = newStatus;
} else
this.online = 0;
if (content.isMajorUpdate)
this.modifytime = new Date();
this.content.set(content.value);
this.topic = topicName;
// let's keep the title property
this.title = content.value.title;
// re-create day of story with respect to site-timezone
if (ctime && ctime != this.createtime) {
this.createtime = ctime;
this.day = ctime.format("yyyyMMdd", this.site.getLocale(), this.site.getTimeZone());
}
if (modifier == this.creator)
if (!this.day) {
this.day = this.createtime.format("yyyyMMdd", site.getLocale(),
site.getTimeZone());
}
// FIXME: Set the story's topic (backwards-compatible)
content.value.tags = this.setTopic(param.topic || param.addToTopic);
// Update tags of the story
this.setTags(content.value.tags);
// store the new values of the story
if (param.publish) {
var newStatus = param.addToFront ? 2 : 1;
if (!this.online || content.isMajorUpdate) {
site.lastupdate = new Date();
}
this.online = newStatus;
} else {
this.online = 0;
}
if (content.isMajorUpdate) {
this.modifytime = new Date();
}
this.content.set(content.value);
// let's keep the title property
this.title = content.value.title;
if (!this.creator || modifier == this.creator) {
this.editableby = !isNaN(param.editableby) ?
parseInt(param.editableby, 10) : EDITABLEBY_ADMINS;
}
this.discussions = param.discussions ? 1 : 0;
this.modifier = modifier;
this.ipaddress = param.http_remotehost;
// send e-mail notification
if (this.site.isNotificationEnabled() && newStatus != 0) {
if (site.isNotificationEnabled() && newStatus != 0) {
// status changes from offline to online
// (this is bad because somebody could send a bunch
// of e-mails simply by toggling the online status.)
@ -678,13 +620,13 @@ Story.prototype.evalStory = function(param, modifier) {
// this.sendNotification("story", "create");
// major update of an already online story
if (this.online != 0 && content.isMajorUpdate)
this.site.sendNotification("update", this);
site.sendNotification("update", this);
}
var result = new Message("storyUpdate");
result.url = this.online > 0 ? this.href() : this.site.stories.href();
result.url = this.online > 0 ? this.href() : site.stories.href();
result.id = this._id;
// add the modified story to search index
app.data.indexManager.getQueue(this.site).add(this);
app.data.indexManager.getQueue(site).add(this);
return result;
};
@ -699,6 +641,7 @@ Story.prototype.setTags = function(input) {
diff[tag] = 1;
}
}
for (var tag in diff) {
switch (diff[tag]) {
case 0:

View file

@ -11,10 +11,6 @@
<tr>
<td><fieldset><legend class="small">Options</legend>
<p><% story.addtofront as="editor" checked="checked" %>&nbsp;Show this story on the front page</p>
Tags:
<% story.content part="tags" as="editor" class="formText" %>
Add this story to a topic<br />
<table style="margin-left:15px;">
<tr>

View file

@ -29,7 +29,6 @@ _prototype = TEXT_PROTOTYPE
_parent = site.stories
day = TEXT_DAY
topic = TEXT_TOPIC
title = TEXT_TITLE
text = TEXT_TEXT
rawcontent = TEXT_RAWCONTENT

View file

@ -110,64 +110,25 @@ StoryMgr.prototype.create_action = function() {
StoryMgr.prototype.evalNewStory = function(param, creator) {
var s = new Story(creator, param.http_remotehost);
// collect content
var content = extractContent(param);
// if all story parts are null, return with error-message
if (!content.exists)
throw new Exception("textMissing");
s.content.setAll(content.value);
// let's keep the title property
s.title = content.value.title;
// check if the create date is set in the param object
if (param.createtime) {
try {
s.createtime = param.createtime.toDate("yyyy-MM-dd HH:mm", this._parent.getTimeZone());
} catch (error) {
throw new Exception("timestampParse", param.createtime);
}
}
s.editableby = !isNaN(parseInt(param.editableby, 10)) ?
parseInt(param.editableby, 10) : EDITABLEBY_ADMINS;
s.discussions = param.discussions ? 1 : 0;
// create day of story with respect to site-timezone
s.day = formatTimestamp(s.createtime, "yyyyMMdd");
// check name of topic (if specified)
if (param.topic) {
// FIXME: this should be solved more elegantly
if (String.URLPATTERN.test(param.topic))
throw new Exception("topicNoSpecialChars");
if (this._parent.topics[param.topic] || this._parent.topics[param.topic + "_action"])
throw new Exception("topicReservedWord");
s.topic = param.topic;
} else if (param.addToTopic)
s.topic = param.addToTopic;
// check the online-status of the story
if (param.publish)
s.online = param.addToFront ? 2 : 1;
else
s.online = 0;
// store the story
if (!this.add(s))
s.evalStory(param, creator);
if (!this.add(s)) {
throw new Exception("storyCreate");
// Update tags of the story
s.setTags(param.content_tags);
}
// send e-mail notification
if (s.site.isNotificationEnabled())
if (s.site.isNotificationEnabled()) {
s.site.sendNotification("create", s);
}
var result = new Message("storyCreate", null, s);
result.id = s._id;
if (s.online) {
s.site.lastupdate = s.modifytime;
result.url = s.href();
} else
} else {
result.url = this.href();
// add the new story to search index
app.data.indexManager.getQueue(this._parent).add(s);
}
return result;
};

View file

@ -41,9 +41,8 @@ allTags = collection(Tag)
allTags.local = site_id
allTags.foreign = site_id
allTags.filter = tag.type = 'Story'
allTags.group = tag.name
allTags.group.order = tag.name asc
allTags.accessname = tag.name
alphabeticalTags = collection(Tag)
alphabeticalTags.accessname = name
alphabeticalTags.local = site_id

View file

@ -1,3 +1,27 @@
//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
Tag.prototype.constructor = function(name, site, type) {
this.name = name;
this.site = site;
@ -6,7 +30,38 @@ Tag.prototype.constructor = function(name, site, type) {
};
Tag.prototype.main_action = function() {
res.debug(this.name + ": " + this.size());
res.handlers.list = new jala.ListRenderer(this.getCollection(this.type));
res.data.body = this.renderSkinAsString("Tag");
res.handlers.site.renderSkin("page");
return;
};
Tag.prototype.href = function() {
var mountpoint;
switch (this.type) {
case "Story":
mountpoint = "stories";
break;
case "Image":
mountpoint = "images";
break;
}
return this.site[mountpoint].tags.href() + encodeURIComponent(this.name);
};
Tag.prototype.getCollection = function(type) {
switch (type) {
case "Story":
return this.stories;
case "Image":
return this.images;
default:
return this;
}
};
Tag.prototype.getNavigationName = function() {
return this.name;
};
Tag.prototype.toString = function() {

5
code/Tag/Tag.skin Normal file
View file

@ -0,0 +1,5 @@
<div class="pagelink"><% linkedpath %></div><br />
<% list.prevLink %>
<% list.render skin="TagHub" %>
<% list.nextLink %>

View file

@ -1,7 +1,31 @@
##
## The Antville Project
## http://code.google.com/p/antville
##
## Copyright 2001-2007 by The Antville People
##
## Licensed under the Apache License, Version 2.0 (the ``License'');
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an ``AS IS'' BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## $Revision: 3300 $
## $LastChangedBy: piefke3000 $
## $LastChangedDate: 2007-06-30 21:25:35 +0200 (Sat, 30 Jun 2007) $
## $URL$
##
_db = antville
_table = tag
_id = id
_parent = site.tags
_parent = site.tags, site.slideshows
name
type
@ -17,9 +41,16 @@ _children.foreign = tag_id
stories = collection(TagHub)
stories.local = id
stories.foreign = tag_id
stories.filter = tagged_type = 'Story'
stories.filter.additionalTables = av_text
stories.filter = av_text.text_f_site = ${site_id} and tagged_type = 'Story' \
and av_text.text_id = tagged_id
stories.order = av_text.text_createtime desc
images = collection(TagHub)
images.local = id
images.foreign = tag_id
images.filter = tagged_type = 'Image'
images.order = image_createtime desc
images.filter.additionalTables = av_image
images.filter = av_image.image_f_site = ${site_id} and tagged_type = 'Image' \
and av_image.image_id = tagged_id
images.order = av_image.image_createtime desc

View file

@ -1,2 +0,0 @@
<% #item %>
<% tagjoin.parent.skin name="preview" %>

View file

@ -1,7 +1,31 @@
//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
TagHub.prototype.constructor = function(name, tagged, user) {
var site = res.handlers.site;
var tag = site.tags.get(name);
if (!tag) {
if (!tag || tag.type !== tagged._prototype) {
tag = new Tag(name, site, tagged._prototype);
site.tags.add(tag);
}
@ -13,10 +37,10 @@ TagHub.prototype.constructor = function(name, tagged, user) {
TagHub.prototype.getMacroHandler = function(name) {
switch (name.toLowerCase()) {
case "parent":
case "tagged":
case "story":
case "image":
return this.parent;
return this.tagged;
break;
}
};

1
code/TagHub/TagHub.skin Normal file
View file

@ -0,0 +1 @@
<% taghub.tagged.skin name="preview" %>

View file

@ -1,3 +1,27 @@
##
## The Antville Project
## http://code.google.com/p/antville
##
## Copyright 2001-2007 by The Antville People
##
## Licensed under the Apache License, Version 2.0 (the ``License'');
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an ``AS IS'' BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## $Revision: 3300 $
## $LastChangedBy: piefke3000 $
## $LastChangedDate: 2007-06-30 21:25:35 +0200 (Sat, 30 Jun 2007) $
## $URL$
##
_db = antville
_table = tag_hub
_id = id

View file

@ -1,3 +1,27 @@
//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
Tags.prototype.main_action = function() {
if (req.data.group) {
this.setGroup(req.data.group)
@ -7,14 +31,13 @@ Tags.prototype.main_action = function() {
this.setPage(req.data.page);
res.redirect(this.href());
}
res.data.body = this.renderSkinAsString("main");
res.data.body = this.renderSkinAsString("Tags");
res.handlers.context.renderSkin("page");
return;
};
Tags.prototype.getChildElement = function(id) {
res.debug(id)
var child = path.site.tags.get(id);
var child = this.getCollection("*").get(id);
return child;
/* if (child && child.size() > 0) {
@ -61,12 +84,12 @@ Tags.prototype.getChildElement = function(id) {
};
Tags.prototype.alphabet_macro = function() {
var collection = this.getCollection("+");
if (collection.size() < 50) {
//return;
if (this.getCollection("*").size() < 50) {
return;
}
var self = this;
var collection = this.getCollection("+");
var prefix = "?group=";
var group = this.getGroup();
@ -115,13 +138,16 @@ Tags.prototype.list_macro = function() {
var size = this.getPageSize();
var start = (page - 1) * size;
var collection = this.getCollection().list(start, size);
var id;
var id, href;
for each (var item in collection) {
id = item.groupname || item.name;
if (item.constructor !== Tag) {
item = item.get(0);
}
Html.openTag("li");
Html.link({href: this.href() + encodeURIComponent(id)}, id);
Html.link({href: item.href()}, item.name);
Html.closeTag("li");
}
return;
};
Tags.prototype.getCollection = function(group) {

15
code/Tags/Tags.skin Normal file
View file

@ -0,0 +1,15 @@
<div class="pagelink"><% linkedpath %></div><br />
<% tags.alphabet prefix='<div>' suffix='</div>' %>
<% tags.pager prefix='<div>' suffix='</div>' %>
<% tags.list prefix="<ul>" suffix="</ul>" %>
<% tags.pager prefix='<div>' suffix='</div>' %>
<% tags.alphabet prefix='<div>' suffix='</div>' %>
<% #TOBEDELETED %>
<div class="listSeparator">&nbsp;</div>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td><a href="<% tag.href %>"><% tag.id %></a></td>
</tr>
</table>

View file

@ -1,7 +0,0 @@
<div><% tags.alphabet %></div>
<div><% tags.pager %></div>
<ul>
<% tags.list %>
</ul>
<div><% tags.pager %></div>
<div><% tags.alphabet %></div>

View file

@ -1,6 +0,0 @@
<div class="listSeparator">&nbsp;</div>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td><a href="<% tag.href %>"><% tag.id %></a></td>
</tr>
</table>

View file

@ -1,26 +1,28 @@
_children = collection(TagJoin)
_children.local.1 = $id
_children.foreign.1 = site_id
## TO BE DELETED
_children.local.2 = $prototype
_children.local.2 = parent_type
#_children = collection(TagJoin)
#_children.local.1 = $id
#_children.foreign.1 = site_id
_children.filter.additionalTables = AV_TEXT
_children.filter = AV_TEXT.TEXT_ID = parent_id
#_children.order = tagjoin.id asc
#_children.local.2 = $prototype
#_children.local.2 = parent_type
_children.group = tagjoin.name
_children.group.order = tagjoin.name asc
#_children.filter.additionalTables = AV_TEXT
#_children.filter = AV_TEXT.TEXT_ID = parent_id
##_children.order = tagjoin.id asc
#_children.cachemode = aggressive
#_children.group = tagjoin.name
#_children.group.order = tagjoin.name asc
cloud = collection(TagJoin)
cloud.local.1 = $id
cloud.foreign.1 = site_id
##_children.cachemode = aggressive
cloud.filter.additionalTables = AV_TEXT
cloud.filter = AV_TEXT.TEXT_ID = parent_id
#cloud = collection(TagJoin)
#cloud.local.1 = $id
#cloud.foreign.1 = site_id
cloud.group = tagjoin.name
cloud.group.order = AV_TEXT.TEXT_CREATETIME desc
#cloud.filter.additionalTables = AV_TEXT
#cloud.filter = AV_TEXT.TEXT_ID = parent_id
#cloud.group = tagjoin.name
#cloud.group.order = AV_TEXT.TEXT_CREATETIME desc

View file

@ -1,97 +0,0 @@
//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
/**
* Display a link to let the user add a new writeup
* to this topic.
*/
Topic.prototype.addstory_macro = function(param) {
try {
path.Site.stories.checkAdd(session.user, req.data.memberlevel);
} catch (deny) {
return;
}
param.linkto = "create";
param.urlparam = "topic=" + this.groupname;
Html.openTag("a", path.Site.stories.createLinkParam(param));
if (param.text)
res.format(param.text);
else
res.write(getMessage("Topic.addStoryToTopic"));
Html.closeTag("a");
return;
};
/**
* Return either the title of the story or
* the id prefixed with standard display name
* to be used in the global linkedpath macro
* @see hopobject.getNavigationName()
*/
Topic.prototype.getNavigationName = function() {
return this.groupname;
};
/**
* function renders the list of stories for day-pages
* and assigns the rendered list to res.data.storylist
* scrollnavigation-links to previous and next page(s) are also
* assigned to res.data (res.data.prevpage, res.data.nextpage)
* using this separate renderFunction instead of doing the stuff
* in storylist_macro() was necessary for completely independent
* placement of the prevpage- and nextpage-links
* @param Int Index-position to start with
*/
Topic.prototype.renderStorylist = function(idx) {
var size = this.size();
if (idx < 0 || isNaN (idx)|| idx > size-1)
idx = 0;
var max = Math.min (idx+10, size);
this.prefetchChildren(idx, max);
if (idx > 0) {
var sp = new Object();
sp.url = this.href() + "?start=" + Math.max(0, idx-10);
sp.text = getMessage("generic.previousPage");
res.data.prevpage = renderSkinAsString("prevpagelink", sp);
}
res.push();
var day;
while (idx < max) {
var s = this.get(idx++);
if (s.day != day) {
s.renderSkin("dayheader");
day = s.day;
}
s.renderSkin("preview");
}
res.data.storylist = res.pop();
if (idx < size) {
var sp = new Object();
sp.url = this.href() + "?start=" + idx;
sp.text = getMessage("generic.nextPage");
res.data.nextpage = renderSkinAsString("nextpagelink", sp);
}
return;
};

View file

@ -1,5 +0,0 @@
<div class="pagelink"><% linkedpath %><br /><br />
<% topic.addimage prefix="...&nbsp;" suffix="<br />" %>
<% response.prevpage %></div>
<% response.storylist %>
<% response.nextpage %>

View file

@ -1,5 +0,0 @@
<div class="pagelink"><% linkedpath %><br /><br />
<% topic.addstory prefix="...&nbsp;" suffix="<br />" %>
<% response.prevpage %></div>
<% response.storylist %>
<% response.nextpage %>

View file

@ -1,25 +0,0 @@
##
## The Antville Project
## http://code.google.com/p/antville
##
## Copyright 2001-2007 by The Antville People
##
## Licensed under the Apache License, Version 2.0 (the ``License'');
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an ``AS IS'' BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## $Revision$
## $LastChangedBy$
## $LastChangedDate$
## $URL$
##
_extends = Day

View file

@ -1,65 +0,0 @@
//
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001-2007 by The Antville People
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Revision$
// $LastChangedBy$
// $LastChangedDate$
// $URL$
//
/**
* main action
*/
TopicMgr.prototype.main_action = function() {
res.data.title = getMessage("TopicMgr.mainTitle", {title: this._parent.title});
res.data.body = this.renderSkinAsString ("main");
this._parent.renderSkin("page");
return;
};
/**
* function renders the list of topics as links
*/
TopicMgr.prototype.topiclist_macro = function(param) {
if (!this.size())
return;
for (var i=0;i<this.size();i++) {
var topic = this.get(i);
res.write(param.itemprefix);
Html.link({href: topic.href()}, topic.groupname);
res.write(param.itemsuffix);
}
return;
};
/**
* permission check (called by hopobject.onRequest())
* @param String name of action
* @param Obj User object
* @param Int Membership level
* @return Obj Exception object or null
*/
TopicMgr.prototype.checkAccess = function(action, usr, level) {
if (!this._parent.online)
checkIfLoggedIn();
try {
this._parent.checkView(usr, level);
} catch (deny) {
res.message = deny.toString();
res.redirect(root.href());
}
return;
};

View file

@ -1,3 +0,0 @@
<% linkedpath %>
<% topicmgr.topiclist prefix="<ul>" suffix="</ul>" itemprefix="<li>" itemsuffix="</li>" %>

View file

@ -1,32 +0,0 @@
##
## The Antville Project
## http://code.google.com/p/antville
##
## Copyright 2001-2007 by The Antville People
##
## Licensed under the Apache License, Version 2.0 (the ``License'');
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an ``AS IS'' BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## $Revision$
## $LastChangedBy$
## $LastChangedDate$
## $URL$
##
_children = collection(Story)
_children.local = SITE_ID
_children.foreign = TEXT_F_SITE
_children.filter = TEXT_PROTOTYPE = 'Story' and TEXT_ISONLINE > 0
_children.order = TEXT_CREATETIME desc
_children.group = TEXT_TOPIC
_children.group.prototype = Topic
_children.group.order = TEXT_TOPIC