Esempio n. 1
0
// Se è un url di un'immagine interna, valorizza in objectID l'oggetto a cui si riferisce.
String IOMLCode::encodeResourceUrlEx(shared_ptr<OMLContext> context, shared_ptr<OMLItem> i, const String& href, String& entityID)
{
	if(context->getMode() == omlRenderModeSearch) // 0.15
		return href;

	String src = cleanUrl(context, href);

	OsirisLink osirisLink(src.to_ascii());
	if(osirisLink.isValid())
	{
		if(osirisLink.getType() == OsirisLink::linkResource)
		{
			src = context->getPage()->getSkin()->getResourceUrl(osirisLink.getParam("path"));
			if(src.empty())
			{
				src = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/img_missing.gif"));
			}
			if(context->getMode() == omlRenderModeExternal)
				src = IdeSystem::instance()->getLocalUrl(src);
		}
		else if(osirisLink.getType() == OsirisLink::linkFile)
		{
			shared_ptr<Portal> portal = nullptr;

			shared_ptr<const IPortalPage> page = context->getPortalPage();

			if(osirisLink.hasParam("portal"))
			{
				PortalID portalID = osirisLink.getPortal();
									
				if( (page != nullptr) && (portalID == page->getPortal()->getPortalID()) ) // Force the use of the current POV
					portal = page->getPortal();
				else
				{
					portal = PortalsSystem::instance()->getFirstPortal(portalID);
				}
			}
			else
			{
				shared_ptr<const IPortalPage> page = context->getPortalPage();
				if(page != nullptr)
				{
					portal = page->getPortal();
				}
			}
						
			if(portal != nullptr)
			{
				String id = osirisLink.getParam("id");
				
				shared_ptr<EntitiesEntity> entity = portal->getEntity(page->getDatabase(), EntityID(id.to_ascii()));

				shared_ptr<ObjectsIObject> current = entity ? entity->getCurrent() : nullptr;

				if( (current != nullptr) && (current->getObjectType() == portalObjectTypeFile) )
				{
					src = portal->getFileLink(id.to_ascii());					
					entityID = id.to_ascii();
				}
				else
				{
					src = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/img_unknown.gif"));					
				}

				if(context->getMode() == omlRenderModeExternal)
					src = IdeSystem::instance()->getLocalUrl(src);
			}
		}
	}
	else
	{
		String protocol = extractProtocol(src);
		if( (protocol == _S("http")) || (protocol == _S("https")) )
		{
			if(context->getMode() == omlRenderModeExternal)
			{			
			}
			else
			{
				// Check se sono abilitati i link esterni
				if((context->getSecure()) || (!bool(context->getPage()->getOption(Options::privacy_options::allow_external_images))))
				{
					context->setSecureCheck(false);
					src = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/img_notallowed.gif"));				
				}
			}
		}		
		else if(protocol == String::EMPTY)
		{
			// Osiris 0.13
			// If protocol can't be determined, it's a relative url. Relative url are accepted.
			if(context->getMode() == omlRenderModeExternal)
				src = IdeSystem::instance()->getLocalUrl(src);

			return src;
		}
		else
		{
			context->addWarningInvalidUrl(i, src);
			src = String::EMPTY;
		}
	}
	return src;
}
Esempio n. 2
0
 inline EntityID operator --(const int)
 {
     decltype(m_ID) previous_val { m_ID };    // postfix
     --(*this);
     return EntityID(previous_val);
 }