Пример #1
0
extern "C" OS_SDK_API os_result osiris_parse_link(const char *link, char *value, os_uint32 *size)
{
	if(Application::exists() == false || Engine::exists() == false)
		return OS_SDK_ERROR_NOT_INITIALIZED;

	if((link == NULL) || (size == NULL))
		return OS_SDK_ERROR_INVALID_PARAM;

	String tmp;	

	OsirisLink shellLink;
	if(shellLink.parse(tmp.from_utf8(link).to_ascii()) == false)
		return OS_SDK_ERROR_ILLEGAL_VALUE;

	tmp.clear();
	if(Engine::instance()->processLink(shellLink, tmp) == false)
		return OS_SDK_ERROR_GENERIC;

	std::string out_value = tmp.to_utf8();

	os_result result = OS_SDK_OK;

	os_uint32 out_size = static_cast<os_uint32>(out_value.size());

	if(value != NULL)
	{
		if(*size < out_size)
			result = OS_SDK_ERROR_BUFFER_TOO_SMALL;
		else
			memcpy(value, out_value.data(), out_size);			
	}

	*size = out_size;

	return result;
}
Пример #2
0
void EntitiesEntity::exportXML(shared_ptr<XMLPortalExporter> exporter)
{
	if(m_current == nullptr)
		return;

	m_current->exportXML(exporter);

	// "showable"  diverso dal "visible" esportato dalla corrente.
	// Un oggetto potrebbe essere invisibile per diversi motivi, ad esempio se il padre  invisibile.
	exporter->getRoot()->setAttributeBool(_S("showable"), m_visible);
	exporter->getRoot()->setAttributeUint32(_S("depth"), m_depth);
	exporter->getRoot()->setAttributeString(_S("section"), m_section.toUTF16());

	/* URGENT da testare
	// Se la sezione non  lui stesso
	if(m_section != getPrimaryID())
	{
		entity_ptr section = getLoggedUser()->getEntity(m_section);
		if(section != nullptr)
		{
			shared_ptr<XMLNode> nodeSection = exporter->getRoot()->addChild(_S("section"));
			shared_ptr<XMLPortalExporter> exporterSection(OS_NEW XMLExporter(nodeSection, getPage(), false));
			section->exportXML(exporterSection);
		}
	}
	*/

	//if(exporter->getMode() == XMLPortalExporter::emFull)
	{
		String id = getEntityID().toUTF16();
		String portal = exporter->getPortal()->getPortalID().toUTF16();
		String title = exporter->getRoot()->getAttributeString(_S("title"));
		if(title.empty())
			title = id;

		/*
		String omlCodeView;
		if(id != String::EMPTY)
			omlCodeView = String::format(_S("[iurl=\"osiris://|url|portals/view|id=%S&portal=%S\"]%S[/iurl]").c_str(), id.c_str(), portal.c_str(), title.c_str());
		else
			omlCodeView = String::format(_S("[iurl=\"osiris://|url|portals/view|portal=%S\"]%S[/iurl]").c_str(), portal.c_str(), title.c_str());
		exporter->getRoot()->setAttributeString(_S("oml_code2"),omlCodeView);
		*/

		OsirisLink link;
		link.setParam("type", _W("url"));
		link.setParam("portal", portal.to_wide());
		if(id != String::EMPTY)
			link.setParam("url",_W("/portals/view?id=") + id.to_wide());
		else
			link.setParam("url",_W("/portals/view"));

		exporter->getRoot()->setAttributeString(_S("oml_code"),_S("[iurl=\"") + link.generate() + _S("\"]") + title + _S("[/iurl]"));	
		
	}
}
Пример #3
0
void Subscribe::onSubscribe()
{
	if(m_driver == nullptr)
	{
		reportError(httpStatusServiceUnavailable);
		return;
	}

	PortalID portalID = m_portalID->getValue().to_ascii();
	String portalName = m_portalName->getValue();
	PovID portalPov = m_portalPov->getValue().to_ascii();

	if(m_showPortalParams->getCheck() == false)
	{
		OsirisLink link;
		if(link.parse(m_portalLink->getValue().to_ascii()) == false || (link.getType() != OsirisLink::linkPortal))
		{
			showError(getText("main.pages.subscribe.error.invalidPortalLink"));
			return;
		}
		
		portalID = link.getPortal();
		portalName = link.getName();
		portalPov = link.getPov();
	}

	shared_ptr<Portal> currentPortal = PortalsSystem::instance()->getPortal(portalID, portalPov);
	if(currentPortal != nullptr)
	{
		redirect(currentPortal->getLink("view"));
		return;
	}

	if(m_driverOptions != nullptr)
	{
		const ordered_map<String, String> &driverParams = m_driverOptions->getParams();
		for(ordered_map<String, String>::const_iterator i = driverParams.begin(); i != driverParams.end(); ++i)
		{
			shared_ptr<IHtmlInput> optionControl = getDriverOptionControl(m_driver->getName(), i->first);
			if(optionControl != nullptr)
			{
				const String &paramValue = optionControl->getValue();
				if(paramValue.empty() == false)
					m_driverOptions->setParam(i->first, paramValue);
			}
		}
	}

	shared_ptr<PortalOptions> options(OS_NEW PortalOptions());
	options->setPortalID(portalID);
	options->setPovID(portalPov);
	options->setName(portalName);
	options->setPassword(m_portalPassword->getValue());
	OS_ASSERT(m_driver->getName() == m_databaseDriver->getValue());
	options->setDatabaseDriver(m_driver->getName());
	options->setDatabaseOptions(m_driverOptions);

	shared_ptr<Portal> portal = PortalsSystem::instance()->subscribePortal(options);
	if(portal != nullptr)
		//redirect(PortalsSystem::instance()->getAccountsLink(PortalsSystem::instance()->getPortal(portalID, portalUser)));
		redirect(PortalsSystem::instance()->getPortalLink(portal, "view"));
	else
		showError(getText("main.pages.subscribe.error.cannotCreate"));
}