aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/default.php
diff options
context:
space:
mode:
authorEvan Winslow <evan.b.winslow@gmail.com>2010-07-01 21:47:11 +0000
committerEvan Winslow <evan.b.winslow@gmail.com>2010-07-01 21:47:11 +0000
commit6bfbc7e58ba48a186d1ea9048aa949d5ebb4ffd6 (patch)
treee02b35506996665a43bbb51da7ae8f3bb2c5434d /views/default/input/default.php
parent194d3592d7359438d4ef71febba410b0c231b5d4 (diff)
downloadelgg-6bfbc7e58ba48a186d1ea9048aa949d5ebb4ffd6.tar.gz
elgg-6bfbc7e58ba48a186d1ea9048aa949d5ebb4ffd6.tar.bz2
Added all valid html5 input types
Diffstat (limited to 'views/default/input/default.php')
-rw-r--r--views/default/input/default.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/views/default/input/default.php b/views/default/input/default.php
new file mode 100644
index 000000000..59ad357e7
--- /dev/null
+++ b/views/default/input/default.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Create an input field
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ *
+ * @uses $vars['internalname'] The name of the input field
+ * @uses $vars['internalid'] The id of the input field
+ * @deprecated $vars['js'] Use named attributes instead
+ *
+ * All other input attributes can be specified using their attribute name
+ * including javascript event attributes such as onclick.
+ */
+
+// 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'])) {
+ $vars['name'] = $vars['internalname'];
+ unset($vars['internalname']);
+}
+
+if (isset($vars['internalid'])) {
+ $vars['id'] = $vars['internalid'];
+ unset($vars['internalid']);
+}
+
+$js = '';
+if (isset($vars['js'])) {
+ $js = $vars['js'];
+ unset($vars['js']);
+}
+
+// default attributes
+$defaults = array(
+ 'type' => 'text',
+ 'value' => '',
+);
+
+$attributes = array_merge($defaults, $vars);
+
+$attributes['value'] = htmlspecialchars($attributes['value'], ENT_QUOTES, 'UTF-8');
+
+
+//Build the input
+$element = array();
+
+$element[] = "<input";
+foreach ($attributes as $attr => $val) {
+ if ($val === TRUE) {
+ $element[] = $attr;
+ } elseif ($val !== FALSE) {
+ $val = addslashes($val);
+ $element[] = "$attr=\"$val\"";
+ }
+}
+$element[] = $js;
+$element[] = "/>";
+
+echo implode(" ", $tag); \ No newline at end of file