Re: [SMW-devel] how to know the validation option for the parameters in SMWResultPrinter::getParamDefinitions( )?

2013-10-17 Thread Jeroen De Dauw
Hey Yury,

The docs here where already updated a little:
https://github.com/wikimedia/mediawiki-extensions-Validator/#implementation-structure

 saw a lot of interesting fields in SMWParamFormat

Do not use SMWParamFormat as an example, its using highly deprecated code.
Try to stick to using the array definition syntax. Creating actual
instances of ParamDefinition is discouraged. Deriving from ParamDefinition
(as SMWParamFormat does) should not be done in new code.

The array definition schema currently does not support specifying
validation callbacks. Validation is typically done by specifying a
parameter type, such as integer, which then makes sure the values is valid
for that type.

You can define your own parameter types, see
Validator/config/DefaultConfig.php, which allows specifying a validation
callback per type. If the validation is not actually validation but making
sure the value can be interpreted, and thus part of the parsing process,
then you should specify a parser instead.

The basic array definition format is not going to break, and neither is the
result object structure you get back from the processor. Other things might
well be broken as ParamProcessor moves towards a better (and more stable to
the outside) design. So only do the more advanced things if you really need
to.

Cheers

--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil. ~=[,,_,,]:3
--
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135031iu=/4140/ostg.clktrk___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] how to know the validation option for the parameters in SMWResultPrinter::getParamDefinitions( )?

2013-10-16 Thread Yury Katkov
Hi Jeroen! Can you recommend any result formats that use Validator in
the right and intense way?
-
Yury Katkov, WikiVote



On Sat, Oct 12, 2013 at 4:56 AM, Jeroen De Dauw jeroended...@gmail.com wrote:
 Hey Yury,

 This is unfortunately not properly documented, and as with a lot of MW code,
 the answer is, at least for now, look at the source. This is certainly not
 a good answer and something that should be addressed. Rather then answering
 in detail here, I'll be adding documentation incrementally to the README
 file of Validator with the aim of having the basics covered there by the
 time of its 1.0 release, which will be shortly before the SMW 1.9 one.

 The README can be seen here:
 https://github.com/wikimedia/mediawiki-extensions-Validator/blob/master/README.md

 Some quick replies:


 What values can I use for the values of the key 'default'?

 Anything. This is self defined.


 Where did these words 'message', 'values', 'default', 'aliases' come from?

 This is the definition format in array form as defined by Validator.

 Are there any other interesting words to use (for example 'mandatory'
 would be nice or 'type')?

 There is a type field. A param is mandatory if it does not have a default.

 Cheers

 --
 Jeroen De Dauw
 http://www.bn2vs.com
 Don't panic. Don't be evil. ~=[,,_,,]:3
 --

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135031iu=/4140/ostg.clktrk
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] how to know the validation option for the parameters in SMWResultPrinter::getParamDefinitions( )?

2013-10-16 Thread Yury Katkov
During the debugging I saw a lot of interesting fields in SMWParamFormat:
* toLower
* trimValue
* applyManipulationsToDefault
* dependencies
* default
* validationFunction
* type

I'm particularly interested in how to use validationFunction: can I
assign my validation callback like that? I tried but nothing have
happened.

public function getParamDefinitions( array $definitions ) {
 $params = parent::getParamDefinitions( $definitions );

  $params['do awesome'] = array(
 validationFunction = MyClass::isDoAwesomeValid
);
}

It seems that I can do the following for the same effect, is that the only way?

public function getParamDefinitions( array $definitions ) {
  $startpr = array(
 'name' = 'do awesome',
 'message' = 'srf_paramdesc_doawesome',
 'default' = '',
  );

  $params['do awesome']=
  ParamDefinitionFactory::singleton()-newDefinitionFromArray( $startpr
  );
  $params['do awesome']-setValidationCallback(ChapTimeline::isDoAwesomeValid);
}

-
Yury Katkov, WikiVote



