Locale `` could not be parsed.
124 $regex .= '(?:[_-](?P<script>[a-z]{4}))?';
125 $regex .= '(?:[_-](?P<territory>[a-z]{2}))?';
126 $regex .= '(?:[_-](?P<variant>[a-z]{5,}))?';
127
128 if (!preg_match("/^{$regex}$/i", $locale, $matches)) {
129 throw new InvalidArgumentException("Locale `{$locale}` could not be parsed.");
130 }
131 return array_filter(array_intersect_key($matches, static::$_tags));
132 }
133
134 /**
168 $locales[] = $locale;
169
170 if ($locale === 'root') {
171 return $locales;
172 }
173 $tags = static::decompose($locale);
174
175 while (count($tags) > 1) {
176 array_pop($tags);
177 $locales[] = static::compose($tags);
178 }
83 $id = strtok('.');
84
85 $names = $name === true ? array_keys(static::$_configurations) : (array) $name;
86 $results = array();
87
88 foreach (Locale::cascade($locale) as $cascaded) {
89 foreach ($names as $name) {
90 $adapter = static::adapter($name);
91
92 if ($result = $adapter->read($category, $cascaded, $options['scope'])) {
93 $results += $result;
192 extract($params);
193
194 if (!isset($cache[$options['scope']][$locale])) {
195 $cache[$options['scope']][$locale] = Catalog::read(
196 true, 'message', $locale, $options
197 );
198 }
199 $page = $cache[$options['scope']][$locale];
200
201 if (!isset($page[$id])) {
202 return null;
135 protected static function _filter($method, $params, $callback, $filters = array()) {
136 $class = get_called_class();
137 $hasNoFilters = empty(static::$_methodFilters[$class][$method]);
138
139 if ($hasNoFilters && !$filters && !Filters::hasApplied($class, $method)) {
140 return $callback($class, $params, null);
141 }
142 if (!isset(static::$_methodFilters[$class][$method])) {
143 static::$_methodFilters += array($class => array());
144 static::$_methodFilters[$class][$method] = array();
145 }
211 $key = $page['pluralRule']($count);
212
213 if (isset($page[$id][$key])) {
214 return $page[$id][$key];
215 }
216 });
217 }
218}
219
220
107 if ($options['noop']) {
108 $result = null;
109 } else {
110 $result = static::_translated($id, abs($options['count']), $options['locale'], array(
111 'scope' => $options['scope']
112 ));
113 }
114
115 if ($result || $options['default']) {
116 return String::insert($result ?: $options['default'], $options);
117 }
139 * @see lithium\net\http\Media::_handle()
140 * @return array Named aliases (`'t'` and `'tn'`) for translation functions.
141 */
142 public static function aliases() {
143 $t = function($message, array $options = array()) {
144 return Message::translate($message, $options + array('default' => $message));
145 };
146 $tn = function($message1, $message2, $count, array $options = array()) {
147 return Message::translate($message1, $options + compact('count') + array(
148 'default' => $count == 1 ? $message1 : $message2
149 ));
3 //if(strlen($locale>2)){$locale='en';}
4 // print_r(Environment::get('locale'));
5 // print_r($locale);
6 <div class="jumbotron container-fluid">
7 <h2>
8 echo $h($t('My XGC Wallet')); <small> echo $h($t('For use only with GreenCoinX- the world\'s first identifiable crypto currency')); </small>
9 </h2>
10 echo $this->_render('element', 'language');
11 </div>
12 <!--<div class="row container-fluid">
13 <div class="alert alert-danger col-md-6 col-md-offset-6" style="margin-top:-60px"><h4>Open a GreenCoinX wallet and receive 10 XGC. Free bonus!</h4></div>
111 } elseif ($this->_view) {
112 extract((array) $this->_view->outputFilters, EXTR_OVERWRITE);
113 }
114
115 ob_start();
116 include $template__;
117 return ob_get_clean();
118 }
119
120 /**
121 * Returns a template file name
388 'renderer' => $_renderer
389 );
390
391 $filter = function($self, $params) {
392 $template = $params['loader']->template($params['step']['path'], $params['params']);
393 return $params['renderer']->render($template, $params['data'], $params['options']);
394 };
395 $result = $this->_filter(__METHOD__, $params, $filter);
396
397 if (is_array($step['capture'])) {
398 switch (key($step['capture'])) {
254 */
255 protected function _filter($method, $params, $callback, $filters = array()) {
256 list($class, $method) = explode('::', $method);
257
258 if (empty($this->_methodFilters[$method]) && empty($filters)) {
259 return $callback($this, $params, null);
260 }
261
262 $f = isset($this->_methodFilters[$method]) ? $this->_methodFilters[$method] : array();
263 $data = array_merge($f, $filters, array($callback));
264 return Filters::run($this, $params, compact('data', 'class', 'method'));
390
391 $filter = function($self, $params) {
392 $template = $params['loader']->template($params['step']['path'], $params['params']);
393 return $params['renderer']->render($template, $params['data'], $params['options']);
394 };
395 $result = $this->_filter(__METHOD__, $params, $filter);
396
397 if (is_array($step['capture'])) {
398 switch (key($step['capture'])) {
399 case 'context':
400 $options['context'][current($step['capture'])] = $result;
323 $params[$name] = $value;
324 $result = $this->_step($step, $params, $data, $options);
325 }
326 continue;
327 }
328 $result = $this->_step((array) $step, $params, $data, $options);
329 }
330 return $result;
331 }
332
333 /**
839 case ($handler['template'] === false) && is_string($data):
840 return $data;
841 case $handler['view']:
842 unset($options['view']);
843 $instance = $self::view($handler, $data, $response, $options);
844 return $instance->render('all', (array) $data, $options);
845 default:
846 throw new MediaException("Could not interpret type settings for handler.");
847 }
848 });
849 }
198 public function next($self, $params, $chain) {
199 if (empty($self) || empty($chain)) {
200 return parent::next();
201 }
202 $next = parent::next();
203 return $next($self, $params, $chain);
204 }
205
206 /**
207 * Gets the method name associated with this filter chain. This is the method being filtered.
208 *
195 * @see lithium\net\http\Media
196 */
197Media::applyFilter('_handle', function($self, $params, $chain) {
198 $params['handler'] += array('outputFilters' => array());
199 $params['handler']['outputFilters'] += Message::aliases();
200 return $chain->next($self, $params, $chain);
201});
202
179 }
180 }
181
182 $chain = new Filters($options);
183 $next = $chain->rewind();
184 return $next($class, $params, $chain);
185 }
186
187 /**
188 * Provides short-hand convenience syntax for filter chaining.
189 *
142 if (!isset(static::$_methodFilters[$class][$method])) {
143 static::$_methodFilters += array($class => array());
144 static::$_methodFilters[$class][$method] = array();
145 }
146 $data = array_merge(static::$_methodFilters[$class][$method], $filters, array($callback));
147 return Filters::run($class, $params, compact('data', 'class', 'method'));
148 }
149
150 /**
151 * Gets and caches an array of the parent methods of a class.
152 *
843 $instance = $self::view($handler, $data, $response, $options);
844 return $instance->render('all', (array) $data, $options);
845 default:
846 throw new MediaException("Could not interpret type settings for handler.");
847 }
848 });
849 }
850
851 /**
852 * Helper method for listing registered media types. Returns all types, or a single
853 * content type if a specific type is specified.
80 case 1:
81 return static::$method($params[0]);
82 case 2:
83 return static::$method($params[0], $params[1]);
84 case 3:
85 return static::$method($params[0], $params[1], $params[2]);
86 case 4:
87 return static::$method($params[0], $params[1], $params[2], $params[3]);
88 case 5:
89 return static::$method($params[0], $params[1], $params[2], $params[3], $params[4]);
90 default:
687 if (isset($types[$type])) {
688 $header = current((array) $types[$type]);
689 $header .= $response->encoding ? "; charset={$response->encoding}" : '';
690 $response->headers('Content-Type', $header);
691 }
692 $response->body($self::invokeMethod('_handle', array($handler, $data, $response)));
693
694 return $response;
695 });
696 }
697
135 protected static function _filter($method, $params, $callback, $filters = array()) {
136 $class = get_called_class();
137 $hasNoFilters = empty(static::$_methodFilters[$class][$method]);
138
139 if ($hasNoFilters && !$filters && !Filters::hasApplied($class, $method)) {
140 return $callback($class, $params, null);
141 }
142 if (!isset(static::$_methodFilters[$class][$method])) {
143 static::$_methodFilters += array($class => array());
144 static::$_methodFilters[$class][$method] = array();
145 }
690 $response->headers('Content-Type', $header);
691 }
692 $response->body($self::invokeMethod('_handle', array($handler, $data, $response)));
693
694 return $response;
695 });
696 }
697
698 /**
699 * Configures a template object instance, based on a media handler configuration.
700 *
275 if ($options['head']) {
276 return;
277 }
278 $response = $media::render($this->response, $this->_render['data'], $options + array(
279 'request' => $this->request
280 ));
281 return ($this->response = $response ?: $this->response);
282 }
283
284 /**
285 * Creates a redirect response by calling `render()` and providing a `'location'` parameter.
33 $path = array('home');
34 $options['compiler'] = array('fallback' => true);
35 }
36
37 $options['template'] = join('/', $path);
38 return $this->render($options);
39 }
40 }
41
42
170 * @return mixed Returns the result of the method call
171 */
172 public function invokeMethod($method, $params = array()) {
173 switch (count($params)) {
174 case 0:
175 return $this->{$method}();
176 case 1:
177 return $this->{$method}($params[0]);
178 case 2:
179 return $this->{$method}($params[0], $params[1]);
180 case 3:
192 if (!method_exists($self, $action)) {
193 throw new DispatchException("Action `{$action}` not found.");
194 }
195 $render['template'] = $render['template'] ?: $action;
196
197 if ($result = $self->invokeMethod($action, $args)) {
198 if (is_string($result)) {
199 $self->render(array('text' => $result));
200 return $self->response;
201 }
202 if (is_array($result)) {
254 */
255 protected function _filter($method, $params, $callback, $filters = array()) {
256 list($class, $method) = explode('::', $method);
257
258 if (empty($this->_methodFilters[$method]) && empty($filters)) {
259 return $callback($this, $params, null);
260 }
261
262 $f = isset($this->_methodFilters[$method]) ? $this->_methodFilters[$method] : array();
263 $data = array_merge($f, $filters, array($callback));
264 return Filters::run($this, $params, compact('data', 'class', 'method'));
206
207 if (!$render['hasRendered'] && $render['auto']) {
208 $self->render();
209 }
210 return $self->response;
211 });
212 }
213
214 /**
215 * This method is used to pass along any data from the controller to the view and layout
216 *
257 */
258 protected static function _call($callable, $request, $params) {
259 $params = compact('callable', 'request', 'params');
260 return static::_filter(__FUNCTION__, $params, function($self, $params) {
261 if (is_callable($callable = $params['callable'])) {
262 return $callable($params['request'], $params['params']);
263 }
264 throw new DispatchException('Result not callable.');
265 });
266 }
267}
135 protected static function _filter($method, $params, $callback, $filters = array()) {
136 $class = get_called_class();
137 $hasNoFilters = empty(static::$_methodFilters[$class][$method]);
138
139 if ($hasNoFilters && !$filters && !Filters::hasApplied($class, $method)) {
140 return $callback($class, $params, null);
141 }
142 if (!isset(static::$_methodFilters[$class][$method])) {
143 static::$_methodFilters += array($class => array());
144 static::$_methodFilters[$class][$method] = array();
145 }
260 return static::_filter(__FUNCTION__, $params, function($self, $params) {
261 if (is_callable($callable = $params['callable'])) {
262 return $callable($params['request'], $params['params']);
263 }
264 throw new DispatchException('Result not callable.');
265 });
266 }
267}
268
269
80 case 1:
81 return static::$method($params[0]);
82 case 2:
83 return static::$method($params[0], $params[1]);
84 case 3:
85 return static::$method($params[0], $params[1], $params[2]);
86 case 4:
87 return static::$method($params[0], $params[1], $params[2], $params[3]);
88 case 5:
89 return static::$method($params[0], $params[1], $params[2], $params[3], $params[4]);
90 default:
149
150 if (!$params) {
151 throw new DispatchException('Could not route request.');
152 }
153 $callable = $self::invokeMethod('_callable', array($result, $params, $options));
154 return $self::invokeMethod('_call', array($callable, $result, $params));
155 });
156 }
157
158 /**
159 * Attempts to apply a set of formatting rules from `$_rules` to a `$params` array, where each
198 public function next($self, $params, $chain) {
199 if (empty($self) || empty($chain)) {
200 return parent::next();
201 }
202 $next = parent::next();
203 return $next($self, $params, $chain);
204 }
205
206 /**
207 * Gets the method name associated with this filter chain. This is the method being filtered.
208 *
46 continue;
47 }
48 $file = "{$config['path']}/config/routes.php";
49 file_exists($file) ? call_user_func(function() use ($file) { include $file; }) : null;
50 }
51 return $chain->next($self, $params, $chain);
52 });
53
54
198 public function next($self, $params, $chain) {
199 if (empty($self) || empty($chain)) {
200 return parent::next();
201 }
202 $next = parent::next();
203 return $next($self, $params, $chain);
204 }
205
206 /**
207 * Gets the method name associated with this filter chain. This is the method being filtered.
208 *
261 $wrap = static::$_exceptionHandler;
262 $_self = get_called_class();
263
264 $filter = function($self, $params, $chain) use ($_self, $conditions, $handler, $wrap) {
265 try {
266 return $chain->next($self, $params, $chain);
267 } catch (Exception $e) {
268 if (!$_self::matches($e, $conditions)) {
269 throw $e;
270 }
271 return $handler($wrap($e, true), $params);
179 }
180 }
181
182 $chain = new Filters($options);
183 $next = $chain->rewind();
184 return $next($class, $params, $chain);
185 }
186
187 /**
188 * Provides short-hand convenience syntax for filter chaining.
189 *
142 if (!isset(static::$_methodFilters[$class][$method])) {
143 static::$_methodFilters += array($class => array());
144 static::$_methodFilters[$class][$method] = array();
145 }
146 $data = array_merge(static::$_methodFilters[$class][$method], $filters, array($callback));
147 return Filters::run($class, $params, compact('data', 'class', 'method'));
148 }
149
150 /**
151 * Gets and caches an array of the parent methods of a class.
152 *
150 if (!$params) {
151 throw new DispatchException('Could not route request.');
152 }
153 $callable = $self::invokeMethod('_callable', array($result, $params, $options));
154 return $self::invokeMethod('_call', array($callable, $result, $params));
155 });
156 }
157
158 /**
159 * Attempts to apply a set of formatting rules from `$_rules` to a `$params` array, where each
160 * formatting rule is applied if the key of the rule in `$_rules` is present and not empty in
41 * @see lithium\action\Response
42 * @see lithium\action\Dispatcher
43 * @see lithium\net\http\Router
44 * @see lithium\action\Controller
45 */
46 echo lithium\action\Dispatcher::run(new lithium\action\Request());
47
48