Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Language Helper: Add optional class variable to label. In addition, rem... #1235

Closed
wants to merge 8 commits into from

3 participants

@jcc2010

...ove the empty check for ID, instead set to NULL.

@jcc2010

Very small and simple change. Allows the language helper to add a class to the label, but only if one is explicitly called. Also changed the condition off !='' on the ID to instead force a NULL.

system/helpers/language_helper.php
((6 lines not shown))
{
$CI =& get_instance();
$line = $CI->lang->line($line);
- if ($id != '')
+ if ( $id && !$class )

Can you remove the spaces between code and brackets please.

if ($id && ! $class)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@philsturgeon

This will need to be documented before we can add this into the develop branch, and it will need to be listed ion the changelog too.

system/helpers/language_helper.php
((12 lines not shown))
{
- $line = '<label for="'.$id.'">'.$line.'</label>';
+ $line = '<label for="'.$id.'">'.$line."</label>";
@narfbg Owner
narfbg added a note

Why is this line changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jcc2010

I believe I have added the requested changes. If further are needed, let me know.

@narfbg narfbg commented on the diff
system/language/english/migration_lang.php
@@ -30,7 +30,11 @@
$lang['migration_multiple_version'] = "This are multiple migrations with the same version number: %d.";
$lang['migration_class_doesnt_exist'] = "The migration class \"%s\" could not be found.";
$lang['migration_missing_up_method'] = "The migration class \"%s\" is missing an 'up' method.";
+<<<<<<< HEAD
@narfbg Owner
narfbg added a note

Um ... that's not right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@narfbg
Owner

Btw, just an idea - could we change the $id parameter to accept an array of attributes as well?
By default it can still interpret non-arrays as the id, but we can deprecate that and encourage everybody to use it like this:

lang($line, array('id' => 'my_id', 'class' => 'my_class', 'other_attribute' => 'my_value');
@narfbg narfbg referenced this pull request from a commit
@narfbg narfbg Language helper lang() to accept optional HTML attributes
(an improved version of PR #1235)
3b40706
@narfbg
Owner

See the above commit.

@narfbg narfbg closed this
@nonchip nonchip referenced this pull request from a commit in nonchip/CodeIgniter
@narfbg narfbg Language helper lang() to accept optional HTML attributes
(an improved version of PR #1235)
fdcaacb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 1, 2012
  1. @jcc2010

    Language Helper: Add optional class variable to label. In addition, r…

    jcc2010 authored
    …emove the empty check for ID, instead set to NULL.
Commits on Apr 5, 2012
  1. @jcc2010

    Removed spacing by request.

    jcc2010 authored
  2. @jcc2010
  3. @jcc2010

    Changed back to single quote.

    jcc2010 authored
Commits on Apr 11, 2012
  1. @jcc2010
Commits on Apr 15, 2012
  1. @jcc2010
Commits on Apr 28, 2012
  1. @jcc2010

    Merge

    jcc2010 authored
  2. @jcc2010
This page is out of date. Refresh to see the latest.
View
8 system/helpers/language_helper.php
@@ -48,15 +48,19 @@
*/
if ( ! function_exists('lang'))
{
- function lang($line, $id = '')
+ function lang($line, $id = NULL, $class = NULL)
{
$CI =& get_instance();
$line = $CI->lang->line($line);
- if ($id != '')
+ if ($id && ! $class)
{
$line = '<label for="'.$id.'">'.$line.'</label>';
}
+ elseif ($id && $class)
+ {
+ $line = '<label for="'.$id.'" class="'.$class.'">'.$line.'</label>';
+ }
return $line;
}
View
4 system/language/english/migration_lang.php
@@ -30,7 +30,11 @@
$lang['migration_multiple_version'] = "This are multiple migrations with the same version number: %d.";
$lang['migration_class_doesnt_exist'] = "The migration class \"%s\" could not be found.";
$lang['migration_missing_up_method'] = "The migration class \"%s\" is missing an 'up' method.";
+<<<<<<< HEAD
@narfbg Owner
narfbg added a note

Um ... that's not right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
$lang['migration_missing_down_method'] = "The migration class \"%s\" is missing a 'down' method.";
+=======
+$lang['migration_missing_down_method'] = "The migration class \"%s\" is missing an 'down' method.";
+>>>>>>> 55ac2138482154c3aed7d6a6a2b6f196d0a04d9e
$lang['migration_invalid_filename'] = "Migration \"%s\" has an invalid filename.";
Something went wrong with that request. Please try again.