How can I associate ".js.php" to JavaScript Syntax in the NetBeans 6.5 IDE? - netbeans

When I generate CSS or JavaScript files using PHP I like to use .js.php or .css.php file extensions. so that I know what's going on.
Is there a way of associating these "compound" file extensions to their respective languages?

I don't use NetBeans or PHP, but the following trick helped me in a similar setting:
<?php if(0) { ?><script><?php } ?>
# code goes here
<?php if(0) { ?></script><?php } ?>
Simply surround the js code with <script> or <style> tags that don't get rendered. No need to configure any special associations, assuming the editor is smart enough about HTML.

What I usually do is condense such "compound" extensions into one, following the tradition of condensing .tar.gz into .tgz.

Related

Can Doxygen project brief contain link?

I am writing my Doxyfile configuration and was wondering if I can include a link within the PROJECT_BRIEF. I have tried HTML and Markdown syntax, but it appears to only accept plaintext. Is there a way to add simple markup to the PROJECT_BRIEF?
PROJECT_BRIEF = "Project heavily inspired by <a href='https://example.com'>Other Project</a>"
PROJECT_BRIEF = "Project heavily inspired by [Other Project](https://example.com)"
My system currently has Doxygen 1.8.17 installed.
I managed to accomplish this using a custom HTML_HEADER.
Generate default templates (we will only be looking at header.html).
doxygen -w html header.html footer.html stylesheet.css Doxyfile
rm footer.html stylesheet.css
Modify header.html.
Find the existing $projectbrief tag.
<div id="projectbrief">$projectbrief</div>
Add some javascript to "unescape" the HTML.
<script>
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
document.getElementById("projectbrief").innerHTML = htmlDecode("$projectbrief");
</script>
Modify Doxyfile to use new HTML_HEADER
HTML_HEADER = header.html
Admire your markup!
Note: Other output types (e.g. LaTeX) also can similarly use custom header files.
Additionally, Markdown syntax is theoretically possible using any number of JavaScript Markdown parsers.

Magento 2 : Is it possible to switch extension from html to phtml

I have an html file and in this file I would like to call some block method
app/design/frontend/Theme/default/Magento_Checkout/web/template/billing-addresses/form.html
So I would like to add something like that :
<?php $store = $block->getStoreCode(); ?>
But the file being an html I can't do that.
My question is : Can I just change the form.html into a form.phtml without breaking anything ?
If I can't, how can I get the value I need ?
Thanks.
No you cant.
.Html files are used for the knockout components, their logic is in the .js files and their data comes from the php files.
.Phtml files for the blocks
If you want to add some extra logic to the html file - check out documentation and other sources about js components.

Typoscript filelink - Wrap URL within link

First, here is the Typoscript :
20 = TEXT
20 {
value {
field = field_title
wrap = |.txt
}
filelink {
stdWrap.wrap = <li>|</li>
path = fileadmin/txt-files/
}
}
The result I get is :
<li>
<a href="/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
And what I need is :
<li>
<a href="/fileadmin/force_download_script.php?filepath=/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
I need to make the link downloadable, rather than opening the file in the browser. For that I have a force_download_script.php, but when I do that :
wrap = fileadmin/force_download_script.php?filepath=|txt
instead of the current wrap, filelink doesn't find the file anymore.
I have tried using ATagBeforeWrap.wrap but it doesn't look like it's made for that purpose. I also tried typolinkConfiguration.wrap without any success.
Any idea of how to achieve that ? Using a COA maybe ?
Thank you !
I would not do this with a script, but with server configuration. If you use Apache and have .htaccess enabled, you can add the configuration to a .htaccess file in the directory where the files are located. See https://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/
Alternatively you can also use the HTML5 download attribute. This is not supported by Internet Explorer however (it is supported by Edge though).
The issue can get quite a bit complicated, but step by step:
your code above might be wrong if it's not just a copy & paste fault:
wrap = fileadmin/force_download_script.php?filepath=|.txt
The dot before txt was missing.
Nevertheless it is still interesting if the php-script is triggered.
It's possible that the script is not triggered due to some settings in typo3conf/LocalConfiguration.php respectively some settings in the install-tool.
Depending on the TYPO3-Version it's also possible that the script is not triggered at all because all scripts are being required now in an extension. That means you might need to create an extension for that script.
Also simple wrapping of the result with the script-path might not be enough, but you have to call it explicitly by TypoScript perhaps by including the script as user-function or lib.
The admin-panel might be useful to debug some things about your script but if not you've to include some debug-output first in your own code, if that's not enough in the core (temporary).
So you've to find out if your script is triggered and if not, the reason for it.
Are you sure .filelink is what you are looking for?
.filelink is for a set of files. For all files in the folder given by .path a link will be generated. see manual
From your description you want a text wrapped with a link to one single file. That would be more a problem for .typolink where you specify the link in .parameter.
if you really want a link list of multiple files, each wrapped with your script you need to modify .typolinkConfiguration.parameter which will be used internaly by .filelink.
Anyway it might be possible to do a wrap which then would be:
.typolinkConfiguration.parameter.wrap = /fileadmin/force_download_script.php?|
Maybe it is easier to build your list with .stdWrap.filelist, where you can use the filenames in any way to wrap your own href parameter for an A-tag.
To use the TYPO3 core solution with file links you can use this guide:
Create a file storage where you want your "secured" files in TYPO3 backend
Do not set the checkbox "Is public?" in the storage record
The links will be rendered with eID and file parameters
You can look into the FileDumpController handling these links: https://github.com/TYPO3/TYPO3.CMS/blob/2348992f8e3045610636666af096911436fa1c89/typo3/sysext/core/Classes/Controller/FileDumpController.php
You can use the included hook to extend this controller with your logic.
Unfortunately I can't find any official documentation for this feature, but will post it when I find something or wrote it myself. ;)
Maybe this can help you, too: https://extensions.typo3.org/extension/fal_securedownload/
Here is the official part, but it's not much: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Fal/Administration/Storages.html?highlight=filedumpcontroller

