[Mpuls-commits] r859 - wasko/branches/2.0/waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jan 26 11:10:53 CET 2010
Author: torsten
Date: 2010-01-26 11:10:52 +0100 (Tue, 26 Jan 2010)
New Revision: 859
Removed:
wasko/branches/2.0/waskaweb/model/navigation.py
Log:
Deleted. Not imported anywhere
Deleted: wasko/branches/2.0/waskaweb/model/navigation.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/navigation.py 2010-01-26 10:07:55 UTC (rev 858)
+++ wasko/branches/2.0/waskaweb/model/navigation.py 2010-01-26 10:10:52 UTC (rev 859)
@@ -1,291 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
-#
-# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
-# Web-Anwendungs-Server fuer Kompetenzagenturen).
-#
-# mpuls WASKA 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.
-#
-# mpuls WASKA 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 mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
-#
-# mpuls WASKA has been developed on behalf of the
-# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
-# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
-# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
-# European Social Fund resources.
-#
-# Authors:
-# Sascha L. Teichmann <teichmann at intevation.de>
-#
-
-from cgi import escape
-
-from paste.httpexceptions import HTTPNotFound
-from waskaweb.lib.helpers import getHelp
-
-from waskaweb.model.nodecomponents import Node
-from waskaweb.model.data import PageNode
-
-
-SELECT_ITEM = u"/case/select_item/%s"
-SELECT_BRANCH = u"/navigation/select_branch/%s"
-CLOSE_BRANCH = u"/navigation/close_branch/%s"
-OPEN_BRANCH = u"/navigation/open_branch/%s"
-
-CHECK_MODIFICATION = u'onclick="return checkModification();"'
-
-class TreeItem:
-
- def __init__(self, name, description, children = None, parent = None):
- self.is_open = False
- self.name = name
- self.description = description
- self.parent = parent
- self.children = children
- self.key = None
- self.next = None
-
- def is_child(self):
- return self.children is None
-
- def deepest_item(self):
- cur = self
- while cur.children:
- cur = cur.children[0]
- return cur
-
- def find_page(self):
- cur = self
- while cur:
- if cur.next: return cur
- cur = cur.parent
- return None
-
- def unfold(self):
- cur = self
- while cur:
- cur.is_open = True
- cur = cur.parent
-
- def render(self, page, out, get_image, error_lookup):
-
- out.append(u'<li class="formpage">')
- out.append(page == self.key \
- and u'<span class="formpage_highlight">' or u'<span>')
-
- has_error = self in error_lookup
- if self.is_child():
-
- select_link = SELECT_ITEM % self.key
-
- out.append(u'<a href="%s" class="navigation" %s>' % (
- select_link, CHECK_MODIFICATION))
-
- if has_error:
- out.append(get_image("/images/icons/formular_page_blue_error.gif",
- u' border="0"'
- u' alt="Fehler auf dieser Seite"'
- u' title="Seite öffnen - Diese Seite enthält Fehler."'))
- else:
- out.append(get_image("/images/icons/formular_page_blue.gif",
- u' border="0"'
- u' alt="Formularseite" title="Seite öffnen"'))
-
- out.append(u'</a> <a href="%s" class="navigation" %s>%s</a></span>\n' % (
- select_link, CHECK_MODIFICATION, escape(self.description)))
- else:
- # when clicking on link select the first page in branch
- deepest = self.deepest_item()
-
- select_link = SELECT_BRANCH % deepest.key
-
- if self.is_open or has_error:
- if not has_error:
- action = CLOSE_BRANCH % self.key
- out.append(u'<a href="%s" class="navigation" %s>' % (
- action, CHECK_MODIFICATION))
-
- out.append(get_image("/images/icons/folder_closed_blue_2.gif",
- u' border="0"'
- u' title="Ordner%s"'
- u' alt="%s"' % (
- not has_error and " schliessen" or "",
- has_error and u"offener" or u"geschlossener")))
-
- out.append(has_error and u' ' or u'</a>')
-
- out.append(u'<a href="%s" class="navigation" %s>%s</a>' % (
- select_link, CHECK_MODIFICATION, escape(self.description)))
-
- out.append(u'</span>\n<ul>\n')
- for child in self.children:
- child.render(page, out, get_image, error_lookup)
- out.append(u'</ul>\n')
- else:
- action = OPEN_BRANCH % self.key
- out.append(u'<a href="%s" class="navigation" %s>' % (
- action, CHECK_MODIFICATION))
-
- out.append(get_image("/images/icons/folder_closed_blue_2.gif",
- u' border="0"'
- u' alt="geschlossener Ordner" title="Ordner öffnen"'))
-
- out.append(u'</a> ')
-
- out.append(u'<a href="%s" class="navigation" %s>%s</a></span>' % (
- select_link, CHECK_MODIFICATION, escape(self.description)))
-
- out.append(u"</li>\n")
-
- def set_open(self, flag):
- self.is_open = flag
-
- def build_error_lookup(self, lookup, error_pages):
- mark = self.name in error_pages
- if self.children:
- for child in self.children:
- if child.build_error_lookup(lookup, error_pages):
- mark = True
- if mark:
- lookup.add(self)
- return mark
-
- def get_description_chain(self, form_data):
- cur = self
- descriptions = []
- while cur:
- if cur.description:
- descriptions.insert(0, u"%s%s" % (
- escape(cur.description), form_data.getHelp(cur.name)))
- cur = cur.parent
- return descriptions
-
- def pureHeaders(self):
- if self.parent:
- for h in self.parent.pureHeaders():
- yield h
- if self.description:
- yield self.description
-
- def renderHeader(self, form_data):
- descriptions = self.get_description_chain(form_data)
- if not descriptions: return u""
- out = [u'<div id="content_ueberschrift"><ul>']
- for depth, desc in enumerate(descriptions):
- depth = min(depth + 1, 4)
- out.append(u'<li><h%d>%s</h%d></li>' % (depth, desc, depth))
- out.append(u'</ul></div>')
- return u"".join(out)
-
- def nextKey(self):
- page = self.find_page()
- if not page: return None
- return page.next
-
-def get_page(nc):
- while nc:
- if isinstance(nc, PageNode):
- return nc.getName()
- nc = nc.parent
- return ""
-
-class NavigationTreeBuilder(object):
-
- def __init__(self, formed):
- self.key = 0
- self.prev = None
- self.first = None
- self.root = self.build(formed, None)
-
- def build(self, nc, parent):
-
- if isinstance(nc, PageNode):
- if nc.isInvisible():
- return None
- ti = TreeItem(nc.getName(), nc.getDescription(), parent = parent)
- if not self.first:
- self.first = ti
- if self.prev:
- self.prev.next = ti
- self.prev = ti
- ti.key = self.key
- self.key += 1
- return ti
-
- if isinstance(nc, Node):
- children = []
- n = TreeItem(
- get_page(nc),
- nc.getDescription(),
- children,
- parent)
- for child in nc.children:
- c = self.build(child, n)
- if c: children.append(c)
- n.key = self.key
- self.key += 1
- return n
-
- ti = TreeItem("xxx", "Unknown Item", parent = parent)
- ti.key = self.key
- self.key += 1
- return ti
-
-class NavigationTree:
-
- def __init__(self, formed, case=None):
- builder = NavigationTreeBuilder(formed.root.children[0])
- self.root = builder.root
- self.first_page = builder.first
-
- def getAllItems(self):
- page = self.first_page
- while page:
- yield page
- page = page.next
-
- def getTreeItem(self, key):
- key = int(key)
- stack = [self.root.children]
- while stack:
- children = stack.pop()
- for c in children:
- if c.key == key:
- return c
- if c.children:
- stack.append(c.children)
- return None
-
- def findTreeItemByPageName(self, name):
- stack = [self.root.children]
- item = None
- while stack:
- children = stack.pop()
- for c in children:
- if c.name == name:
- return c
- if c.children:
- stack.append(c.children)
- return None
-
- def render(self, page, file_cache, error_pages = set()):
- error_lookup = set()
- self.root.build_error_lookup(error_lookup, error_pages)
- out = [u'<ul>']
- get_image = file_cache.get_image
- for child in self.root.children:
- child.render(page, out, get_image, error_lookup)
- out.append(u"</ul>")
- return u"".join(out)
-
-# vim:set ts=4 sw=4 si et sta sts=4 :
More information about the Mpuls-commits
mailing list