| 268 | | def getEntries(self, category=None, maxResults=None, fromHere=0, filterState=1, sort=1, join=0, addCrossPostInfo=0, **kwargs): |
|---|
| | 268 | def getEntries(self, category=None, maxResults=None, fromHere=0, filterState=1, sort=1, join=0, addCrossPostInfo=0, skipOnTop=0, **kwargs): |
|---|
| 280 | | # first the items that need to be listed on top |
|---|
| 281 | | localOnTop = self.portal_catalog.searchResults(query, meta_type='BlogEntry', path={'query':self.simpleblog_tool.getObjectPath(self),'level':0}, sort_order='reverse', sort_on='effective') |
|---|
| 282 | | localOnTop = [r.getObject() for r in localOnTop ] |
|---|
| 283 | | # then the other items |
|---|
| 284 | | query['getAlwaysOnTop']=0 |
|---|
| 285 | | localNoTop = self.portal_catalog.searchResults(query, meta_type='BlogEntry', path={'query':self.simpleblog_tool.getObjectPath(self),'level':0}, sort_order='reverse', sort_on='effective') |
|---|
| | 279 | query['path'] = {'query':self.simpleblog_tool.getObjectPath(self),'level':0} |
|---|
| | 280 | query['sort_order'] = 'reverse' |
|---|
| | 281 | query['sort_on'] = 'effective' |
|---|
| | 282 | query['meta_type'] = 'BlogEntry' |
|---|
| | 283 | if not skipOnTop: |
|---|
| | 284 | query['getAlwaysOnTop']=1 |
|---|
| | 285 | # first the items that need to be listed on top |
|---|
| | 286 | localOnTop = self.portal_catalog.searchResults(query) |
|---|
| | 287 | localOnTop = [r.getObject() for r in localOnTop ] |
|---|
| | 288 | # then the other items |
|---|
| | 289 | query['getAlwaysOnTop']=0 |
|---|
| | 290 | else: |
|---|
| | 291 | localOnTop = [] |
|---|
| | 292 | localNoTop = self.portal_catalog.searchResults(query) |
|---|
| 288 | | # foreign items |
|---|
| 289 | | #if self.getAllowCrossPosting(): |
|---|
| 290 | | # foreignEntries = self.getForeignEntries() |
|---|
| 291 | | #else: |
|---|
| 292 | | # foreignEntries=[] |
|---|
| 293 | | |
|---|
| 294 | | # filter out the always on top entries |
|---|
| 295 | | #foreignOnTop = [e for e in foreignEntries if e.getAlwaysOnTop()] |
|---|
| 296 | | #foreignNoTop = [e for e in foreignEntries if not e.getAlwaysOnTop()] |
|---|
| 297 | | # so, now we have: |
|---|
| 298 | | # total = localOnTop + foreignOnTop + localNoTop + foreignNoTop |
|---|
| 299 | | # and that needs to be sorted |
|---|
| 300 | | #if addCrossPostInfo: |
|---|
| 301 | | # # make each object a tuple (obj, <iscrosspost>) |
|---|
| 302 | | # foreignOnTop = [(e,1) for e in foreignOnTop] |
|---|
| 303 | | # foreignNoTop = [(e,1) for e in foreignNoTop] |
|---|
| 304 | | # localOnTop = [(e,0) for e in localOnTop] |
|---|
| 305 | | # localNoTop = [(e,0) for e in localNoTop] |
|---|
| 306 | | onTop = localOnTop #foreignOnTop + |
|---|
| 307 | | onBottom = localNoTop #foreignNoTop + |
|---|
| 308 | | #if sort and foreignEntries: |
|---|
| 309 | | # if addCrossPostInfo: |
|---|
| 310 | | # onTop.sort((lambda x,y:cmp(y[0].effective(), x[0].effective()))) |
|---|
| 311 | | # onBottom.sort((lambda x,y:cmp(y[0].effective(), x[0].effective()))) |
|---|
| 312 | | # else: |
|---|
| 313 | | # onTop.sort((lambda x,y:cmp(y.effective(), x.effective()))) |
|---|
| 314 | | # onBottom.sort((lambda x,y:cmp(y.effective(), x.effective()))) |
|---|
| | 295 | onTop = localOnTop |
|---|
| | 296 | onBottom = localNoTop |
|---|