xinha editor enabiling GetHtml - php

Does anyone know how to enable GetHtml in xinha editor?
I tried to implement this:
GetHtml is a replacement for the getHTML() function in htmlarea.js. It
offers several improvements over the original, including:
Produces valid XHTML code
Formats code in HTML view in indented, readable format.
Much faster than HTMLArea.getHTML()
Eliminates many hacks to accomodate browser quirks
Returns correct code for Flash objects and scripts
Preserves formatting inside script and pre tags
You can enable this by setting xinha_config.getHtmlMethod to "TransformInnerHTML"
But I didn't understand very well and this is my attempt:
var xinha_plugins =
[
'GetHtml','ExtendedFileManager','Linker','InsertSmiley'
];
I just added the plug-in to the plug-ins library above(like my code), but the plug-ins didn't work! I need to insert flash in xinha editor.

Related

PHP mPDF QR-Code: How to control the auto-generated QR-Code-border?

To meet given requirements, we are asked to alter the auto-generated QR-Code-border. We’ve searched a lot for describing resources and tested a view guesses but ended up with no working solution. Our best shot was simply CSS, but it just adds an additional border and does not replace the element’s default one. We’ve also tried border="0" or border="false" within the calling HTML-snippet, but this has no effect on the actual output. Furthermore, we would be interested in adding attributes like line-width & -style, color, border-radius, padding and so on.
Additional info: To create QR-Codes within the UTF-8 coded HTML we use code snippets like:
<barcode code="Text goes here" size="0.8" type="QR" error="M" class="barcode" />
Since v7.0.0 there is a disableborder="1" attribute achieving this.
See Issue #368:
There is currently no way to achieve this with standard mPDF use.
Well…
It's actually a 7-line change in the code allowing use of a disableborder="1" HTML attribute which should make it work as you need. See above.

configure htmlpurifier with html5 and css3

