]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #3239 added a new sticky forms function to grab all variables and integrated...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 12:47:14 +0000 (12:47 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 12:47:14 +0000 (12:47 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8836 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/input.php
mod/blog/lib/blog.php

index c3fabbe5dbab796ca870add9f2f4676fc7264b93..25416b8689c955af0bf3775a889dc4889eac9225 100644 (file)
@@ -180,6 +180,30 @@ function elgg_get_sticky_value($form_name, $variable = '', $default = NULL, $fil
        return $default;
 }
 
+/**
+ * Get all the values in a sticky form in an array
+ *
+ * @param string $form_name    The name of the form
+ * @param bool $filter_result  Filter for bad input if true
+ *
+ * @return array
+ * @since 1.8.0
+ */
+function elgg_get_sticky_values($form_name, $filter_result = true) {
+       if (!isset($_SESSION['sticky_forms'][$form_name])) {
+               return array();
+       }
+
+       $values = $_SESSION['sticky_forms'][$form_name];
+       if ($filter_result) {
+               foreach ($values as $key => $value) {
+                       // XSS filter result
+                       $values[$key] = filter_tags($value);
+               }
+       }
+       return $values;
+}
+
 /**
  * Clear a specific sticky variable
  *
index e5a44a2009beb451d1091964682a611efd7bbb1e..512f8f6d5de6aedc3ac276f1912b8904cf5d0f24 100644 (file)
@@ -248,6 +248,8 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) {
  */
 function blog_get_page_content_edit($page, $guid = 0, $revision = NULL) {
 
+       elgg_load_js('elgg.blog');
+
        $return = array(
                'buttons' => '',
                'filter' => '',
@@ -338,24 +340,27 @@ function blog_prepare_form_vars($post = NULL, $revision = NULL) {
                'draft_warning' => '',
        );
 
-       if (elgg_is_sticky_form('blog')) {
+       if ($post) {
                foreach (array_keys($values) as $field) {
-                       $values[$field] = elgg_get_sticky_value('blog', $field);
+                       if (isset($post->$field)) {
+                               $values[$field] = $post->$field;
+                       }
                }
        }
 
+       if (elgg_is_sticky_form('blog')) {
+               $sticky_values = elgg_get_sticky_values('blog');
+               foreach ($sticky_values as $key => $value) {
+                       $values[$key] = $value;
+               }
+       }
+       
        elgg_clear_sticky_form('blog');
 
        if (!$post) {
                return $values;
        }
 
-       foreach (array_keys($values) as $field) {
-               $values[$field] = $post->$field;
-       }
-
-       $values['entity'] = $post;
-
        // load the revision annotation if requested
        if ($revision instanceof ElggAnnotation && $revision->entity_guid == $post->getGUID()) {
                $values['revision'] = $revision;