/** * Return an html label linked to a given input field * @param string $name the name of the Jam_Model attribute * @param string $label the text of the label, can be autogenerated if NULL * @param array $attributes of the input field, extract the id from there * @return string */ public function label($name, $label = NULL, array $attributes = array()) { $field_attributes = $this->default_attributes($name, $attributes); if ($label === NULL) { if ($this->meta()->field($name) and $this->meta()->field($name)->label !== NULL) { $label = UTF8::ucfirst($this->meta()->field($name)->label); } else { $label = UTF8::ucfirst(Inflector::humanize($name)); } } return Form::label($field_attributes['id'], $label, $attributes); }
<span class="error-message"><?php echo UTF8::ucfirst($field->error()); ?> </span>
/** * Group events by city * * @param array|Database_Result $events * @return array */ protected function _group_by_city($events) { $grouped = array(); if (count($events)) { // Build grouped array foreach ($events as $event) { // Date $date = date('Y-m-d', $event->stamp_begin); if (!isset($grouped[$date])) { $grouped[$date] = array(); } // City $city = UTF8::ucfirst(mb_strtolower($event->city_id ? $event->city()->name : $event->city_name)); if (!isset($grouped[$date][$city])) { $grouped[$date][$city] = array(); } $grouped[$date][$city][] = $event; } // Sort by city $dates = array_keys($grouped); foreach ($dates as $date) { ksort($grouped[$date]); // Drop empty cities to last if (isset($grouped[$date][''])) { $grouped[$date][__('Elsewhere')] = $grouped[$date]['']; unset($grouped[$date]['']); } } } return $grouped; }
foreach ($notifications as $type => $notification) { ?> <?php if (!empty($notification)) { ?> <?php foreach ($notification as $notice) { ?> <div class="<?php echo $type; ?> "> <div class="inner"> <h6><?php echo __(UTF8::ucfirst($type)); ?> </h6> <?php if ($notice['message'] !== NULL) { ?> <p><?php echo $notice['message']; ?> </p> <?php } ?> <?php
/** * Return or create a new driver instance * * @access public * @param mixed $save_instance. (default: FALSE) * @return Formo_Driver */ public function driver($save_instance = TRUE) { // Fetch the current settings $driver = $this->get('driver'); $instance = $this->get('driver_instance'); $class = 'Formo_Driver_' . ucfirst($driver); // If the instance is the correct driver for the field, return it if ($instance and $instance instanceof $class) { return $instance; } // Build the class name $driver_class_name = Kohana::config('formo')->driver_prefix . UTF8::ucfirst($driver); // Create the new instance $instance = new $driver_class_name($this); if ($save_instance === TRUE) { // Save the instance if asked to $this->set('driver_instance', $instance); } $this->_loaded['driver'] = TRUE; // Return the new driver instance return $instance; }
/** * Tests if the route matches a given Request. A successful match will return * all of the routed parameters as an array. A failed match will return * boolean FALSE. * * // Params: controller = users, action = edit, id = 10 * $params = $route->matches(Request::factory('users/edit/10')); * * This method should almost always be used within an if/else block: * * if ($params = $route->matches($request)) * { * // Parse the parameters * } * * @param Request $request Request object to match * @return array on success * @return FALSE on failure * @uses Lang::$i18n_routes * @uses Route::matches * @uses Route::remap * @uses Request::$lang * @uses Lang::$default * @uses HTTP_Exception_404 */ public function matches(Request $request) { if (!Lang::$i18n_routes) { // i18n routes are off return parent::matches($request); } // Set params $params = parent::matches($request); if ($params !== FALSE) { foreach ($params as $label => &$param) { if (isset($this->_translate['<' . $label . '>']) or isset($this->_translate[$param])) { // If param might be translated see if it needs to be // converted back to application (source) language $source_param = Route::remap(UTF8::strtolower($param)); if (Request::$lang !== Lang::$default and isset($this->_translate['<' . $label . '>']) and $source_param === $param and strtolower($param) !== $this->_defaults[$label]) { // To avoid duplicate content throw 404 throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(':uri' => $request->uri())); } // Set translated param $param = UTF8::ucfirst($source_param); } } // Return URI converted back to application (source) language return $params; } else { // No match return FALSE; } }
/** * @return array */ public function get_editable_types() { if ($this->is_superadmin()) { return array(self::TYPE_SUPERADMIN => UTF8::ucfirst(__(UTF8::strtolower(self::TYPE_SUPERADMIN))), self::TYPE_ADMIN => UTF8::ucfirst(__(UTF8::strtolower(self::TYPE_ADMIN))), self::TYPE_INTERNAL => UTF8::ucfirst(__(UTF8::strtolower(self::TYPE_INTERNAL)))); } if ($this->is_only_admin()) { return array(self::TYPE_EXTERNAL => UTF8::ucfirst(__(UTF8::strtolower(self::TYPE_EXTERNAL)))); } return array(); }
private function _send_mail() { $message = array("user" => array("name" => "*****@*****.**", "from" => "*****@*****.**", "from_name" => UTF8::ucfirst(UTF8::get_value($this->_form, "display_name")), "to" => "*****@*****.**", "subject" => UTF8::get_value($this->_form, "reason"), "html" => UTF8::get_value($this->_form, "message"), "user_email" => UTF8::get_value($this->_form, "user_email"))); Mailer::factory("user", "say_hello", $message); }
/** * Group events by city * * @param array|Database_Result $events * @return array */ protected function _group_by_city($events) { $grouped = array(); if (count($events)) { // Build grouped array foreach ($events as $event) { $city = UTF8::ucfirst(mb_strtolower($event->city_name)); $days = ceil(($event->stamp_end - $event->stamp_begin) / Date::DAY); for ($day = 0; $day < $days; $day++) { $date = date('Y-m-d', strtotime('+' . $day . ' days', $event->stamp_begin)); if (!isset($grouped[$date])) { $grouped[$date] = array(); } if (!isset($grouped[$date][$city])) { $grouped[$date][$city] = array(); } $grouped[$date][$city][] = $event; } } // Sort by city $dates = array_keys($grouped); foreach ($dates as $date) { ksort($grouped[$date]); // Drop empty cities to last if (isset($grouped[$date][''])) { $grouped[$date][__('Elsewhere')] = $grouped[$date]['']; unset($grouped[$date]['']); } } } return $grouped; }
<div class="group"> <h2><?php echo UTF8::ucfirst($group->alias()); ?> </h2> <?php if ($group->error) { ?> <div>There were errors with this section</div> <?php } ?> <?php foreach ($group->fields() as $group) { ?> <?php echo $group->generate(); ?> <?php } ?> </div>
<span class="label"><?php echo UTF8::ucfirst($field->label()); ?> :</span>
private function _model_messages_dump(Jam_Model $model) { $messages = array(); foreach ($model->errors() as $attribute_name => $errors) { if ($model->meta()->association($attribute_name) instanceof Jam_Association_Collection) { foreach ($model->{$attribute_name} as $i => $item) { if (!$item->is_valid()) { $messages[] = UTF8::ucfirst(Inflector::humanize($attribute_name)) . ' (' . $i . '): ' . join(', ', $this->_model_messages_dump($item)); } } } elseif ($model->meta()->association($attribute_name) and $model->{$attribute_name}) { $messages[] = UTF8::ucfirst(Inflector::humanize($attribute_name)) . ': ' . join(', ', $this->_model_messages_dump($model->{$attribute_name})); } else { foreach ($errors as $error => $params) { $messages[] = Jam_Errors::message($model->meta()->errors_filename(), $attribute_name, $error, Arr::merge($params, array(':model' => $model->meta()->model(), ':attribute' => Jam_Errors::attribute_label($model->meta(), $attribute_name)))); } } } return $messages; }
<ul class="nav"> <?php foreach ($links as $link) { printf('<li%s>%s</li>', html::attributes(array('class' => Request::instance()->controller == $link ? 'active' : NULL)), html::anchor($link, UTF8::ucfirst($link))); } ?> </ul>
<?php if ($error = $form->error() and $error !== TRUE) { ?> <span class="error-message"><?php echo UTF8::ucfirst($form->error()); ?> </span> <?php } ?> <?php echo $form->open(); ?> <?php foreach ($form->fields() as $field) { ?> <?php echo $field->render('html'); ?> <?php } echo $form->close();
/** * Build filter items * * @param array $events * @return array */ protected function _filters(array $events = null) { $filters = array(); if (count($events)) { $cities = array(); $empty = false; $elsewhere = URL::title(__('Elsewhere')); // Build filter list foreach ($events as $day) { foreach ($day as $city => $city_events) { // City filter $filter = URL::title($city); if ($filter == $elsewhere) { $empty = true; continue; } if (!isset($cities[$filter])) { $cities[$filter] = $city; } } } // Drop empty to last ksort($cities); if ($empty) { $cities[$elsewhere] = UTF8::ucfirst(mb_strtolower(__('Elsewhere'))); } // Build city filter $filters['city'] = array('name' => __('City'), 'filters' => $cities); } return $filters; }
/** * Tests UTF8::ucfirst * * @test * @dataProvider provider_ucfirst */ public function test_ucfirst($input, $expected) { $this->assertSame($expected, UTF8::ucfirst($input)); }
private function _user_row() { $encrypt = Encrypt::instance(); return array("user_nicename" => $this->_display_name, "user_pass" => $encrypt->encode("T0d@y"), "user_email" => $this->_user_email, "user_login" => UTF8::ucfirst($this->_display_name), "display_name" => UTF8::ucfirst($this->_display_name), "user_registered" => Date::formatted_time()); }