I am using htmlpurifier. I have some doubts which are as below.
1- My config file contain
$config->set('HTML.Trusted' ,true);
$config->set('CSS.Trusted', true);
But a simple Google is landing me to pages where there are recommendation not to use *.Trusted as "true".
I am not able to understand why should we should not set *.Trusted to true? Can you please explain me. Because if I remove it than I wont get inline css? Even CSS.AllowTricky is not helping.
2- I found that HTML5 and CSS3 selectors are not allowed.
like the code at htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php
// - No Unicode support
// - No escapes support
// - No string support (by proxy no attrib support)
// - element_name is matched against allowed
// elements (some people might find this
// annoying...)
// - Pseudo-elements one of :first-child, :link,
// :visited, :active, :hover, :focus
// handle ruleset
$selectors = array_map('trim', explode(',', $selector));
$new_selectors = array();
foreach ($selectors as $sel) {
//some code to filter css selectors
}
do not contain any code which can allow selectors like '[class*="grid-"]'. Hence all such css is getting removed after purification. Is ther some way to allow all CSS3?
3- Is there some way to allow all HTML 5 tags? for example if we have html like
<section class="mainhead">
<div class="subhead"> </div> </section>
then purifier removes and due to which some css like
.mainhead .subhead { //some css}
wont work.
Setting HTML.Trusted to true enables unsafe elements, such as script and forms. If you, for example, want to allow forms, but don't want to allow scripts, just add them to HTML.ForbiddenElements:
$config->set('HTML.Trusted', true);
$config->set('HTML.ForbiddenElements', ['script']);
CSS3 selectors are not supported - there is a pending Pull Request, but it has been inactive for more than a year (as of Aug 2019). I don't think this will change any soon.
As for HTML5 support - you can use an extension package https://github.com/xemlock/htmlpurifier-html5 (which I'm the author of), which adds spec compliant definitions of HTML5 elements. It's usage is almost the same the bare HTML Purifier - you just have to replace HTMLPurifier_Config with HTMLPurifier_HTML5Config.

What is a good way to change/replace elements in a php+css document?

Forgive me for possibly misusing certain terminology. I would like to:
open a html/php file, with php
find elements with certain class
change its innerHtml basically
than save the file.
I have a feeling DOMElement in php could help, since I've used it for similar things in javascript, but I am (still) unsure of its function in PHP and php.net sais a DOM document "Represents an entire HTML or XML document" (so no php/javascript containing document).
So: which function(s), libraries should I study to best perform those operations?
Possibly: Aside from php.net do you perhaps have a good tutorial for ^that^ solution?
Edit: Possibly related: Manipulate HTML from php
Edit2: If I would build something with my knowledge a.t.m. it would probably be almost as violent as solutions I tried earlier: https://stackoverflow.com/a/8960363/574700
There will be php in the document.
There will be some inline css and javascript in there.
1.open a html/php file, with php
Include htmlsimpledom and open you php file.
$html = file_get_html('myfile.html');
2.find elements with certain class
foreach($html -> find('.class-name') as $element)
$element - > plaintext. '<br>';
3.change its innerHtml basically
$html -> find('.class-name') -> innertext = 'text-here';
4.then save the file.
file_put_contents($filename, $html);

htmlpurifier removes all the formatting done by CKEDitor

I am using CKEditor to let the user post their comments. I thought to use the htmlpurifier to secure my html. But when I tried it, it actually removes all the formatting done by CKEditor.
The CKEditor generated the following html
<div class="originalpost"><span style="color:#B22222;">
<em><u><strong><span style="font-size:250%;">
This is Pakistan</span></strong></u></em></span></div>
After purifying with htmlpurifier the html became like this
<div class=""originalpost""><span><em><u><strong>
<span>This is Pakistan</span></strong></u></em></span></div>
It actually removes all the inline css styles and also class=""originalpost"" is not understand able.
I have used the following way to purify the html with htmlpurifier
require_once("path\HTMLPurifier.auto.php");
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$html = "xyzhtml";
$clean_html = $purifier->purify($html);
I want to keep the user formatting, How can I configure htmlpurifier to keep the user formatting also don't change the inline css.
It actually removes all the inline css styles
Inline styles are indeed dangerous - JavaScript can be injected into them using url(), IE's dodgy expression() and browser-specific behavioural extensions.
HTMLPurifier can parse inline styles and filter the dangerous properties and values. You can turn this on by including style in your whitelisted attributes.
$config->set('HTML.AllowedAttributes', '*.style, ...');
style is not included in the default attribute list because parsing styles is a lot of extra complexity (with accompanying chance of bugs) and most applications don't need it.
You can configure the properties that are permitted using %CSS.AllowedProperties if you wish.
I can't reproduce the " problem but certainly ensuring PHP's magic_quotes_gpc option is turned off is an all-round good thing...
I bet that you need to turn off Sybase quotes.

PHP Class to Rewrite CSS3 Rules for Cross Browser Compatibility

I need some help writing an awesome class to take a style sheet, detect browser specific CSS3 rules, and add support for all compatible browsers. This way, we can just write our styles sheets for one browser and then process the CSS files when we are ready for production.
Here's my thoughts on the class so far:
class CssRewriter {
public function reformCss($file) {
// Get the CSS as a string
$cssString = file_get_contents($file);
// Use regex to capture all styles delimited by {...}
// Use regex to determine if the any of the captured styles are browser
// specific (starts with -moz, -webkit, etc)
// Determine which CSS3 rules are not present and add them to the style
// (so if you have -moz-linear-gradient, automatically add the webkit
// version)
}
}
Yikes. CSS parsers are not as easy as you imagine, man. Depending on regular expressions is just asking for one typo to be totally misinterpreted.
Not the answer you were looking for, but quite possibly a better one: have you considered using Sass and mixins? You're not the first to hit the issue of the repetitive nature of CSS, so someone else has already faced the challenge of a CSS pre-processor for you.
Your best bet would be to modify existing CSS parser like CSS Tidy and add in a additional logic to output backwards-compatible CSS.

Categories