# -*- coding: iso-8859-15 -*- # Glasnost # By: Odile Bénassy # Romain Chantereau # Nicolas Clapiès # Pierre-Antoine Dejace # Thierry Dulieu # Florent Monnier # Cédric Musso # Frédéric Péters # Benjamin Poussin # Emmanuel Raviart # Sébastien Régnier # Emmanuel Saracco # # Copyright (C) 2000, 2001 Easter-eggs & Emmanuel Raviart # Copyright (C) 2002 Odile Bénassy, Code Lutin, Thierry Dulieu, Easter-eggs, # Entr'ouvert, Frédéric Péters, Benjamin Poussin, Emmanuel Raviart, # Emmanuel Saracco & Théridion # Copyright (C) 2003 Odile Bénassy, Romain Chantereau, Nicolas Clapiès, # Code Lutin, Pierre-Antoine Dejace, Thierry Dulieu, Easter-eggs, # Entr'ouvert, Florent Monnier, Cédric Musso, Ouvaton, Frédéric Péters, # Benjamin Poussin, Rodolphe Quiédeville, Emmanuel Raviart, Sébastien # Régnier, Emmanuel Saracco, Théridion & Vecam # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. from __future__ import nested_scopes __doc__ = """Glasnost Web Widgets""" __version__ = '$Revision$'[11:-2] import difflib import locale import re import time import types import urllib import glasnost.common.context as context import glasnost.common.faults as faults import glasnost.common.parsers as parsers import glasnost.common.tools_new as commonTools import glasnost.common.xhtmlgenerator as X import glasnost.proxy.widgets as proxyWidgets import kinds import properties import things import calendaring from tools import * import translation register = things.register helpTextRegEx = re.compile(r'\[(\S+)->(\S+)\]') class WidgetMixin(things.ThingMixin): def fillModelFieldChildrenLayout(self, slot, fields, layout, **keywords): label = self.getHtmlFieldLabel(slot) layout += label balloonHelp = slot.getKind().balloonHelp if balloonHelp and not self.isReadOnly(slot): helpMode = context.getVar('helpMode') if helpMode == 'none': regEx = r'\1' elif helpMode == 'local': regEx = r'\1' elif helpMode == 'internet': regEx = r'\1' layout += X.div(_class = 'formHelp')(X.asIs( helpTextRegEx.sub(regEx, _(balloonHelp)))) cell = self.getHtmlFieldValue(slot, fields, **keywords) if cell is not None: if isinstance(cell, X.array): tooltipCell = [x for x in cell.children if x][0] else: tooltipCell = cell if self.colSpan: cell.setAttribute('class', ' '.join( [cell.getAttribute('class'), 'fullwidth'])) if slot.getObject().getError(slot.getPath()) and \ not context.getVar('hideErrors'): layout.setAttribute('class', ' '.join( [layout.getAttribute('class'), 'error'])) layout += self.getModelErrorLayout(slot, fields) layout += cell def getHtmlColumnLabel(self, slot): label = self.getModelLabel(slot) return X.th(scope = 'col')(_(label)) def getHtmlColumnValue(self, slot, fields, **keywords): tdAttributes = {} return X.td(**tdAttributes)( self.getHtmlValue(slot, fields, **keywords)) def getHtmlCompactValue(self, slot, fields, **keywords): # We have to enclose the field value in a tag with class 'cell' but we # want a nice markup so we can't simply
v
and # go away with this. return X.enclose(self.getHtmlValue(slot, fields, **keywords), _class = 'compact-value') def getHtmlFieldLabel(self, slot): label = self.getModelLabel(slot) # Disabled since