void ATemplateNodeHandler_MODEL::Node::process(ATemplateContext& context, AOutputBuffer& output) { AAutoPtr<AEventVisitor::ScopedEvent> scoped; if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) { scoped.reset(new AEventVisitor::ScopedEvent(context.useEventVisitor(), ASW("ATemplateNodeHandler_MODEL",26), m_BlockData, AEventVisitor::EL_DEBUG)); } if (m_BlockData.isEmpty()) return; AXmlElement *pElement = context.useModel().useRoot().findElement(m_BlockData); if (pElement) { //a_Found object pElement->emitContent(output); } else { ARope rope("<!--Unable to find element for '",32); rope.append(m_BlockData); rope.append("'-->",4); output.append(rope); } }
void ATemplateNodeHandler_DADA::Node::process(ATemplateContext& context, AOutputBuffer& output) { AAutoPtr<AEventVisitor::ScopedEvent> scoped; if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) { scoped.reset(new AEventVisitor::ScopedEvent(context.useEventVisitor(), ASWNL("ATemplateNodeHandler_DADA::Node"), m_BlockData, AEventVisitor::EL_DEBUG)); } if (m_BlockData.isEmpty()) return; AString dataset; if (!context.useModel().useRoot().emitContentFromPath(AOS_DadaData_Constants::DATASETPATH, dataset)) { context.useEventVisitor().addEvent(ASWNL("ATemplateNodeHandler_DADA::Node:") + " dataset not defined for the node", AEventVisitor::EL_ERROR); return; } ADadaDataHolder *pddh = ((ATemplateNodeHandler_DADA *)mp_Handler)->m_Objects.useAsPtr<ADadaDataHolder>(dataset); if (!pddh) { context.useEventVisitor().addEvent(ASWNL("ATemplateNodeHandler_DADA::Node:") + " ADadaDataHolder not found for name: "+dataset, AEventVisitor::EL_ERROR); return; } VARIABLEMAP *pGlobals = context.useObjects().useAsPtr<VARIABLEMAP>(AOS_DadaData_Constants::GLOBALSPATH); if (NULL == pGlobals) { pGlobals = new VARIABLEMAP(); context.useObjects().insert(AOS_DadaData_Constants::GLOBALSPATH, pGlobals, true); } _generateLine(pddh, pGlobals->vmap, m_BlockData, context, output); }
void ATemplateNodeHandler_RESOURCE::Node::process(ATemplateContext& ctx, AOutputBuffer& output) { AAutoPtr<AEventVisitor::ScopedEvent> scoped; if (ctx.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) { scoped.reset(new AEventVisitor::ScopedEvent(ctx.useEventVisitor(), ASW("ATemplateNodeHandler_RESOURCE",28), m_BlockData, AEventVisitor::EL_DEBUG)); } if (m_BlockData.isEmpty()) return; // Get resource AOSContext *pContext = ctx.useObjects().useAsPtr<AOSContext>(AOSContext::OBJECTNAME); if (!pContext) { ARope rope("Must have AOSContext object named: ",35); rope.append(AOSContext::OBJECTNAME); ATHROW_EX(this, AException::NotFound, rope); } LIST_AString languages; pContext->useRequestHeader().getAcceptLanguageList(languages); const AXmlDocument *pDoc = pContext->useServices().useResourceManager().getResources(languages); if (!pDoc) { if (pContext->useEventVisitor().isLogging(AEventVisitor::EL_WARN)) { pContext->useEventVisitor().startEvent(ASW("Unable to find resource container for locales in Accept-Languages",65), AEventVisitor::EL_WARN); } return; } const AXmlElement *pElement = pDoc->getRoot().findElement(m_BlockData); if (pElement) { //a_Found object pElement->emitContent(output); } else { if (pContext->useEventVisitor().isLogging(AEventVisitor::EL_WARN)) { ARope rope("Unable to find resource element: ",33); rope.append(m_BlockData); pContext->useEventVisitor().startEvent(rope, AEventVisitor::EL_WARN); } } }
void ATemplateNodeHandler_LUA::Node::process(ATemplateContext& context, AOutputBuffer& output) { AAutoPtr<AEventVisitor::ScopedEvent> scoped; if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) { scoped.reset(new AEventVisitor::ScopedEvent(context.useEventVisitor(), ASW("ATemplateNodeHandler_LUA",24), m_BlockData, AEventVisitor::EL_DEBUG)); } if (m_BlockData.isEmpty()) return; ALuaTemplateContext *pLuaTemplateContext = dynamic_cast<ALuaTemplateContext *>(&context); if (pLuaTemplateContext) { //a_Have a Lua context with its own interpreter if (!pLuaTemplateContext->useLua().execute(m_BlockData, context, output)) { output.append(" block(context)={{{\r\n",21); output.append(m_BlockData); output.append("}}}\r\n",5); context.useEventVisitor().addEvent(output, AEventVisitor::EL_ERROR); } } else { //a_Create a temporary interpreter, this is the less efficient way of doing it ALuaEmbed lua; if (!lua.execute(m_BlockData, context, output)) { output.append(" block(local)={{{\r\n",19); output.append(m_BlockData); output.append("}}}\r\n",5); context.useEventVisitor().addEvent(output, AEventVisitor::EL_ERROR); } } }