What is or might be the best practice to integrate the HTMLPurifier in Zend Framework 2?
The goal is to filter Zend Form Elements and input fields, which where not generated with Zend Form.
How would you do this?
From my point of view I would say you can create a new filter. If Purifier were already a 'part' of Zend then it might be name Zend\Filter\HtmlPurifier. That's where I see it fitting the most.
You could also make it a Validator (Zend\Validator\HtmlPurifier) so you can tell if a piece of text 'passes' or not. Depends on what you want to do.
If you want to reject bad input, use the validator path. If you want to filter out bad input use the filter path.
After you've made your Zend filter/validator, use it like you would any other filter/validator.
Related
I am relatively new to Grails and I am little disappointed with the way _form.gsp removed with field plugin in Grails 3. _form.gsp seemed to be good time saving option when we need to customize views with Bootsrap or materialize.
Now with grails 3, install-templates does not create _form.gsp. As per this documentation, we can achieve customization by creating _wrapper.gsp, _widget.gsp etc under view/_fields/default directory. But I am not able to find the example of such custom GSPs.
Also, let's say if I customize all the four GSPs (_wrapper.gsp, _widget.gsp, _displayWrapper.gsp, _displayWidget.gsp) will it generate actual code when we run generate-view command? I mean will it replace, f:all, f:table etc tag with actual code? If not then there is quite amount of work to do I guess. Because after we are confident about our domain class and tested all CRUD operation, we run generate-view command for creating all the domain specific GSPs. Then in most cases, we need to do some changes according to our requirement, like re-ordering the fields, hiding some of the fields
So in conclusion I have two goals:
Customizing default templates and start developing.
When I run generate-view, I do not want f:all, f:table etc abstract tags. I need actual fields in place so that I can customize generated views of domain.
If any one has achieved this, then please share the solution.
Grails 3 comes with the fields plugin by default. The templates used in Grails 2.x have been replaced in full. So, your goal 2. will be hard to achieve with Grails 3 it seems.
However, here is a helpful blog which explains how you can adjust some of the fields templates by replacing them in your project: http://blog.anorakgirl.co.uk/2016/01/what-the-f-is-ftable/
Similar to the description provided, you can place a modified _list.gsp template in folder in
/grails-app/views/templates/_fields/
Hope it helps.
I am a newbie in MTurk, and I am trying to create a very simple Categorization Project via their Requester UI (rather then the API).
Each batch I use has 10 items (question and possible answer). I have searched their documentation and forums with not help and so I have several questions:
When i use their Standard Categorization template, I have no option for modifying the HTML and layout (as shown for "Tagging of an image" project). the only formatting options are for the categories, instructions and includes/excludes. Is there a way to edit the HTML of the standard template they provide?
In the Standard Categorization template, while my input data file (csv file) contains 10 items, only 5 are shown (tried with 6, still only 5 are displayed in the preview). Is there a way to change this limitation?
When I try to use the "Create HITs Individually" (rather than the standard template, as explained above), I have the "Design Layout" options, but I cannot find a way to make the questions in the "form" required (which is possible via the API). Is there a way to achieve this?
If you stick to the standard project templates, you can't modify them. That's the reason to create HITs individually (through the RUI or via the API).
You'll have to show us your CSV file, because it's not really clear from your description what the issues could be.
Your third question is unclear, but basically for creating HITs individually, you simply do standard HTML markup and put in ${variablename} placeholders wherever you want one of your CSV upload variables to be placed.
If your project is at all large, I would definitely recommend going through the API. It's simply much more flexible than the RUI for creating any kind of customized design.
In my MVC application, I need to display data in tabular format (no edit, only readonly) in one of the razor view. Some of the columns should be hyperlink, a couple of columns showing image, and rest columns in plain text.
I know one option is to loop through each row in the dataset (model), and build the table. Anyone has any idea if there is any other way of doing it? (without any third-party control)
Any advice on this, much appreciated.
You can use Phil Haack's tabular template in aspx
or my updated version that is done in razor
About the Visual Studio Add Controller and Add View templates
You may also get some ideas from the List.tt template in [Visual Studio Install Directory]\Common7\IDE\ItemTemplates\[CSharp | VisualBasic]\Web\MVC\CodeTemplates\
My article on changing/customizing that
The closest "non-third party" control I can think of is the WebGrid, but even that isn't included in the ASP.NET MVC distribution if I remember correctly (you might want to check though as I'm not 100% sure).
However, using a simple foreach to generate your table isn't a bad way of doing it either, especially if all you need to do is display some data.
Why no third-party control? Personally, I like datatables.net.
Currently I'm trying JSF 2.0 and still learning the more advanced features.
JSF2 is comfortable when having to deal with pre-defined views (fixed component trees) whose widgets are completely known at compile time -- of course with the exception of repeating data list/table entries and light dynamic modification of forms via the DataTable "trick" (as I read here, especially under JSF2, can I add JSF components dynamically? and How to create dynamic JSF 1.2 form fields).
Now I'm wondering about the realization of completely dynamic JSF2 component trees, where a web user, for each given content type (e.g. 'Person', 'PersonList' but also 'PersonalManagementPanel'), can choose one from a list of content-type compatible widgets (=JSF custom components).
As result, this user will always see the "Personal Manager Page" rendered with his/her prefered "PersonalManagerPanel", which in turn also renders its nested components ('Person', 'PersonList') with the user's preferred variants.
Obviously, the goal is to get a selectively configurable/customizable JSF Page -- at runtime.
Is this scenario realizable in JSF2? -- How could this be done?
Are there more appropriate Java technologies for this requierement?
-- One possible alternative I'm thinking of is XML plus XSLT.
Thank you very much for your help and suggestions.
Best regards
Martin
You can use something like this:
<ui:include src="#{bean.template}" />
Or if you want more complicated components, you should take a look at the PreRenderViewEvent.
Note that there are issues with both solutions.
http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-770
http://java.net/jira/browse/JAVASERVERFACES-1708
http://java.net/jira/browse/JAVASERVERFACES-2041
I am using Kohana 3 ORM and it seems that the Inflector is singularising the word 'causes' to the form 'caus' instead of 'cause'. I have a _has_many_"through" relationship setup and even through all my foreign keys are setup to read 'cause_id' it still wants to setup an ON clause in SQL where it references 'caus_id' rather than 'cause_id'.
Is there a way to set up the Cause model to recognise the default singular form is 'cause'?
Or is there a way to add an Inflector->irregular array in the Bootstrap.php file?
I've hacked the SYSPATH.'config/inflector.php' file adding the exception and it does fix the problem but I would prefer a method that doesn't involve hacking the system files.
What is the 'best practice' approach please.
Copy SYSPATH/config/inflector.php to APPPATH/config/inflector.php and change what you want. This will allow you to upgrade framework core without loosing your modifications.
Post an issue and this will be fixed in the next release.