@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * Loads the class file for a given class name. |
121 | 121 | * |
122 | 122 | * @param string $class The fully-qualified class name. |
123 | - * @return mixed The mapped file name on success, or boolean false on |
|
123 | + * @return string|false The mapped file name on success, or boolean false on |
|
124 | 124 | * failure. |
125 | 125 | */ |
126 | 126 | public function loadClass($class) |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @param string $prefix The namespace prefix. |
155 | 155 | * @param string $relative_class The relative class name. |
156 | - * @return mixed Boolean false if no mapped file can be loaded, or the |
|
156 | + * @return string|false Boolean false if no mapped file can be loaded, or the |
|
157 | 157 | * name of the mapped file that was loaded. |
158 | 158 | */ |
159 | 159 | protected function loadMappedFile($prefix, $relative_class) |
@@ -45,150 +45,150 @@ |
||
45 | 45 | class Psr4Autoloader |
46 | 46 | { |
47 | 47 | |
48 | - /** |
|
49 | - * namespace separator |
|
50 | - */ |
|
51 | - const NS = '\\'; |
|
52 | - |
|
53 | - /** |
|
54 | - * An associative array where the key is a namespace prefix and the value |
|
55 | - * is an array of base directories for classes in that namespace. |
|
56 | - * |
|
57 | - * @var array |
|
58 | - */ |
|
59 | - protected $prefixes = array(); |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * returns an array of registered namespace prefixes |
|
64 | - * |
|
65 | - * @param string $prefix |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function prefixes($prefix = '') |
|
69 | - { |
|
70 | - if (! empty($prefix)) { |
|
71 | - // are there any base directories for this namespace prefix? |
|
72 | - return isset($this->prefixes[ $prefix ]) ? $this->prefixes[ $prefix ] : array(); |
|
73 | - } |
|
74 | - return $this->prefixes; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Register loader with SPL autoloader stack. |
|
80 | - * |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function register() |
|
84 | - { |
|
85 | - spl_autoload_register(array($this, 'loadClass')); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * Adds a base directory for a namespace prefix. |
|
91 | - * |
|
92 | - * @param string $prefix The namespace prefix. |
|
93 | - * @param string $base_dir A base directory for class files in the |
|
94 | - * namespace. |
|
95 | - * @param bool $prepend If true, prepend the base directory to the stack |
|
96 | - * instead of appending it; this causes it to be searched first rather |
|
97 | - * than last. |
|
98 | - * @return void |
|
99 | - */ |
|
100 | - public function addNamespace($prefix, $base_dir, $prepend = false) |
|
101 | - { |
|
102 | - // normalize namespace prefix |
|
103 | - $prefix = trim($prefix, Psr4Autoloader::NS) . Psr4Autoloader::NS; |
|
104 | - // normalize the base directory with a trailing separator |
|
105 | - $base_dir = \EEH_File::standardise_and_end_with_directory_separator($base_dir); |
|
106 | - // initialize the namespace prefix array |
|
107 | - if (isset($this->prefixes[ $prefix ]) === false) { |
|
108 | - $this->prefixes[ $prefix ] = array(); |
|
109 | - } |
|
110 | - // retain the base directory for the namespace prefix |
|
111 | - if ($prepend) { |
|
112 | - array_unshift($this->prefixes[ $prefix ], $base_dir); |
|
113 | - } else { |
|
114 | - $this->prefixes[ $prefix ][] = $base_dir; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * Loads the class file for a given class name. |
|
121 | - * |
|
122 | - * @param string $class The fully-qualified class name. |
|
123 | - * @return mixed The mapped file name on success, or boolean false on |
|
124 | - * failure. |
|
125 | - */ |
|
126 | - public function loadClass($class) |
|
127 | - { |
|
128 | - // the current namespace prefix |
|
129 | - $prefix = $class; |
|
130 | - // work backwards through the namespace names of the fully-qualified |
|
131 | - // class name to find a mapped file name |
|
132 | - while (false !== $pos = strrpos($prefix, Psr4Autoloader::NS)) { |
|
133 | - // retain the trailing namespace separator in the prefix |
|
134 | - $prefix = substr($class, 0, $pos + 1); |
|
135 | - // the rest is the relative class name |
|
136 | - $relative_class = substr($class, $pos + 1); |
|
137 | - // try to load a mapped file for the prefix and relative class |
|
138 | - $mapped_file = $this->loadMappedFile($prefix, $relative_class); |
|
139 | - if ($mapped_file) { |
|
140 | - return $mapped_file; |
|
141 | - } |
|
142 | - // remove the trailing namespace separator for the next iteration |
|
143 | - // of strrpos() |
|
144 | - $prefix = rtrim($prefix, Psr4Autoloader::NS); |
|
145 | - } |
|
146 | - // never found a mapped file |
|
147 | - return false; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * Load the mapped file for a namespace prefix and relative class. |
|
153 | - * |
|
154 | - * @param string $prefix The namespace prefix. |
|
155 | - * @param string $relative_class The relative class name. |
|
156 | - * @return mixed Boolean false if no mapped file can be loaded, or the |
|
157 | - * name of the mapped file that was loaded. |
|
158 | - */ |
|
159 | - protected function loadMappedFile($prefix, $relative_class) |
|
160 | - { |
|
161 | - // look through base directories for this namespace prefix |
|
162 | - foreach ($this->prefixes($prefix) as $base_dir) { |
|
163 | - // replace the namespace prefix with the base directory, |
|
164 | - // replace namespace separators with directory separators |
|
165 | - // in the relative class name, append with .php |
|
166 | - $file = $base_dir |
|
167 | - . str_replace(Psr4Autoloader::NS, DS, $relative_class) |
|
168 | - . '.php'; |
|
169 | - // if the mapped file exists, require it |
|
170 | - if ($this->requireFile($file)) { |
|
171 | - // yes, we're done |
|
172 | - return $file; |
|
173 | - } |
|
174 | - } |
|
175 | - // never found it |
|
176 | - return false; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * If a file exists, require it from the file system. |
|
182 | - * |
|
183 | - * @param string $file The file to require. |
|
184 | - * @return bool True if the file exists, false if not. |
|
185 | - */ |
|
186 | - protected function requireFile($file) |
|
187 | - { |
|
188 | - if (file_exists($file)) { |
|
189 | - require $file; |
|
190 | - return true; |
|
191 | - } |
|
192 | - return false; |
|
193 | - } |
|
48 | + /** |
|
49 | + * namespace separator |
|
50 | + */ |
|
51 | + const NS = '\\'; |
|
52 | + |
|
53 | + /** |
|
54 | + * An associative array where the key is a namespace prefix and the value |
|
55 | + * is an array of base directories for classes in that namespace. |
|
56 | + * |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + protected $prefixes = array(); |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * returns an array of registered namespace prefixes |
|
64 | + * |
|
65 | + * @param string $prefix |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function prefixes($prefix = '') |
|
69 | + { |
|
70 | + if (! empty($prefix)) { |
|
71 | + // are there any base directories for this namespace prefix? |
|
72 | + return isset($this->prefixes[ $prefix ]) ? $this->prefixes[ $prefix ] : array(); |
|
73 | + } |
|
74 | + return $this->prefixes; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Register loader with SPL autoloader stack. |
|
80 | + * |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function register() |
|
84 | + { |
|
85 | + spl_autoload_register(array($this, 'loadClass')); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * Adds a base directory for a namespace prefix. |
|
91 | + * |
|
92 | + * @param string $prefix The namespace prefix. |
|
93 | + * @param string $base_dir A base directory for class files in the |
|
94 | + * namespace. |
|
95 | + * @param bool $prepend If true, prepend the base directory to the stack |
|
96 | + * instead of appending it; this causes it to be searched first rather |
|
97 | + * than last. |
|
98 | + * @return void |
|
99 | + */ |
|
100 | + public function addNamespace($prefix, $base_dir, $prepend = false) |
|
101 | + { |
|
102 | + // normalize namespace prefix |
|
103 | + $prefix = trim($prefix, Psr4Autoloader::NS) . Psr4Autoloader::NS; |
|
104 | + // normalize the base directory with a trailing separator |
|
105 | + $base_dir = \EEH_File::standardise_and_end_with_directory_separator($base_dir); |
|
106 | + // initialize the namespace prefix array |
|
107 | + if (isset($this->prefixes[ $prefix ]) === false) { |
|
108 | + $this->prefixes[ $prefix ] = array(); |
|
109 | + } |
|
110 | + // retain the base directory for the namespace prefix |
|
111 | + if ($prepend) { |
|
112 | + array_unshift($this->prefixes[ $prefix ], $base_dir); |
|
113 | + } else { |
|
114 | + $this->prefixes[ $prefix ][] = $base_dir; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * Loads the class file for a given class name. |
|
121 | + * |
|
122 | + * @param string $class The fully-qualified class name. |
|
123 | + * @return mixed The mapped file name on success, or boolean false on |
|
124 | + * failure. |
|
125 | + */ |
|
126 | + public function loadClass($class) |
|
127 | + { |
|
128 | + // the current namespace prefix |
|
129 | + $prefix = $class; |
|
130 | + // work backwards through the namespace names of the fully-qualified |
|
131 | + // class name to find a mapped file name |
|
132 | + while (false !== $pos = strrpos($prefix, Psr4Autoloader::NS)) { |
|
133 | + // retain the trailing namespace separator in the prefix |
|
134 | + $prefix = substr($class, 0, $pos + 1); |
|
135 | + // the rest is the relative class name |
|
136 | + $relative_class = substr($class, $pos + 1); |
|
137 | + // try to load a mapped file for the prefix and relative class |
|
138 | + $mapped_file = $this->loadMappedFile($prefix, $relative_class); |
|
139 | + if ($mapped_file) { |
|
140 | + return $mapped_file; |
|
141 | + } |
|
142 | + // remove the trailing namespace separator for the next iteration |
|
143 | + // of strrpos() |
|
144 | + $prefix = rtrim($prefix, Psr4Autoloader::NS); |
|
145 | + } |
|
146 | + // never found a mapped file |
|
147 | + return false; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Load the mapped file for a namespace prefix and relative class. |
|
153 | + * |
|
154 | + * @param string $prefix The namespace prefix. |
|
155 | + * @param string $relative_class The relative class name. |
|
156 | + * @return mixed Boolean false if no mapped file can be loaded, or the |
|
157 | + * name of the mapped file that was loaded. |
|
158 | + */ |
|
159 | + protected function loadMappedFile($prefix, $relative_class) |
|
160 | + { |
|
161 | + // look through base directories for this namespace prefix |
|
162 | + foreach ($this->prefixes($prefix) as $base_dir) { |
|
163 | + // replace the namespace prefix with the base directory, |
|
164 | + // replace namespace separators with directory separators |
|
165 | + // in the relative class name, append with .php |
|
166 | + $file = $base_dir |
|
167 | + . str_replace(Psr4Autoloader::NS, DS, $relative_class) |
|
168 | + . '.php'; |
|
169 | + // if the mapped file exists, require it |
|
170 | + if ($this->requireFile($file)) { |
|
171 | + // yes, we're done |
|
172 | + return $file; |
|
173 | + } |
|
174 | + } |
|
175 | + // never found it |
|
176 | + return false; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * If a file exists, require it from the file system. |
|
182 | + * |
|
183 | + * @param string $file The file to require. |
|
184 | + * @return bool True if the file exists, false if not. |
|
185 | + */ |
|
186 | + protected function requireFile($file) |
|
187 | + { |
|
188 | + if (file_exists($file)) { |
|
189 | + require $file; |
|
190 | + return true; |
|
191 | + } |
|
192 | + return false; |
|
193 | + } |
|
194 | 194 | } |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function prefixes($prefix = '') |
69 | 69 | { |
70 | - if (! empty($prefix)) { |
|
70 | + if ( ! empty($prefix)) { |
|
71 | 71 | // are there any base directories for this namespace prefix? |
72 | - return isset($this->prefixes[ $prefix ]) ? $this->prefixes[ $prefix ] : array(); |
|
72 | + return isset($this->prefixes[$prefix]) ? $this->prefixes[$prefix] : array(); |
|
73 | 73 | } |
74 | 74 | return $this->prefixes; |
75 | 75 | } |
@@ -100,18 +100,18 @@ discard block |
||
100 | 100 | public function addNamespace($prefix, $base_dir, $prepend = false) |
101 | 101 | { |
102 | 102 | // normalize namespace prefix |
103 | - $prefix = trim($prefix, Psr4Autoloader::NS) . Psr4Autoloader::NS; |
|
103 | + $prefix = trim($prefix, Psr4Autoloader::NS).Psr4Autoloader::NS; |
|
104 | 104 | // normalize the base directory with a trailing separator |
105 | 105 | $base_dir = \EEH_File::standardise_and_end_with_directory_separator($base_dir); |
106 | 106 | // initialize the namespace prefix array |
107 | - if (isset($this->prefixes[ $prefix ]) === false) { |
|
108 | - $this->prefixes[ $prefix ] = array(); |
|
107 | + if (isset($this->prefixes[$prefix]) === false) { |
|
108 | + $this->prefixes[$prefix] = array(); |
|
109 | 109 | } |
110 | 110 | // retain the base directory for the namespace prefix |
111 | 111 | if ($prepend) { |
112 | - array_unshift($this->prefixes[ $prefix ], $base_dir); |
|
112 | + array_unshift($this->prefixes[$prefix], $base_dir); |
|
113 | 113 | } else { |
114 | - $this->prefixes[ $prefix ][] = $base_dir; |
|
114 | + $this->prefixes[$prefix][] = $base_dir; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | /** |
31 | 31 | * @param RecipeInterface $recipe |
32 | 32 | * @param array $arguments |
33 | - * @return mixed |
|
33 | + * @return boolean |
|
34 | 34 | */ |
35 | 35 | public function brew(RecipeInterface $recipe, $arguments = array()) |
36 | 36 | { |
@@ -18,43 +18,43 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function type() |
|
25 | - { |
|
26 | - return CoffeeMaker::BREW_SHARED; |
|
27 | - } |
|
21 | + /** |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function type() |
|
25 | + { |
|
26 | + return CoffeeMaker::BREW_SHARED; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @param RecipeInterface $recipe |
|
32 | - * @param array $arguments |
|
33 | - * @return mixed |
|
34 | - */ |
|
35 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
36 | - { |
|
37 | - $this->resolveClassAndFilepath($recipe); |
|
38 | - $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
39 | - $method = $this->resolveInstantiationMethod($reflector); |
|
40 | - switch ($method) { |
|
41 | - case 'instance': |
|
42 | - case 'new_instance': |
|
43 | - case 'new_instance_from_db': |
|
44 | - $service = call_user_func_array( |
|
45 | - array($reflector->getName(), $method), |
|
46 | - $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
47 | - ); |
|
48 | - break; |
|
49 | - case 'newInstance': |
|
50 | - $service = $reflector->newInstance(); |
|
51 | - break; |
|
52 | - case 'newInstanceArgs': |
|
53 | - default: |
|
54 | - $service = $reflector->newInstanceArgs( |
|
55 | - $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
56 | - ); |
|
57 | - } |
|
58 | - return $this->coffeePot()->addService($recipe->identifier(), $service); |
|
59 | - } |
|
30 | + /** |
|
31 | + * @param RecipeInterface $recipe |
|
32 | + * @param array $arguments |
|
33 | + * @return mixed |
|
34 | + */ |
|
35 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
36 | + { |
|
37 | + $this->resolveClassAndFilepath($recipe); |
|
38 | + $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
39 | + $method = $this->resolveInstantiationMethod($reflector); |
|
40 | + switch ($method) { |
|
41 | + case 'instance': |
|
42 | + case 'new_instance': |
|
43 | + case 'new_instance_from_db': |
|
44 | + $service = call_user_func_array( |
|
45 | + array($reflector->getName(), $method), |
|
46 | + $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
47 | + ); |
|
48 | + break; |
|
49 | + case 'newInstance': |
|
50 | + $service = $reflector->newInstance(); |
|
51 | + break; |
|
52 | + case 'newInstanceArgs': |
|
53 | + default: |
|
54 | + $service = $reflector->newInstanceArgs( |
|
55 | + $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
56 | + ); |
|
57 | + } |
|
58 | + return $this->coffeePot()->addService($recipe->identifier(), $service); |
|
59 | + } |
|
60 | 60 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | /** |
34 | 34 | * Taken from https://gist.github.com/jaywilliams/119517 |
35 | 35 | * |
36 | - * @param $string |
|
36 | + * @param string $string |
|
37 | 37 | * @return string |
38 | 38 | */ |
39 | 39 | protected function convertAscii($string) |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace EventEspresso\core\services\formatters; |
4 | 4 | |
5 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
6 | - |
|
7 | 5 | /** |
8 | 6 | * Class AsciiOnly |
9 | 7 | * Removes all non-ascii characters from the string |
@@ -15,58 +15,58 @@ |
||
15 | 15 | class AsciiOnly extends FormatterBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Removes all non Ascii characters from string |
|
20 | - * |
|
21 | - * @param string|int|float $input anything easily cast into a string |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function format($input) |
|
25 | - { |
|
26 | - // in case an int or float etc was passed in |
|
27 | - $input = (string) $input; |
|
28 | - $input = $this->convertAscii($input); |
|
29 | - return $input; |
|
30 | - } |
|
18 | + /** |
|
19 | + * Removes all non Ascii characters from string |
|
20 | + * |
|
21 | + * @param string|int|float $input anything easily cast into a string |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function format($input) |
|
25 | + { |
|
26 | + // in case an int or float etc was passed in |
|
27 | + $input = (string) $input; |
|
28 | + $input = $this->convertAscii($input); |
|
29 | + return $input; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Taken from https://gist.github.com/jaywilliams/119517 |
|
35 | - * |
|
36 | - * @param $string |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - protected function convertAscii($string) |
|
40 | - { |
|
41 | - // Replace Single Curly Quotes |
|
42 | - $search[] = chr(226) . chr(128) . chr(152); |
|
43 | - $replace[] = "'"; |
|
44 | - $search[] = chr(226) . chr(128) . chr(153); |
|
45 | - $replace[] = "'"; |
|
46 | - // Replace Smart Double Curly Quotes |
|
47 | - $search[] = chr(226) . chr(128) . chr(156); |
|
48 | - $replace[] = '"'; |
|
49 | - $search[] = chr(226) . chr(128) . chr(157); |
|
50 | - $replace[] = '"'; |
|
51 | - // Replace En Dash |
|
52 | - $search[] = chr(226) . chr(128) . chr(147); |
|
53 | - $replace[] = '--'; |
|
54 | - // Replace Em Dash |
|
55 | - $search[] = chr(226) . chr(128) . chr(148); |
|
56 | - $replace[] = '---'; |
|
57 | - // Replace Bullet |
|
58 | - $search[] = chr(226) . chr(128) . chr(162); |
|
59 | - $replace[] = '*'; |
|
60 | - // Replace Middle Dot |
|
61 | - $search[] = chr(194) . chr(183); |
|
62 | - $replace[] = '*'; |
|
63 | - // Replace Ellipsis with three consecutive dots |
|
64 | - $search[] = chr(226) . chr(128) . chr(166); |
|
65 | - $replace[] = '...'; |
|
66 | - // Apply Replacements |
|
67 | - $string = str_replace($search, $replace, $string); |
|
68 | - // Remove any non-ASCII Characters |
|
69 | - $string = preg_replace("/[^\x01-\x7F]/", "", $string); |
|
70 | - return $string; |
|
71 | - } |
|
33 | + /** |
|
34 | + * Taken from https://gist.github.com/jaywilliams/119517 |
|
35 | + * |
|
36 | + * @param $string |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + protected function convertAscii($string) |
|
40 | + { |
|
41 | + // Replace Single Curly Quotes |
|
42 | + $search[] = chr(226) . chr(128) . chr(152); |
|
43 | + $replace[] = "'"; |
|
44 | + $search[] = chr(226) . chr(128) . chr(153); |
|
45 | + $replace[] = "'"; |
|
46 | + // Replace Smart Double Curly Quotes |
|
47 | + $search[] = chr(226) . chr(128) . chr(156); |
|
48 | + $replace[] = '"'; |
|
49 | + $search[] = chr(226) . chr(128) . chr(157); |
|
50 | + $replace[] = '"'; |
|
51 | + // Replace En Dash |
|
52 | + $search[] = chr(226) . chr(128) . chr(147); |
|
53 | + $replace[] = '--'; |
|
54 | + // Replace Em Dash |
|
55 | + $search[] = chr(226) . chr(128) . chr(148); |
|
56 | + $replace[] = '---'; |
|
57 | + // Replace Bullet |
|
58 | + $search[] = chr(226) . chr(128) . chr(162); |
|
59 | + $replace[] = '*'; |
|
60 | + // Replace Middle Dot |
|
61 | + $search[] = chr(194) . chr(183); |
|
62 | + $replace[] = '*'; |
|
63 | + // Replace Ellipsis with three consecutive dots |
|
64 | + $search[] = chr(226) . chr(128) . chr(166); |
|
65 | + $replace[] = '...'; |
|
66 | + // Apply Replacements |
|
67 | + $string = str_replace($search, $replace, $string); |
|
68 | + // Remove any non-ASCII Characters |
|
69 | + $string = preg_replace("/[^\x01-\x7F]/", "", $string); |
|
70 | + return $string; |
|
71 | + } |
|
72 | 72 | } |
@@ -39,29 +39,29 @@ |
||
39 | 39 | protected function convertAscii($string) |
40 | 40 | { |
41 | 41 | // Replace Single Curly Quotes |
42 | - $search[] = chr(226) . chr(128) . chr(152); |
|
42 | + $search[] = chr(226).chr(128).chr(152); |
|
43 | 43 | $replace[] = "'"; |
44 | - $search[] = chr(226) . chr(128) . chr(153); |
|
44 | + $search[] = chr(226).chr(128).chr(153); |
|
45 | 45 | $replace[] = "'"; |
46 | 46 | // Replace Smart Double Curly Quotes |
47 | - $search[] = chr(226) . chr(128) . chr(156); |
|
47 | + $search[] = chr(226).chr(128).chr(156); |
|
48 | 48 | $replace[] = '"'; |
49 | - $search[] = chr(226) . chr(128) . chr(157); |
|
49 | + $search[] = chr(226).chr(128).chr(157); |
|
50 | 50 | $replace[] = '"'; |
51 | 51 | // Replace En Dash |
52 | - $search[] = chr(226) . chr(128) . chr(147); |
|
52 | + $search[] = chr(226).chr(128).chr(147); |
|
53 | 53 | $replace[] = '--'; |
54 | 54 | // Replace Em Dash |
55 | - $search[] = chr(226) . chr(128) . chr(148); |
|
55 | + $search[] = chr(226).chr(128).chr(148); |
|
56 | 56 | $replace[] = '---'; |
57 | 57 | // Replace Bullet |
58 | - $search[] = chr(226) . chr(128) . chr(162); |
|
58 | + $search[] = chr(226).chr(128).chr(162); |
|
59 | 59 | $replace[] = '*'; |
60 | 60 | // Replace Middle Dot |
61 | - $search[] = chr(194) . chr(183); |
|
61 | + $search[] = chr(194).chr(183); |
|
62 | 62 | $replace[] = '*'; |
63 | 63 | // Replace Ellipsis with three consecutive dots |
64 | - $search[] = chr(226) . chr(128) . chr(166); |
|
64 | + $search[] = chr(226).chr(128).chr(166); |
|
65 | 65 | $replace[] = '...'; |
66 | 66 | // Apply Replacements |
67 | 67 | $string = str_replace($search, $replace, $string); |
@@ -473,7 +473,7 @@ |
||
473 | 473 | * |
474 | 474 | * @param EE_Ticket $ticket |
475 | 475 | * @param int $qty |
476 | - * @return TRUE on success, FALSE on fail |
|
476 | + * @return boolean on success, FALSE on fail |
|
477 | 477 | * @throws InvalidArgumentException |
478 | 478 | * @throws InvalidInterfaceException |
479 | 479 | * @throws InvalidDataTypeException |
@@ -33,526 +33,526 @@ |
||
33 | 33 | class ProcessTicketSelector |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var EE_Cart $cart |
|
38 | - */ |
|
39 | - private $cart; |
|
36 | + /** |
|
37 | + * @var EE_Cart $cart |
|
38 | + */ |
|
39 | + private $cart; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var EE_Core_Config $core_config |
|
43 | - */ |
|
44 | - private $core_config; |
|
41 | + /** |
|
42 | + * @var EE_Core_Config $core_config |
|
43 | + */ |
|
44 | + private $core_config; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var Request $request |
|
48 | - */ |
|
49 | - private $request; |
|
46 | + /** |
|
47 | + * @var Request $request |
|
48 | + */ |
|
49 | + private $request; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var EE_Session $session |
|
53 | - */ |
|
54 | - private $session; |
|
51 | + /** |
|
52 | + * @var EE_Session $session |
|
53 | + */ |
|
54 | + private $session; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @var EEM_Ticket $ticket_model |
|
58 | - */ |
|
59 | - private $ticket_model; |
|
56 | + /** |
|
57 | + * @var EEM_Ticket $ticket_model |
|
58 | + */ |
|
59 | + private $ticket_model; |
|
60 | 60 | |
61 | - /** |
|
62 | - * @var TicketDatetimeAvailabilityTracker $tracker |
|
63 | - */ |
|
64 | - private $tracker; |
|
61 | + /** |
|
62 | + * @var TicketDatetimeAvailabilityTracker $tracker |
|
63 | + */ |
|
64 | + private $tracker; |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * ProcessTicketSelector constructor. |
|
69 | - * NOTE: PLZ use the Loader to instantiate this class if need be |
|
70 | - * so that all dependencies get injected correctly (which will happen automatically) |
|
71 | - * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
72 | - * |
|
73 | - * @param EE_Core_Config $core_config |
|
74 | - * @param Request $request |
|
75 | - * @param EE_Session $session |
|
76 | - * @param EEM_Ticket $ticket_model |
|
77 | - * @param TicketDatetimeAvailabilityTracker $tracker |
|
78 | - * @throws InvalidArgumentException |
|
79 | - * @throws InvalidDataTypeException |
|
80 | - * @throws InvalidInterfaceException |
|
81 | - */ |
|
82 | - public function __construct( |
|
83 | - EE_Core_Config $core_config = null, |
|
84 | - Request $request = null, |
|
85 | - EE_Session $session = null, |
|
86 | - EEM_Ticket $ticket_model = null, |
|
87 | - TicketDatetimeAvailabilityTracker $tracker = null |
|
88 | - ) { |
|
89 | - /** @var LoaderInterface $loader */ |
|
90 | - $loader = LoaderFactory::getLoader(); |
|
91 | - $this->core_config = $core_config instanceof EE_Core_Config |
|
92 | - ? $core_config |
|
93 | - : $loader->getShared('EE_Core_Config'); |
|
94 | - $this->request = $request instanceof Request |
|
95 | - ? $request |
|
96 | - : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
97 | - $this->session = $session instanceof EE_Session |
|
98 | - ? $session |
|
99 | - : $loader->getShared('EE_Session'); |
|
100 | - $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
101 | - ? $ticket_model |
|
102 | - : $loader->getShared('EEM_Ticket'); |
|
103 | - $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
104 | - ? $tracker |
|
105 | - : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
106 | - } |
|
67 | + /** |
|
68 | + * ProcessTicketSelector constructor. |
|
69 | + * NOTE: PLZ use the Loader to instantiate this class if need be |
|
70 | + * so that all dependencies get injected correctly (which will happen automatically) |
|
71 | + * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
72 | + * |
|
73 | + * @param EE_Core_Config $core_config |
|
74 | + * @param Request $request |
|
75 | + * @param EE_Session $session |
|
76 | + * @param EEM_Ticket $ticket_model |
|
77 | + * @param TicketDatetimeAvailabilityTracker $tracker |
|
78 | + * @throws InvalidArgumentException |
|
79 | + * @throws InvalidDataTypeException |
|
80 | + * @throws InvalidInterfaceException |
|
81 | + */ |
|
82 | + public function __construct( |
|
83 | + EE_Core_Config $core_config = null, |
|
84 | + Request $request = null, |
|
85 | + EE_Session $session = null, |
|
86 | + EEM_Ticket $ticket_model = null, |
|
87 | + TicketDatetimeAvailabilityTracker $tracker = null |
|
88 | + ) { |
|
89 | + /** @var LoaderInterface $loader */ |
|
90 | + $loader = LoaderFactory::getLoader(); |
|
91 | + $this->core_config = $core_config instanceof EE_Core_Config |
|
92 | + ? $core_config |
|
93 | + : $loader->getShared('EE_Core_Config'); |
|
94 | + $this->request = $request instanceof Request |
|
95 | + ? $request |
|
96 | + : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
97 | + $this->session = $session instanceof EE_Session |
|
98 | + ? $session |
|
99 | + : $loader->getShared('EE_Session'); |
|
100 | + $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
101 | + ? $ticket_model |
|
102 | + : $loader->getShared('EEM_Ticket'); |
|
103 | + $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
104 | + ? $tracker |
|
105 | + : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * cancelTicketSelections |
|
111 | - * |
|
112 | - * @return bool |
|
113 | - * @throws EE_Error |
|
114 | - * @throws InvalidArgumentException |
|
115 | - * @throws InvalidInterfaceException |
|
116 | - * @throws InvalidDataTypeException |
|
117 | - */ |
|
118 | - public function cancelTicketSelections() |
|
119 | - { |
|
120 | - // check nonce |
|
121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
122 | - return false; |
|
123 | - } |
|
124 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
125 | - if ($this->request->requestParamIsSet('event_id')) { |
|
126 | - EEH_URL::safeRedirectAndExit( |
|
127 | - EEH_Event_View::event_link_url( |
|
128 | - $this->request->getRequestParam('event_id') |
|
129 | - ) |
|
130 | - ); |
|
131 | - } |
|
132 | - EEH_URL::safeRedirectAndExit( |
|
133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
134 | - ); |
|
135 | - return true; |
|
136 | - } |
|
109 | + /** |
|
110 | + * cancelTicketSelections |
|
111 | + * |
|
112 | + * @return bool |
|
113 | + * @throws EE_Error |
|
114 | + * @throws InvalidArgumentException |
|
115 | + * @throws InvalidInterfaceException |
|
116 | + * @throws InvalidDataTypeException |
|
117 | + */ |
|
118 | + public function cancelTicketSelections() |
|
119 | + { |
|
120 | + // check nonce |
|
121 | + if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
122 | + return false; |
|
123 | + } |
|
124 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
125 | + if ($this->request->requestParamIsSet('event_id')) { |
|
126 | + EEH_URL::safeRedirectAndExit( |
|
127 | + EEH_Event_View::event_link_url( |
|
128 | + $this->request->getRequestParam('event_id') |
|
129 | + ) |
|
130 | + ); |
|
131 | + } |
|
132 | + EEH_URL::safeRedirectAndExit( |
|
133 | + site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
134 | + ); |
|
135 | + return true; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * processTicketSelectorNonce |
|
141 | - * |
|
142 | - * @param string $nonce_name |
|
143 | - * @param string $id |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - private function processTicketSelectorNonce($nonce_name, $id = '') |
|
147 | - { |
|
148 | - $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
149 | - if (! $this->request->isAdmin() |
|
150 | - && ( |
|
151 | - ! $this->request->is_set($nonce_name_with_id) |
|
152 | - || ! wp_verify_nonce( |
|
153 | - $this->request->get($nonce_name_with_id), |
|
154 | - $nonce_name |
|
155 | - ) |
|
156 | - ) |
|
157 | - ) { |
|
158 | - EE_Error::add_error( |
|
159 | - sprintf( |
|
160 | - esc_html__( |
|
161 | - 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
162 | - 'event_espresso' |
|
163 | - ), |
|
164 | - '<br/>' |
|
165 | - ), |
|
166 | - __FILE__, |
|
167 | - __FUNCTION__, |
|
168 | - __LINE__ |
|
169 | - ); |
|
170 | - return false; |
|
171 | - } |
|
172 | - return true; |
|
173 | - } |
|
139 | + /** |
|
140 | + * processTicketSelectorNonce |
|
141 | + * |
|
142 | + * @param string $nonce_name |
|
143 | + * @param string $id |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + private function processTicketSelectorNonce($nonce_name, $id = '') |
|
147 | + { |
|
148 | + $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
149 | + if (! $this->request->isAdmin() |
|
150 | + && ( |
|
151 | + ! $this->request->is_set($nonce_name_with_id) |
|
152 | + || ! wp_verify_nonce( |
|
153 | + $this->request->get($nonce_name_with_id), |
|
154 | + $nonce_name |
|
155 | + ) |
|
156 | + ) |
|
157 | + ) { |
|
158 | + EE_Error::add_error( |
|
159 | + sprintf( |
|
160 | + esc_html__( |
|
161 | + 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
162 | + 'event_espresso' |
|
163 | + ), |
|
164 | + '<br/>' |
|
165 | + ), |
|
166 | + __FILE__, |
|
167 | + __FUNCTION__, |
|
168 | + __LINE__ |
|
169 | + ); |
|
170 | + return false; |
|
171 | + } |
|
172 | + return true; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * process_ticket_selections |
|
178 | - * |
|
179 | - * @return array|bool |
|
180 | - * @throws EE_Error |
|
181 | - * @throws InvalidArgumentException |
|
182 | - * @throws InvalidDataTypeException |
|
183 | - * @throws InvalidInterfaceException |
|
184 | - */ |
|
185 | - public function processTicketSelections() |
|
186 | - { |
|
187 | - do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
188 | - if ($this->request->isBot()) { |
|
189 | - EEH_URL::safeRedirectAndExit( |
|
190 | - apply_filters( |
|
191 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
192 | - site_url() |
|
193 | - ) |
|
194 | - ); |
|
195 | - } |
|
196 | - // do we have an event id? |
|
197 | - $id = $this->getEventId(); |
|
198 | - // we should really only have 1 registration in the works now |
|
199 | - // (ie, no MER) so unless otherwise requested, clear the session |
|
200 | - if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
201 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
202 | - } |
|
203 | - // validate/sanitize/filter data |
|
204 | - $valid = apply_filters( |
|
205 | - 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
206 | - $this->validatePostData($id) |
|
207 | - ); |
|
208 | - // check total tickets ordered vs max number of attendees that can register |
|
209 | - if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
210 | - $this->maxAttendeesViolation($valid); |
|
211 | - } else { |
|
212 | - // all data appears to be valid |
|
213 | - if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
214 | - return true; |
|
215 | - } |
|
216 | - } |
|
217 | - // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
218 | - // at this point, just return if registration is being made from admin |
|
219 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
220 | - return false; |
|
221 | - } |
|
222 | - if ($valid['return_url']) { |
|
223 | - EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
224 | - } |
|
225 | - if ($id) { |
|
226 | - EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
227 | - } |
|
228 | - echo EE_Error::get_notices(); |
|
229 | - return false; |
|
230 | - } |
|
176 | + /** |
|
177 | + * process_ticket_selections |
|
178 | + * |
|
179 | + * @return array|bool |
|
180 | + * @throws EE_Error |
|
181 | + * @throws InvalidArgumentException |
|
182 | + * @throws InvalidDataTypeException |
|
183 | + * @throws InvalidInterfaceException |
|
184 | + */ |
|
185 | + public function processTicketSelections() |
|
186 | + { |
|
187 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
188 | + if ($this->request->isBot()) { |
|
189 | + EEH_URL::safeRedirectAndExit( |
|
190 | + apply_filters( |
|
191 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
192 | + site_url() |
|
193 | + ) |
|
194 | + ); |
|
195 | + } |
|
196 | + // do we have an event id? |
|
197 | + $id = $this->getEventId(); |
|
198 | + // we should really only have 1 registration in the works now |
|
199 | + // (ie, no MER) so unless otherwise requested, clear the session |
|
200 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
201 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
202 | + } |
|
203 | + // validate/sanitize/filter data |
|
204 | + $valid = apply_filters( |
|
205 | + 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
206 | + $this->validatePostData($id) |
|
207 | + ); |
|
208 | + // check total tickets ordered vs max number of attendees that can register |
|
209 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
210 | + $this->maxAttendeesViolation($valid); |
|
211 | + } else { |
|
212 | + // all data appears to be valid |
|
213 | + if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
214 | + return true; |
|
215 | + } |
|
216 | + } |
|
217 | + // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
218 | + // at this point, just return if registration is being made from admin |
|
219 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
220 | + return false; |
|
221 | + } |
|
222 | + if ($valid['return_url']) { |
|
223 | + EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
224 | + } |
|
225 | + if ($id) { |
|
226 | + EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
227 | + } |
|
228 | + echo EE_Error::get_notices(); |
|
229 | + return false; |
|
230 | + } |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * @return int |
|
235 | - */ |
|
236 | - private function getEventId() |
|
237 | - { |
|
238 | - // do we have an event id? |
|
239 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
240 | - // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
241 | - EE_Error::add_error( |
|
242 | - sprintf( |
|
243 | - esc_html__( |
|
244 | - 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
245 | - 'event_espresso' |
|
246 | - ), |
|
247 | - '<br/>' |
|
248 | - ), |
|
249 | - __FILE__, |
|
250 | - __FUNCTION__, |
|
251 | - __LINE__ |
|
252 | - ); |
|
253 | - } |
|
254 | - // if event id is valid |
|
255 | - return absint($this->request->getRequestParam('tkt-slctr-event-id')); |
|
256 | - } |
|
233 | + /** |
|
234 | + * @return int |
|
235 | + */ |
|
236 | + private function getEventId() |
|
237 | + { |
|
238 | + // do we have an event id? |
|
239 | + if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
240 | + // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
241 | + EE_Error::add_error( |
|
242 | + sprintf( |
|
243 | + esc_html__( |
|
244 | + 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
245 | + 'event_espresso' |
|
246 | + ), |
|
247 | + '<br/>' |
|
248 | + ), |
|
249 | + __FILE__, |
|
250 | + __FUNCTION__, |
|
251 | + __LINE__ |
|
252 | + ); |
|
253 | + } |
|
254 | + // if event id is valid |
|
255 | + return absint($this->request->getRequestParam('tkt-slctr-event-id')); |
|
256 | + } |
|
257 | 257 | |
258 | 258 | |
259 | - /** |
|
260 | - * validate_post_data |
|
261 | - * |
|
262 | - * @param int $id |
|
263 | - * @return array|FALSE |
|
264 | - */ |
|
265 | - private function validatePostData($id = 0) |
|
266 | - { |
|
267 | - if (! $id) { |
|
268 | - EE_Error::add_error( |
|
269 | - esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
270 | - __FILE__, |
|
271 | - __FUNCTION__, |
|
272 | - __LINE__ |
|
273 | - ); |
|
274 | - return false; |
|
275 | - } |
|
276 | - // start with an empty array() |
|
277 | - $valid_data = array(); |
|
278 | - // grab valid id |
|
279 | - $valid_data['id'] = $id; |
|
280 | - // array of other form names |
|
281 | - $inputs_to_clean = array( |
|
282 | - 'event_id' => 'tkt-slctr-event-id', |
|
283 | - 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
284 | - 'rows' => 'tkt-slctr-rows-', |
|
285 | - 'qty' => 'tkt-slctr-qty-', |
|
286 | - 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
287 | - 'return_url' => 'tkt-slctr-return-url-', |
|
288 | - ); |
|
289 | - // let's track the total number of tickets ordered.' |
|
290 | - $valid_data['total_tickets'] = 0; |
|
291 | - // cycle through $inputs_to_clean array |
|
292 | - foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
293 | - // check for POST data |
|
294 | - if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
295 | - // grab value |
|
296 | - $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
297 | - switch ($what) { |
|
298 | - // integers |
|
299 | - case 'event_id': |
|
300 | - $valid_data[ $what ] = absint($input_value); |
|
301 | - // get event via the event id we put in the form |
|
302 | - break; |
|
303 | - case 'rows': |
|
304 | - case 'max_atndz': |
|
305 | - $valid_data[ $what ] = absint($input_value); |
|
306 | - break; |
|
307 | - // arrays of integers |
|
308 | - case 'qty': |
|
309 | - /** @var array $row_qty */ |
|
310 | - $row_qty = $input_value; |
|
311 | - // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
312 | - if (! is_array($row_qty)) { |
|
313 | - /** @var string $row_qty */ |
|
314 | - // get number of rows |
|
315 | - $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
316 | - ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
317 | - : 1; |
|
318 | - // explode integers by the dash |
|
319 | - $row_qty = explode('-', $row_qty); |
|
320 | - $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
321 | - $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
322 | - $row_qty = array($row => $qty); |
|
323 | - for ($x = 1; $x <= $rows; $x++) { |
|
324 | - if (! isset($row_qty[ $x ])) { |
|
325 | - $row_qty[ $x ] = 0; |
|
326 | - } |
|
327 | - } |
|
328 | - } |
|
329 | - ksort($row_qty); |
|
330 | - // cycle thru values |
|
331 | - foreach ($row_qty as $qty) { |
|
332 | - $qty = absint($qty); |
|
333 | - // sanitize as integers |
|
334 | - $valid_data[ $what ][] = $qty; |
|
335 | - $valid_data['total_tickets'] += $qty; |
|
336 | - } |
|
337 | - break; |
|
338 | - // array of integers |
|
339 | - case 'ticket_id': |
|
340 | - // cycle thru values |
|
341 | - foreach ((array) $input_value as $key => $value) { |
|
342 | - // allow only integers |
|
343 | - $valid_data[ $what ][ $key ] = absint($value); |
|
344 | - } |
|
345 | - break; |
|
346 | - case 'return_url': |
|
347 | - // grab and sanitize return-url |
|
348 | - $input_value = esc_url_raw($input_value); |
|
349 | - // was the request coming from an iframe ? if so, then: |
|
350 | - if (strpos($input_value, 'event_list=iframe')) { |
|
351 | - // get anchor fragment |
|
352 | - $input_value = explode('#', $input_value); |
|
353 | - $input_value = end($input_value); |
|
354 | - // use event list url instead, but append anchor |
|
355 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
356 | - } |
|
357 | - $valid_data[ $what ] = $input_value; |
|
358 | - break; |
|
359 | - } // end switch $what |
|
360 | - } |
|
361 | - } // end foreach $inputs_to_clean |
|
362 | - return $valid_data; |
|
363 | - } |
|
259 | + /** |
|
260 | + * validate_post_data |
|
261 | + * |
|
262 | + * @param int $id |
|
263 | + * @return array|FALSE |
|
264 | + */ |
|
265 | + private function validatePostData($id = 0) |
|
266 | + { |
|
267 | + if (! $id) { |
|
268 | + EE_Error::add_error( |
|
269 | + esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
270 | + __FILE__, |
|
271 | + __FUNCTION__, |
|
272 | + __LINE__ |
|
273 | + ); |
|
274 | + return false; |
|
275 | + } |
|
276 | + // start with an empty array() |
|
277 | + $valid_data = array(); |
|
278 | + // grab valid id |
|
279 | + $valid_data['id'] = $id; |
|
280 | + // array of other form names |
|
281 | + $inputs_to_clean = array( |
|
282 | + 'event_id' => 'tkt-slctr-event-id', |
|
283 | + 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
284 | + 'rows' => 'tkt-slctr-rows-', |
|
285 | + 'qty' => 'tkt-slctr-qty-', |
|
286 | + 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
287 | + 'return_url' => 'tkt-slctr-return-url-', |
|
288 | + ); |
|
289 | + // let's track the total number of tickets ordered.' |
|
290 | + $valid_data['total_tickets'] = 0; |
|
291 | + // cycle through $inputs_to_clean array |
|
292 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
293 | + // check for POST data |
|
294 | + if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
295 | + // grab value |
|
296 | + $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
297 | + switch ($what) { |
|
298 | + // integers |
|
299 | + case 'event_id': |
|
300 | + $valid_data[ $what ] = absint($input_value); |
|
301 | + // get event via the event id we put in the form |
|
302 | + break; |
|
303 | + case 'rows': |
|
304 | + case 'max_atndz': |
|
305 | + $valid_data[ $what ] = absint($input_value); |
|
306 | + break; |
|
307 | + // arrays of integers |
|
308 | + case 'qty': |
|
309 | + /** @var array $row_qty */ |
|
310 | + $row_qty = $input_value; |
|
311 | + // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
312 | + if (! is_array($row_qty)) { |
|
313 | + /** @var string $row_qty */ |
|
314 | + // get number of rows |
|
315 | + $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
316 | + ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
317 | + : 1; |
|
318 | + // explode integers by the dash |
|
319 | + $row_qty = explode('-', $row_qty); |
|
320 | + $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
321 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
322 | + $row_qty = array($row => $qty); |
|
323 | + for ($x = 1; $x <= $rows; $x++) { |
|
324 | + if (! isset($row_qty[ $x ])) { |
|
325 | + $row_qty[ $x ] = 0; |
|
326 | + } |
|
327 | + } |
|
328 | + } |
|
329 | + ksort($row_qty); |
|
330 | + // cycle thru values |
|
331 | + foreach ($row_qty as $qty) { |
|
332 | + $qty = absint($qty); |
|
333 | + // sanitize as integers |
|
334 | + $valid_data[ $what ][] = $qty; |
|
335 | + $valid_data['total_tickets'] += $qty; |
|
336 | + } |
|
337 | + break; |
|
338 | + // array of integers |
|
339 | + case 'ticket_id': |
|
340 | + // cycle thru values |
|
341 | + foreach ((array) $input_value as $key => $value) { |
|
342 | + // allow only integers |
|
343 | + $valid_data[ $what ][ $key ] = absint($value); |
|
344 | + } |
|
345 | + break; |
|
346 | + case 'return_url': |
|
347 | + // grab and sanitize return-url |
|
348 | + $input_value = esc_url_raw($input_value); |
|
349 | + // was the request coming from an iframe ? if so, then: |
|
350 | + if (strpos($input_value, 'event_list=iframe')) { |
|
351 | + // get anchor fragment |
|
352 | + $input_value = explode('#', $input_value); |
|
353 | + $input_value = end($input_value); |
|
354 | + // use event list url instead, but append anchor |
|
355 | + $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
356 | + } |
|
357 | + $valid_data[ $what ] = $input_value; |
|
358 | + break; |
|
359 | + } // end switch $what |
|
360 | + } |
|
361 | + } // end foreach $inputs_to_clean |
|
362 | + return $valid_data; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | |
366 | - /** |
|
367 | - * @param array $valid |
|
368 | - */ |
|
369 | - private function maxAttendeesViolation(array $valid) |
|
370 | - { |
|
371 | - // ordering too many tickets !!! |
|
372 | - $total_tickets_string = esc_html( |
|
373 | - _n( |
|
374 | - 'You have attempted to purchase %s ticket.', |
|
375 | - 'You have attempted to purchase %s tickets.', |
|
376 | - $valid['total_tickets'], |
|
377 | - 'event_espresso' |
|
378 | - ) |
|
379 | - ); |
|
380 | - $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
381 | - // dev only message |
|
382 | - $max_attendees_string = esc_html( |
|
383 | - _n( |
|
384 | - 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
385 | - 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
386 | - $valid['max_atndz'], |
|
387 | - 'event_espresso' |
|
388 | - ) |
|
389 | - ); |
|
390 | - $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
391 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
392 | - } |
|
366 | + /** |
|
367 | + * @param array $valid |
|
368 | + */ |
|
369 | + private function maxAttendeesViolation(array $valid) |
|
370 | + { |
|
371 | + // ordering too many tickets !!! |
|
372 | + $total_tickets_string = esc_html( |
|
373 | + _n( |
|
374 | + 'You have attempted to purchase %s ticket.', |
|
375 | + 'You have attempted to purchase %s tickets.', |
|
376 | + $valid['total_tickets'], |
|
377 | + 'event_espresso' |
|
378 | + ) |
|
379 | + ); |
|
380 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
381 | + // dev only message |
|
382 | + $max_attendees_string = esc_html( |
|
383 | + _n( |
|
384 | + 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
385 | + 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
386 | + $valid['max_atndz'], |
|
387 | + 'event_espresso' |
|
388 | + ) |
|
389 | + ); |
|
390 | + $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
391 | + EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
392 | + } |
|
393 | 393 | |
394 | 394 | |
395 | - /** |
|
396 | - * @param array $valid |
|
397 | - * @return int|TRUE |
|
398 | - * @throws EE_Error |
|
399 | - * @throws InvalidArgumentException |
|
400 | - * @throws InvalidDataTypeException |
|
401 | - * @throws InvalidInterfaceException |
|
402 | - */ |
|
403 | - private function addTicketsToCart(array $valid) |
|
404 | - { |
|
405 | - $tickets_added = 0; |
|
406 | - $tickets_selected = false; |
|
407 | - if ($valid['total_tickets'] > 0) { |
|
408 | - // load cart using factory because we don't want to do so until actually needed |
|
409 | - $this->cart = CartFactory::getCart(); |
|
410 | - // cycle thru the number of data rows sent from the event listing |
|
411 | - for ($x = 0; $x < $valid['rows']; $x++) { |
|
412 | - // does this row actually contain a ticket quantity? |
|
413 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
414 | - // YES we have a ticket quantity |
|
415 | - $tickets_selected = true; |
|
416 | - $valid_ticket = false; |
|
417 | - // \EEH_Debug_Tools::printr( |
|
418 | - // $valid['ticket_id'][ $x ], |
|
419 | - // '$valid[\'ticket_id\'][ $x ]', |
|
420 | - // __FILE__, __LINE__ |
|
421 | - // ); |
|
422 | - if (isset($valid['ticket_id'][ $x ])) { |
|
423 | - // get ticket via the ticket id we put in the form |
|
424 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
425 | - if ($ticket instanceof EE_Ticket) { |
|
426 | - $valid_ticket = true; |
|
427 | - $tickets_added += $this->addTicketToCart( |
|
428 | - $ticket, |
|
429 | - $valid['qty'][ $x ] |
|
430 | - ); |
|
431 | - } |
|
432 | - } |
|
433 | - if ($valid_ticket !== true) { |
|
434 | - // nothing added to cart retrieved |
|
435 | - EE_Error::add_error( |
|
436 | - sprintf( |
|
437 | - esc_html__( |
|
438 | - 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
439 | - 'event_espresso' |
|
440 | - ), |
|
441 | - '<br/>' |
|
442 | - ), |
|
443 | - __FILE__, |
|
444 | - __FUNCTION__, |
|
445 | - __LINE__ |
|
446 | - ); |
|
447 | - } |
|
448 | - if (EE_Error::has_error()) { |
|
449 | - break; |
|
450 | - } |
|
451 | - } |
|
452 | - } |
|
453 | - } |
|
454 | - do_action( |
|
455 | - 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
456 | - $this->cart, |
|
457 | - $this |
|
458 | - ); |
|
459 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
460 | - // no ticket quantities were selected |
|
461 | - EE_Error::add_error( |
|
462 | - esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
463 | - __FILE__, |
|
464 | - __FUNCTION__, |
|
465 | - __LINE__ |
|
466 | - ); |
|
467 | - } |
|
468 | - return $tickets_added; |
|
469 | - } |
|
395 | + /** |
|
396 | + * @param array $valid |
|
397 | + * @return int|TRUE |
|
398 | + * @throws EE_Error |
|
399 | + * @throws InvalidArgumentException |
|
400 | + * @throws InvalidDataTypeException |
|
401 | + * @throws InvalidInterfaceException |
|
402 | + */ |
|
403 | + private function addTicketsToCart(array $valid) |
|
404 | + { |
|
405 | + $tickets_added = 0; |
|
406 | + $tickets_selected = false; |
|
407 | + if ($valid['total_tickets'] > 0) { |
|
408 | + // load cart using factory because we don't want to do so until actually needed |
|
409 | + $this->cart = CartFactory::getCart(); |
|
410 | + // cycle thru the number of data rows sent from the event listing |
|
411 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
412 | + // does this row actually contain a ticket quantity? |
|
413 | + if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
414 | + // YES we have a ticket quantity |
|
415 | + $tickets_selected = true; |
|
416 | + $valid_ticket = false; |
|
417 | + // \EEH_Debug_Tools::printr( |
|
418 | + // $valid['ticket_id'][ $x ], |
|
419 | + // '$valid[\'ticket_id\'][ $x ]', |
|
420 | + // __FILE__, __LINE__ |
|
421 | + // ); |
|
422 | + if (isset($valid['ticket_id'][ $x ])) { |
|
423 | + // get ticket via the ticket id we put in the form |
|
424 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
425 | + if ($ticket instanceof EE_Ticket) { |
|
426 | + $valid_ticket = true; |
|
427 | + $tickets_added += $this->addTicketToCart( |
|
428 | + $ticket, |
|
429 | + $valid['qty'][ $x ] |
|
430 | + ); |
|
431 | + } |
|
432 | + } |
|
433 | + if ($valid_ticket !== true) { |
|
434 | + // nothing added to cart retrieved |
|
435 | + EE_Error::add_error( |
|
436 | + sprintf( |
|
437 | + esc_html__( |
|
438 | + 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
439 | + 'event_espresso' |
|
440 | + ), |
|
441 | + '<br/>' |
|
442 | + ), |
|
443 | + __FILE__, |
|
444 | + __FUNCTION__, |
|
445 | + __LINE__ |
|
446 | + ); |
|
447 | + } |
|
448 | + if (EE_Error::has_error()) { |
|
449 | + break; |
|
450 | + } |
|
451 | + } |
|
452 | + } |
|
453 | + } |
|
454 | + do_action( |
|
455 | + 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
456 | + $this->cart, |
|
457 | + $this |
|
458 | + ); |
|
459 | + if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
460 | + // no ticket quantities were selected |
|
461 | + EE_Error::add_error( |
|
462 | + esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
463 | + __FILE__, |
|
464 | + __FUNCTION__, |
|
465 | + __LINE__ |
|
466 | + ); |
|
467 | + } |
|
468 | + return $tickets_added; |
|
469 | + } |
|
470 | 470 | |
471 | 471 | |
472 | - /** |
|
473 | - * adds a ticket to the cart |
|
474 | - * |
|
475 | - * @param EE_Ticket $ticket |
|
476 | - * @param int $qty |
|
477 | - * @return TRUE on success, FALSE on fail |
|
478 | - * @throws InvalidArgumentException |
|
479 | - * @throws InvalidInterfaceException |
|
480 | - * @throws InvalidDataTypeException |
|
481 | - * @throws EE_Error |
|
482 | - */ |
|
483 | - private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
484 | - { |
|
485 | - // get the number of spaces left for this datetime ticket |
|
486 | - $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
487 | - // compare available spaces against the number of tickets being purchased |
|
488 | - if ($available_spaces >= $qty) { |
|
489 | - // allow addons to prevent a ticket from being added to cart |
|
490 | - if (! apply_filters( |
|
491 | - 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
492 | - true, |
|
493 | - $ticket, |
|
494 | - $qty, |
|
495 | - $available_spaces |
|
496 | - )) { |
|
497 | - return false; |
|
498 | - } |
|
499 | - $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
500 | - // add event to cart |
|
501 | - if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
502 | - $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
503 | - return true; |
|
504 | - } |
|
505 | - return false; |
|
506 | - } |
|
507 | - $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
508 | - return false; |
|
509 | - } |
|
472 | + /** |
|
473 | + * adds a ticket to the cart |
|
474 | + * |
|
475 | + * @param EE_Ticket $ticket |
|
476 | + * @param int $qty |
|
477 | + * @return TRUE on success, FALSE on fail |
|
478 | + * @throws InvalidArgumentException |
|
479 | + * @throws InvalidInterfaceException |
|
480 | + * @throws InvalidDataTypeException |
|
481 | + * @throws EE_Error |
|
482 | + */ |
|
483 | + private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
484 | + { |
|
485 | + // get the number of spaces left for this datetime ticket |
|
486 | + $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
487 | + // compare available spaces against the number of tickets being purchased |
|
488 | + if ($available_spaces >= $qty) { |
|
489 | + // allow addons to prevent a ticket from being added to cart |
|
490 | + if (! apply_filters( |
|
491 | + 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
492 | + true, |
|
493 | + $ticket, |
|
494 | + $qty, |
|
495 | + $available_spaces |
|
496 | + )) { |
|
497 | + return false; |
|
498 | + } |
|
499 | + $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
500 | + // add event to cart |
|
501 | + if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
502 | + $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
503 | + return true; |
|
504 | + } |
|
505 | + return false; |
|
506 | + } |
|
507 | + $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
508 | + return false; |
|
509 | + } |
|
510 | 510 | |
511 | 511 | |
512 | - /** |
|
513 | - * @param $tickets_added |
|
514 | - * @return bool |
|
515 | - * @throws InvalidInterfaceException |
|
516 | - * @throws InvalidDataTypeException |
|
517 | - * @throws EE_Error |
|
518 | - * @throws InvalidArgumentException |
|
519 | - */ |
|
520 | - private function processSuccessfulCart($tickets_added) |
|
521 | - { |
|
522 | - // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
523 | - if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
524 | - // make sure cart is loaded |
|
525 | - if (! $this->cart instanceof EE_Cart) { |
|
526 | - $this->cart = CartFactory::getCart(); |
|
527 | - } |
|
528 | - do_action( |
|
529 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
530 | - $this->cart, |
|
531 | - $this |
|
532 | - ); |
|
533 | - $this->cart->recalculate_all_cart_totals(); |
|
534 | - $this->cart->save_cart(false); |
|
535 | - // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
536 | - // just return TRUE for registrations being made from admin |
|
537 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
538 | - return true; |
|
539 | - } |
|
540 | - EEH_URL::safeRedirectAndExit( |
|
541 | - apply_filters( |
|
542 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
543 | - $this->core_config->reg_page_url() |
|
544 | - ) |
|
545 | - ); |
|
546 | - } |
|
547 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
548 | - // nothing added to cart |
|
549 | - EE_Error::add_attention( |
|
550 | - esc_html__('No tickets were added for the event', 'event_espresso'), |
|
551 | - __FILE__, |
|
552 | - __FUNCTION__, |
|
553 | - __LINE__ |
|
554 | - ); |
|
555 | - } |
|
556 | - return false; |
|
557 | - } |
|
512 | + /** |
|
513 | + * @param $tickets_added |
|
514 | + * @return bool |
|
515 | + * @throws InvalidInterfaceException |
|
516 | + * @throws InvalidDataTypeException |
|
517 | + * @throws EE_Error |
|
518 | + * @throws InvalidArgumentException |
|
519 | + */ |
|
520 | + private function processSuccessfulCart($tickets_added) |
|
521 | + { |
|
522 | + // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
523 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
524 | + // make sure cart is loaded |
|
525 | + if (! $this->cart instanceof EE_Cart) { |
|
526 | + $this->cart = CartFactory::getCart(); |
|
527 | + } |
|
528 | + do_action( |
|
529 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
530 | + $this->cart, |
|
531 | + $this |
|
532 | + ); |
|
533 | + $this->cart->recalculate_all_cart_totals(); |
|
534 | + $this->cart->save_cart(false); |
|
535 | + // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
536 | + // just return TRUE for registrations being made from admin |
|
537 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
538 | + return true; |
|
539 | + } |
|
540 | + EEH_URL::safeRedirectAndExit( |
|
541 | + apply_filters( |
|
542 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
543 | + $this->core_config->reg_page_url() |
|
544 | + ) |
|
545 | + ); |
|
546 | + } |
|
547 | + if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
548 | + // nothing added to cart |
|
549 | + EE_Error::add_attention( |
|
550 | + esc_html__('No tickets were added for the event', 'event_espresso'), |
|
551 | + __FILE__, |
|
552 | + __FUNCTION__, |
|
553 | + __LINE__ |
|
554 | + ); |
|
555 | + } |
|
556 | + return false; |
|
557 | + } |
|
558 | 558 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function cancelTicketSelections() |
119 | 119 | { |
120 | 120 | // check nonce |
121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
121 | + if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | $this->session->clear_session(__CLASS__, __FUNCTION__); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ); |
131 | 131 | } |
132 | 132 | EEH_URL::safeRedirectAndExit( |
133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
133 | + site_url('/'.$this->core_config->event_cpt_slug.'/') |
|
134 | 134 | ); |
135 | 135 | return true; |
136 | 136 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | private function processTicketSelectorNonce($nonce_name, $id = '') |
147 | 147 | { |
148 | 148 | $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
149 | - if (! $this->request->isAdmin() |
|
149 | + if ( ! $this->request->isAdmin() |
|
150 | 150 | && ( |
151 | 151 | ! $this->request->is_set($nonce_name_with_id) |
152 | 152 | || ! wp_verify_nonce( |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | private function getEventId() |
237 | 237 | { |
238 | 238 | // do we have an event id? |
239 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
239 | + if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
240 | 240 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
241 | 241 | EE_Error::add_error( |
242 | 242 | sprintf( |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | private function validatePostData($id = 0) |
266 | 266 | { |
267 | - if (! $id) { |
|
267 | + if ( ! $id) { |
|
268 | 268 | EE_Error::add_error( |
269 | 269 | esc_html__('The event id provided was not valid.', 'event_espresso'), |
270 | 270 | __FILE__, |
@@ -291,29 +291,29 @@ discard block |
||
291 | 291 | // cycle through $inputs_to_clean array |
292 | 292 | foreach ($inputs_to_clean as $what => $input_to_clean) { |
293 | 293 | // check for POST data |
294 | - if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
294 | + if ($this->request->requestParamIsSet($input_to_clean.$id)) { |
|
295 | 295 | // grab value |
296 | - $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
296 | + $input_value = $this->request->getRequestParam($input_to_clean.$id); |
|
297 | 297 | switch ($what) { |
298 | 298 | // integers |
299 | 299 | case 'event_id': |
300 | - $valid_data[ $what ] = absint($input_value); |
|
300 | + $valid_data[$what] = absint($input_value); |
|
301 | 301 | // get event via the event id we put in the form |
302 | 302 | break; |
303 | 303 | case 'rows': |
304 | 304 | case 'max_atndz': |
305 | - $valid_data[ $what ] = absint($input_value); |
|
305 | + $valid_data[$what] = absint($input_value); |
|
306 | 306 | break; |
307 | 307 | // arrays of integers |
308 | 308 | case 'qty': |
309 | 309 | /** @var array $row_qty */ |
310 | 310 | $row_qty = $input_value; |
311 | 311 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
312 | - if (! is_array($row_qty)) { |
|
312 | + if ( ! is_array($row_qty)) { |
|
313 | 313 | /** @var string $row_qty */ |
314 | 314 | // get number of rows |
315 | - $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
316 | - ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
315 | + $rows = $this->request->requestParamIsSet('tkt-slctr-rows-'.$id) |
|
316 | + ? absint($this->request->getRequestParam('tkt-slctr-rows-'.$id)) |
|
317 | 317 | : 1; |
318 | 318 | // explode integers by the dash |
319 | 319 | $row_qty = explode('-', $row_qty); |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
322 | 322 | $row_qty = array($row => $qty); |
323 | 323 | for ($x = 1; $x <= $rows; $x++) { |
324 | - if (! isset($row_qty[ $x ])) { |
|
325 | - $row_qty[ $x ] = 0; |
|
324 | + if ( ! isset($row_qty[$x])) { |
|
325 | + $row_qty[$x] = 0; |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | foreach ($row_qty as $qty) { |
332 | 332 | $qty = absint($qty); |
333 | 333 | // sanitize as integers |
334 | - $valid_data[ $what ][] = $qty; |
|
334 | + $valid_data[$what][] = $qty; |
|
335 | 335 | $valid_data['total_tickets'] += $qty; |
336 | 336 | } |
337 | 337 | break; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | // cycle thru values |
341 | 341 | foreach ((array) $input_value as $key => $value) { |
342 | 342 | // allow only integers |
343 | - $valid_data[ $what ][ $key ] = absint($value); |
|
343 | + $valid_data[$what][$key] = absint($value); |
|
344 | 344 | } |
345 | 345 | break; |
346 | 346 | case 'return_url': |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | $input_value = explode('#', $input_value); |
353 | 353 | $input_value = end($input_value); |
354 | 354 | // use event list url instead, but append anchor |
355 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
355 | + $input_value = EEH_Event_View::event_archive_url().'#'.$input_value; |
|
356 | 356 | } |
357 | - $valid_data[ $what ] = $input_value; |
|
357 | + $valid_data[$what] = $input_value; |
|
358 | 358 | break; |
359 | 359 | } // end switch $what |
360 | 360 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | ) |
389 | 389 | ); |
390 | 390 | $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
391 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
391 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | // cycle thru the number of data rows sent from the event listing |
411 | 411 | for ($x = 0; $x < $valid['rows']; $x++) { |
412 | 412 | // does this row actually contain a ticket quantity? |
413 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
413 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
414 | 414 | // YES we have a ticket quantity |
415 | 415 | $tickets_selected = true; |
416 | 416 | $valid_ticket = false; |
@@ -419,14 +419,14 @@ discard block |
||
419 | 419 | // '$valid[\'ticket_id\'][ $x ]', |
420 | 420 | // __FILE__, __LINE__ |
421 | 421 | // ); |
422 | - if (isset($valid['ticket_id'][ $x ])) { |
|
422 | + if (isset($valid['ticket_id'][$x])) { |
|
423 | 423 | // get ticket via the ticket id we put in the form |
424 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
424 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]); |
|
425 | 425 | if ($ticket instanceof EE_Ticket) { |
426 | 426 | $valid_ticket = true; |
427 | 427 | $tickets_added += $this->addTicketToCart( |
428 | 428 | $ticket, |
429 | - $valid['qty'][ $x ] |
|
429 | + $valid['qty'][$x] |
|
430 | 430 | ); |
431 | 431 | } |
432 | 432 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $this->cart, |
457 | 457 | $this |
458 | 458 | ); |
459 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
459 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
460 | 460 | // no ticket quantities were selected |
461 | 461 | EE_Error::add_error( |
462 | 462 | esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | // compare available spaces against the number of tickets being purchased |
488 | 488 | if ($available_spaces >= $qty) { |
489 | 489 | // allow addons to prevent a ticket from being added to cart |
490 | - if (! apply_filters( |
|
490 | + if ( ! apply_filters( |
|
491 | 491 | 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
492 | 492 | true, |
493 | 493 | $ticket, |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
523 | 523 | if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
524 | 524 | // make sure cart is loaded |
525 | - if (! $this->cart instanceof EE_Cart) { |
|
525 | + if ( ! $this->cart instanceof EE_Cart) { |
|
526 | 526 | $this->cart = CartFactory::getCart(); |
527 | 527 | } |
528 | 528 | do_action( |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | ) |
545 | 545 | ); |
546 | 546 | } |
547 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
547 | + if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
548 | 548 | // nothing added to cart |
549 | 549 | EE_Error::add_attention( |
550 | 550 | esc_html__('No tickets were added for the event', 'event_espresso'), |
@@ -13,28 +13,28 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @param string $name |
|
18 | - * @param array $widget_options |
|
19 | - * @param array $control_options |
|
20 | - */ |
|
21 | - public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
22 | - { |
|
23 | - $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
24 | - $control_options['id_base'] = $id_base; |
|
25 | - $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
26 | - $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
27 | - // Register widget with WordPress |
|
28 | - parent::__construct($id_base, $name, $widget_options, $control_options); |
|
29 | - } |
|
16 | + /** |
|
17 | + * @param string $name |
|
18 | + * @param array $widget_options |
|
19 | + * @param array $control_options |
|
20 | + */ |
|
21 | + public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
22 | + { |
|
23 | + $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
24 | + $control_options['id_base'] = $id_base; |
|
25 | + $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
26 | + $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
27 | + // Register widget with WordPress |
|
28 | + parent::__construct($id_base, $name, $widget_options, $control_options); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param string $widget_class |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public static function getIdBase($widget_class) |
|
37 | - { |
|
38 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param string $widget_class |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public static function getIdBase($widget_class) |
|
37 | + { |
|
38 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
39 | + } |
|
40 | 40 | } |
@@ -35,6 +35,6 @@ |
||
35 | 35 | */ |
36 | 36 | public static function getIdBase($widget_class) |
37 | 37 | { |
38 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
38 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)).'-widget'; |
|
39 | 39 | } |
40 | 40 | } |
@@ -17,359 +17,359 @@ |
||
17 | 17 | class TicketSelectorRowStandard extends TicketSelectorRow |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var TicketDetails $ticket_details |
|
22 | - */ |
|
23 | - protected $ticket_details; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | - */ |
|
28 | - protected $template_settings; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var EE_Tax_Config $tax_settings |
|
32 | - */ |
|
33 | - protected $tax_settings; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var boolean $prices_displayed_including_taxes |
|
37 | - */ |
|
38 | - protected $prices_displayed_including_taxes; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var int $row |
|
42 | - */ |
|
43 | - protected $row; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var int $cols |
|
47 | - */ |
|
48 | - protected $cols; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var boolean $hidden_input_qty |
|
52 | - */ |
|
53 | - protected $hidden_input_qty; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $ticket_datetime_classes |
|
57 | - */ |
|
58 | - protected $ticket_datetime_classes; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * TicketDetails constructor. |
|
63 | - * |
|
64 | - * @param TicketDetails $ticket_details |
|
65 | - * @param EE_Tax_Config $tax_settings |
|
66 | - * @param int $total_tickets |
|
67 | - * @param int $max_attendees |
|
68 | - * @param int $row |
|
69 | - * @param int $cols |
|
70 | - * @param boolean $required_ticket_sold_out |
|
71 | - * @param string $event_status |
|
72 | - * @param string $ticket_datetime_classes |
|
73 | - * @throws EE_Error |
|
74 | - * @throws UnexpectedEntityException |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - TicketDetails $ticket_details, |
|
78 | - EE_Tax_Config $tax_settings, |
|
79 | - $total_tickets, |
|
80 | - $max_attendees, |
|
81 | - $row, |
|
82 | - $cols, |
|
83 | - $required_ticket_sold_out, |
|
84 | - $event_status, |
|
85 | - $ticket_datetime_classes |
|
86 | - ) { |
|
87 | - $this->ticket_details = $ticket_details; |
|
88 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
89 | - $this->tax_settings = $tax_settings; |
|
90 | - $this->row = $row; |
|
91 | - $this->cols = $cols; |
|
92 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
93 | - parent::__construct( |
|
94 | - $ticket_details->getTicket(), |
|
95 | - $max_attendees, |
|
96 | - $ticket_details->getDateFormat(), |
|
97 | - $event_status, |
|
98 | - $required_ticket_sold_out, |
|
99 | - $total_tickets |
|
100 | - ); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * other ticket rows will need to know if a required ticket is sold out, |
|
106 | - * so that they are not offered for sale |
|
107 | - * |
|
108 | - * @return boolean |
|
109 | - */ |
|
110 | - public function getRequiredTicketSoldOut() |
|
111 | - { |
|
112 | - return $this->required_ticket_sold_out; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return int |
|
118 | - */ |
|
119 | - public function getCols() |
|
120 | - { |
|
121 | - return $this->cols; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * getHtml |
|
127 | - * |
|
128 | - * @return string |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function getHtml() |
|
132 | - { |
|
133 | - $this->min = 0; |
|
134 | - $this->max = $this->ticket->max(); |
|
135 | - $remaining = $this->ticket->remaining(); |
|
136 | - if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
137 | - $this->setTicketMinAndMax($remaining); |
|
138 | - } else { |
|
139 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
140 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
141 | - ? $this->ticket->start_date() |
|
142 | - : $this->required_ticket_sold_out; |
|
143 | - } |
|
144 | - $this->setTicketPriceDetails(); |
|
145 | - $this->setTicketStatusClasses($remaining); |
|
146 | - $filtered_row_html = $this->getFilteredRowHtml(); |
|
147 | - if ($filtered_row_html !== false) { |
|
148 | - return $filtered_row_html; |
|
149 | - } |
|
150 | - $ticket_selector_row_html = EEH_HTML::tr( |
|
151 | - '', |
|
152 | - '', |
|
153 | - "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
154 | - . espresso_get_object_css_class($this->ticket) |
|
155 | - ); |
|
156 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
157 | - if ($filtered_row_content !== false && $this->max_attendees === 1) { |
|
158 | - return $ticket_selector_row_html |
|
159 | - . $filtered_row_content |
|
160 | - . $this->ticketQtyAndIdHiddenInputs() |
|
161 | - . EEH_HTML::trx(); |
|
162 | - } |
|
163 | - if ($filtered_row_content !== false) { |
|
164 | - return $ticket_selector_row_html |
|
165 | - . $filtered_row_content |
|
166 | - . EEH_HTML::trx(); |
|
167 | - } |
|
168 | - $this->hidden_input_qty = $this->max_attendees > 1; |
|
169 | - |
|
170 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
171 | - $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
172 | - $ticket_selector_row_html .= EEH_HTML::td( |
|
173 | - '', |
|
174 | - '', |
|
175 | - 'tckt-slctr-tbl-td-qty cntr', |
|
176 | - '', |
|
177 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
178 | - ); |
|
179 | - $this->setTicketStatusDisplay($remaining); |
|
180 | - if (empty($this->ticket_status_display)) { |
|
181 | - if ($this->max_attendees === 1) { |
|
182 | - // only ONE attendee is allowed to register at a time |
|
183 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
184 | - } elseif ($this->max > 0) { |
|
185 | - $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
186 | - } |
|
187 | - } |
|
188 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
189 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
190 | - $ticket_selector_row_html .= $this->ticket_details->display( |
|
191 | - $this->ticket_price, |
|
192 | - $remaining, |
|
193 | - $this->cols |
|
194 | - ); |
|
195 | - $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
196 | - $ticket_selector_row_html .= EEH_HTML::trx(); |
|
197 | - |
|
198 | - |
|
199 | - $this->row++; |
|
200 | - return $ticket_selector_row_html; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * getTicketPriceDetails |
|
206 | - * |
|
207 | - * @return void |
|
208 | - * @throws EE_Error |
|
209 | - */ |
|
210 | - protected function setTicketPriceDetails() |
|
211 | - { |
|
212 | - $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
213 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
214 | - : $this->ticket->get_ticket_subtotal(); |
|
215 | - $this->ticket_bundle = false; |
|
216 | - $ticket_min = $this->ticket->min(); |
|
217 | - // for ticket bundles, set min and max qty the same |
|
218 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
219 | - $this->ticket_price *= $ticket_min; |
|
220 | - $this->ticket_bundle = true; |
|
221 | - } |
|
222 | - $this->ticket_price = apply_filters( |
|
223 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
224 | - $this->ticket_price, |
|
225 | - $this->ticket |
|
226 | - ); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * ticketNameTableCell |
|
232 | - * |
|
233 | - * @return string |
|
234 | - * @throws EE_Error |
|
235 | - */ |
|
236 | - protected function ticketNameTableCell() |
|
237 | - { |
|
238 | - $html = EEH_HTML::td( |
|
239 | - '', |
|
240 | - '', |
|
241 | - 'tckt-slctr-tbl-td-name', |
|
242 | - '', |
|
243 | - 'headers="details-' . $this->EVT_ID . '"' |
|
244 | - ); |
|
245 | - $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
246 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
247 | - if ($this->ticket->required()) { |
|
248 | - $html .= EEH_HTML::p( |
|
249 | - apply_filters( |
|
250 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
251 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
252 | - ), |
|
253 | - '', |
|
254 | - 'ticket-required-pg' |
|
255 | - ); |
|
256 | - } |
|
257 | - $html .= EEH_HTML::tdx(); |
|
258 | - return $html; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * ticketPriceTableCell |
|
264 | - * |
|
265 | - * @return string |
|
266 | - * @throws EE_Error |
|
267 | - */ |
|
268 | - protected function ticketPriceTableCell() |
|
269 | - { |
|
270 | - $html = ''; |
|
271 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
272 | - $html .= EEH_HTML::td( |
|
273 | - '', |
|
274 | - '', |
|
275 | - 'tckt-slctr-tbl-td-price jst-rght', |
|
276 | - '', |
|
277 | - 'headers="price-' . $this->EVT_ID . '"' |
|
278 | - ); |
|
279 | - $html .= \EEH_Template::format_currency($this->ticket_price); |
|
280 | - $html .= $this->ticket->taxable() |
|
281 | - ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
282 | - : ''; |
|
283 | - $html .= ' '; |
|
284 | - // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
285 | - $html .= EEH_HTML::span( |
|
286 | - $this->ticket_bundle |
|
287 | - ? apply_filters( |
|
288 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
289 | - __(' / bundle', 'event_espresso') |
|
290 | - ) |
|
291 | - : apply_filters( |
|
292 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
293 | - __('', 'event_espresso') |
|
294 | - ), |
|
295 | - '', |
|
296 | - 'smaller-text no-bold' |
|
297 | - ); |
|
298 | - $html .= ' '; |
|
299 | - $html .= EEH_HTML::tdx(); |
|
300 | - $this->cols++; |
|
301 | - } |
|
302 | - return $html; |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * onlyOneAttendeeCanRegister |
|
308 | - * |
|
309 | - * @return string |
|
310 | - */ |
|
311 | - protected function onlyOneAttendeeCanRegister() |
|
312 | - { |
|
313 | - // display submit button since we have tickets available |
|
314 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
315 | - $this->hidden_input_qty = false; |
|
316 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
317 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
318 | - $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
319 | - $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
320 | - $html .= ' id="' . $id . '"'; |
|
321 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
322 | - $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
323 | - $html .= ' title=""/>'; |
|
324 | - return $html; |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * ticketQuantitySelector |
|
330 | - * |
|
331 | - * @return string |
|
332 | - * @throws EE_Error |
|
333 | - */ |
|
334 | - protected function ticketQuantitySelector() |
|
335 | - { |
|
336 | - // display submit button since we have tickets available |
|
337 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
338 | - $this->hidden_input_qty = false; |
|
339 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
340 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
341 | - $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
342 | - $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
343 | - $html .= ' id="' . $id . '"'; |
|
344 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
345 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
346 | - if ($this->min !== 0 && ! $this->ticket->required()) { |
|
347 | - $html .= '<option value="0"> 0 </option>'; |
|
348 | - } |
|
349 | - // offer ticket quantities from the min to the max |
|
350 | - for ($i = $this->min; $i <= $this->max; $i++) { |
|
351 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
352 | - } |
|
353 | - $html .= '</select>'; |
|
354 | - return $html; |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - /** |
|
359 | - * getHiddenInputs |
|
360 | - * |
|
361 | - * @return string |
|
362 | - * @throws EE_Error |
|
363 | - */ |
|
364 | - protected function ticketQtyAndIdHiddenInputs() |
|
365 | - { |
|
366 | - $html = ''; |
|
367 | - // depending on group reg we need to change the format for qty |
|
368 | - if ($this->hidden_input_qty) { |
|
369 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
370 | - } |
|
371 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
372 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
373 | - return $html; |
|
374 | - } |
|
20 | + /** |
|
21 | + * @var TicketDetails $ticket_details |
|
22 | + */ |
|
23 | + protected $ticket_details; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | + */ |
|
28 | + protected $template_settings; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var EE_Tax_Config $tax_settings |
|
32 | + */ |
|
33 | + protected $tax_settings; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var boolean $prices_displayed_including_taxes |
|
37 | + */ |
|
38 | + protected $prices_displayed_including_taxes; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var int $row |
|
42 | + */ |
|
43 | + protected $row; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var int $cols |
|
47 | + */ |
|
48 | + protected $cols; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var boolean $hidden_input_qty |
|
52 | + */ |
|
53 | + protected $hidden_input_qty; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $ticket_datetime_classes |
|
57 | + */ |
|
58 | + protected $ticket_datetime_classes; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * TicketDetails constructor. |
|
63 | + * |
|
64 | + * @param TicketDetails $ticket_details |
|
65 | + * @param EE_Tax_Config $tax_settings |
|
66 | + * @param int $total_tickets |
|
67 | + * @param int $max_attendees |
|
68 | + * @param int $row |
|
69 | + * @param int $cols |
|
70 | + * @param boolean $required_ticket_sold_out |
|
71 | + * @param string $event_status |
|
72 | + * @param string $ticket_datetime_classes |
|
73 | + * @throws EE_Error |
|
74 | + * @throws UnexpectedEntityException |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + TicketDetails $ticket_details, |
|
78 | + EE_Tax_Config $tax_settings, |
|
79 | + $total_tickets, |
|
80 | + $max_attendees, |
|
81 | + $row, |
|
82 | + $cols, |
|
83 | + $required_ticket_sold_out, |
|
84 | + $event_status, |
|
85 | + $ticket_datetime_classes |
|
86 | + ) { |
|
87 | + $this->ticket_details = $ticket_details; |
|
88 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
89 | + $this->tax_settings = $tax_settings; |
|
90 | + $this->row = $row; |
|
91 | + $this->cols = $cols; |
|
92 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
93 | + parent::__construct( |
|
94 | + $ticket_details->getTicket(), |
|
95 | + $max_attendees, |
|
96 | + $ticket_details->getDateFormat(), |
|
97 | + $event_status, |
|
98 | + $required_ticket_sold_out, |
|
99 | + $total_tickets |
|
100 | + ); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * other ticket rows will need to know if a required ticket is sold out, |
|
106 | + * so that they are not offered for sale |
|
107 | + * |
|
108 | + * @return boolean |
|
109 | + */ |
|
110 | + public function getRequiredTicketSoldOut() |
|
111 | + { |
|
112 | + return $this->required_ticket_sold_out; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return int |
|
118 | + */ |
|
119 | + public function getCols() |
|
120 | + { |
|
121 | + return $this->cols; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * getHtml |
|
127 | + * |
|
128 | + * @return string |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function getHtml() |
|
132 | + { |
|
133 | + $this->min = 0; |
|
134 | + $this->max = $this->ticket->max(); |
|
135 | + $remaining = $this->ticket->remaining(); |
|
136 | + if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
137 | + $this->setTicketMinAndMax($remaining); |
|
138 | + } else { |
|
139 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
140 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
141 | + ? $this->ticket->start_date() |
|
142 | + : $this->required_ticket_sold_out; |
|
143 | + } |
|
144 | + $this->setTicketPriceDetails(); |
|
145 | + $this->setTicketStatusClasses($remaining); |
|
146 | + $filtered_row_html = $this->getFilteredRowHtml(); |
|
147 | + if ($filtered_row_html !== false) { |
|
148 | + return $filtered_row_html; |
|
149 | + } |
|
150 | + $ticket_selector_row_html = EEH_HTML::tr( |
|
151 | + '', |
|
152 | + '', |
|
153 | + "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
154 | + . espresso_get_object_css_class($this->ticket) |
|
155 | + ); |
|
156 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
157 | + if ($filtered_row_content !== false && $this->max_attendees === 1) { |
|
158 | + return $ticket_selector_row_html |
|
159 | + . $filtered_row_content |
|
160 | + . $this->ticketQtyAndIdHiddenInputs() |
|
161 | + . EEH_HTML::trx(); |
|
162 | + } |
|
163 | + if ($filtered_row_content !== false) { |
|
164 | + return $ticket_selector_row_html |
|
165 | + . $filtered_row_content |
|
166 | + . EEH_HTML::trx(); |
|
167 | + } |
|
168 | + $this->hidden_input_qty = $this->max_attendees > 1; |
|
169 | + |
|
170 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
171 | + $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
172 | + $ticket_selector_row_html .= EEH_HTML::td( |
|
173 | + '', |
|
174 | + '', |
|
175 | + 'tckt-slctr-tbl-td-qty cntr', |
|
176 | + '', |
|
177 | + 'headers="quantity-' . $this->EVT_ID . '"' |
|
178 | + ); |
|
179 | + $this->setTicketStatusDisplay($remaining); |
|
180 | + if (empty($this->ticket_status_display)) { |
|
181 | + if ($this->max_attendees === 1) { |
|
182 | + // only ONE attendee is allowed to register at a time |
|
183 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
184 | + } elseif ($this->max > 0) { |
|
185 | + $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
186 | + } |
|
187 | + } |
|
188 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
189 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
190 | + $ticket_selector_row_html .= $this->ticket_details->display( |
|
191 | + $this->ticket_price, |
|
192 | + $remaining, |
|
193 | + $this->cols |
|
194 | + ); |
|
195 | + $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
196 | + $ticket_selector_row_html .= EEH_HTML::trx(); |
|
197 | + |
|
198 | + |
|
199 | + $this->row++; |
|
200 | + return $ticket_selector_row_html; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * getTicketPriceDetails |
|
206 | + * |
|
207 | + * @return void |
|
208 | + * @throws EE_Error |
|
209 | + */ |
|
210 | + protected function setTicketPriceDetails() |
|
211 | + { |
|
212 | + $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
213 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
214 | + : $this->ticket->get_ticket_subtotal(); |
|
215 | + $this->ticket_bundle = false; |
|
216 | + $ticket_min = $this->ticket->min(); |
|
217 | + // for ticket bundles, set min and max qty the same |
|
218 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
219 | + $this->ticket_price *= $ticket_min; |
|
220 | + $this->ticket_bundle = true; |
|
221 | + } |
|
222 | + $this->ticket_price = apply_filters( |
|
223 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
224 | + $this->ticket_price, |
|
225 | + $this->ticket |
|
226 | + ); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * ticketNameTableCell |
|
232 | + * |
|
233 | + * @return string |
|
234 | + * @throws EE_Error |
|
235 | + */ |
|
236 | + protected function ticketNameTableCell() |
|
237 | + { |
|
238 | + $html = EEH_HTML::td( |
|
239 | + '', |
|
240 | + '', |
|
241 | + 'tckt-slctr-tbl-td-name', |
|
242 | + '', |
|
243 | + 'headers="details-' . $this->EVT_ID . '"' |
|
244 | + ); |
|
245 | + $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
246 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
247 | + if ($this->ticket->required()) { |
|
248 | + $html .= EEH_HTML::p( |
|
249 | + apply_filters( |
|
250 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
251 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
252 | + ), |
|
253 | + '', |
|
254 | + 'ticket-required-pg' |
|
255 | + ); |
|
256 | + } |
|
257 | + $html .= EEH_HTML::tdx(); |
|
258 | + return $html; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * ticketPriceTableCell |
|
264 | + * |
|
265 | + * @return string |
|
266 | + * @throws EE_Error |
|
267 | + */ |
|
268 | + protected function ticketPriceTableCell() |
|
269 | + { |
|
270 | + $html = ''; |
|
271 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
272 | + $html .= EEH_HTML::td( |
|
273 | + '', |
|
274 | + '', |
|
275 | + 'tckt-slctr-tbl-td-price jst-rght', |
|
276 | + '', |
|
277 | + 'headers="price-' . $this->EVT_ID . '"' |
|
278 | + ); |
|
279 | + $html .= \EEH_Template::format_currency($this->ticket_price); |
|
280 | + $html .= $this->ticket->taxable() |
|
281 | + ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
282 | + : ''; |
|
283 | + $html .= ' '; |
|
284 | + // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
285 | + $html .= EEH_HTML::span( |
|
286 | + $this->ticket_bundle |
|
287 | + ? apply_filters( |
|
288 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
289 | + __(' / bundle', 'event_espresso') |
|
290 | + ) |
|
291 | + : apply_filters( |
|
292 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
293 | + __('', 'event_espresso') |
|
294 | + ), |
|
295 | + '', |
|
296 | + 'smaller-text no-bold' |
|
297 | + ); |
|
298 | + $html .= ' '; |
|
299 | + $html .= EEH_HTML::tdx(); |
|
300 | + $this->cols++; |
|
301 | + } |
|
302 | + return $html; |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * onlyOneAttendeeCanRegister |
|
308 | + * |
|
309 | + * @return string |
|
310 | + */ |
|
311 | + protected function onlyOneAttendeeCanRegister() |
|
312 | + { |
|
313 | + // display submit button since we have tickets available |
|
314 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
315 | + $this->hidden_input_qty = false; |
|
316 | + $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
317 | + $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
318 | + $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
319 | + $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
320 | + $html .= ' id="' . $id . '"'; |
|
321 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
322 | + $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
323 | + $html .= ' title=""/>'; |
|
324 | + return $html; |
|
325 | + } |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * ticketQuantitySelector |
|
330 | + * |
|
331 | + * @return string |
|
332 | + * @throws EE_Error |
|
333 | + */ |
|
334 | + protected function ticketQuantitySelector() |
|
335 | + { |
|
336 | + // display submit button since we have tickets available |
|
337 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
338 | + $this->hidden_input_qty = false; |
|
339 | + $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
340 | + $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
341 | + $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
342 | + $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
343 | + $html .= ' id="' . $id . '"'; |
|
344 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
345 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
346 | + if ($this->min !== 0 && ! $this->ticket->required()) { |
|
347 | + $html .= '<option value="0"> 0 </option>'; |
|
348 | + } |
|
349 | + // offer ticket quantities from the min to the max |
|
350 | + for ($i = $this->min; $i <= $this->max; $i++) { |
|
351 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
352 | + } |
|
353 | + $html .= '</select>'; |
|
354 | + return $html; |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + /** |
|
359 | + * getHiddenInputs |
|
360 | + * |
|
361 | + * @return string |
|
362 | + * @throws EE_Error |
|
363 | + */ |
|
364 | + protected function ticketQtyAndIdHiddenInputs() |
|
365 | + { |
|
366 | + $html = ''; |
|
367 | + // depending on group reg we need to change the format for qty |
|
368 | + if ($this->hidden_input_qty) { |
|
369 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
370 | + } |
|
371 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
372 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
373 | + return $html; |
|
374 | + } |
|
375 | 375 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | '', |
175 | 175 | 'tckt-slctr-tbl-td-qty cntr', |
176 | 176 | '', |
177 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
177 | + 'headers="quantity-'.$this->EVT_ID.'"' |
|
178 | 178 | ); |
179 | 179 | $this->setTicketStatusDisplay($remaining); |
180 | 180 | if (empty($this->ticket_status_display)) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | '', |
241 | 241 | 'tckt-slctr-tbl-td-name', |
242 | 242 | '', |
243 | - 'headers="details-' . $this->EVT_ID . '"' |
|
243 | + 'headers="details-'.$this->EVT_ID.'"' |
|
244 | 244 | ); |
245 | 245 | $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
246 | 246 | $html .= $this->ticket_details->getShowHideLinks(); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | '', |
275 | 275 | 'tckt-slctr-tbl-td-price jst-rght', |
276 | 276 | '', |
277 | - 'headers="price-' . $this->EVT_ID . '"' |
|
277 | + 'headers="price-'.$this->EVT_ID.'"' |
|
278 | 278 | ); |
279 | 279 | $html .= \EEH_Template::format_currency($this->ticket_price); |
280 | 280 | $html .= $this->ticket->taxable() |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | // display submit button since we have tickets available |
314 | 314 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
315 | 315 | $this->hidden_input_qty = false; |
316 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
317 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
318 | - $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
319 | - $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
320 | - $html .= ' id="' . $id . '"'; |
|
321 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
316 | + $id = 'ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row; |
|
317 | + $html = '<label class="ee-a11y-screen-reader-text" for="'.$id.'">'; |
|
318 | + $html .= esc_html__('Select this ticket', 'event_espresso').'</label>'; |
|
319 | + $html .= '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"'; |
|
320 | + $html .= ' id="'.$id.'"'; |
|
321 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"'; |
|
322 | 322 | $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
323 | 323 | $html .= ' title=""/>'; |
324 | 324 | return $html; |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | // display submit button since we have tickets available |
337 | 337 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
338 | 338 | $this->hidden_input_qty = false; |
339 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
340 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
341 | - $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
342 | - $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
343 | - $html .= ' id="' . $id . '"'; |
|
339 | + $id = 'ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row; |
|
340 | + $html = '<label class="ee-a11y-screen-reader-text" for="'.$id.'">'; |
|
341 | + $html .= esc_html__('Quantity', 'event_espresso').'</label>'; |
|
342 | + $html .= '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"'; |
|
343 | + $html .= ' id="'.$id.'"'; |
|
344 | 344 | $html .= ' class="ticket-selector-tbl-qty-slct">'; |
345 | 345 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
346 | 346 | if ($this->min !== 0 && ! $this->ticket->required()) { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | } |
349 | 349 | // offer ticket quantities from the min to the max |
350 | 350 | for ($i = $this->min; $i <= $this->max; $i++) { |
351 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
351 | + $html .= '<option value="'.$i.'"> '.$i.' </option>'; |
|
352 | 352 | } |
353 | 353 | $html .= '</select>'; |
354 | 354 | return $html; |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | $html = ''; |
367 | 367 | // depending on group reg we need to change the format for qty |
368 | 368 | if ($this->hidden_input_qty) { |
369 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
369 | + $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>'; |
|
370 | 370 | } |
371 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
372 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
371 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"'; |
|
372 | + $html .= ' value="'.$this->ticket->ID().'"/>'; |
|
373 | 373 | return $html; |
374 | 374 | } |
375 | 375 | } |
@@ -14,24 +14,24 @@ |
||
14 | 14 | class TicketSelectorIframeEmbedButton extends IframeEmbedButton |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * TicketSelectorIframeEmbedButton constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - parent::__construct( |
|
23 | - esc_html__('Ticket Selector', 'event_espresso'), |
|
24 | - 'ticket_selector' |
|
25 | - ); |
|
26 | - } |
|
17 | + /** |
|
18 | + * TicketSelectorIframeEmbedButton constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + parent::__construct( |
|
23 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
24 | + 'ticket_selector' |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Adds an iframe embed code button to the Event editor. |
|
31 | - */ |
|
32 | - public function addEventEditorIframeEmbedButton() |
|
33 | - { |
|
34 | - // add button for iframe code to event editor. |
|
35 | - $this->addEventEditorIframeEmbedButtonFilter(); |
|
36 | - } |
|
29 | + /** |
|
30 | + * Adds an iframe embed code button to the Event editor. |
|
31 | + */ |
|
32 | + public function addEventEditorIframeEmbedButton() |
|
33 | + { |
|
34 | + // add button for iframe code to event editor. |
|
35 | + $this->addEventEditorIframeEmbedButtonFilter(); |
|
36 | + } |
|
37 | 37 | } |
@@ -14,121 +14,121 @@ |
||
14 | 14 | class TicketSelectorStandard extends TicketSelector |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var string $date_format |
|
19 | - */ |
|
20 | - protected $date_format; |
|
17 | + /** |
|
18 | + * @var string $date_format |
|
19 | + */ |
|
20 | + protected $date_format; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var string $time_format |
|
24 | - */ |
|
25 | - protected $time_format; |
|
22 | + /** |
|
23 | + * @var string $time_format |
|
24 | + */ |
|
25 | + protected $time_format; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
29 | - */ |
|
30 | - protected $ticket_selector_config; |
|
27 | + /** |
|
28 | + * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
29 | + */ |
|
30 | + protected $ticket_selector_config; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var \EE_Tax_Config $tax_config |
|
34 | - */ |
|
35 | - protected $tax_config; |
|
32 | + /** |
|
33 | + * @var \EE_Tax_Config $tax_config |
|
34 | + */ |
|
35 | + protected $tax_config; |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * TicketSelectorSimple constructor. |
|
40 | - * |
|
41 | - * @param \EE_Event $event |
|
42 | - * @param \EE_Ticket[] $tickets |
|
43 | - * @param int $max_attendees |
|
44 | - * @param array $template_args |
|
45 | - * @param string $date_format |
|
46 | - * @param string $time_format |
|
47 | - * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
48 | - * @param \EE_Tax_Config $tax_config |
|
49 | - */ |
|
50 | - public function __construct( |
|
51 | - \EE_Event $event, |
|
52 | - array $tickets, |
|
53 | - $max_attendees, |
|
54 | - array $template_args, |
|
55 | - $date_format = 'Y-m-d', |
|
56 | - $time_format = 'g:i a', |
|
57 | - \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
58 | - \EE_Tax_Config $tax_config = null |
|
59 | - ) { |
|
60 | - $this->date_format = $date_format; |
|
61 | - $this->time_format = $time_format; |
|
62 | - // get EE_Ticket_Selector_Config and TicketDetails |
|
63 | - $this->ticket_selector_config = isset(\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
64 | - ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
65 | - : new \EE_Ticket_Selector_Config(); |
|
66 | - // $template_settings->setDatetimeSelectorThreshold(2); |
|
67 | - // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
68 | - // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
69 | - $this->tax_config = isset(\EE_Registry::instance()->CFG->tax_settings) |
|
70 | - ? \EE_Registry::instance()->CFG->tax_settings |
|
71 | - : new \EE_Tax_Config(); |
|
72 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
73 | - } |
|
38 | + /** |
|
39 | + * TicketSelectorSimple constructor. |
|
40 | + * |
|
41 | + * @param \EE_Event $event |
|
42 | + * @param \EE_Ticket[] $tickets |
|
43 | + * @param int $max_attendees |
|
44 | + * @param array $template_args |
|
45 | + * @param string $date_format |
|
46 | + * @param string $time_format |
|
47 | + * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
48 | + * @param \EE_Tax_Config $tax_config |
|
49 | + */ |
|
50 | + public function __construct( |
|
51 | + \EE_Event $event, |
|
52 | + array $tickets, |
|
53 | + $max_attendees, |
|
54 | + array $template_args, |
|
55 | + $date_format = 'Y-m-d', |
|
56 | + $time_format = 'g:i a', |
|
57 | + \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
58 | + \EE_Tax_Config $tax_config = null |
|
59 | + ) { |
|
60 | + $this->date_format = $date_format; |
|
61 | + $this->time_format = $time_format; |
|
62 | + // get EE_Ticket_Selector_Config and TicketDetails |
|
63 | + $this->ticket_selector_config = isset(\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
64 | + ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
65 | + : new \EE_Ticket_Selector_Config(); |
|
66 | + // $template_settings->setDatetimeSelectorThreshold(2); |
|
67 | + // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
68 | + // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
69 | + $this->tax_config = isset(\EE_Registry::instance()->CFG->tax_settings) |
|
70 | + ? \EE_Registry::instance()->CFG->tax_settings |
|
71 | + : new \EE_Tax_Config(); |
|
72 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * sets any and all template args that are required for this Ticket Selector |
|
78 | - * |
|
79 | - * @return void |
|
80 | - * @throws \EE_Error |
|
81 | - */ |
|
82 | - protected function addTemplateArgs() |
|
83 | - { |
|
84 | - $row = 1; |
|
85 | - $ticket_row_html = ''; |
|
86 | - $required_ticket_sold_out = false; |
|
87 | - // flag to indicate that at least one taxable ticket has been encountered |
|
88 | - $taxable_tickets = false; |
|
89 | - $datetime_selector = null; |
|
90 | - $this->template_args['datetime_selector'] = ''; |
|
91 | - if ($this->ticket_selector_config->getShowDatetimeSelector() |
|
92 | - !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
93 | - ) { |
|
94 | - $datetime_selector = new DatetimeSelector( |
|
95 | - $this->event, |
|
96 | - $this->tickets, |
|
97 | - $this->ticket_selector_config, |
|
98 | - $this->date_format, |
|
99 | - $this->time_format |
|
100 | - ); |
|
101 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
102 | - } |
|
103 | - $total_tickets = count($this->tickets); |
|
104 | - // loop through tickets |
|
105 | - foreach ($this->tickets as $TKT_ID => $ticket) { |
|
106 | - if ($ticket instanceof \EE_Ticket) { |
|
107 | - $cols = 2; |
|
108 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
109 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
110 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
111 | - $this->tax_config, |
|
112 | - $total_tickets, |
|
113 | - $this->max_attendees, |
|
114 | - $row, |
|
115 | - $cols, |
|
116 | - $required_ticket_sold_out, |
|
117 | - $this->template_args['event_status'], |
|
118 | - $datetime_selector instanceof DatetimeSelector |
|
119 | - ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
120 | - : '' |
|
121 | - ); |
|
122 | - $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
123 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
124 | - $row++; |
|
125 | - } |
|
126 | - } |
|
127 | - $this->template_args['row'] = $row; |
|
128 | - $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
129 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
130 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
131 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
132 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
133 | - } |
|
76 | + /** |
|
77 | + * sets any and all template args that are required for this Ticket Selector |
|
78 | + * |
|
79 | + * @return void |
|
80 | + * @throws \EE_Error |
|
81 | + */ |
|
82 | + protected function addTemplateArgs() |
|
83 | + { |
|
84 | + $row = 1; |
|
85 | + $ticket_row_html = ''; |
|
86 | + $required_ticket_sold_out = false; |
|
87 | + // flag to indicate that at least one taxable ticket has been encountered |
|
88 | + $taxable_tickets = false; |
|
89 | + $datetime_selector = null; |
|
90 | + $this->template_args['datetime_selector'] = ''; |
|
91 | + if ($this->ticket_selector_config->getShowDatetimeSelector() |
|
92 | + !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
93 | + ) { |
|
94 | + $datetime_selector = new DatetimeSelector( |
|
95 | + $this->event, |
|
96 | + $this->tickets, |
|
97 | + $this->ticket_selector_config, |
|
98 | + $this->date_format, |
|
99 | + $this->time_format |
|
100 | + ); |
|
101 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
102 | + } |
|
103 | + $total_tickets = count($this->tickets); |
|
104 | + // loop through tickets |
|
105 | + foreach ($this->tickets as $TKT_ID => $ticket) { |
|
106 | + if ($ticket instanceof \EE_Ticket) { |
|
107 | + $cols = 2; |
|
108 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
109 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
110 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
111 | + $this->tax_config, |
|
112 | + $total_tickets, |
|
113 | + $this->max_attendees, |
|
114 | + $row, |
|
115 | + $cols, |
|
116 | + $required_ticket_sold_out, |
|
117 | + $this->template_args['event_status'], |
|
118 | + $datetime_selector instanceof DatetimeSelector |
|
119 | + ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
120 | + : '' |
|
121 | + ); |
|
122 | + $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
123 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
124 | + $row++; |
|
125 | + } |
|
126 | + } |
|
127 | + $this->template_args['row'] = $row; |
|
128 | + $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
129 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
130 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
131 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
132 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
133 | + } |
|
134 | 134 | } |
@@ -128,7 +128,7 @@ |
||
128 | 128 | $this->template_args['ticket_row_html'] = $ticket_row_html; |
129 | 129 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
130 | 130 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
131 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
131 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
132 | 132 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
133 | 133 | } |
134 | 134 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | class TicketSelectorRowSimple extends TicketSelectorRow |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @throws EE_Error |
|
19 | - */ |
|
20 | - public function setupTicketStatusDisplay() |
|
21 | - { |
|
22 | - $remaining = $this->ticket->remaining(); |
|
23 | - $this->setTicketMinAndMax($remaining); |
|
24 | - $this->setTicketStatusClasses($remaining); |
|
25 | - $this->setTicketStatusDisplay($remaining); |
|
26 | - } |
|
17 | + /** |
|
18 | + * @throws EE_Error |
|
19 | + */ |
|
20 | + public function setupTicketStatusDisplay() |
|
21 | + { |
|
22 | + $remaining = $this->ticket->remaining(); |
|
23 | + $this->setTicketMinAndMax($remaining); |
|
24 | + $this->setTicketStatusClasses($remaining); |
|
25 | + $this->setTicketStatusDisplay($remaining); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - public function getTicketDescription() |
|
30 | - { |
|
31 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
32 | - if ($filtered_row_content !== false) { |
|
33 | - remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
34 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_false'); |
|
35 | - return $filtered_row_content; |
|
36 | - } |
|
37 | - return $this->ticket->description(); |
|
38 | - } |
|
29 | + public function getTicketDescription() |
|
30 | + { |
|
31 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
32 | + if ($filtered_row_content !== false) { |
|
33 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
34 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_false'); |
|
35 | + return $filtered_row_content; |
|
36 | + } |
|
37 | + return $this->ticket->description(); |
|
38 | + } |
|
39 | 39 | } |