elgg_extend_view('js/initialise_elgg', 'js/html5');\r
}\r
\r
+function html5_get_html_attributes(array $attrs = array(), $quote_style = ENT_COMPAT, $charset = 'UTF-8', $double_encode = TRUE) {\r
+ $attrs = html5_clean_vars($attrs);\r
+ $attributes = array();\r
+ \r
+ if (isset($attrs['js'])) {\r
+ elgg_deprecated_notice("Use of the 'js' attribute was deprecated in 1.8. You can now use the js attributes directly.", '1.8');\r
+ \r
+ if (!empty($attrs['js'])) {\r
+ $attributes[] = $attrs['js'];\r
+ }\r
+ \r
+ unset($attrs['js']);\r
+ }\r
+ \r
+ foreach ($attrs as $attr => $val) {\r
+ $attr = strtolower($attr);\r
+ \r
+ if ($val === TRUE) {\r
+ $attributes[] = $attr;\r
+ } elseif (!empty($val)) {\r
+ //allow multi-value attributes to be passed as array\r
+ if (is_array($val)) {\r
+ sort($val); //gzip?\r
+ \r
+ $val = implode(' ', $val);\r
+ }\r
+ \r
+ $val = htmlspecialchars($val, $quote_style, $charset, $double_encode);\r
+ $attributes[] = "$attr=\"$val\"";\r
+ }\r
+ }\r
+\r
+ sort($attributes); //gzip?\r
+ \r
+ return implode(' ', $attributes);\r
+}\r
+\r
+// remove all the junk that elgg_view throws into $vars\r
+function html5_clean_vars(array $vars = array()) {\r
+ unset($vars['config']);\r
+ unset($vars['url']);\r
+ unset($vars['page_owner']);\r
+ unset($vars['page_owner_user']);\r
+ \r
+ foreach ($_SESSION as $key => $value) {\r
+ unset($vars[$key]);\r
+ }\r
+ \r
+ // backwards compatibility code\r
+ if (isset($vars['internalname'])) {\r
+ $vars['name'] = $vars['internalname'];\r
+ unset($vars['internalname']);\r
+ }\r
+ \r
+ if (isset($vars['internalid'])) {\r
+ $vars['id'] = $vars['internalid'];\r
+ unset($vars['internalid']);\r
+ }\r
+ \r
+ return $vars;\r
+}\r
+\r
register_elgg_event_handler('init', 'system', 'html5_init');\r
+++ /dev/null
-<?php
-$defaults = array(
- 'method' => 'POST',
- 'body' => '',
-);
-
-$overrides = array(
- 'tag' => 'form',
-);
-
-echo elgg_view('html/tag', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
$defaults = array(
'alt' => '',
'title' => '',
+ 'border' => 0,
);
-$overrides = array(
- 'tag' => 'img',
- 'body' => NULL,
-);
+$attributes = html5_get_html_attributes(array_merge($defaults, $vars));
-echo elgg_view('html/tag', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+echo "<img $attributes />";
\ No newline at end of file
+++ /dev/null
-<?php
-$defaults = array(
- 'type' => 'text',
-);
-
-$overrides = array(
- 'tag' => 'input',
-);
-
-$args = array_merge($defaults, $vars, $overrides);
-
-echo elgg_view('html/tag', $args);
\ No newline at end of file
+++ /dev/null
-<?php
-
-// remove all the junk that elgg_view throws into $vars
-
-unset($vars['config']);
-unset($vars['url']);
-unset($vars['page_owner']);
-unset($vars['page_owner_user']);
-foreach ($_SESSION as $key=>$value) {
- unset($vars[$key]);
-}
-
-// backwards compatibility code
-if (isset($vars['internalname'])) {
- //@todo put deprecated notice
- $vars['name'] = $vars['internalname'];
- unset($vars['internalname']);
-}
-
-if (isset($vars['internalid'])) {
- //@todo put deprecated notice
- $vars['id'] = $vars['internalid'];
- unset($vars['internalid']);
-}
-
-$js = '';
-if (isset($vars['js'])) {
- //@todo put deprecated notice
- $js = $vars['js'];
- unset($vars['js']);
-}
-
-$tag = $vars['tag'];
-unset($vars['tag']);
-
-$body = $vars['body'];
-unset($vars['body']);
-
-//Build the input
-$element = array();
-
-$element[] = "<$tag";
-foreach ($vars as $attr => $val) {
- if ($val === TRUE) {
- $element[] = $attr;
- } elseif (!empty($val)) {
- $val = htmlspecialchars($val);
- $element[] = "$attr=\"$val\"";
- }
-}
-
-if (!empty($js)) {
- $element[] = $js;
-}
-
-if (!isset($body)) {
- $element[] = '/';
-}
-
-echo implode(" ", $element).">";
-
-if (isset($body)) {
- echo "$body</$tag>";
-}
\ No newline at end of file
+++ /dev/null
-<?php
-$defaults = array(
- 'body' => '',
- 'class' => 'input-textarea',
-);
-
-$overrides = array(
- 'tag' => 'textarea',
-);
-
-if (isset($vars['value'])) {
- $vars['body'] = $vars['value'];
- unset($vars['value']);
-}
-
-echo elgg_view('html/tag', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
-<?php\r
-\r
-$overrides = array(\r
- 'type' => 'button',\r
-);\r
-\r
-$args = array_merge($vars, $overrides);\r
-\r
-echo elgg_view('html/input', $args);
\ No newline at end of file
+<input type="button" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
-<?php\r
-\r
-$overrides = array(\r
- 'type' => 'checkbox',\r
-);\r
-\r
-$args = array_merge($vars, $overrides);\r
-\r
-echo elgg_view('html/input', $args);
\ No newline at end of file
+<input type="checkbox" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
$defaults = array(
'class' => 'input-checkboxes',
- 'default' => 0,
'disabled' => FALSE,
);
-$args = array_merge($defaults, $vars);
+$vars = array_merge($defaults, $vars);
-$value_array = (is_array($args['value'])) ? array_map('strtolower', $args['value']) : array(strtolower($args['value']));
+$value = $vars['value'];
+unset($vars['value']);
-$options = $args['options'];
+$value_array = (is_array($value)) ? array_map('strtolower', $value) : array(strtolower($value));
+
+$options = $vars['options'];
+unset($vars['options']);
if ($options) {
- // include a default value so if nothing is checked 0 will be passed.
- if ($args['internalname']) {
- echo elgg_view('input/hidden', array('internalname' => $args['internalname'], 'value' => $args['default']));
- }
-
- foreach($options as $option => $label) {
- $opts = array(
- 'value' => $option,
- 'checked' => in_array(strtolower($option), $value_array),
- 'class' => $args['class'],
- 'disabled' => $args['disabled'],
- 'js' => $args['js'],
- 'internalname' => $args['internalname'].'[]',
- );
-
- echo "<label>".elgg_view('input/checkbox', $opts)."$label</label><br />";
+ foreach($options as $value => $label) {
+ echo "<label>";
+ echo elgg_view('input/checkbox', array_merge($vars, array(
+ 'value' => $value,
+ 'internalname' => $vars['internalname'].'[]',
+ 'checked' => in_array(strtolower($value), $value_array),
+ )));
+ echo "$label</label><br />";
}
}
\ No newline at end of file
-<?php\r
-\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:color'),\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'color',\r
-);\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="color" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
<?php\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:date'), //'yyyy-mm-dd',\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'date',\r
-);\r
-\r
if (isset($vars['value']) && is_int($vars['value'])) {\r
$vars['value'] = date("Y-m-d", $vars['value']);\r
}\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+?>\r
+<input type="date" <?php echo html5_get_html_attributes($vars); ?> />\r
<?php\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:datetime-local'), //'yyyy-mm-ddThh:mm:ss',\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'datetime-local',\r
-);\r
-\r
if (isset($vars['value']) && is_int($vars['value'])) {\r
$vars['value'] = date("Y-m-d\TH:i:s", $vars['value']);\r
}\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+?>\r
+<input type="datetime-local" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
<?php\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:datetime'), //'yyyy-mm-ddThh:mm:ss+hh:mm',\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'datetime',\r
-);\r
-\r
if (isset($vars['value']) && is_int($vars['value'])) {\r
$vars['value'] = date("c", $vars['value']);\r
}\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+?>\r
+<input type="datetime" <?php echo html5_get_html_attributes($vars); ?> />\r
+++ /dev/null
-<?php\r
-/**\r
- * Create an input field\r
- *\r
- * @package Elgg\r
- * @subpackage Core\r
- * @author Curverider Ltd\r
- * @link http://elgg.org/\r
- *\r
- * @uses $vars['internalname'] The name of the input field\r
- * @uses $vars['internalid'] The id of the input field\r
- * @deprecated $vars['js'] Use named attributes instead\r
- *\r
- * All other input attributes can be specified using their attribute name\r
- * including javascript event attributes such as onclick.\r
- */\r
-\r
-//@todo put deprecated notice\r
-echo elgg_view('html/input', $vars);
\ No newline at end of file
-<?php\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:email'),\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'email',\r
-);\r
-\r
-$args = array_merge($defaults, $vars, $overrides);\r
-\r
-echo elgg_view('html/input', $args);
\ No newline at end of file
+<input type="email" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
-<?php\r
-\r
-$defaults = array(\r
-\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'file',\r
-);\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="file" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
* @link http://elgg.org/
*
* @uses $vars['body'] The body of the form (made up of other input/xxx views and html
- * @uses $vars['method'] Method (default POST)
- * @uses $vars['enctype'] How the form is encoded, default blank
- * @uses $vars['action'] URL of the action being called
* @uses $vars['disable_security'] Force the securitytokens not to be added to this form (@todo what's the point??)
*
*/
+$defaults = array(
+ 'body' => '',
+ 'method' => 'POST',
+);
+
+$vars = array_merge($defaults, $vars);
if ($vars['disable_security'] != TRUE) {
- $vars['body'] .= elgg_view('input/securitytoken');
+ $body .= elgg_view('input/securitytoken');
}
-
unset($vars['disable_security']);
-echo elgg_view('html/form', $vars);
+$body = $vars['body'];
+unset($vars['body']);
+
+$attributes = html5_get_html_attributes($vars);
+
+echo "<form $attributes>$body</form>";
-<?php\r
-\r
-$defaults = array(\r
-\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'hidden',\r
-);\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="hidden" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
-<?php\r
-\r
-$defaults = array(\r
-\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'image',\r
-);\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="image" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'class' => 'input-richtext',
);
-echo elgg_view('html/textarea', array_merge($defaults, $vars));
\ No newline at end of file
+$value = $vars['value'];
+unset($vars['value']);
+
+$attributes = html5_get_html_attributes(array_merge($defaults, $vars));
+
+echo "<textarea $attributes>$value</textarea>";
\ No newline at end of file
<?php\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:month'),\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'month',\r
-);\r
-\r
if (isset($vars['value']) && is_int($vars['value'])) {\r
$vars['value'] = date("Y-m", $vars['value']);\r
}\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="month" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
-<?php\r
-\r
-$defaults = array(\r
-\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'number',\r
-);\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="number" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
<?php
-$defaults = array(
+$text = $vars['text'];
-);
-
-$overrides = array(
- 'tag' => 'option',
-);
-
-$args = array_merge($defaults, $vars, $overrides);
-
-if (!isset($args['body'])) {
- $args['body'] = $args['value'];
+if (!isset($text)) {
+ $text = $vars['value'];
+ unset($vars['value']);
}
-if (isset($args['body'])) {
- $args['body'] = htmlentities($args['body'], ENT_QUOTES, 'UTF-8');
-}
+$text = htmlentities($text, ENT_QUOTES, 'UTF-8');
+$attributes = html5_get_html_attributes($vars);
-echo elgg_view('html/tag', $args);
\ No newline at end of file
+echo "<option $attributes>$text</option>";
\ No newline at end of file
-<?php\r
-\r
-$defaults = array(\r
- 'placeholder' => elgg_echo('placeholder:password'),\r
-);\r
-\r
-$overrides = array(\r
- 'type' => 'password',\r
-);\r
-\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="password" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
<?php
/**
- *
+ * Elgg long text input
+ * Displays a long text input field
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ *
*/
-echo elgg_view('html/textarea', $vars);
\ No newline at end of file
+$defaults = array(
+ 'class' => 'input-plaintext',
+);
+
+$value = $vars['value'];
+unset($vars['value']);
+
+$attributes = html5_get_html_attributes(array_merge($defaults, $vars));
+
+echo "<textarea $attributes>$value</textarea>";
\ No newline at end of file
* @author Curverider Ltd
* @link http://elgg.org/
*
- * @uses $vars['value'] The current value, if any
- * @uses $vars['js'] Any Javascript to enter into the input tag
- * @uses $vars['internalname'] The name of the input field
* @uses $vars['options'] An array of strings representing the options for the pulldown field
* @uses $vars['options_values'] An associative array of "value" => "option" where "value" is an internal name and "option" is
* the value displayed on the button. Replaces $vars['options'] when defined.
'class' => 'input-pulldown',
);
-$overrides = array(
- 'tag' => 'select',
-);
+$vars = array_merge($defaults, $vars);
+
+$options_values = $vars['options_values'];
+unset($vars['options_values']);
-$args = array_merge($defaults, $vars, $overrides);
+$options = $vars['options'];
+unset($options);
-$body = '';
+$value = $vars['value'];
+unset($vars['value']);
+?>
-if ($vars['options_values']) {
- foreach($vars['options_values'] as $value => $option) {
- $option_args = array(
- 'value' => $value,
- 'body' => $option,
- 'selected' => ($value == $args['value']),
- );
-
- $body .= elgg_view('input/option', $option_args);
+<select <?php echo html5_get_html_attributes($vars); ?>>
+<?php
+if ($options_values) {
+ foreach($options_values as $opt_val => $opt_text) {
+ echo elgg_view('input/option', array(
+ 'value' => $opt_val,
+ 'text' => $opt_text,
+ 'selected' => ($opt_val == $value),
+ ));
}
} else {
- foreach($vars['options'] as $option) {
- $option_args = array(
- 'body' => $option,
- 'selected' => ($option == $args['value']),
- );
-
- $body .= elgg_view('input/option', $option_args);
+ foreach($options as $option) {
+ echo elgg_view('input/option', array(
+ 'text' => $option,
+ 'selected' => ($option == $value),
+ ));
}
}
-
-$args['body'] = $body;
-
-echo elgg_view('html/tag', $args);
+?>
+</select>
\ No newline at end of file
\r
);\r
\r
-$overrides = array(\r
- 'type' => 'range',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="range" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'value' => elgg_echo('reset'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'reset',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="reset" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'placeholder' => elgg_echo('placeholder:search'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'search',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="search" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'value' => elgg_echo('submit'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'submit',\r
-);\r
-\r
-$args = array_merge($vars, $overrides);\r
+$vars = array_merge($defaults, $vars); \r
+?>\r
\r
-echo elgg_view('html/input', $args);
\ No newline at end of file
+<input type="submit" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
* @link http://elgg.org/
*
* @uses $vars['value'] The current value, if any - string or array - tags will be encoded
- * @uses $vars['js'] Any Javascript to enter into the input tag
- * @uses $vars['internalname'] The name of the input field
- * @uses $vars['internalid'] The id of the input field
- * @uses $vars['class'] CSS class override
- * @uses $vars['disabled'] Is the input field disabled?
*/
-
$defaults = array(
'class' => 'input-tags',
'placeholder' => elgg_echo('placeholder:tags'),
<?php\r
-\r
$defaults = array(\r
'placeholder' => elgg_echo('placeholder:tel'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'tel',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="tel" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'placeholder' => elgg_echo('placeholder:text'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'text',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="text" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'placeholder' => elgg_echo('placeholder:time'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'time',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="time" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'placeholder' => elgg_echo('placeholder:url'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'url',\r
-);\r
-\r
-$args = array_merge($vars, $overrides);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', $args);
\ No newline at end of file
+<input type="url" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file
'placeholder' => elgg_echo('placeholder:week'),\r
);\r
\r
-$overrides = array(\r
- 'type' => 'week',\r
-);\r
+$vars = array_merge($defaults, $vars);\r
+?>\r
\r
-echo elgg_view('html/input', array_merge($defaults, $vars, $overrides));
\ No newline at end of file
+<input type="week" <?php echo html5_get_html_attributes($vars); ?> />
\ No newline at end of file