Forums / Developer / How to override the EZ automatic validation process ?

How to override the EZ automatic validation process ?

Author Message

Hakim Bouras

Wednesday 19 August 2009 1:27:52 am

Hi,

Ez Publish provides an automatic validation system when editing an abject based on the class description.

Would it be possible to "override" this automatic validation using a workflow extension ?

Something that will happen just after the automatic validation process is done, and that will provide us a way to change the output of the automatic validation (either by adding extra validation problem to the $validation template variable or by removing validation problems added by the automatic process).

If this is possible, what are:
- the event to plug in (before content publish ?)
- the variable storing the result of the validation
- how to change the result of the automatic validation (validation OK or problem) so that the normal EZ editing process can continue ?

Thanks for your help,
Hakim

Bruce Morrison

Wednesday 19 August 2009 2:26:52 am

Hi Hakim

My gut feeling is that the answer is that it's not possible. The validation is done in the datatype and I believe the content object will have to pass validation before it is published (so before the before publish workflow has a change to kick in).

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Heath

Wednesday 19 August 2009 3:40:42 am

Hello Hakim,

I have provided similar features per unique customer requests in the past.

Most of the time depending on what your trying to do this gets complicated. Most will tell you it's not possible. That is not always the case. Often I have had great success with custom validation within copies of ezpublish datatypes to provide for more user friendly validation / storage / etc .

I find that for the most part, the best results are found in focusing your changes to the datateypes themselves (making variations with modifications)

- I have added ezimage datatype to ignore validation errors and always store the uploaded image regardless of other attribute validation errors. This helps editors greatly for example.

- I have manipulated other various datatypes to ignore default php code and content class definition attribute / datatype defaults (such as validation settings stored within the class definitions in the admin). This let a customer work with an existing configuration / content in a unique way which avoided default validation and instead provided extended clientside (javascript) and serverside validation which functioned in a more user friendly way.

This code was published as a number of projects, http://projects.ez.no/bcicfv

I hope this helps.

Cheers
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Hakim Bouras

Wednesday 19 August 2009 8:43:26 am

Thanks for you answers.

Since I am using version 4.1 of eZ Publish, do you know if the "Enhanced" content edit handler for validation rules in eZ Publish 4.1 might be a solution ?

Did you get to use it ?

It is not clear to me how it is possible, while using custom validation rules in some context (specific attributes, specific templates) to be able to call the "automatic" EZ validation process otherwise (as a default validation mechanism). Any idea ?

in my custom edit handler :

function validateInput( $http, &$module, ... ) {

    if (conditions for custom validation 1) {
        $result = manage_custom_validation1();
    } elseif (conditions for custom validation 2) {
        $result = manage_custom_validation2();
    } else {
        $result = HOW_TO_RELY_ON_EZ_AUTOMATIC_VALIDATION();
    }

    return $result;

    }	

Hakim

Bruce Morrison

Wednesday 19 August 2009 5:05:06 pm

Hi Hakim

I've had a quick poke around the source and documentation and it would appear that a Custom edit handler validateInput method provides <b>additional</b> validation that is performed after the validation present in the datatype. You can see this in kernel/content/attribute_edit.php 246-270 So it would appear that this method would be unsuitable for what you want to achieve.

Perhaps if you can provide some more context as to why you want to do this I may be able to provide an alternative solution.

Details on the Custom edit handler and the enhancement:
http://serwatka.net/blog/ez_publish_3_8_new_custom_edit_handler
http://pubsvn.ez.no/nextgen/trunk/doc/features/4.1/enhanced_custom_edit_handler.txt

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Hakim Bouras

Thursday 20 August 2009 2:07:54 am

Hi Bruce,

Your explanations makes the picture a lot clearer, and I can now understand better the limit of what I wanted to achieve.

In fact, I am trying to move to version 4.1, and was having validation issues with custom edit templates which do not provide all the required fields existing in a class.

This was working fine, untill the version 4.1.

It looks like the easiest solutions will then be either for me to remove the "required" characteristic of the field, or to add the required fields back in the custom templates.

<b>By any chance, do you know where in the code the events "before publish" and "after publish" are triggered ?</b>

Thanks for your help,
Hakim

eZ debug

Timing: Jan 19 2025 14:01:25
Script start
Timing: Jan 19 2025 14:01:25
Module start 'content'
Timing: Jan 19 2025 14:01:26
Module end 'content'
Timing: Jan 19 2025 14:01:26
Script end

Main resources:

Total runtime1.0782 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 589.1016180.8125
Module start 'content' 0.00700.9426 769.9141638.0938
Module end 'content' 0.94960.1286 1,408.0078345.0547
Script end 1.0781  1,753.0625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3920210.0002
Check MTime0.00140.1281210.0001
Mysql Total
Database connection0.00070.068110.0007
Mysqli_queries0.984491.29492050.0048
Looping result0.00220.20522030.0000
Template Total1.045997.020.5230
Template load0.00200.189020.0010
Template processing1.043996.813520.5219
Template load and register function0.00010.010010.0001
states
state_id_array0.00230.210410.0023
state_identifier_array0.00140.126920.0007
Override
Cache load0.00180.1702600.0000
Sytem overhead
Fetch class attribute can translate value0.00140.128540.0003
Fetch class attribute name0.00210.197290.0002
XML
Image XML parsing0.00510.474740.0013
class_abstraction
Instantiating content class attribute0.00000.0027120.0000
General
dbfile0.01081.0024400.0003
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs