How to add a script to all my visual pages? - salesforce

I am using for the very first time salesforce as backend.
I need to add the same script to all the visualpages.
Is there a way to achieve this other than copy the same thing to all the visual pages?
A tool for importing the same script for instance.
Thanks

I'm not sure if I understand the question, but I presume you don't want to copy the whole script?
Somehow you still have to tell the VF page to use the script. I think the best practice would be to "pack" the script into a file (if this is JavaScript file the extension would be .js) and upload the file as a Static resource. You can then call the script on every VF page like so:
<apex:includeScript value="{!URLFOR($Resource.NAME_OF_YOUR_SCRIPT)}"></apex:includeScript>
Is that what you had in mind? :)
Cheers, G.

Related

load cakephp from index.php with parameters

I'm working on an internal project and the tech team is requiring that the scheduled task be pointed to an actual file (index.php) and cannot access from localhost/controller/action. They are wanting
localhost/index.php?parm=&parm=
How can I do this?
Add your file in the webfoot folder. You should be able to access this in the browser.
You should not call "scheduled tasks" (cron jobs I assume) by an URL. You simply don't want to expose this kind of functionality to the public.
Write a shell for it and use command line args instead, this is the proper solution for that task and should be pretty easy to do if you followed the best practice "fat model, skinny controller" advice because you can simply reuse the logic there.

Hiding the word "joomla" from a script in contact form

Whenever i create a contact form in my Joomla! 3.3.6, some script appears in the the page's HTML code that contains many words Joomla in it. I'd like to change those Joomla words and replace them with another words (i.e. Foo) for some security issue. I'd like to know whether or not i'm able to do so and how.
That script is:
<script>(function(){var strings={"JLIB_FORM_FIELD_INVALID":"\u0641\u06cc\u0644\u062f \u0646\u0627\u0645\u0639\u062a\u0628\u0631:&#160"};if(typeof Joomla=='undefined'){Joomla={};Joomla.JText=strings;}
else{Joomla.JText.load(strings);}})();</script>
I have no idea whether a plugin or an extension creates it or not.
Thank you
Regards
This script seems to be translating some text required for the form to use in its javascript, eg validation messages. It does this using a javascript version of JText, which is part of core Joomla. There is some info on how that works here. Weirdly, there seems to be little information in the official Joomla documentation about it.
The main JText function it is calling appears here: media/system/js/core.js
I'm sure it would be possible to write a plug-in to remove this script before the page is rendered and then to translate any untranslated text with your own scripts. However, I'm not sure I see any security benefit in doing this so it seems a waste of time.
Ultimately, someone sniffing a site for what it is built in is far more likely to see if core files exist by going direct to places like media/system/js/core.js, rather than to scan the code for the word "Joomla" - which would trigger a lot of false-positives (any site which just mentions Joomla) and negatives (any page which doesn't have a form on it). It also does not reveal the version of Joomla, which is the info a hacker would more likely be after.
I think you have to search for the script (i.e via Notepad++) in the whole directory. It must be a plugin for the contact form that has some inline script in it.
also do you use any special third party plugin or so? that might be the source of it.
PS: also i had some similar experience, i don't know exactly how i got rid of those words, but like you, i wanted to do that to hide the fact that i'm using joomla for security.
Its actually Joomla who add this, from the file: Joomlainstall/libraries/joomla/document/html/renderer/head.php
And load it globaly from:
Joomlainstall/libraries/cms/html/formbehavior.php
The developer ad that code by using the function, JText, for an example:
JText::_( 'COM_CONTACT_EMAIL_FORM' )
In my case it was the plugin ContactUs Form who add the javascript. If JText is not used, it is not loaded. If I disabled the plugin, the javascript was then not loaded. If you have that plugin enabled, my be try an other contact form?
For security reson it is bad programming by the developer off Joomla, for sure.

building a dotnetnuke skin

I've created a dotnetnuke. I have two files named index.ascx and index.html that as you know index.ascx is made after the parsing of DNN.
Question: Do I still need the index.html after the skin is parsed by dotnetnuke?
You do not need the .html file on the webserver, it is not used for anything after the skin has been converted to .ascx.
You probably want to keep it on your local machine however. It depends on how you plan to implement any changes to your skin. If you want to change the .ascx directly then you don't need the .html any more. If you want to make changes in the .html and then regenerate the .ascx, yes of course you still need it.
Personally I always create skins in .ascx straight away and skip the .html step - then you don't have to worry about the converter getting it wrong.
you do not need the html unless you intend to access the file on your server and edit it. Once you edited the html file, you can then parse the skin again to reproduce the ASCX. other than that it serves no purpose sitting on the server
.HTML files usually aids a skin designer. You can keep it local and open it on normal browser to get the idea of the layout. On other hand .ascx file is everything

Cakephp: Include php script in .ctp file

I want to add captcha in myfile.ctp. For this i found source for captcha along with some resource files includs(js, php).
I know the folder for js files & include this file using <?php echo $javascript->link(array('ajax_captcha.js'));?>. But I don't know where to place .php file &
also how to include it in myfile.ctp
Or if anybody help me to implement Captcha in Cakephp.
For your js, use $javascript->link('ajax_captcha',false); Not the omission of the extension. false will place it in the section of the HTML. This will look for the script in webroot/js
Personally, I would just use a standard php include directive for the php side of things, bearing in mind that the location will be relative to webroot, i.e. '/myPHP/captcha.php'will be webroot/myPHP/captcha.php.
Don't forget, CakePHP is PHP.
I'd use a plugin or component, http://bakery.cakephp.org/articles/view/captcha-component-with-phpcaptcha
This works very well with PHPCaptcha for all your Human vs Computer shenanigans. Feel free to google around for your preferred plugin/component.
There is another article in the bakery - Integrate CakePHP with Kcaptcha (read the comments there too). I have successfully implemented kcaptcha in my application.
Elements are a good way to pull code that gets sprinkled over and over around various views:
http://book.cakephp.org/2.0/en/views.html#elements

LocBaml include previous translations

Is there a way to combine a previous translation when extracting the csv file from an application?
Or any other tool that could do this job for me?
I can’t really see how could i use locbaml if i had to translate everything from scratch every time i add a new control in my application.
You might consider using something like WinMerge to merge the existing file with the old one.
You can try my open source addin http://easybaml.codeplex.com, which combines previous translations automatically. Right now it uses .resx instead of .csv, which can be changed if needed.

Resources