| 247 | | |
|---|
| 248 | | security.declarePublic('searchForEntries') |
|---|
| 249 | | def collectEntries(self, context, category=None, maxResults=None, filterState=1, allBlogs=0, **kwargs): |
|---|
| 250 | | # first get all the blogs |
|---|
| 251 | | if allBlogs: |
|---|
| 252 | | query = {'meta_type':'Blog', |
|---|
| 253 | | 'path':{'query':self.getObjectPath(context),'level':0} |
|---|
| 254 | | } # used meta_type because for some reason, syndication objects also show up. |
|---|
| 255 | | blogs = [b.getObject() for b in self.portal_catalog.searchResults(query)] |
|---|
| 256 | | onTop=[] |
|---|
| 257 | | atBottom=[] |
|---|
| 258 | | # now collect all the entries |
|---|
| 259 | | for blog in blogs: |
|---|
| 260 | | tmpTop, tmpBottom = blog.getEntries(category=category, maxResults=maxResults, filterState = filterState, sort=0, **kwargs) |
|---|
| 261 | | onTop = onTop+tmpTop |
|---|
| 262 | | atBottom = atBottom+tmpBottom |
|---|
| 263 | | #sort |
|---|
| 264 | | onTop.sort((lambda x,y:cmp(y.effective(), x.effective()))) |
|---|
| 265 | | atBottom.sort((lambda x,y:cmp(y.effective(), x.effective()))) |
|---|
| 266 | | |
|---|
| 267 | | results = onTop+atBottom |
|---|
| 268 | | else: |
|---|
| 269 | | results = context.getEntries(category=category, maxResults=maxResults, filterState = filterState, sort=0, join=1, skipOnTop=1, **kwargs) |
|---|
| 270 | | |
|---|
| 271 | | if maxResults==0: |
|---|
| 272 | | return results |
|---|
| 273 | | elif maxResults==None: |
|---|
| 274 | | return results[:self._getMaxItemsInPortlet()] |
|---|
| 275 | | else: |
|---|
| 276 | | return results[:maxResults] |
|---|