Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: addEntryToBlogCmd Arguments: title,blogName,entry,img Description: Changes a blog entry. Page type: webl Render function: Module: siteutil Page source: // img: may be a URL or a string containing html for an image (with width and height parameters). var finfo = (Wub_GetFunctionInfo(blogName) ? nil); var module = (finfo.module ? wubinfo.user); var res = nil; var blogData = (WubEval(finfo.exec) ? nil); var blogtitle = (blogData.title ? nil); var entries = (blogData.entries ? nil); var editname = (blogData.editname ? nil); var editable = (blogData.editable ? "false"); if (blogData == nil) or (blogtitle == nil) or (entries == nil) then res = `Error: "` + blogName + `" does not appear to be a blog.` elsif (editname == nil) and (editable == "false") then res = `Error: "` + blogName + `" does not appear to be an editable blog.\nIf this is a blog, you should add a field "editname"="<yourmodule.yourblogname>".` end; // No errors, continue if res == nil then var id = (ToInt(entries[0].id) + 1 ? 1); var newEntry = [. title=title, content=entry, postedby=wubinfo.user, when=Wub_GetDateTimeStr(), id = id .]; if (img != nil) and (Str_Trim(img) != "") then if Str_IndexOf(`<img`, img) >= 0 then newEntry.image := img else newEntry.image := `<img src="` + img + `">` end end; blogData.entries := [newEntry] + blogData.entries; finfo.exec := ToSource(blogData); res = Wub_SaveFunctionInfo(finfo); // res = finfo end; res;