Limiting Forms: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 17: Line 17:
La mayoria de estos estilos de límites y sus códigos auxiliaries se pueden encontrar en el módulo '''form-limits.'''  
La mayoria de estos estilos de límites y sus códigos auxiliaries se pueden encontrar en el módulo '''form-limits.'''  


==Structure of Limiting Data==
==Estructura de los Límites de Datos==
We allow, on a per-form basis, logical compounds of limits of any field through a nested array (or magic data) structure. The structure of a limit ''expression node'' is as follows:
Permitimos formulario por formulario, la existencia de compuestos lógicos de límites de cualquier campo a través de una estructura de arreglo anidado (o datos magic). La estructura del límite de un ''expression node'' es de la siguiente manera:
*operator: Required. Tells us what type of node this expression node is. Valid values are 'FIELD_LIMIT', 'AND', 'XOR', 'OR', and 'NOT'
*operator: Requerido. Nos dice que tipo de nodo es este nodo de expresión. Los valores válidos son 'FIELD_LIMIT', 'AND', 'XOR', 'OR', y 'NOT'
*operand: Used only in the case of 'AND', 'XOR', 'OR' and 'NOT' in which case it is required. It is a sub-array/sub-node consisting of zero or more ''limit expression nodes.''  In the case of 'NOT' there is the further limitation that the number is exactly one.
*operand: Solamente se utiliza en el caso de 'AND', 'XOR', 'OR' y 'NOT' el cual es requerido. Es un sub-arreglo/sub-nodo que consiste de cero o mas ''limit expression nodes.''  En el caso de 'NOT' existe la mayor limitación de que el número es exactamente uno.
*field: Used only need in the case of 'FIELD_LIMIT' in which case it is requiredIt is the name of the field for this form we are limiting on.
*field: Solamente se utiliza en el caso de 'FIELD_LIMIT' el cual es requeridoEs el nombre del campo para la forma que estmos limitando.
*style: Used only need in the case of 'FIELD_LIMIT' in which case it is required. It is the limit style.
*style: Solamente se utiliza en el caso de 'FIELD_LIMIT' el cual es requerido. Es el estilo de l límite.
*data: Used only need in the case of 'FIELD_LIMIT.' It is a associative array of data used to limit the data by. If not set, it should be interpreted as the empty array.
*data: Utilizado solamente en el caso de 'FIELD_LIMIT.' Es un arreglo asociativo de datos utilizados para límitar los datos. Si no se establece, debería interpretarse como un arreglo vacío.


For example for a person, we may have:
Por ejemplo, para una persona podremos tener:
  array(
  array(
   'operator'=>'AND',
   'operator'=>'AND',
Line 65: Line 65:
   )
   )


would be interpreted in SQL as:
sería interpretado en SQL como:
  ((`person+surname` LIKE 'N%th') AND ( NOT (( `person+othername` = 'Mike') OR (`person+othername` = 'Michael'))))
  ((`person+surname` LIKE 'N%th') AND ( NOT (( `person+othername` = 'Mike') OR (`person+othername` = 'Michael'))))
Unfortunately, with such a statement, you would not find [http://en.wikipedia.org/wiki/Michael_Nesmith#The_Monkees Mike Nesmith].
Desafortunadamente, con tal afirmación no encontraría[http://en.wikipedia.org/wiki/Michael_Nesmith#The_Monkees Mike Nesmith].


==Existing Styles==
==Estilos Existentes==
These are the limit styles provided by ''form-limits'' version 3.2.0.  Please see the class itself for more up-to-date information.
Estos son los estilos de limites proporcionados por ''form-limits'' versión 3.2.0.  Por favor vea la clase misma para obtener información más actualizada.
*I2CE_FormField
*I2CE_FormField
**null: No data array.
**null: No data array.

Revision as of 09:41, 29 September 2013

Los datos en iHRIS se guardan en formularios y campos. Puede ser que quiera limitar una búsqueda de un formulario en particular utilizando una propiedad en sus campos. Por ejemplo, puede querer buscar a una persona cuyo primer nombre es "Jill." Este artículo describe la estructura de como se aplican diferentes límites a los formularios.

El sistema iHRIS tomará esta representación abstracta de un límite de un formulario y lo traducirá a un código PHP o SQL adecuado según sea necesario.

Usos

La estructura de límites de datos se utiliza en, por ejemplo:

  • I2CE_Form::search()
  • I2CE_Form::listFields()
  • Form Relationships
  • Report Limits

Los métodos de I2CE_Form incluyen la habilidad de limitar valores en base al mecanismo de almacenamiento. Si desea crear un nuevo mecanismo de almacenamiento con capacidades de búsqueda, sera necesario que produzca algún código que permita pegar la estructura de limitación de datos descrita a continuación o, si su mecanismo de almacenamiento es accessible a la base de datps, simplemente convierta I2CE_FormStorage_Helper_DB en una sub-clase.

Estilos de Límites

Hay varias maneras en las que desearía limitar los valores de un campo en particular, a estos nos freferimos como limit style. Por ejemplo, equals o like.

Recuerde que cada campo tiene un tipo, tal como INT o INT_LIST, que se traduce en una clase, tal como I2CE_FormField_INT o I2CE_FormField_INT_LIST, todas las que son sub-clase de I2CE_FormField. Un tipo se hhace disponible a alguna sub-clase (al igual que todas sus sub-clases) de I2CE_FormField.

La mayoria de estos estilos de límites y sus códigos auxiliaries se pueden encontrar en el módulo form-limits.

Estructura de los Límites de Datos

Permitimos formulario por formulario, la existencia de compuestos lógicos de límites de cualquier campo a través de una estructura de arreglo anidado (o datos magic). La estructura del límite de un expression node es de la siguiente manera:

  • operator: Requerido. Nos dice que tipo de nodo es este nodo de expresión. Los valores válidos son 'FIELD_LIMIT', 'AND', 'XOR', 'OR', y 'NOT'
  • operand: Solamente se utiliza en el caso de 'AND', 'XOR', 'OR' y 'NOT' el cual es requerido. Es un sub-arreglo/sub-nodo que consiste de cero o mas limit expression nodes. En el caso de 'NOT' existe la mayor limitación de que el número es exactamente uno.
  • field: Solamente se utiliza en el caso de 'FIELD_LIMIT' el cual es requerido. Es el nombre del campo para la forma que estmos limitando.
  • style: Solamente se utiliza en el caso de 'FIELD_LIMIT' el cual es requerido. Es el estilo de l límite.
  • data: Utilizado solamente en el caso de 'FIELD_LIMIT.' Es un arreglo asociativo de datos utilizados para límitar los datos. Si no se establece, debería interpretarse como un arreglo vacío.

Por ejemplo, para una persona podremos tener:

array(
  'operator'=>'AND',
  'operand'=>array(
    0=>array(
      'operator'=>'FIELD_LIMIT',
      'field'=>'surname',
      'style'=>'like',
      'data'=>array(
        'value'=>'N%th'
      )
    )
    1=>array(
      'operator'=>'NOT',
      'operand'=>array(
        0=>array(
          'operator'=>'OR',
          'operand'=>array(
            0=>array(
              'operator'=>'FIELD_LIMIT',
              'field'=>'othername',
              'style'=>'equals',
              'data'=>array(
                'value'=>'Mike'
               )
            ),
            1=>array(
              'operator'=>'FIELD_LIMIT',
              'field'=>'othername',
              'style'=>'equals',
              'data'=>array(
               'value'=>'Michael'
              )
            )
          )
        )
      )
    )
  )

sería interpretado en SQL como:

((`person+surname` LIKE 'N%th') AND ( NOT (( `person+othername` = 'Mike') OR (`person+othername` = 'Michael'))))

Desafortunadamente, con tal afirmación no encontraríaMike Nesmith.

Estilos Existentes

Estos son los estilos de limites proporcionados por form-limits versión 3.2.0. Por favor vea la clase misma para obtener información más actualizada.

  • I2CE_FormField
    • null: No data array.
    • not_null: No data array.
    • null_not_null: Choose if a value is null or not. Data array has key 'value' which is either (evaluates to) true for null, or (evaluates to) false for not null.
    • max_parent: No data array. Only valid in form relationship context.
    • min_parent: No data array. Only valid in form relationship context.
    • max_parent_form: No data array. Only valid in form relationship context.
    • min_parent_form: No data array. Only valid in form relationship context.
  • I2CE_FormField_BOOL
    • truefalse: No data array.
    • true: No data array.
    • false: No data array.
  • I2CE_FormField_DB_DATE
    • greaterthan_now: No data array.
    • lessthan_now: No data array.
  • I2CE_FormField_DATE_Y
    • greaterthan: Data array has key 'year' which is a year (integer).
    • greaterthan_equals: Data array has key 'year' which is a year (integer).
    • equals: Data array has key 'year' which is a year (integer).
    • lessthan_equals: Data array has key 'year' which is a year (integer).
    • less_than: Data array has key 'year' which is a year (integer).
    • between: Data array has keys 'min' and 'max' each of which is an array containing the key 'year' which is a year (integer).
  • I2CE_FormField_DATE_YMD
    • greaterthan: Data array has key 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • greaterthan_equals: Data array has key 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • equals: Data array has key 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • lessthan_equals: Data array has key 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • less_than: Data array has key 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • between: Data array has keys 'min' and 'max' each of which is an array containing the key 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
  • I2CE_FormField_DATE_MD
    • greaterthan: Data array has key 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • greaterthan_equals: Data array has key'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • equals: Data array has key 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • lessthan_equals: Data array has key 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • less_than: Data array has key 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • between: Data array has keys 'min' and 'max' each of which is an array containing the key 'month' which is a month (integer), and 'day' which is the day of the month (integer).
  • I2CE_FormField_DATE_HMS:
    • greaterthan: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer).
    • greaterthan_equals: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer).
    • equals: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer).
    • lessthan_equals: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer).
    • lessthan: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer).
    • between: Data array has keys 'min' and 'max' each of which is an array which contains the keys 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer).
  • I2CE_FormField_DATE_TIME:
    • greaterthan: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • greaterthan_equals: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • equals: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • lessthan_equals: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • lessthan: Data array has key 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
    • between: Data array has keys 'min' and 'max' each of which is an array which contains the keys 'hour' which is an hour (integer), 'minute' which is a minute (integer), and 'second' (integer), 'year' which is a year (integer), 'month' which is a month (integer), and 'day' which is the day of the month (integer).
  • I2CE_FormField_DB_INT
    • between. Data array has keys 'min' and 'max.'
    • equals. Data array has key 'value' which is a scalar.
    • in. Data array has key 'value' which is a an array of scalar values.
    • greaterthan. Data array has key 'value' which is a scalar.
    • greaterthan_equals. Data array has key 'value' which is a scalar.
    • lessthan. Data array has key 'value' which is a scalar.
    • lessthan_equals. Data array has key 'value' which is a scalar.
  • I2CE_FormField_DB_STRING
    • between. Data array has keys 'min' and 'max.'
    • equals. Data array has key 'value' which is a scalar.
    • in. Data array has key 'value' which is a an array of scalar values.
    • greaterthan. Data array has key 'value' which is a scalar.
    • greaterthan_equals. Data array has key 'value' which is a scalar.
    • lessthan. Data array has key 'value' which is a scalar.
    • lessthan_equals. Data array has key 'value' which is a scalar.
    • like. Data array has key 'value' which is a scalar.
    • lowerlike. Data array has key 'value' which is a scalar. match is case insensitive
    • contains. Data array has key 'value' which is a scalar. match is case insensitive
  • I2CE_FormField_DB_TEXT
    • between. Data array has keys 'min' and 'max.'
    • equals. Data array has key 'value' which is a scalar.
    • in. Data array has key 'value' which is a an array of scalar values.
    • greaterthan. Data array has key 'value' which is a scalar.
    • greaterthan_equals. Data array has key 'value' which is a scalar.
    • lessthan. Data array has key 'value' which is a scalar.
    • lessthan_equals. Data array has key 'value' which is a scalar.
    • like. Data array has key 'value' which is a scalar.
    • lowerlike. Data array has key 'value' which is a scalar. match is case insensitive
    • contains. Data array has key 'value' which is a scalar. match is case insensitive
  • I2CE_FormField_YESNO
    • yesno: No data array.
    • yes: No data array.
    • no: No data array.