@@ -39,7 +39,6 @@ discard block |
||
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Return the schema for a given model from a given model. |
42 | - * @param \EEM_Base $model |
|
43 | 42 | * @return array |
44 | 43 | */ |
45 | 44 | public function getModelSchema() |
@@ -103,7 +102,6 @@ discard block |
||
103 | 102 | |
104 | 103 | /** |
105 | 104 | * Outputs the schema header for a model. |
106 | - * @param \EEM_Base $model |
|
107 | 105 | * @return array |
108 | 106 | */ |
109 | 107 | public function getInitialSchemaStructure() |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function getModelSchemaForFields(array $model_fields, array $schema) |
65 | 65 | { |
66 | 66 | foreach ($model_fields as $field => $model_field) { |
67 | - if (! $model_field instanceof EE_Model_Field_Base) { |
|
67 | + if ( ! $model_field instanceof EE_Model_Field_Base) { |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | $schema['properties'][$field] = $model_field->getSchema(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
96 | 96 | { |
97 | 97 | foreach ($relations_on_model as $model_name => $relation) { |
98 | - if (! $relation instanceof EE_Model_Relation_Base) { |
|
98 | + if ( ! $relation instanceof EE_Model_Relation_Base) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
@@ -25,120 +25,120 @@ |
||
25 | 25 | class JsonModelSchema |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var \EEM_Base |
|
30 | - */ |
|
31 | - protected $model; |
|
32 | - |
|
33 | - /** |
|
34 | - * JsonModelSchema constructor. |
|
35 | - * |
|
36 | - * @param \EEM_Base $model |
|
37 | - */ |
|
38 | - public function __construct(EEM_Base $model) |
|
39 | - { |
|
40 | - $this->model = $model; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Return the schema for a given model from a given model. |
|
45 | - * @param \EEM_Base $model |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - public function getModelSchema() |
|
49 | - { |
|
50 | - return $this->getModelSchemaForRelations( |
|
51 | - $this->model->relation_settings(), |
|
52 | - $this->getModelSchemaForFields( |
|
53 | - $this->model->field_settings(), |
|
54 | - $this->getInitialSchemaStructure() |
|
55 | - ) |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Get the schema for a given set of model fields. |
|
62 | - * @param \EE_Model_Field_Base[] $model_fields |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public function getModelSchemaForFields(array $model_fields, array $schema) |
|
66 | - { |
|
67 | - foreach ($model_fields as $field => $model_field) { |
|
68 | - if (! $model_field instanceof EE_Model_Field_Base) { |
|
69 | - continue; |
|
70 | - } |
|
71 | - $schema['properties'][$field] = $model_field->getSchema(); |
|
72 | - |
|
73 | - //if this is a primary key field add the primary key item |
|
74 | - if ($model_field instanceof EE_Primary_Key_Field_Base) { |
|
75 | - $schema['properties'][$field]['primary_key'] = true; |
|
76 | - if ($model_field instanceof EE_Primary_Key_Int_Field) { |
|
77 | - $schema['properties'][$field]['readonly'] = true; |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - //if this is a foreign key field add the foreign key item |
|
82 | - if ($model_field instanceof EE_Foreign_Key_Field_Base) { |
|
83 | - $schema['properties'][$field]['foreign_key'] = array( |
|
84 | - 'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'), |
|
85 | - 'type' => 'array', |
|
86 | - 'enum' => $model_field->get_model_class_names_pointed_to() |
|
87 | - ); |
|
88 | - } |
|
89 | - } |
|
90 | - return $schema; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * Get the schema for a given set of model relations |
|
96 | - * @param EE_Model_Relation_Base[] $relations_on_model |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
|
100 | - { |
|
101 | - foreach ($relations_on_model as $model_name => $relation) { |
|
102 | - if (! $relation instanceof EE_Model_Relation_Base) { |
|
103 | - continue; |
|
104 | - } |
|
105 | - $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
|
106 | - ? strtolower($model_name) |
|
107 | - : EEH_Inflector::pluralize_and_lower($model_name); |
|
108 | - $schema['properties'][$model_name_for_schema] = $relation->getSchema(); |
|
109 | - $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name; |
|
110 | - } |
|
111 | - return $schema; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Outputs the schema header for a model. |
|
117 | - * @param \EEM_Base $model |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function getInitialSchemaStructure() |
|
121 | - { |
|
122 | - return array( |
|
123 | - '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
124 | - 'title' => $this->model->get_this_model_name(), |
|
125 | - 'type' => 'object', |
|
126 | - 'properties' => array() |
|
127 | - ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Allows one to just use the object as a string to get the json. |
|
133 | - * eg. |
|
134 | - * |
|
135 | - * $json_schema = new JsonModelSchema(EEM_Event::instance()); |
|
136 | - * echo $json_schema; //outputs the schema as a json formatted string. |
|
137 | - * |
|
138 | - * @return bool|false|mixed|string |
|
139 | - */ |
|
140 | - public function __toString() |
|
141 | - { |
|
142 | - return wp_json_encode($this->getModelSchema()); |
|
143 | - } |
|
28 | + /** |
|
29 | + * @var \EEM_Base |
|
30 | + */ |
|
31 | + protected $model; |
|
32 | + |
|
33 | + /** |
|
34 | + * JsonModelSchema constructor. |
|
35 | + * |
|
36 | + * @param \EEM_Base $model |
|
37 | + */ |
|
38 | + public function __construct(EEM_Base $model) |
|
39 | + { |
|
40 | + $this->model = $model; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Return the schema for a given model from a given model. |
|
45 | + * @param \EEM_Base $model |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + public function getModelSchema() |
|
49 | + { |
|
50 | + return $this->getModelSchemaForRelations( |
|
51 | + $this->model->relation_settings(), |
|
52 | + $this->getModelSchemaForFields( |
|
53 | + $this->model->field_settings(), |
|
54 | + $this->getInitialSchemaStructure() |
|
55 | + ) |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Get the schema for a given set of model fields. |
|
62 | + * @param \EE_Model_Field_Base[] $model_fields |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public function getModelSchemaForFields(array $model_fields, array $schema) |
|
66 | + { |
|
67 | + foreach ($model_fields as $field => $model_field) { |
|
68 | + if (! $model_field instanceof EE_Model_Field_Base) { |
|
69 | + continue; |
|
70 | + } |
|
71 | + $schema['properties'][$field] = $model_field->getSchema(); |
|
72 | + |
|
73 | + //if this is a primary key field add the primary key item |
|
74 | + if ($model_field instanceof EE_Primary_Key_Field_Base) { |
|
75 | + $schema['properties'][$field]['primary_key'] = true; |
|
76 | + if ($model_field instanceof EE_Primary_Key_Int_Field) { |
|
77 | + $schema['properties'][$field]['readonly'] = true; |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + //if this is a foreign key field add the foreign key item |
|
82 | + if ($model_field instanceof EE_Foreign_Key_Field_Base) { |
|
83 | + $schema['properties'][$field]['foreign_key'] = array( |
|
84 | + 'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'), |
|
85 | + 'type' => 'array', |
|
86 | + 'enum' => $model_field->get_model_class_names_pointed_to() |
|
87 | + ); |
|
88 | + } |
|
89 | + } |
|
90 | + return $schema; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * Get the schema for a given set of model relations |
|
96 | + * @param EE_Model_Relation_Base[] $relations_on_model |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
|
100 | + { |
|
101 | + foreach ($relations_on_model as $model_name => $relation) { |
|
102 | + if (! $relation instanceof EE_Model_Relation_Base) { |
|
103 | + continue; |
|
104 | + } |
|
105 | + $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
|
106 | + ? strtolower($model_name) |
|
107 | + : EEH_Inflector::pluralize_and_lower($model_name); |
|
108 | + $schema['properties'][$model_name_for_schema] = $relation->getSchema(); |
|
109 | + $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name; |
|
110 | + } |
|
111 | + return $schema; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Outputs the schema header for a model. |
|
117 | + * @param \EEM_Base $model |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function getInitialSchemaStructure() |
|
121 | + { |
|
122 | + return array( |
|
123 | + '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
124 | + 'title' => $this->model->get_this_model_name(), |
|
125 | + 'type' => 'object', |
|
126 | + 'properties' => array() |
|
127 | + ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Allows one to just use the object as a string to get the json. |
|
133 | + * eg. |
|
134 | + * |
|
135 | + * $json_schema = new JsonModelSchema(EEM_Event::instance()); |
|
136 | + * echo $json_schema; //outputs the schema as a json formatted string. |
|
137 | + * |
|
138 | + * @return bool|false|mixed|string |
|
139 | + */ |
|
140 | + public function __toString() |
|
141 | + { |
|
142 | + return wp_json_encode($this->getModelSchema()); |
|
143 | + } |
|
144 | 144 | } |
@@ -5,63 +5,63 @@ |
||
5 | 5 | |
6 | 6 | interface HasSchemaInterface |
7 | 7 | { |
8 | - /** |
|
9 | - * Returns whatever is set as the nicename for the object. |
|
10 | - * |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - public function getSchemaDescription(); |
|
8 | + /** |
|
9 | + * Returns whatever is set as the nicename for the object. |
|
10 | + * |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + public function getSchemaDescription(); |
|
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * Returns whatever is set as the $_schema_type property for the object. |
|
18 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
19 | - * |
|
20 | - * @return string|array |
|
21 | - */ |
|
22 | - public function getSchemaType(); |
|
16 | + /** |
|
17 | + * Returns whatever is set as the $_schema_type property for the object. |
|
18 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
19 | + * |
|
20 | + * @return string|array |
|
21 | + */ |
|
22 | + public function getSchemaType(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
27 | - * this method and return the properties for the schema. |
|
28 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
29 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
30 | - * |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function getSchemaProperties(); |
|
25 | + /** |
|
26 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
27 | + * this method and return the properties for the schema. |
|
28 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
29 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
30 | + * |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function getSchemaProperties(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * If a child class has enum values, they should override this method and provide a simple array |
|
37 | - * of the enum values. |
|
38 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
39 | - * are set on the instantiated object that could be filtered after construct. |
|
40 | - * |
|
41 | - * @return array |
|
42 | - */ |
|
43 | - public function getSchemaEnum(); |
|
35 | + /** |
|
36 | + * If a child class has enum values, they should override this method and provide a simple array |
|
37 | + * of the enum values. |
|
38 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
39 | + * are set on the instantiated object that could be filtered after construct. |
|
40 | + * |
|
41 | + * @return array |
|
42 | + */ |
|
43 | + public function getSchemaEnum(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * This returns the value of the $_schema_format property on the object. |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getSchemaFormat(); |
|
45 | + /** |
|
46 | + * This returns the value of the $_schema_format property on the object. |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getSchemaFormat(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * This returns the value of the $_schema_readonly property on the object. |
|
54 | - * |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - public function getSchemaReadonly(); |
|
52 | + /** |
|
53 | + * This returns the value of the $_schema_readonly property on the object. |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + public function getSchemaReadonly(); |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * This returns elements used to represent this field in the json schema. |
|
62 | - * |
|
63 | - * @link http://json-schema.org/ |
|
64 | - * @return array |
|
65 | - */ |
|
66 | - public function getSchema(); |
|
60 | + /** |
|
61 | + * This returns elements used to represent this field in the json schema. |
|
62 | + * |
|
63 | + * @link http://json-schema.org/ |
|
64 | + * @return array |
|
65 | + */ |
|
66 | + public function getSchema(); |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -4,22 +4,22 @@ |
||
4 | 4 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - public function __construct($table_column, $nicename) |
|
8 | - { |
|
9 | - parent::__construct($table_column, $nicename, null); |
|
10 | - } |
|
7 | + public function __construct($table_column, $nicename) |
|
8 | + { |
|
9 | + parent::__construct($table_column, $nicename, null); |
|
10 | + } |
|
11 | 11 | |
12 | - /** |
|
13 | - * removes all tags when setting |
|
14 | - * |
|
15 | - * @param string $value_inputted_for_field_on_model_object |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
19 | - { |
|
20 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
21 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
22 | - } |
|
23 | - return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
24 | - } |
|
12 | + /** |
|
13 | + * removes all tags when setting |
|
14 | + * |
|
15 | + * @param string $value_inputted_for_field_on_model_object |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
19 | + { |
|
20 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
21 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
22 | + } |
|
23 | + return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -4,6 +4,9 @@ |
||
4 | 4 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | + /** |
|
8 | + * @param string $table_column |
|
9 | + */ |
|
7 | 10 | public function __construct($table_column, $nicename) |
8 | 11 | { |
9 | 12 | parent::__construct($table_column, $nicename, null); |
@@ -6,14 +6,14 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_All_Caps_Text_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * makes it all upper case, and key-like |
|
11 | - * |
|
12 | - * @param string $value_inputted_for_field_on_model_object |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | - { |
|
17 | - return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | - } |
|
9 | + /** |
|
10 | + * makes it all upper case, and key-like |
|
11 | + * |
|
12 | + * @param string $value_inputted_for_field_on_model_object |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | + { |
|
17 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | /** @var string $default_hidden_inputs */ |
5 | 5 | ?> |
6 | 6 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
7 | - <?php echo apply_filters( 'FHEE__registration_page_attendee_information__attendee_information_pg', sprintf( __('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>' )); ?> |
|
7 | + <?php echo apply_filters('FHEE__registration_page_attendee_information__attendee_information_pg', sprintf(__('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>')); ?> |
|
8 | 8 | </p> |
9 | 9 | |
10 | 10 | <?php |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | $prev_event = 0; |
13 | 13 | $prev_ticket = 0; |
14 | 14 | |
15 | -if ( count( $registrations ) > 0 ) { |
|
16 | - foreach ( $registrations as $registration ) { |
|
17 | - if ( $registration instanceof EE_Registration ) { |
|
15 | +if (count($registrations) > 0) { |
|
16 | + foreach ($registrations as $registration) { |
|
17 | + if ($registration instanceof EE_Registration) { |
|
18 | 18 | $att_nmbr++; |
19 | 19 | ?> |
20 | 20 | |
21 | - <div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link();?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID();?>"> |
|
21 | + <div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link(); ?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID(); ?>"> |
|
22 | 22 | |
23 | - <?php if ( $registration->event()->ID() !== $prev_event ) { ?> |
|
23 | + <?php if ($registration->event()->ID() !== $prev_event) { ?> |
|
24 | 24 | <h4 id="event_title-<?php echo $registration->event()->ID() ?>" class="big-event-title-hdr"> |
25 | 25 | <?php echo $registration->event()->name(); ?> |
26 | 26 | </h4> |
27 | 27 | <?php } ?> |
28 | - <?php if ( $registration->ticket()->ID() !== $prev_ticket ) { ?> |
|
29 | - <?php if ( ! $revisit ) { ?> |
|
28 | + <?php if ($registration->ticket()->ID() !== $prev_ticket) { ?> |
|
29 | + <?php if ( ! $revisit) { ?> |
|
30 | 30 | <div class="spco-ticket-info-dv small-text"> |
31 | - <h5><?php _e('Details', 'event_espresso');?></h5> |
|
31 | + <h5><?php _e('Details', 'event_espresso'); ?></h5> |
|
32 | 32 | <table> |
33 | 33 | <thead> |
34 | 34 | <tr> |
35 | - <th scope="col" width=""><?php _e('Name and Description', 'event_espresso');?></th> |
|
36 | - <th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso');?></th> |
|
37 | - <th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso');?></th> |
|
38 | - <th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso');?></th> |
|
35 | + <th scope="col" width=""><?php _e('Name and Description', 'event_espresso'); ?></th> |
|
36 | + <th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso'); ?></th> |
|
37 | + <th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso'); ?></th> |
|
38 | + <th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso'); ?></th> |
|
39 | 39 | </tr> |
40 | 40 | </thead> |
41 | 41 | <tbody> |
42 | - <?php echo $ticket_line_item[ $registration->ticket()->ID() ]; ?> |
|
42 | + <?php echo $ticket_line_item[$registration->ticket()->ID()]; ?> |
|
43 | 43 | </tbody> |
44 | 44 | </table> |
45 | 45 | </div> |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | <?php |
50 | 50 | // ATTENDEE QUESTIONS |
51 | - $reg_form = EE_Template_Layout::get_subform_name( $registration->reg_url_link() ); |
|
51 | + $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
52 | 52 | echo ${$reg_form}; |
53 | 53 | ?> |
54 | 54 |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * @param string $table_column |
16 | 16 | * @param string $nicename |
17 | 17 | * @param bool $nullable |
18 | - * @param null $default_value |
|
18 | + * @param string|null $default_value |
|
19 | 19 | */ |
20 | 20 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
21 | 21 | { |
@@ -11,28 +11,28 @@ |
||
11 | 11 | abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $table_column |
|
16 | - * @param string $nicename |
|
17 | - * @param bool $nullable |
|
18 | - * @param null $default_value |
|
19 | - */ |
|
20 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
21 | - { |
|
22 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
23 | - $this->setSchemaReadOnly(true); |
|
24 | - } |
|
14 | + /** |
|
15 | + * @param string $table_column |
|
16 | + * @param string $nicename |
|
17 | + * @param bool $nullable |
|
18 | + * @param null $default_value |
|
19 | + */ |
|
20 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
21 | + { |
|
22 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
23 | + $this->setSchemaReadOnly(true); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * All these children classes are for the db-only (meaning, we should select them |
|
29 | - * on get_all queries, update, delete, and will still want to set their default value |
|
30 | - * on inserts, but the model object won't have reference to these fields) |
|
31 | - * |
|
32 | - * @return boolean |
|
33 | - */ |
|
34 | - function is_db_only_field() |
|
35 | - { |
|
36 | - return true; |
|
37 | - } |
|
27 | + /** |
|
28 | + * All these children classes are for the db-only (meaning, we should select them |
|
29 | + * on get_all queries, update, delete, and will still want to set their default value |
|
30 | + * on inserts, but the model object won't have reference to these fields) |
|
31 | + * |
|
32 | + * @return boolean |
|
33 | + */ |
|
34 | + function is_db_only_field() |
|
35 | + { |
|
36 | + return true; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @param string $table_column |
13 | 13 | * @param string $nicename |
14 | 14 | * @param bool $nullable |
15 | - * @param null $default_value |
|
15 | + * @param integer|null $default_value |
|
16 | 16 | */ |
17 | 17 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
18 | 18 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
28 | 28 | * Returns a float |
29 | 29 | * |
30 | - * @param type $value_inputted_for_field_on_model_object |
|
30 | + * @param string $value_inputted_for_field_on_model_object |
|
31 | 31 | * @return float |
32 | 32 | */ |
33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) |
@@ -8,64 +8,64 @@ |
||
8 | 8 | class EE_Float_Field extends EE_Model_Field_Base |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * @param string $table_column |
|
13 | - * @param string $nicename |
|
14 | - * @param bool $nullable |
|
15 | - * @param null $default_value |
|
16 | - */ |
|
17 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
18 | - { |
|
19 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
20 | - $this->setSchemaType('number'); |
|
21 | - } |
|
11 | + /** |
|
12 | + * @param string $table_column |
|
13 | + * @param string $nicename |
|
14 | + * @param bool $nullable |
|
15 | + * @param null $default_value |
|
16 | + */ |
|
17 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
18 | + { |
|
19 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
20 | + $this->setSchemaType('number'); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
26 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
27 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
28 | - * Returns a float |
|
29 | - * |
|
30 | - * @param type $value_inputted_for_field_on_model_object |
|
31 | - * @return float |
|
32 | - */ |
|
33 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
34 | - { |
|
24 | + /** |
|
25 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
26 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
27 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
28 | + * Returns a float |
|
29 | + * |
|
30 | + * @param type $value_inputted_for_field_on_model_object |
|
31 | + * @return float |
|
32 | + */ |
|
33 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
34 | + { |
|
35 | 35 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
36 | - //remove whitespaces and thousands separators |
|
37 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
38 | - $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | - "", $value_inputted_for_field_on_model_object); |
|
36 | + //remove whitespaces and thousands separators |
|
37 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
38 | + $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | + "", $value_inputted_for_field_on_model_object); |
|
40 | 40 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
41 | 41 | //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
42 | - $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
43 | - $value_inputted_for_field_on_model_object); |
|
42 | + $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
43 | + $value_inputted_for_field_on_model_object); |
|
44 | 44 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
45 | 45 | //double-check there's absolutely nothing left on this string besides numbers |
46 | - $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
47 | - $value_inputted_for_field_on_model_object); |
|
48 | - } |
|
46 | + $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
47 | + $value_inputted_for_field_on_model_object); |
|
48 | + } |
|
49 | 49 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
50 | - return floatval($value_inputted_for_field_on_model_object); |
|
51 | - } |
|
50 | + return floatval($value_inputted_for_field_on_model_object); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
55 | - * |
|
56 | - * @param float $value_on_field_to_be_outputted |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
60 | - { |
|
61 | - $EE = EE_Registry::instance(); |
|
62 | - return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
63 | - $EE->CFG->currency->thsnds); |
|
64 | - } |
|
53 | + /** |
|
54 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
55 | + * |
|
56 | + * @param float $value_on_field_to_be_outputted |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
60 | + { |
|
61 | + $EE = EE_Registry::instance(); |
|
62 | + return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
63 | + $EE->CFG->currency->thsnds); |
|
64 | + } |
|
65 | 65 | |
66 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
67 | - { |
|
66 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
67 | + { |
|
68 | 68 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
69 | - return floatval($value_found_in_db_for_model_object); |
|
70 | - } |
|
69 | + return floatval($value_found_in_db_for_model_object); |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -8,7 +8,7 @@ |
||
8 | 8 | * @param string $table_column name fo column for field |
9 | 9 | * @param string $nicename should eb internationalized with __('blah','event_espresso') |
10 | 10 | * @param boolean $nullable |
11 | - * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
11 | + * @param integer|null $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
12 | 12 | * dbe a string |
13 | 13 | * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the |
14 | 14 | * "EEM_" |
@@ -4,37 +4,37 @@ |
||
4 | 4 | class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * @param string $table_column name fo column for field |
|
9 | - * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
10 | - * @param boolean $nullable |
|
11 | - * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
12 | - * dbe a string |
|
13 | - * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the |
|
14 | - * "EEM_" |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value, $model_name) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name); |
|
19 | - $this->setSchemaType('integer'); |
|
20 | - } |
|
7 | + /** |
|
8 | + * @param string $table_column name fo column for field |
|
9 | + * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
10 | + * @param boolean $nullable |
|
11 | + * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
12 | + * dbe a string |
|
13 | + * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the |
|
14 | + * "EEM_" |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value, $model_name) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name); |
|
19 | + $this->setSchemaType('integer'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param int|EE_Base_Class $value_inputted_for_field_on_model_object |
|
25 | - * @return int |
|
26 | - */ |
|
27 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
28 | - { |
|
29 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
30 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
31 | - } |
|
32 | - return absint($value_inputted_for_field_on_model_object); |
|
33 | - } |
|
23 | + /** |
|
24 | + * @param int|EE_Base_Class $value_inputted_for_field_on_model_object |
|
25 | + * @return int |
|
26 | + */ |
|
27 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
28 | + { |
|
29 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
30 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
31 | + } |
|
32 | + return absint($value_inputted_for_field_on_model_object); |
|
33 | + } |
|
34 | 34 | |
35 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
36 | - { |
|
37 | - return intval($value_found_in_db_for_model_object); |
|
38 | - } |
|
35 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
36 | + { |
|
37 | + return intval($value_found_in_db_for_model_object); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * @param string $table_column |
12 | 12 | * @param string $nicename |
13 | 13 | * @param bool $nullable |
14 | - * @param null $default_value |
|
14 | + * @param integer|null $default_value |
|
15 | 15 | */ |
16 | 16 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
17 | 17 | { |
@@ -7,26 +7,26 @@ |
||
7 | 7 | */ |
8 | 8 | class EE_Integer_Field extends EE_Model_Field_Base |
9 | 9 | { |
10 | - /** |
|
11 | - * @param string $table_column |
|
12 | - * @param string $nicename |
|
13 | - * @param bool $nullable |
|
14 | - * @param null $default_value |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | - $this->setSchemaType('integer'); |
|
20 | - } |
|
10 | + /** |
|
11 | + * @param string $table_column |
|
12 | + * @param string $nicename |
|
13 | + * @param bool $nullable |
|
14 | + * @param null $default_value |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | + $this->setSchemaType('integer'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | - { |
|
25 | - return intval($value_inputted_for_field_on_model_object); |
|
26 | - } |
|
23 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | + { |
|
25 | + return intval($value_inputted_for_field_on_model_object); |
|
26 | + } |
|
27 | 27 | |
28 | - function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
29 | - { |
|
30 | - return intval($value_inputted_for_field_on_model_object); |
|
31 | - } |
|
28 | + function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
29 | + { |
|
30 | + return intval($value_inputted_for_field_on_model_object); |
|
31 | + } |
|
32 | 32 | } |