On Wed, Oct 16, 2013 at 4:19 PM, Yury Katkov katkov.ju...@gmail.com wrote:
 Hi Jeroen! Can you recommend any result formats that use Validator in
 the right and intense way?
 -
 Yury Katkov, WikiVote



 On Sat, Oct 12, 2013 at 4:56 AM, Jeroen De Dauw jeroended...@gmail.com 
 wrote:
 Hey Yury,

 This is unfortunately not properly documented, and as with a lot of MW code,
 the answer is, at least for now, look at the source. This is certainly not
 a good answer and something that should be addressed. Rather then answering
 in detail here, I'll be adding documentation incrementally to the README
 file of Validator with the aim of having the basics covered there by the
 time of its 1.0 release, which will be shortly before the SMW 1.9 one.

 The README can be seen here:
 https://github.com/wikimedia/mediawiki-extensions-Validator/blob/master/README.md

 Some quick replies:


 What values can I use for the values of the key 'default'?

 Anything. This is self defined.


 Where did these words 'message', 'values', 'default', 'aliases' come from?

 This is the definition format in array form as defined by Validator.

 Are there any other interesting words to use (for example 'mandatory'
 would be nice or 'type')?

 There is a type field. A param is mandatory if it does not have a default.

 Cheers

 --
 Jeroen De Dauw
 http://www.bn2vs.com
 Don't panic. Don't be evil. ~=[,,_,,]:3
 --

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135031iu=/4140/ostg.clktrk
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


[SMW-devel] how to know the validation option for the parameters in SMWResultPrinter::getParamDefinitions( )?

2013-10-11 Thread Yury Katkov
Hey guys, especially Validator lovers and especially Jeroen!

If I understand correctly we can now use this beautiful function
SMWResultPrinter::getParamDefinitions in our result printers to
validate if all the parameters of {{#ask}} function is ok. Typically
the text of overrided getParamDefinitions function looks like that:


public function getParamDefinitions( array $definitions ) {
 $params = parent::getParamDefinitions( $definitions );

 $definitions['limit']-setDefault( $GLOBALS['smwgQMaxInlineLimit'] );
 $definitions['link']-setDefault( 'none' );
 $definitions['headers']-setDefault( 'hide' );

 ### new params: ###
 $params['titles'] = array(
 'message' = 'srf_paramdesc_pagetitle',
 'values' = array( 'show', 'hide' ),
 'aliases' = array( 'pagetitle', 'pagetitles' ),
 'default' = 'show',
 );

$params['hidegaps'] = array(
'message' = 'srf_paramdesc_hidegaps',
'values' = array( 'none', 'all', 'property', 'record' ),
'default' = 'none',
'manipulatedefault' = false,
);

}

It looks like magic for me but I feel that these are very powerful spells.

Where did these words 'message', 'values', 'default', 'aliases' come from?
What values can I use for the values of the key 'default'?
Are there any other interesting words to use (for example 'mandatory'
would be nice or 'type')?
Is there any documentation on that anywhere?

Cheers,
-
Yury Katkov, WikiVote

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] how to know the validation option for the parameters in SMWResultPrinter::getParamDefinitions( )?

2013-10-11 Thread Jeroen De Dauw
Hey Yury,

This is unfortunately not properly documented, and as with a lot of MW
code, the answer is, at least for now, look at the source. This is
certainly not a good answer and something that should be addressed. Rather
then answering in detail here, I'll be adding documentation incrementally
to the README file of Validator with the aim of having the basics covered
there by the time of its 1.0 release, which will be shortly before the SMW
1.9 one.

The README can be seen here:
https://github.com/wikimedia/mediawiki-extensions-Validator/blob/master/README.md

Some quick replies:

 What values can I use for the values of the key 'default'?

Anything. This is self defined.

 Where did these words 'message', 'values', 'default', 'aliases' come from?

This is the definition format in array form as defined by Validator.

 Are there any other interesting words to use (for example 'mandatory'
would be nice or 'type')?

There is a type field. A param is mandatory if it does not have a default.

Cheers

--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil. ~=[,,_,,]:3
--
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel