Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
ATContentTypes.browser.nextprevious.ATFolderNextPrevious Class Reference

List of all members.

Public Member Functions

def __init__
def getNextItem
def getPreviousItem
def enabled
def itemRelatives
def buildNextPreviousQuery
def buildNextPreviousItem
def getViewUrl

Public Attributes

 context
 view_action_types

Detailed Description

Let a folder act as a next/previous provider. This will be 
automatically found by the @@plone_nextprevious_view and viewlet.

Definition at line 12 of file nextprevious.py.


Constructor & Destructor Documentation

Definition at line 20 of file nextprevious.py.

00020 
00021     def __init__(self, context):
00022         self.context  = context
00023         
00024         sp = getToolByName(self.context, 'portal_properties').site_properties
00025         self.view_action_types = sp.getProperty('typesUseViewActionInListings', ())


Member Function Documentation

Definition at line 100 of file nextprevious.py.

00100 
00101     def buildNextPreviousItem(self, brain):
00102         return {'id'          : brain.getId,
00103                 'url'         : self.getViewUrl(brain),
00104                 'title'       : brain.Title,
00105                 'description' : brain.Description,
00106                 'portal_type' : brain.portal_type,
00107                 }

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.browser.nextprevious.ATFolderNextPrevious.buildNextPreviousQuery (   self,
  position,
  range,
  sort_order = None 
)

Definition at line 74 of file nextprevious.py.

00074 
00075     def buildNextPreviousQuery(self, position, range, sort_order = None):
00076         sort_on                  = 'getObjPositionInParent'
00077         
00078         query                    = {}
00079         query['sort_on']         = sort_on
00080         query['sort_limit']      = 1
00081         query['path']            = dict(query = '/'.join(self.context.getPhysicalPath()),
00082                                         depth = 1)
00083                 
00084         # Query the position using a range
00085         if position == 0:
00086             query[sort_on]       = 0
00087         else:
00088             query[sort_on]       = dict(query = position, range = range)
00089 
00090         # Filters on content
00091         query['is_default_page'] = False
00092         query['is_folderish']    = False
00093 
00094         # Should I sort in any special way ?
00095         if sort_order:
00096             query['sort_order']  = sort_order
00097 
00098         return query
00099 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 35 of file nextprevious.py.

00035 
00036     def enabled(self):
00037         return self.context.getNextPreviousEnabled()

Definition at line 26 of file nextprevious.py.

00026 
00027     def getNextItem(self, obj):
00028         relatives = self.itemRelatives(obj.getId())
00029         return relatives["next"]
        

Here is the call graph for this function:

Definition at line 30 of file nextprevious.py.

00030 
00031     def getPreviousItem(self, obj):
00032         relatives = self.itemRelatives(obj.getId())
00033         return relatives["previous"]

Here is the call graph for this function:

create link and support contents that requires /view 

Definition at line 108 of file nextprevious.py.

00108 
00109     def getViewUrl(self, brain):
00110         """create link and support contents that requires /view 
00111         """
00112         item_url = brain.getURL()
00113     
00114         if brain.portal_type in self.view_action_types:
00115             item_url += '/view'
00116     
        return item_url

Here is the caller graph for this function:

Get the relative next and previous items

Definition at line 39 of file nextprevious.py.

00039 
00040     def itemRelatives(self, oid):
00041         """Get the relative next and previous items
00042         """
00043         folder   = self.context
00044         catalog  = getToolByName(self.context, 'portal_catalog')
00045         position = folder.getObjectPosition(oid)
00046 
00047         previous = None
00048         next     = None
00049 
00050         # Get the previous item
00051         if position - 1 >= 0:
00052             prev_brain = catalog(self.buildNextPreviousQuery(position   = position - 1,
00053                                                              range      = 'max',
00054                                                              sort_order = 'reverse'))
00055             if prev_brain and len(prev_brain) > 0:
00056                 previous = self.buildNextPreviousItem(prev_brain[0])
00057 
00058 
00059         # Get the next item
00060         if (position + 1) < len(folder._objects):
00061             next_brain = catalog(self.buildNextPreviousQuery(position   = position + 1,
00062                                                              range      = 'min'))
00063             
00064             if next_brain and len(next_brain) > 0:
00065                 next   = self.buildNextPreviousItem(next_brain[0])
00066 
00067 
00068         nextPrevious = {
00069             'next'      : next,
00070             'previous'  : previous,
00071             }
00072 
00073         return nextPrevious
        

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 21 of file nextprevious.py.

Definition at line 24 of file nextprevious.py.


The documentation for this class was generated from the following file: