############################################################################
# Copyright 2009,2010 Benjamin Kellermann #
# #
# This file is part of dudle. #
# #
# Dudle is free software: you can redistribute it and/or modify it under #
# the terms of the GNU Affero General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# Dudle 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 Affero General Public License #
# along with dudle. If not, see . #
############################################################################
class PollHead
def initialize
@data = {}
end
def col_size
@data.size
end
# returns a sorted array of all columns
# column should be the internal representation
# column.to_s should deliver humanreadable form
def columns
@data.keys.sort
end
# column is in human readable form
# returns true if deletion sucessfull
def delete_column(column)
@data.delete(column) != nil
end
# add new column if columnid = ""
# returns parsed title or false if parsed title == ""
def edit_column(column, newtitle, cgi)
delete_column(column) if column != ""
parsedtitle = newtitle.strip
if parsedtitle != ""
@data[parsedtitle] = CGI.escapeHTML(cgi["columndescription"].strip)
return parsedtitle
else
return false
end
end
def to_html(scols, showeditbuttons = false,activecolumn = nil)
def sortsymb(scols,col)
return < #{scols.include?(col) ? SORT : NOSORT}
SORTSYMBOL
end
ret = "
\n"
ret
end
def edit_column_htmlform(activecolumn, revision)
if activecolumn != ""
title = activecolumn
description = @data[title]
title = CGI.escapeHTML(title)
hiddeninput = ""
end
columntitlestr = _("Alternative")
descriptionstr = _("Description (optional)")
addeditstr = _("Add/Edit Column")
previewstr = _("Preview")
hint = _("Enter all alternatives (columns), you want to ask the participants of the poll. The participants will state one vote for every alternative you give here separately.")
ret = <