Пример #1
0
String OMLReplace::processHtml(shared_ptr<OMLItem> i, shared_ptr<OMLContext> context) const
{
	if( (m_maxParams == 0) && (i->hasParams()) )
	{
		context->addWarningCantHaveParams(i);		
	}

	if( (m_minParams == 1) && (!i->hasParams()) )
	{
		context->addWarningParamRequired(i);
		return String::EMPTY;
	}

	if(!m_mapDefaultParamTo.empty())
	{
		mapDefaultParamTo(i, m_mapDefaultParamTo);
	}	

	String childsHtml = i->getHtmlChilds(context);

	String out;
	if(context->getMode() == omlRenderModeSearch)
		out = m_replacePlain;		
	else
		out = m_replaceHtml;
	
	out = out.replace_all(_S("{$body}"), childsHtml);
	for(StringCollection<String>::iterator i3 = i->getParams().begin(); i3 != i->getParams().end(); ++i3)
	{
		String paramName = i3->first;
		String paramValue = *i3->second;

		out = out.replace_all(_S("{$") + paramName + _S("}"), encodeToAttribute(context, paramValue));
	}

	// 11/05/2009 - Da abolire insieme alle varie "replace", in favore di classi specifiche.
	out = out.replace_all(_S("{$title}"), String::EMPTY);
	
	return out;
}
Пример #2
0
String OMLView::processHtml(shared_ptr<OMLItem> i, shared_ptr<OMLContext> context) const
{	
	if(context->checkPortalPageAvailable(i) == false) 
		return String::EMPTY;

	shared_ptr<IPortalPage> page = context->getPortalPage();
	if(page == nullptr) return String::EMPTY;

	mapDefaultParamTo(i, _S("mode"));

	String id = i->getHtmlChilds(context);

	String mode = i->getParam(_S("mode"));
	if(mode.empty())
	{
		mode = _S("row");
		i->setParam(_S("mode"), mode);
	}

	if( (mode != _S("row")) && (mode != _S("lite")) && (mode != _S("full")) )
	{
		context->addWarning(String::format(_S("%S doesn't support the mode '%S'.").c_str(), context->getFriendlyName(i).c_str(), mode.c_str()));
		return String::EMPTY;
	}

	shared_ptr<XMLDocument> doc = initDocument(i, context);
		
	XMLPortalExporter::ExportMode exportMode = (mode != _S("row")) ? XMLPortalExporter::emFull : XMLPortalExporter::emLite;
	bool withStats = (mode != _S("row"));

	shared_ptr<XMLNode> nodeUser = doc->getRoot()->addChild(_S("object"));
	shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(nodeUser, page, exportMode, withStats));
	shared_ptr<ObjectsIObject> object = page->getObject(id.to_ascii());
	if(object != nullptr)
	{
		object->exportXML(exporter);
	}

	return processDocument(doc, i, context);	
}
Пример #3
0
String OMLQuote::processHtml(shared_ptr<OMLItem> i, shared_ptr<OMLContext> context) const
{	
	mapDefaultParamTo(i, _S("title"));

	String title = encodeOML(context, i->getParam(_S("title")));

	if(context->getMode() != omlRenderModeSearch)
	{			
		if(i->hasParam(_S("id")))
		{
			shared_ptr<const IPortalPage> page = context->getPortalPage();
			if(page != nullptr)
			{
				String id = i->getParam(_S("id"));
				shared_ptr<EntitiesEntity> entity = page->getPortal()->getEntity(page->getDatabase(), id.to_ascii());
				if(entity != nullptr)
				{
					shared_ptr<ObjectsIRevisionable> current = entity->getCurrent();
					if(current != nullptr)
					{
						if(current->isVisible())
						{
							shared_ptr<ObjectsUser> author = objects_user_cast(page->getObject(current->getAuthor()));

							String authorNick = encode(context, author->name);
							String itemDate = encode(context, context->getPage()->formatDate(current->submit_date, DateTime::dpUserFriendly));

							String imageLinkUrl = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/quote_link.gif"));
							imageLinkUrl = encode(context, imageLinkUrl);
							
							if(!title.empty())
								title += _S(" ");
							String entryHref = encode(context, entity->getViewLink(page->getPortal()));
							title += String::format(_S("(%S @ %S)<a href=\"%S\"><img src=\"%S\"></a>").c_str(), authorNick.c_str(), itemDate.c_str(), entryHref.c_str(), imageLinkUrl.c_str());
						}
						else
						{
							title += getText(context, _S("oml.quote.messages.hidden_id"));
						}
					}
					else
					{
						title += getText(context, _S("oml.quote.messages.skipped_id"));
					}
				}
				else
				{
					title += getText(context, _S("oml.quote.messages.unknown_id"));
				}
			}
		}	
	}

	String body = i->getHtmlChilds(context);
	
	if(context->getMode() == omlRenderModeSearch)
	{
		return _S(" ") + title + _S(" ") + body + _S(" ");
	}
	else
	{
		return _S("<div class=\"") + OS_CSS_OML_QUOTETOP + _S("\">") + title + _S("</div><div class=\"") + OS_CSS_OML_QUOTEMAIN + _S("\">") + body + _S("</div>");
	}
}