def setContent(self, page_id, new_val=""): new_val = unicode(new_val, 'utf8') new_val = new_val.replace("\r\n", "\n") #Update Page with new title Model.Pages.setPageContent(page_id, new_val) AmiCache.expireCache(page_id) if Users.getViewEditMode() == 'on': result = Model.Pages.getPageById(page_id).getContentEdit() else: result = Model.Pages.getPageById(page_id).getContent() return result
def setPageHidden(self, page_id, value): Users.checkCurrentPagePermissions() Model.Pages.setPageHidden(page_id, value) #Expire the parent also page_obj = Model.Pages.getPageById(page_id) if page_obj.parent_id: AmiCache.expireCache(page_obj.parent_id) #Expire every page in the menu for m_item in Model.MenuItems.getItemsByMenuId(1): AmiCache.expireCache(m_item.page_id) AmiCache.expireCurrentPage() return value
def setParent(self, page_id, parent_id): page_id = int(page_id) parent_id = int(parent_id) if parent_id == 0: parent_id = None current_page = Model.Pages.getPageById(page_id) if parent_id: parent_page = Model.Pages.getPageById(parent_id) #Make sure the current page isn't a parent for that parent parents = parent_page.getParentList() for pa in parents: if pa.id == page_id: raise amiweb.AppError( "You can't changes a parents child to be a parent of the parent... I.e. recursion problem!" ) old_parent = current_page.getParent() Model.Pages.setParent(page_id, parent_id) #Expire havoc AmiCache.expireCache(page_id) if old_parent: AmiCache.expireCache(old_parent.id) if parent_id: AmiCache.expireCache(parent_id) return "ok"
def revert(self, page_id, rev): obj_rev = Model.PageLogs.getLogByRev(page_id, rev) Model.Pages.setPageContent(page_id, obj_rev.text) AmiCache.expireCache(page_id) return 'ok'
def pageLinkUpdate(self, page_link_id, new_page_id, current_pid): Model.PageLinks.set(page_link_id, new_page_id) AmiCache.expireCache(current_pid) page = Model.Pages.getPageById(new_page_id) return "%s/siteedit/%s" % (BASE_URL, page.getFullLink())
def pageCreate(self, parent_id, name): new_page = Model.Pages.insertPageFromWiki(parent_id, name) AmiCache.expireCache(parent_id) raise amiweb.HTTPFound("%s/siteedit/?page_id=%i" % (BASE_URL, new_page.id))
def expirePages(self, id): for page in upload_model.Files.getAllPagesWhereFileIsUsed(id): AmiCache.expireCache(page.id)