ReplyPtr TempaltePageHandler::Process(ContextPtr ctx) { try { StringPtr page(new std::string(ctx->Cfg()->PageTemplate())); ReplaceAll(ReplaceAll(page, "{{VIEWS}}", ctx->Db()->Views()->AllAsJson()), "{{CURRENT_VIEW}}", ctx->Query()->HasView() ? "'" + ctx->Query()->ViewName() + "'" : "null"); return Html(page); } catch(Exception& fe) { return Handler::Error(fe, true); } catch(std::exception& e) { return Handler::Error(FUGU_EXCEPT(e.what() ,"TempaltePageHandler::Process"), true); } }
/* --------------------------------------------------------------------------- * did_it_rlevel: Have player do something to/with thing, watching the * attributes. 'what' is actually ignored, the desclist match being used * instead. */ void did_it_rlevel ( dbref player, dbref thing, int what, const UTF8 *def, int owhat, const UTF8 *odef, int awhat, int ctrl_flags, const UTF8 *args[], int nargs ) { if (MuxAlarm.bAlarmed) { return; } UTF8 *d, *buff, *act, *charges, *bp; dbref aowner; int num, aflags; int i; bool found_a_desc; reg_ref **preserve = NULL; bool need_pres = false; // Message to player. // if (0 < what) { // Get description list. // DESC_INFO *desclist = desclist_match(player, thing); found_a_desc = false; for (i = 0; i < desclist->n; i++) { // Ok, if it's A_DESC, we need to check against A_IDESC. // if ( A_IDESC == what && A_DESC == desclist->descs[i]) { d = atr_pget(thing, A_IDESC, &aowner, &aflags); } else { d = atr_pget(thing, desclist->descs[i], &aowner, &aflags); } if ('\0' != d[0]) { // No need for the 'def' message. // found_a_desc = true; if (!need_pres) { need_pres = true; preserve = PushRegisters(MAX_GLOBAL_REGS); save_global_regs(preserve); } buff = bp = alloc_lbuf("did_it.1"); mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player, AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP), args, nargs); *bp = '\0'; if ( A_HTDESC == desclist->descs[i] && Html(player)) { safe_str(T("\r\n"), buff, &bp); *bp = '\0'; notify_html(player, buff); } else { notify(player, buff); } free_lbuf(buff); } free_lbuf(d); } if (!found_a_desc) { // No desc found... try the default desc (again). // A_DESC or A_HTDESC... the worst case we look for it twice. // d = atr_pget(thing, what, &aowner, &aflags); if ('\0' != d[0]) { // No need for the 'def' message // found_a_desc = true; if (!need_pres) { need_pres = true; preserve = PushRegisters(MAX_GLOBAL_REGS); save_global_regs(preserve); } buff = bp = alloc_lbuf("did_it.1"); mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player, AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP), args, nargs); *bp = '\0'; if ( A_HTDESC == what && Html(player)) { safe_str(T("\r\n"), buff, &bp); *bp = '\0'; notify_html(player, buff); } else { notify(player, buff); } free_lbuf(buff); } else if (def) { notify(player, def); } free_lbuf(d); } } else if ( what < 0 && def) { notify(player, def); } if (isPlayer(thing)) { d = atr_pget(mudconf.master_room, get_atr(T("ASSET_DESC")), &aowner, &aflags); if (*d) { if (!need_pres) { need_pres = true; preserve = PushRegisters(MAX_GLOBAL_REGS); save_global_regs(preserve); } buff = bp = alloc_lbuf("did_it.1"); mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player, AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP), args, nargs); *bp = '\0'; notify(player, buff); free_lbuf(buff); } free_lbuf(d); } // Message to neighbors. // dbref loc; if ( 0 < owhat && Has_location(player) && Good_obj(loc = Location(player))) { d = atr_pget(thing, owhat, &aowner, &aflags); if (*d) { if (!need_pres) { need_pres = true; preserve = PushRegisters(MAX_GLOBAL_REGS); save_global_regs(preserve); } buff = bp = alloc_lbuf("did_it.2"); mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player, AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP), args, nargs); *bp = '\0'; if (*buff) { if (aflags & AF_NONAME) { notify_except2_rlevel2(loc, player, player, thing, buff); } else { notify_except2_rlevel2(loc, player, player, thing, tprintf(T("%s %s"), Name(player), buff)); } } free_lbuf(buff); } else if (odef) { if (ctrl_flags & VERB_NONAME) { notify_except2_rlevel2(loc, player, player, thing, odef); } else { notify_except2_rlevel2(loc, player, player, thing, tprintf(T("%s %s"), Name(player), odef)); } } free_lbuf(d); } else if ( owhat < 0 && odef && Has_location(player) && Good_obj(loc = Location(player))) { if (ctrl_flags & VERB_NONAME) { notify_except2_rlevel2(loc, player, player, thing, odef); } else { notify_except2_rlevel2(loc, player, player, thing, tprintf(T("%s %s"), Name(player), odef)); } } // If we preserved the state of the global registers, restore them. // if (need_pres) { restore_global_regs(preserve); PopRegisters(preserve, MAX_GLOBAL_REGS); } // Do the action attribute. // if ( awhat > 0 && IsReal(thing, player)) { act = atr_pget(thing, awhat, &aowner, &aflags); if (*act != '\0') { charges = atr_pget(thing, A_CHARGES, &aowner, &aflags); if (*charges) { num = mux_atol(charges); if (num > 0) { buff = alloc_sbuf("did_it.charges"); mux_ltoa(num-1, buff); atr_add_raw(thing, A_CHARGES, buff); free_sbuf(buff); } else { buff = atr_pget(thing, A_RUNOUT, &aowner, &aflags); if (*buff != '\0') { free_lbuf(act); act = buff; } else { free_lbuf(act); free_lbuf(buff); free_lbuf(charges); return; } } } free_lbuf(charges); CLinearTimeAbsolute lta; wait_que(thing, player, player, AttrTrace(aflags, 0), false, lta, NOTHING, 0, act, nargs, args, mudstate.global_regs); } free_lbuf(act); } }
//##ModelId=474D3058036E BOOL COleClipSource::DoImmediateRender() { if(m_bLoadedFormats) return TRUE; m_bLoadedFormats = true; int count = m_ClipIDs.GetSize(); if(count <= 0) return 0; BOOL bProcessedMult = FALSE; if(count > 1) { CStringA SepA = CTextConvert::ConvertToChar(g_Opt.GetMultiPasteSeparator()); CCF_TextAggregator CFText(SepA); if(m_ClipIDs.AggregateData(CFText, CF_TEXT, g_Opt.m_bMultiPasteReverse && g_Opt.m_bHistoryStartTop)) { CacheGlobalData(CF_TEXT, CFText.GetHGlobal()); bProcessedMult = TRUE; } CStringW SepW = CTextConvert::ConvertToUnicode(g_Opt.GetMultiPasteSeparator()); CCF_UnicodeTextAggregator CFUnicodeText(SepW); if(m_ClipIDs.AggregateData(CFUnicodeText, CF_UNICODETEXT, g_Opt.m_bMultiPasteReverse && g_Opt.m_bHistoryStartTop)) { CacheGlobalData(CF_UNICODETEXT, CFUnicodeText.GetHGlobal()); bProcessedMult = TRUE; } if(m_bOnlyPaste_CF_TEXT == false) { CCF_HDropAggregator HDrop; if(m_ClipIDs.AggregateData(HDrop, CF_HDROP, g_Opt.m_bMultiPasteReverse && g_Opt.m_bHistoryStartTop)) { CacheGlobalData(CF_HDROP, HDrop.GetHGlobal()); bProcessedMult = TRUE; } CRichTextAggregator RichText(SepA); if(m_ClipIDs.AggregateData(RichText, theApp.m_RTFFormat, g_Opt.m_bMultiPasteReverse && g_Opt.m_bHistoryStartTop)) { CacheGlobalData(theApp.m_RTFFormat, RichText.GetHGlobal()); bProcessedMult = TRUE; } CHTMLFormatAggregator Html(SepA); if(m_ClipIDs.AggregateData(Html, theApp.m_HTML_Format, g_Opt.m_bMultiPasteReverse && g_Opt.m_bHistoryStartTop)) { CacheGlobalData(theApp.m_HTML_Format, Html.GetHGlobal()); bProcessedMult = TRUE; } } } if(count >= 1 && bProcessedMult == FALSE) { CClip clip; CClipFormats formats; clip.LoadFormats(m_ClipIDs[0], m_bOnlyPaste_CF_TEXT); return PutFormatOnClipboard(&clip.m_Formats, m_bPasteHTMLFormatAs_CF_TEXT); } return bProcessedMult; }
BOOL COleClipSource::DoImmediateRender() { if(m_bLoadedFormats) return TRUE; m_bLoadedFormats = true; if(m_pasteOptions.m_pPasteFormats != NULL) { return PutFormatOnClipboard(m_pasteOptions.m_pPasteFormats) > 0; } INT_PTR count = m_ClipIDs.GetSize(); if(count <= 0) return 0; CClip clip; if(count > 1) { CStringA SepA = CTextConvert::ConvertToChar(g_Opt.GetMultiPasteSeparator()); CCF_TextAggregator CFText(SepA); if(m_ClipIDs.AggregateData(CFText, CF_TEXT, g_Opt.m_bMultiPasteReverse)) { CClipFormat cf(CF_TEXT, CFText.GetHGlobal()); clip.m_Formats.Add(cf); //clip.m_Formats now owns the global data cf.m_autoDeleteData = false; } CStringW SepW = CTextConvert::ConvertToUnicode(g_Opt.GetMultiPasteSeparator()); CCF_UnicodeTextAggregator CFUnicodeText(SepW); if(m_ClipIDs.AggregateData(CFUnicodeText, CF_UNICODETEXT, g_Opt.m_bMultiPasteReverse)) { CClipFormat cf(CF_UNICODETEXT, CFUnicodeText.GetHGlobal()); clip.m_Formats.Add(cf); //clip.m_Formats now owns the global data cf.m_autoDeleteData = false; } if ((m_pasteOptions.LimitFormatsToText()) && clip.m_Formats.GetCount() == 0) { CCF_HDropAggregator HDrop; if (m_ClipIDs.AggregateData(HDrop, CF_HDROP, g_Opt.m_bMultiPasteReverse)) { CClipFormat cf(CF_UNICODETEXT, HDrop.GetHGlobalAsString()); clip.m_Formats.Add(cf); //clip.m_Formats now owns the global data cf.m_autoDeleteData = false; } } else if (m_pasteOptions.LimitFormatsToText() == false) { CCF_HDropAggregator HDrop; if(m_ClipIDs.AggregateData(HDrop, CF_HDROP, g_Opt.m_bMultiPasteReverse)) { CClipFormat cf(CF_HDROP, HDrop.GetHGlobal()); clip.m_Formats.Add(cf); //clip.m_Formats now owns the global data cf.m_autoDeleteData = false; } CRichTextAggregator RichText(SepA); if(m_ClipIDs.AggregateData(RichText, theApp.m_RTFFormat, g_Opt.m_bMultiPasteReverse)) { CClipFormat cf(theApp.m_RTFFormat, RichText.GetHGlobal()); clip.m_Formats.Add(cf); //clip.m_Formats now owns the global data cf.m_autoDeleteData = false; } CHTMLFormatAggregator Html(SepA); if(m_ClipIDs.AggregateData(Html, theApp.m_HTML_Format, g_Opt.m_bMultiPasteReverse)) { CClipFormat cf(theApp.m_HTML_Format, Html.GetHGlobal()); clip.m_Formats.Add(cf); //clip.m_Formats now owns the global data cf.m_autoDeleteData = false; } } } if (count >= 1 && clip.m_Formats.GetCount() == 0) { clip.LoadFormats(m_ClipIDs[0], m_pasteOptions.LimitFormatsToText(), m_pasteOptions.IncludeRTFForTextOnly()); } if (m_pasteOptions.LimitFormatsToText()) { PlainTextFilter(clip); } if(m_pasteOptions.m_pasteUpperCase || m_pasteOptions.m_pasteLowerCase) { DoUpperLowerCase(clip, m_pasteOptions.m_pasteUpperCase); } else if(m_pasteOptions.m_pasteCapitalize) { Capitalize(clip); } else if(m_pasteOptions.m_pasteSentenceCase) { SentenceCase(clip); } else if(m_pasteOptions.m_pasteRemoveLineFeeds) { RemoveLineFeeds(clip); } else if(m_pasteOptions.m_pasteAddOneLineFeed) { AddLineFeeds(clip, 1); } else if (m_pasteOptions.m_pasteAddTwoLineFeeds) { AddLineFeeds(clip, 2); } else if (m_pasteOptions.m_pasteTypoglycemia) { Typoglycemia(clip); } return PutFormatOnClipboard(&clip.m_Formats) > 0; }