]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
moved sticky forms into the input library
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 7 Feb 2011 01:43:55 +0000 (01:43 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 7 Feb 2011 01:43:55 +0000 (01:43 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8055 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php
engine/lib/input.php

index de2d9bcddfafca9f96a06e44ef7560ab046528cf..cd746b3d8b7380bbad31276c6ca8cd0bcac715b4 100644 (file)
@@ -1329,7 +1329,7 @@ function elgg_http_add_url_query_elements($url, array $elements) {
  * @param string $url2          Second URL
  * @param array  $ignore_params GET params to ignore in the comparison
  *
- * @return BOOL
+ * @return bool
  * @since 1.8.0
  */
 function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset', 'limit')) {
@@ -1417,130 +1417,6 @@ function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset
        return TRUE;
 }
 
-/**
- * Load all the REQUEST variables into the sticky form cache
- *
- * Call this from an action when you want all your submitted variables
- * available if the submission fails validation and is sent back to the form
- *
- * @param string $form_name Name of the sticky form
- *
- * @return void
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_make_sticky_form($form_name = 'default') {
-
-       elgg_clear_sticky_form($form_name);
-
-       if (!isset($_SESSION['sticky_forms'])) {
-               $_SESSION['sticky_forms'] = array();
-       }
-       $_SESSION['sticky_forms'][$form_name] = array();
-
-       foreach ($_REQUEST as $key => $var) {
-               // will go through XSS filtering on the get function
-               $_SESSION['sticky_forms'][$form_name][$key] = $var;
-       }
-}
-
-/**
- * Clear the sticky form cache
- *
- * Call this if validation is successful in the action handler or
- * when they sticky values have been used to repopulate the form
- * after a validation error.
- *
- * @param string $form_name Form namespace
- *
- * @return void
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_clear_sticky_form($form_name) {
-       unset($_SESSION['sticky_forms'][$form_name]);
-}
-
-/**
- * Has this form been made sticky?
- *
- * @param string $form_name Form namespace
- *
- * @return boolean
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_is_sticky_form($form_name) {
-       return isset($_SESSION['sticky_forms'][$form_name]);
-}
-
-/**
- * Get a specific sticky variable
- *
- * @param string  $form_name     The name of the form
- * @param string  $variable      The name of the variable
- * @param mixed   $default       Default value if the variable does not exist in sticky cache
- * @param boolean $filter_result Filter for bad input if true
- *
- * @return mixed
- *
- * @todo should this filter the default value?
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_get_sticky_value($form_name, $variable = '', $default = NULL, $filter_result = true) {
-       if (isset($_SESSION['sticky_forms'][$form_name][$variable])) {
-               $value = $_SESSION['sticky_forms'][$form_name][$variable];
-               if ($filter_result) {
-                       // XSS filter result
-                       $value = filter_tags($value);
-               }
-               return $value;
-       }
-       return $default;
-}
-
-/**
- * Clear a specific sticky variable
- *
- * @param string $form_name The name of the form
- * @param string $variable  The name of the variable to clear
- *
- * @return void
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_clear_sticky_value($form_name, $variable) {
-       unset($_SESSION['sticky_forms'][$form_name][$variable]);
-}
-
-/**
- * Returns the current active sticky form.
- *
- * @return mixed Str | FALSE
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_get_active_sticky_form() {
-       global $CONFIG;
-
-       if (isset($CONFIG->active_sticky_form)) {
-               $form_name = $CONFIG->active_sticky_form;
-       } else {
-               return FALSE;
-       }
-
-       return (elgg_is_sticky_form($form_name)) ? $form_name : FALSE;
-}
-
-/**
- * Sets the active sticky form.
- *
- * @param string $form_name The name of the form
- *
- * @return void
- * @link http://docs.elgg.org/Tutorials/UI/StickyForms
- */
-function elgg_set_active_sticky_form($form_name) {
-       global $CONFIG;
-
-       $CONFIG->active_sticky_form = $form_name;
-}
-
 /**
  * Checks for $array[$key] and returns its value if it exists, else
  * returns $default.
index 5ec34787732aa8e84d0212a061841845be5a6eb4..b5bf4eea59395724a013586cdc7c860fcd33ab9b 100644 (file)
@@ -97,6 +97,103 @@ function is_email_address($address) {
        return filter_var($address, FILTER_VALIDATE_EMAIL) === $address;
 }
 
+/**
+ * Load all the REQUEST variables into the sticky form cache
+ *
+ * Call this from an action when you want all your submitted variables
+ * available if the submission fails validation and is sent back to the form
+ *
+ * @param string $form_name Name of the sticky form
+ *
+ * @return void
+ * @link http://docs.elgg.org/Tutorials/UI/StickyForms
+ * @since 1.8.0
+ */
+function elgg_make_sticky_form($form_name) {
+
+       elgg_clear_sticky_form($form_name);
+
+       if (!isset($_SESSION['sticky_forms'])) {
+               $_SESSION['sticky_forms'] = array();
+       }
+       $_SESSION['sticky_forms'][$form_name] = array();
+
+       foreach ($_REQUEST as $key => $var) {
+               // will go through XSS filtering on the get function
+               $_SESSION['sticky_forms'][$form_name][$key] = $var;
+       }
+}
+
+/**
+ * Clear the sticky form cache
+ *
+ * Call this if validation is successful in the action handler or
+ * when they sticky values have been used to repopulate the form
+ * after a validation error.
+ *
+ * @param string $form_name Form namespace
+ *
+ * @return void
+ * @link http://docs.elgg.org/Tutorials/UI/StickyForms
+ * @since 1.8.0
+ */
+function elgg_clear_sticky_form($form_name) {
+       unset($_SESSION['sticky_forms'][$form_name]);
+}
+
+/**
+ * Has this form been made sticky?
+ *
+ * @param string $form_name Form namespace
+ *
+ * @return boolean
+ * @link http://docs.elgg.org/Tutorials/UI/StickyForms
+ * @since 1.8.0
+ */
+function elgg_is_sticky_form($form_name) {
+       return isset($_SESSION['sticky_forms'][$form_name]);
+}
+
+/**
+ * Get a specific sticky variable
+ *
+ * @param string  $form_name     The name of the form
+ * @param string  $variable      The name of the variable
+ * @param mixed   $default       Default value if the variable does not exist in sticky cache
+ * @param boolean $filter_result Filter for bad input if true
+ *
+ * @return mixed
+ *
+ * @todo should this filter the default value?
+ * @link http://docs.elgg.org/Tutorials/UI/StickyForms
+ * @since 1.8.0
+ */
+function elgg_get_sticky_value($form_name, $variable = '', $default = NULL, $filter_result = true) {
+       if (isset($_SESSION['sticky_forms'][$form_name][$variable])) {
+               $value = $_SESSION['sticky_forms'][$form_name][$variable];
+               if ($filter_result) {
+                       // XSS filter result
+                       $value = filter_tags($value);
+               }
+               return $value;
+       }
+       return $default;
+}
+
+/**
+ * Clear a specific sticky variable
+ *
+ * @param string $form_name The name of the form
+ * @param string $variable  The name of the variable to clear
+ *
+ * @return void
+ * @link http://docs.elgg.org/Tutorials/UI/StickyForms
+ * @since 1.8.0
+ */
+function elgg_clear_sticky_value($form_name, $variable) {
+       unset($_SESSION['sticky_forms'][$form_name][$variable]);
+}
+
 /**
  * Page handler for autocomplete endpoint.
  *