Can't add javascript to rich text editor

I'm trying to allow javascript in rich text editor inputs in my Umbraco setup. I'm using Umbraco 7.2. I've enabled the script tag in tinyMceConfig.config so the editor no longer eats my script tags. The problem now is that my content is cut off.
For example, in my RTE I put:
<p>before</p>
<script>
alert('blam');
</script>
<p>after</p>
This get's transformed by TinyMCE to:
<p>before</p>
<script>// <![CDATA[
alert('blam');
// ]]></script>
<p>after</p>
The problem is the value of Umbraco.Field("myRte") ends up being:
<p>before</p>
<script>// <![CDATA[
alert('blam');
// ]]
It seems related to CDATA. Does anyone else have javascript in RTE working in Umbraco 7?
A possible workaround would be to create a macro that would allow you to insert a script into the RTE. The macro would have a single Textarea parameter where you would paste in your script tag, and you would simply render the parameter value as raw Html. However, it might be a good idea to check that the input is valid html before you attempt to render it on the page.
If you use a razor macro the partial view could look like this:
#inherits Umbraco.Web.Macros.PartialViewMacroPage
#{
var script = Model.MacroParameters["script"].ToString();
}
#if (!script.IsNullOrWhiteSpace())
{
#Html.ValidateHtml(script)
}
Where ValidateHtml is an extension method to the Mvc HtmlHelper:
public static IHtmlString ValidateHtml(this HtmlHelper helper, string input)
{
if (!string.IsNullOrEmpty(input))
{
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(input);
if (htmlDoc.ParseErrors.Count() == 0)
{
return new MvcHtmlString(input);
}
}
return null;
}
The helper method uses the Html Agility Pack and I got the code from an answer posted to another SO question.
I've tested this on an Umbraco 7.2.1 install and it works fine even if you select the "Render in rich text editor and the grid" option.
My solution is not write direct script in editor, write it in a test.js file after that include
<script src="https:/....test.js></script>
In tiniMceConfig.config file (config folder)
validElements tag, add this
,script[type|src|language]
so it will look like this
<![CDATA[+a[id|style|rel
.....
,bdo,button,script[type|src|language]]]>
Test and work on Umbraco 4.7.x. I'm not test on umbraco 7

PHP5.3 Oriented Object Modeling for HTML generation, a possibility or performance bottleneck?

The main motivation in this is that I was very tired or using php tags to write php views that were very ugly. Consider this approach:
<?php
<ul>
<?php echo foreach($products as $product): ?>
<li><?php echo $product->getName()?><li>
</ul>
This is the basic approach of trivial MVC with views, but I was tired of that, so I use phpQuery instead:
<?php
$ul = pq('<ul />');
foreach($products as $product) {
$ul->append(pq('<li />')
->html($product->getName())
);
}
echo $ul;
This is much cleaner. Unfortunately, phpQuery does not seem active on development. The thing is, phpQuery is programmed in a procedural way and is really hard to understand and maintain and contains some bugs that make it rather useless in most DOM manipulation cases. I was thinking of writing an OO approach to DOM writing based on jQuery using Zend Framework's component Zend_Dom_Query, with the same approach of phpQuery: same interface as jQuery.
After some search on the net on PHP HTML Generators, I cannot seem to find much that has been done on that part, and my question is, is using OO with PHP to generate HTML a performance bottleneck, since all static HTML would be server side generated?
I know there is the HAML approach, but I like the idea of DOM manipulation, so that it is possible to inject html at any time anywhere during the script execution. DOM manipulation on the server side leads to view script inheritence like this:
//a parent index.phtml
$container = pq('<div />')
->addClass('.container')
->html($this->_("Hello World!"));
$this->setRenderReturn($container);
//a child index.phtml
$container = $this->renderParent(__FILE__); //retrieves the parent just like the conventional parent:: in php scripts
$container->addClass('anotherClass');
$this->setRenderReturn($container);
Also, in case I missed a PHP library that does just that, I would gladly appreciate if someone could point me to it.
In direct answer to your question...
is using OO with PHP to generate HTML a performance bottleneck, since all static HTML would be server side generated?
Yes.
You should have a look at Twig and particularly the extensions added in Symfony 2. It supports template inheritance as well as named sections for overwriting / inserting markup.