what is db_clean in codeigniter? - codeigniter

What is the use of db_clean() with a simple example?

Seems like db_clean() is a customized helper which is calling xss_clean().
See this link, db_clean() is stored in MY_security_helper.php, whereby MY_ is the naming convention to extend native helper.
xss_clean()
Provides Cross Site Script Hack filtering. This function is an alias
to the one in the Input class. More info can be found there.
Source: https://www.codeigniter.com/user_guide/helpers/security_helper.html

Related

Laravel 5.7+, How to use helper functions within Blade templates smartly

Since Laravel 5.7, the majority of global Helper functions (specifically the ones related with "Arrays & Objects" and "Strings") are now based on Facades (using Illuminate\Support\Str and Illuminate\Support\Arr classes) instead of being defined as "normal" helper functions, as they were before 5.7 (see difference with previous Laravel 5.6 docs).
Does it really mean that we are not allowed to use them anymore directly within our Blade views? If we do, they have to be obviously prefixed with its full path in any case, resulting in a dirtier Blade views...
Is not this change counter-productive?
EDIT:
Made some googling and found this article that confirms the situation.
Also, I have seen that in 5.8.17 it is planned to include Arr and Str aliases by default within config/app.php (link).
In the meanwhile, I proceed to register Arr and Str aliases in my config/app.php config file to avoid the full path issue.
Thanks

Symfony translation inside validation won't work

If I try to use translations inside validation like described here
http://inchoo.net/tools-frameworks/symfony2-translating-validator-messages/
I get always
not.blank.username
as output on Error. It seems like symfony didn't find the message-translation. I placed all my translationfiles inside app/ressources/translations and they are named as
messages.de.yml
....
What am I doing wrong? Do I have to place the translationfiles insde each Bundle?
Kind regards
EDIT: Problem ist clear and fixed, but when I try to use "MinLength" I get an strange error:
Attempted to load class "MinLength" from namespace
"Symfony\Component\Validator\Constraints" in /var/www/symfony/webprojekt/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php line 64.
Do you need to "use" it from another namespace?
I already included
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\MinLength;
use Symfony\Component\Validator\Constraints\MaxLength;
AM I missing something?
To translate validation messages you need to create files with the following name structure inside translations folder:
validators.LANG.yml
Also, you can check in your config.yml, inside framework, if exists the translator:
framework:
translator: { fallback: %locale% }
This is required.
The accepted answer applies to using the magical default translation domain for the validator config. You can also override this in config/packages/validator.yaml
framework:
validation:
enable_annotations: true
translation_domain: 'validations'
Then in translations/ make a file validations.LANG.yaml, for example translations/validations.en.yaml. You don't need to do this but sometimes it's better to explicitly set these magical bit and know where they're coming from.

Smarty getting page content

I need to edit a page on prestashop, I've found that code
<ul id="idTab2" class="bullet">{$agencies->content}</ul>
And where should i search for that $agencies variable ?
I have found the text which is being displayed into that place in CMS.
However I'd that variable need to be define somewhere, am I right ? Anyone knows where should i search for that ? I'm new to prestashop.
Why am i asking for this ? I need to add another page for example
<ul id="idTab2" class="bullet">{$test->content}</ul>
- but I can't just simply add another page called test.
The {$agencies} variable is being set in a object derived from either the Controller or Module classes but to be honest it looks like you're working with code that has been customised (via a class override or a module) making it impossible to provide a definitive answer to your question without knowing more detail.
If you can locate the term 'agencies' in a file located under \controllers, \modules or \override in your installation, then you will be closer to finding your answer. It will be contained in a function call similar to:
$this->context->smarty->assign('agencies' , [some-variable]);
Note that the parameters to the function may also be passed as an array for multiple assignments.

Concrete5 – Implicit Aliases for the Subpages of an Alias

I use the internationalization module for a new project. But for a one page and it's subpages I want to handle the translation manualy coded in the pagetype. There will be thousands of subpages, so I want to avoid actually creating an alias for each of them.
For example, if there is a page with an URL like this:
domain.com/en/section-to-be-aliased/a-sub-page
... it should also be reachable via
domain.com/de/section-to-be-aliased/a-sub-page
... while there is only an alias for the superior page, called "section-to-be-aliased" here.
What would you suggest to be the cleanest way to do that, keeping all caching-functionality alife?
My first approache would be to inherit the Concrete5_Library_Request class and overwrite the function getRequestedPage().
But I'm wondering if there is a simpler solution. Also i recognized, that in the sitemap the alias shows the number of subpages of it's original ... which suggests that they are already accessable via the alias? Well I tried the corresponding URLs and they didn't work.

Codeigniter extend helper but want to call old helper

I am developing an Application in Bonfire.
They have extended the form helper.
Is there a way to call the original form helper from Codigniter without removing the extended one from Bonfire?
"Helpers" are just files with PHP functions in them. They aren't actually "extended", Codeigniter loads it's default helpers after loading yours, and checks if you "overwrote" a function like so:
if ( ! function_exists('form_open'))
{
function form_open() {/* default code */}
}
So unfortunately, no - there's no way to call the original function if you already declared your own.
HOWEVER: It appears that Bonfire does the exact same thing, checking with function_exists, so if you want to - you should be able to load your own form helper before it, but you still cannot simply load the original one without hacking Bonfire and removing the functions (which could have terrible side effects).
Faced the same prob, user742736's comment is the only answer that solved the prob.
Explained in detail, may be this can help some one
You can create your own helper function with out the divs surrounding the drop down here
bonfire/application/helpers/MY_form_helper.php
make a copy of the function form_dropdown, name it like form_dropdown_plain
modify the last few lines of the function to output with out divs
call form_dropdown_plain instead of form_dropdown

Resources