Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
plone.app.viewletmanager.manager.ManageViewlets Class Reference
Inheritance diagram for plone.app.viewletmanager.manager.ManageViewlets:
Inheritance graph
[legend]
Collaboration diagram for plone.app.viewletmanager.manager.ManageViewlets:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def show
def hide
def moveAbove
def moveBelow
def __call__

Private Member Functions

def _getOrder

Detailed Description

Definition at line 154 of file manager.py.


Member Function Documentation

Definition at line 217 of file manager.py.

00217 
00218     def __call__(self):
00219         base_url = "%s/@@manage-viewlets" % str(
00220                        getMultiAdapter((self.context, self.request),
00221                        name='absolute_url')
00222                    )
00223         qs = self.request.get('QUERY_STRING', None)
00224         if qs is not None:
00225             query = parse_qs(qs)
00226             if 'show' in query:
00227                 for name in query['show']:
00228                     manager, viewlet = name.split(':')
00229                     self.show(manager, viewlet)
00230                     self.request.response.redirect(base_url)
00231                     return ''
00232             if 'hide' in query:
00233                 for name in query['hide']:
00234                     manager, viewlet = name.split(':')
00235                     self.hide(manager, viewlet)
00236                     self.request.response.redirect(base_url)
00237                     return ''
00238             if 'move_above' in query:
00239                 for name in query['move_above']:
00240                     manager, viewlets = name.split(':')
00241                     viewlet, dest = viewlets.split(';')
00242                     self.moveAbove(manager, viewlet, dest)
00243                     self.request.response.redirect(base_url)
00244                     return ''
00245             if 'move_below' in query:
00246                 for name in query['move_below']:
00247                     manager, viewlets = name.split(':')
00248                     viewlet, dest = viewlets.split(';')
00249                     self.moveBelow(manager, viewlet, dest)
00250                     self.request.response.redirect(base_url)
00251                     return ''
00252         return self.index()

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.viewletmanager.manager.ManageViewlets._getOrder (   self,
  manager_name 
) [private]

Definition at line 173 of file manager.py.

00173 
00174     def _getOrder(self, manager_name):
00175         storage = getUtility(IViewletSettingsStorage)
00176         skinname = self.context.getCurrentSkinName()
00177         manager = queryMultiAdapter(
00178             (self.context, self.request, self), IContentProvider, manager_name)
00179         viewlets = getAdapters(
00180             (manager.context, manager.request, manager.__parent__, manager),
00181             IViewlet)
00182         order_by_name = storage.getOrder(manager_name, skinname)
00183         # first get the known ones
00184         name_map = dict(viewlets)
00185         result = []
00186         for name in order_by_name:
00187             if name in name_map:
00188                 result.append((name, name_map[name]))
00189                 del name_map[name]
00190 
00191         # then sort the remaining ones
00192         # Copied from Five
00193         remaining = sorted(name_map.items(),
00194                            lambda x, y: cmp(aq_base(x[1]), aq_base(y[1])))
00195 
00196         return [x[0] for x in result + remaining]

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.viewletmanager.manager.ManageViewlets.hide (   self,
  manager,
  viewlet 
)

Definition at line 165 of file manager.py.

00165 
00166     def hide(self, manager, viewlet):
00167         storage = getUtility(IViewletSettingsStorage)
00168         skinname = self.context.getCurrentSkinName()
00169         hidden = storage.getHidden(manager, skinname)
00170         if viewlet not in hidden:
00171             hidden = hidden + (viewlet,)
00172             storage.setHidden(manager, skinname, hidden)

Here is the caller graph for this function:

def plone.app.viewletmanager.manager.ManageViewlets.moveAbove (   self,
  manager,
  viewlet,
  dest 
)

Definition at line 197 of file manager.py.

00197 
00198     def moveAbove(self, manager, viewlet, dest):
00199         storage = getUtility(IViewletSettingsStorage)
00200         skinname = self.context.getCurrentSkinName()
00201         order = self._getOrder(manager)
00202         viewlet_index = order.index(viewlet)
00203         del order[viewlet_index]
00204         dest_index = order.index(dest)
00205         order.insert(dest_index, viewlet)
00206         storage.setOrder(manager, skinname, order)

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.viewletmanager.manager.ManageViewlets.moveBelow (   self,
  manager,
  viewlet,
  dest 
)

Definition at line 207 of file manager.py.

00207 
00208     def moveBelow(self, manager, viewlet, dest):
00209         storage = getUtility(IViewletSettingsStorage)
00210         skinname = self.context.getCurrentSkinName()
00211         order = self._getOrder(manager)
00212         viewlet_index = order.index(viewlet)
00213         del order[viewlet_index]
00214         dest_index = order.index(dest)
00215         order.insert(dest_index+1, viewlet)
00216         storage.setOrder(manager, skinname, order)

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.viewletmanager.manager.ManageViewlets.show (   self,
  manager,
  viewlet 
)

Definition at line 157 of file manager.py.

00157 
00158     def show(self, manager, viewlet):
00159         storage = getUtility(IViewletSettingsStorage)
00160         skinname = self.context.getCurrentSkinName()
00161         hidden = storage.getHidden(manager, skinname)
00162         if viewlet in hidden:
00163             hidden = tuple(x for x in hidden if x != viewlet)
00164             storage.setHidden(manager, skinname, hidden)

Here is the caller graph for this function:


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