Index: /waeup/branches/ulif-layout/src/waeup/browser/layout.py
===================================================================
--- /waeup/branches/ulif-layout/src/waeup/browser/layout.py	(revision 4648)
+++ /waeup/branches/ulif-layout/src/waeup/browser/layout.py	(revision 4649)
@@ -16,13 +16,29 @@
 
 grok.templatedir('templates')
-    
+
+# The list of primary navigation tabs.
+# Each entry is a tuple
+#
+#   (<id_number>, <order_number>, <text_to_render>, <link_target>)
+#
+# where id number is the number pages can use as their pnav attribute,
+# order number determines the order in which the primary tabs are
+# rendered, text_to_render gives the text displayed and link_target
+# says, what url (relative to application URL) the tab should link to.
+#
+PRIMARY_NAV = [
+    (0, 0, u'Home', ''),
+    (1, 1, u'Faculties', '/faculties'),
+    (2, 2, u'Search', '/search'),
+    ]
+
 class UtilityView(object):
     """A view mixin with useful methods.
 
-    XXX: This class was copied verbatim from megrok.layout trunk. It
-    can be imported with next release of megrok.layout, so that this
-    piece can be removed.
+    The ``pnav`` attribute (a number) tells, to which primary
+    navigation tab a page declares to belong.
     """
     title = u'' # What appears in the content title...
+    pnav = 0 # Primary navigation index...
     
     def application_url(self, name=None):
@@ -95,4 +111,34 @@
     grok.context(IWAeUPObject)
 
+    def getPrimaryNav(self, view):
+        """Get an ordered list of primary navigation entries.
+
+        Each is a dict with keys
+
+          'url': <link-target>
+          'active' : <value for HTML class attribute: 'active' or ''
+          'title': <text to be rendered in menu tab>
+          'order': <num indicating order num of this entry>
+
+        Pages attatched to this layout can provide an attribute 'pnav'
+        to indicate, to which tab they belong. This tab will then be
+        rendered 'active'.
+        """
+        result = []
+        app_url = view.application_url()
+        for item in PRIMARY_NAV:
+            active = ''
+            pnav = getattr(view, 'pnav', 0)
+            if pnav == item[0]:
+                active = 'active'
+            url =  app_url + item[3]
+            result.append(
+                dict(title=item[2],
+                     url=url,
+                     order=item[1],
+                     active=active)
+                )
+        return sorted(result, key=lambda x: x['order'])
+    
     def isAuthenticated(self):
         """Return True if the calling user is authenticated.
@@ -102,9 +148,11 @@
     
     def getUserTitle(self):
+        """Return principal title of current user.
+        """
         usertitle = self.request.principal.title
         if usertitle == 'Unauthenticated User':
             return u''
         return usertitle
-    
+
     def update(self):
         yui.reset_fonts_grids.need()
