antville/code/TagHub/TagHub.js
Tobi Schäfer 896f5daf28 * Added Membership.comments collection to fix a bug causing display of the number of comments of a user throughout the whole installation instead of those of the member of the site only
* Replaced custom SQL query in Comment.remove() with code using new Membership.comments collection
 * Removed obsolete Sql.COMMENTS statement
 * Added getConfirmText() method to Comment, File, Image, Layout, Membership, Poll, Skin and Story prototypes – which is used in HopObject.delete_action() for more convenient feedback about what is going to be deleted (fixes issue 37 for now)
 * Fully enabled translation in global breadcrumb_macro()
 * Removed obsolete Layout.getTitle() method
 * Disabled translation in HopObject.toString() methods
 * Fixed and added some i18n messages to ease translation
2010-02-06 15:13:39 +00:00

77 lines
1.8 KiB
JavaScript

//
// 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$
//
/**
* @fileOverview Defines the TagHub prototype
*/
/**
* @name TagHub
* @constructor
* @param {String} name
* @param {Story|Image} tagged
* @param {User} user
* @property {Tag} tag
* @property {Number} tag_id
* @property {Story|Image} tagged
* @property {Number} tagged_id
* @property {String} tagged_type
* @property {User} user
* @extends HopObject
*/
TagHub.prototype.constructor = function(name, tagged, user) {
var site = tagged.site || res.handlers.site;
var tag = site.getTags(tagged._prototype, Tags.ALL).get(name);
if (!tag) {
tag = new Tag(name, site, tagged._prototype);
site.$tags.add(tag);
//res.commit();
}
this.tag = tag;
this.tagged = tagged;
this.user = user;
return this;
}
/**
*
* @param {String} name
* @returns {HopObject}
*/
TagHub.prototype.getMacroHandler = function(name) {
switch (name.toLowerCase()) {
case "tagged":
case "story":
case "image":
return this.tagged;
break;
}
}
/**
* @return {String}
*/
TagHub.prototype.toString = function() {
return "Tag " + this.tag.name + " of " + this.tagged.toString();
}