$thisMonth = intval( gmdate( 'n' ) );
$thisYear = intval( gmdate( 'Y' ) );
if( intval($encMonth) > $thisMonth ) {
$thisMonth = intval( gmdate( 'n' ) );
$thisYear = intval( gmdate( 'Y' ) );
if( intval($encMonth) > $thisMonth ) {
- * @param $selected The language code of the selected language
- * @param $customisedOnly If true only languages which have some content are listed
+ * @param $selected string The language code of the selected language
+ * @param $customisedOnly bool If true only languages which have some content are listed
* @return array of label and select
*/
public static function languageSelector( $selected, $customisedOnly = true ) {
* @return array of label and select
*/
public static function languageSelector( $selected, $customisedOnly = true ) {
* Shortcut to make a span element
* @param $text String content of the element, will be escaped
* @param $class String class name of the span element
* Shortcut to make a span element
* @param $text String content of the element, will be escaped
* @param $class String class name of the span element
* Shortcut to make a specific element with a class attribute
* @param $text content of the element, will be escaped
* @param $class class name of the span element
* Shortcut to make a specific element with a class attribute
* @param $text content of the element, will be escaped
* @param $class class name of the span element
- public static function wrapClass( $text, $class, $tag='span', $attribs=array() ) {
+ public static function wrapClass( $text, $class, $tag = 'span', $attribs = array() ) {
return self::tags( $tag, array( 'class' => $class ) + $attribs, $text );
}
/**
* Convenience function to build an HTML text input field
* @param $name String value of the name attribute
return self::tags( $tag, array( 'class' => $class ) + $attribs, $text );
}
/**
* Convenience function to build an HTML text input field
* @param $name String value of the name attribute
- * @param $size value of the size attribute
- * @param $value value of the value attribute
- * @param $attribs other attributes
+ * @param $size int value of the size attribute
+ * @param $value mixed value of the value attribute
+ * @param $attribs array other attributes
- public static function input( $name, $size=false, $value=false, $attribs=array() ) {
+ public static function input( $name, $size = false, $value = false, $attribs = array() ) {
- * @param $name value of the name attribute
- * @param $size value of the size attribute
- * @param $value value of the value attribute
- * @param $attribs other attributes
+ * @param $name string value of the name attribute
+ * @param $size int value of the size attribute
+ * @param $value mixed value of the value attribute
+ * @param $attribs array other attributes
- public static function password( $name, $size=false, $value=false, $attribs=array() ) {
- return self::input( $name, $size, $value, array_merge($attribs, array('type' => 'password')));
+ public static function password( $name, $size = false, $value = false, $attribs = array() ) {
+ return self::input( $name, $size, $value, array_merge( $attribs, array( 'type' => 'password' ) ) );
- * @param $name value of the name attribute
- * @param $value value of the value attribute
- * @param $checked Whether the checkbox is checked or not
- * @param $attribs other attributes
+ * @param $name String value of the name attribute
+ * @param $value String value of the value attribute
+ * @param $checked Bool Whether the checkbox is checked or not
+ * @param $attribs Array other attributes
- public static function radio( $name, $value, $checked=false, $attribs=array() ) {
+ public static function radio( $name, $value, $checked = false, $attribs = array() ) {
- * so this function will cherry-pick appropriate attributes to
- * apply to the label as well; currently only class is applied.
+ * so this function will cherry-pick appropriate attributes to
+ * apply to the label as well; only class and title are applied.
* @param $label String text of the label
* @param $name String value of the name attribute
* @param $id String id of the input
* @param $label String text of the label
* @param $name String value of the name attribute
* @param $id String id of the input
- * @param $size value of the size attribute
- * @param $value value of the value attribute
- * @param $attribs other attributes
+ * @param $size Int|Bool value of the size attribute
+ * @param $value String|Bool value of the value attribute
+ * @param $attribs array other attributes
- public static function inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=array() ) {
+ public static function inputLabel( $label, $name, $id, $size=false, $value=false, $attribs = array() ) {
list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs );
return $label . ' ' . $input;
}
/**
* Same as Xml::inputLabel() but return input and label in an array
list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs );
return $label . ' ' . $input;
}
/**
* Same as Xml::inputLabel() but return input and label in an array
- public static function inputLabelSep( $label, $name, $id, $size=false, $value=false, $attribs=array() ) {
+ public static function inputLabelSep( $label, $name, $id, $size = false, $value = false, $attribs = array() ) {
return array(
Xml::label( $label, $id, $attribs ),
self::input( $name, $size, $value, array( 'id' => $id ) + $attribs )
return array(
Xml::label( $label, $id, $attribs ),
self::input( $name, $size, $value, array( 'id' => $id ) + $attribs )
- public static function checkLabel( $label, $name, $id, $checked=false, $attribs=array() ) {
+ public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) {
return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
' ' .
self::label( $label, $id, $attribs );
return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
' ' .
self::label( $label, $id, $attribs );
- public static function radioLabel( $label, $name, $value, $id, $checked=false, $attribs=array() ) {
+ public static function radioLabel( $label, $name, $value, $id, $checked = false, $attribs = array() ) {
return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) .
' ' .
self::label( $label, $id, $attribs );
return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) .
' ' .
self::label( $label, $id, $attribs );
- /**
- * @deprecated Synonymous to Html::hidden()
- */
- public static function hidden( $name, $value, $attribs = array() ) {
- return Html::hidden( $name, $value, $attribs );
- }
-
/**
* Convenience function to build an HTML drop-down list item.
* @param $text String: text for this item
/**
* Convenience function to build an HTML drop-down list item.
* @param $text String: text for this item
- public static function option( $text, $value=null, $selected=false,
- $attribs=array() ) {
+ public static function option( $text, $value=null, $selected = false,
+ $attribs = array() ) {
if( !is_null( $value ) ) {
$attribs['value'] = $value;
}
if( $selected ) {
$attribs['selected'] = 'selected';
}
if( !is_null( $value ) ) {
$attribs['value'] = $value;
}
if( $selected ) {
$attribs['selected'] = 'selected';
}
- public static function listDropDown( $name= '', $list = '', $other = '', $selected = '', $class = '', $tabindex = Null ) {
+ public static function listDropDown( $name= '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) {
*
* @param $legend Legend of the fieldset. If evaluates to false, legend is not added.
* @param $content Pre-escaped content for the fieldset. If false, only open fieldset is returned.
*
* @param $legend Legend of the fieldset. If evaluates to false, legend is not added.
* @param $content Pre-escaped content for the fieldset. If false, only open fieldset is returned.
*/
public static function fieldset( $legend = false, $content = false, $attribs = array() ) {
$s = Xml::openElement( 'fieldset', $attribs ) . "\n";
*/
public static function fieldset( $legend = false, $content = false, $attribs = array() ) {
$s = Xml::openElement( 'fieldset', $attribs ) . "\n";
- * @param $name The 'name' for the textarea
- * @param $content Content for the textarea
- * @param $cols The number of columns for the textarea
- * @param $rows The number of rows for the textarea
- * @param $attribs Any other attributes for the textarea
+ * @param $name string The 'name' for the textarea
+ * @param $content string Content for the textarea
+ * @param $cols int The number of columns for the textarea
+ * @param $rows int The number of rows for the textarea
+ * @param $attribs array Any other attributes for the textarea
+ *
+ * @return string
*/
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) {
return self::element( 'textarea',
*/
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) {
return self::element( 'textarea',
"\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER
"\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
);
"\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER
"\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
);
* Arrays are converted to JS arrays, objects are converted to JS associative
* arrays (objects). So cast your PHP associative arrays to objects before
* passing them to here.
* Arrays are converted to JS arrays, objects are converted to JS associative
* arrays (objects). So cast your PHP associative arrays to objects before
* passing them to here.
*/
public static function encodeJsVar( $value ) {
if ( is_bool( $value ) ) {
$s = $value ? 'true' : 'false';
} elseif ( is_null( $value ) ) {
$s = 'null';
*/
public static function encodeJsVar( $value ) {
if ( is_bool( $value ) ) {
$s = $value ? 'true' : 'false';
} elseif ( is_null( $value ) ) {
$s = 'null';
} elseif ( is_array( $value ) && // Make sure it's not associative.
array_keys($value) === range( 0, count($value) - 1 ) ||
count($value) == 0
} elseif ( is_array( $value ) && // Make sure it's not associative.
array_keys($value) === range( 0, count($value) - 1 ) ||
count($value) == 0
- * Create a call to a JavaScript function. The supplied arguments will be
- * encoded using Xml::encodeJsVar().
+ * Create a call to a JavaScript function. The supplied arguments will be
+ * encoded using Xml::encodeJsVar().
* which evaluates to a function object which is called.
* @param $args Array of arguments to pass to the function.
* which evaluates to a function object which is called.
* @param $args Array of arguments to pass to the function.
- * @param $rows An array of arrays of strings, each to be a row in a table
- * @param $attribs An array of attributes to apply to the table tag [optional]
- * @param $headers An array of strings to use as table headers [optional]
+ * @param $rows array An array of arrays of strings, each to be a row in a table
+ * @param $attribs array An array of attributes to apply to the table tag [optional]
+ * @param $headers array An array of strings to use as table headers [optional]
* @return string
*/
public static function buildTable( $rows, $attribs = array(), $headers = null ) {
$s = Xml::openElement( 'table', $attribs );
* @return string
*/
public static function buildTable( $rows, $attribs = array(), $headers = null ) {
$s = Xml::openElement( 'table', $attribs );
- * @param $attribs An array of attributes to apply to the tr tag
- * @param $cells An array of strings to put in <td>
+ * @param $attribs array An array of attributes to apply to the tr tag
+ * @param $cells array An array of strings to put in <td>
* @return string
*/
public static function buildTableRow( $attribs, $cells ) {
$s = Xml::openElement( 'tr', $attribs );
* @return string
*/
public static function buildTableRow( $attribs, $cells ) {
$s = Xml::openElement( 'tr', $attribs );
public function setAttribute( $name, $value ) {
$this->attributes[$name] = $value;
}
public function setAttribute( $name, $value ) {
$this->attributes[$name] = $value;
}
public function addOption( $name, $value = false ) {
// Stab stab stab
$value = ($value !== false) ? $value : $name;
public function addOption( $name, $value = false ) {
// Stab stab stab
$value = ($value !== false) ? $value : $name;
- // This accepts an array of form
- // label => value
- // label => ( label => value, label => value )
+ /**
+ * This accepts an array of form
+ * label => value
+ * label => ( label => value, label => value )
+ *
+ * @param $options
+ */
- // This accepts an array of form
- // label => value
- // label => ( label => value, label => value )
+ /**
+ * This accepts an array of form
+ * label => value
+ * label => ( label => value, label => value )
+ *
+ * @param $options
+ * @param bool $default
+ * @return string
+ */
foreach( $options as $label => $value ) {
if ( is_array( $value ) ) {
$contents = self::formatOptions( $value, $default );
foreach( $options as $label => $value ) {
if ( is_array( $value ) ) {
$contents = self::formatOptions( $value, $default );
+ foreach ( $this->options as $options ) {
+ $contents .= self::formatOptions( $options, $this->default );
+ }
+
+ return Html::rawElement( 'select', $this->attributes, rtrim( $contents ) );
+ }
- * A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to
- * interpret a given string as being a JavaScript expression, instead of string
+ * A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to
+ * interpret a given string as being a JavaScript expression, instead of string