Ejemplo n.º 1
0
void HtmlImage::onRender(HtmlWriter &writer)
{
	writer.openTag(_S("img"));
	renderAttributes(writer);
	writer.selfCloseTag();
	writer.writeLine();
}
Ejemplo n.º 2
0
void HtmlTable::onRender(HtmlWriter &writer)
{
	writer.openTag(_S("table"));
	renderAttributes(writer);
	writer.closeTag();
	writer.writeLine();
	renderChilds(writer);
	writer.closeTag(_S("table"));
	writer.writeLine();
}
Ejemplo n.º 3
0
void HtmlImage::renderAttributes(HtmlWriter &writer)
{
	ControlBase::renderAttributes(writer);

	if(m_url.empty() == false)
		writer.writeAttribute(_S("src"), m_url);

	if(m_title.empty() == false)
		writer.writeAttribute(_S("title"), m_title);
}
Ejemplo n.º 4
0
void HtmlOptionGroup::onRender(HtmlWriter &writer)
{
	writer.openTag(_S("optgroup"));
	renderAttributes(writer);
	writer.closeTag();
	writer.writeLine();
	renderChilds(writer);
	writer.closeTag(_S("optgroup"));
	writer.writeLine();
}
Ejemplo n.º 5
0
void HtmlLinkButton::onRender(HtmlWriter &writer)
{
	writer.openTag(_S("a"));
	renderAttributes(writer);
	writer.closeTag();
	writer.writeLine();
	renderChilds(writer);
	writer.closeTag(_S("a"));
	writer.writeLine();
}
Ejemplo n.º 6
0
void IHtmlSelect::onRender(HtmlWriter &writer)
{
	writer.openTag(_S("select"));
	renderAttributes(writer);
	writer.closeTag();
	writer.writeLine();
	renderChilds(writer);
	writer.closeTag(_S("select"));
	writer.writeLine();
}
Ejemplo n.º 7
0
void HtmlCheckBox::renderAttributes(HtmlWriter &writer)
{
	ControlBase::renderAttributes(writer);

	writer.writeAttribute(_S("type"), _S("checkbox"));

	if(getCheck())
		writer.writeAttribute(_S("checked"), _S("checked"));

	if(getAutoPostBack())
		writer.writeAttribute(_S("onchange"), _S("javascript:return osAutoPostBack(this);"));
}
Ejemplo n.º 8
0
void IHtmlSelect::renderAttributes(HtmlWriter &writer)
{
	ControlBase::renderAttributes(writer);

	if(hasID())
	{
		writer.writeAttribute(_S("id"), getTarget());
		writer.writeAttribute(_S("name"), getTarget());
	}

	if(getEventChange()->empty() == false)
		writer.writeAttribute(_S("onchange"), getEventCommand(EVENT_ONCHANGE));
	else if(getAutoPostBack())
		writer.writeAttribute(_S("onchange"), _S("javascript:return osAutoPostBack(this);"));	
}
Ejemplo n.º 9
0
void HtmlOptionGroup::renderAttributes(HtmlWriter &writer)
{
	ControlBase::renderAttributes(writer);

	if(m_label.empty() == false)
		writer.writeAttribute(_S("label"), m_label);
}
Ejemplo n.º 10
0
void HtmlLinkButton::renderAttributes(HtmlWriter &writer)
{
	ControlBase::renderAttributes(writer);

	if(hasID())
		writer.writeAttribute(_S("href"), getEventCommand(EVENT_ONCLICK));
}
Ejemplo n.º 11
0
QString ReportDialog::generateHtmlReport( bool embedded )
{
    HtmlWriter writer;
    writer.setEmbedded( embedded );

    if ( m_source == ProjectSource ) {
        ProjectSummaryGenerator generator;
        generator.setProject( m_projectId );

        writer.setTitle( generator.title() );
        generator.write( &writer, HtmlText::NoInternalLinks );
    } else {
        ReportGenerator generator;

        if ( m_source == FolderSource ) {
            if ( m_folderId != 0 )
                generator.setFolderSource( m_folderId, m_issues );
            else if ( m_typeId != 0 )
                generator.setGlobalListSource( m_typeId, m_issues );

            if ( m_tableButton->isChecked() )
                generator.setTableMode( m_currentColumns );
            else if ( m_fullTableButton->isChecked() )
                generator.setTableMode( m_availableColumns );
            else
                generator.setSummaryMode( false, IssueDetailsGenerator::NoHistory );
        } else if ( m_source == IssueSource && !m_issues.isEmpty() ) {
            generator.setIssueSource( m_issues.first() );
            generator.setSummaryMode( true, m_fullReportButton->isChecked() ? m_history : IssueDetailsGenerator::NoHistory );
        }

        writer.setTitle( generator.title() );
        generator.write( &writer );
    }

    return writer.toHtml();
}
Ejemplo n.º 12
0
void HtmlLinkTag::render(HtmlWriter &writer)
{
	writer.openTag(_S("link"));

	if(m_rel.empty() == false)
        writer.writeAttribute(_S("rel"), m_rel);
	if(m_href.empty() == false)
		writer.writeAttribute(_S("href"), m_href);
	if(m_type.empty() == false)
        writer.writeAttribute(_S("type"), m_type);
	if(m_title.empty() == false)
        writer.writeAttribute(_S("title"), m_title);
	if(m_hreflang.empty() == false)
        writer.writeAttribute(_S("hreflang"), m_hreflang);

	//writer.closeTag();
	writer.selfCloseTag(); // 0.13 RC2
}
Ejemplo n.º 13
0
void FeedViewer::onLoad()
{
	ViewerBase::onLoad();

	shared_ptr<XMLNode> root = getModuleDocument()->getRoot();
	OS_ASSERT(root != nullptr);

	// Ajax:
	// - Creo un controllo per contenere quanto sotto
	// - Chiamo un "isDirect" a livello di ModuleViewer, che restituisce un "true" se son puntato diretto.
	// - Se si, leggo il parametro "mode", se è "direct" restituisco il contenuto del controllo secco via transmit-buffer
	// - Qui dumpo una chiamata ad ajax passandogli l'url di me in direct mode
	String mode = _S("direct");  // Proprietà?
	mode = _S("ajax");
	
	shared_ptr<HtmlDiv> divData(OS_NEW HtmlDiv());

	String controlID = getInstance().toUTF16();
	if(controlID.empty())
	{
		controlID = _S("preview"); // Se il modulo è in preview, non ha un'ID di istanza. Ma un ID mi serve x forza per gli eventi.
		mode = _S("direct"); // Ajax non è supportato nell'anteprima, perchè non ho un id da referenziare secco per avere il contenuto in un secondo momento.
	}
	setID(controlID);

	if(mode == _S("ajax"))
	{
		// - Chiamo un "isDirect" a livello di ModuleViewer, che restituisce un "true" se son puntato diretto.
		// - Se si, leggo il parametro "mode", se è "direct" restituisco il contenuto del controllo secco via transmit-buffer
		if(getPage()->getRequest()->getUrlParam(_W("mode")) == _W("content"))
			mode = _S("content");
		else
			mode = _S("delayed");
	}

	if( (mode == _S("direct")) || (mode == _S("content")) )
	{	
		String url = root->getAttributeString(OS_MODULES_FEED_URL);
		bool showTitle = root->getAttributeBool(OS_MODULES_FEED_SHOWTITLE);
		bool showDescription = root->getAttributeBool(OS_MODULES_FEED_SHOWDESCRIPTION);
		bool showImage = root->getAttributeBool(OS_MODULES_FEED_SHOWIMAGE);
		int32 nItems = root->getAttributeInt32(OS_MODULES_FEED_NITEMS);
		String showItemDescription = root->getAttributeString(OS_MODULES_FEED_SHOWITEMDESCRIPTION);
		String templateModel = root->getAttributeString(OS_MODULES_FEED_TEMPLATEMODEL);
		String templateCustom = root->getAttributeString(OS_MODULES_FEED_TEMPLATECUSTOM);

		shared_ptr<XMLDocument> document(OS_NEW XMLDocument());
		shared_ptr<XMLStylesheet> transformer(OS_NEW XMLStylesheet());

		try
		{
			shared_ptr<boost::asio::io_service> service = getSession()->getService();

			String output;
			String error;

			String userAgent = Engine::getDefaultHttpUserAgent();	
			document->parseUrl(url.to_ascii(), userAgent, service, Engine::instance()->createTCPSocket(service, true, true));

			shared_ptr<XMLNode> rssRoot = document->getRoot();

			if(rssRoot == nullptr)
			{
				// Error reading RSS Feed.				
				error = _S("Feed reading error.");				
			}
			else
			{		
				// Aggiungo all'xml RSS le proprietà del modulo.
				rssRoot->setAttributeString(OS_MODULES_FEED_URL, url);
				rssRoot->setAttributeBool(OS_MODULES_FEED_SHOWTITLE, showTitle);
				rssRoot->setAttributeBool(OS_MODULES_FEED_SHOWDESCRIPTION, showDescription);
				rssRoot->setAttributeBool(OS_MODULES_FEED_SHOWIMAGE, showImage);
				rssRoot->setAttributeInt32(OS_MODULES_FEED_NITEMS, nItems);
				rssRoot->setAttributeString(OS_MODULES_FEED_SHOWITEMDESCRIPTION, showItemDescription);
				rssRoot->setAttributeString(OS_MODULES_FEED_TEMPLATEMODEL, templateModel);
				
				if(templateModel.empty())
				{
					shared_ptr<XMLStylesheet> stylesheet(OS_NEW XMLStylesheet());
					if(stylesheet->parseString(templateCustom))
					{
						// Inizializza le funzioni del template
						getPage()->initStylesheet(stylesheet);

						if(stylesheet->applyToString(document, output))
						{
							//getControls()->add(shared_ptr<HtmlLiteral>(OS_NEW HtmlLiteral(getPage()->parseBBCode(output, true, false, false, false))));
						}
						else
						{
							// Transformazione fallita.
							error = _S("Transformation failed.");
						}
					}
					else
					{
						// Template custom invalido.
						error = _S("Invalid custom template.");
					}
				}
				else
				{
					shared_ptr<XMLStylesheet> stylesheet(OS_NEW XMLStylesheet());
					// Inizializza le funzioni del template
					getPage()->initStylesheet(stylesheet);

					String path = utils::makeFilePath(utils::makeFolderPath(g_componentsPath, _S("feed")), _S("feed_viewer_") + templateModel + _S(".xsl"));

					// Carica l'xsl
					if(stylesheet->parseFile(path))
					{
						if(stylesheet->applyToString(document, output))
						{
							// Qui potrei aggiungere un literal diretto, non parserizzato bb...
							//getControls()->add(shared_ptr<HtmlLiteral>(OS_NEW HtmlLiteral(getPage()->parseBBCode(output, true, false, false, false))));
						}
						else
						{
							// Transformazione fallita.
							error = _S("Transformation failed.");
						}
					}
					else
					{
						// Template non valido.
						error = _S("Invalid template.");
					}
				}

				if(output.empty() == true)
				{
					error = _S("Unknown error.");										
				}
			}

			if(error.empty() == false)
			{
				divData->setCss(_S("os_plugins_components_feed_error_reading"));
				divData->getControls()->add(shared_ptr<HtmlText>(OS_NEW HtmlText(error)));
			}
			else
			{
				divData->setCss(_S("os_plugins_components_feed_ok"));
				output = output.trim();
				//output = _S("[nobr]") + output + _S("[/nobr]");

				// Debugging
				//output = _S("[code]") + output + _S("[/code]") + output;
				
				divData->getControls()->add(shared_ptr<HtmlLiteral>(OS_NEW HtmlLiteral(getPage()->parseOml(output, true, false, false, omlRenderModeOsiris, getInstance().getString()))));
			}
		}
		catch(std::exception &e)
		{
			OS_LOG_ERROR(e.what());
		}	
	}

	if(mode == _S("direct"))
	{
		getControls()->add(divData);		
	}
	else if(mode == _S("delayed"))
	{
		String urlAjaxContent = getPage()->getPortal()->getViewObjectLink(getInstance()) + _S("&mode=content");
		divData->getControls()->add(shared_ptr<HtmlLiteral>(OS_NEW HtmlLiteral(_S("<div data-os-wait=\"center\" data-os-url=\"") + urlAjaxContent + _S("\"></div>"))));		
		getControls()->add(divData);		
	}
	else if(mode == _S("content"))
	{
		// trasmitbuffer solo di divData.
		HtmlWriter writer;
		divData->render(getPage(), writer);		
		
		getPage()->getSession()->transmitHtml(writer.getHtml().to_utf8(), httpStatusOK);
	}
}
Ejemplo n.º 14
0
void HtmlBR::onRender(HtmlWriter &writer)
{
	writer.br();
}