Version 1.8.0
(??? from http://code.elgg.org/branches/1.8/)
- API changes:
+ User-visible changes:
+
+ Generic API changes:
* Added elgg_instanceof().
- UI/UX
+ UI/UX API changes:
* Added elgg_push_breadcrumb(), elgg_pop_breadcrumb(), and elgg_get_breadcrumbs().
* Added navigation/breadcrumbs.
+ * Added sticky form support with elgg_make_sticky_form(),
+ elgg_clear_sticky_form(), elgg_is_sticky_form(), and elgg_get_sticky_value().
}
+/**
+ * Sticky forms
+ */
+
+/**
+ * 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
+ */
+function elgg_make_sticky_form() {
+ elgg_clear_sticky_form();
+
+ $_SESSION['sticky_form'] = array();
+
+ foreach($_REQUEST as $key => $var) {
+ // will go through XSS filtering on the get function
+ $_SESSION['sticky_form'][$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.
+ */
+function elgg_clear_sticky_form() {
+ unset($_SESSION['sticky_form']);
+}
+
+/**
+ * Has this form been made sticky
+ *
+ * @return boolean
+ */
+function elgg_is_sticky_form() {
+ return isset($_SESSION['sticky_form']);
+}
+
+/**
+ * Get a specific stick variable
+ *
+ * @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?
+ */
+function elgg_get_sticky_value($variable, $default = "", $filter_result = true) {
+ if (isset($_SESSION['sticky_form'][$variable])) {
+ $value = $_SESSION['sticky_form'][$variable];
+ if ($filter_result) {
+ // XSS filter result
+ $value = filter_tags($value);
+ }
+ return $value;
+ }
+ return $default;
+}
+
+/**
+ * Clear a specific sticky variable
+ *
+ * @param string $variable The name of the variable to clear
+ */
+function elgg_clear_sticky_value($variable) {
+ unset($_SESSION['sticky_form'][$variable]);
+}
+
+
/**
* Returns the PHP INI setting in bytes
*
/**
* Elgg long text input with the tinymce text editor intacts
* Displays a long text input field
- *
+ *
* @package ElggTinyMCE
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008-2010
* @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
- *
+ *
*/
global $tinymce_js_loaded;
-
+
+ if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+ }
+
$input = rand(0,9999);
-
+
if (!isset($tinymce_js_loaded)) $tinymce_js_loaded = false;
if (!$tinymce_js_loaded) {
-
+
?>
<!-- include tinymce -->
<script language="javascript" type="text/javascript" src="<?php echo $vars['url']; ?>mod/tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<!-- intialise tinymce, you can find other configurations here http://wiki.moxiecode.com/examples/tinymce/installation_example_01.php -->
<script language="javascript" type="text/javascript">
- tinyMCE.init({
+tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "safari,spellchecker,autosave,fullscreen,preview,paste",
theme_advanced_path : true,
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
setup : function(ed) {
- // Add a custom button
- //ed.addButton('more', {
- // title : 'more',
- // image : '<?php echo $vars['url']; ?>mod/tinymce/graphics/more.gif',
- // onclick : function() {
- // ed.selection.setContent('{{more}}');
- // }
- //});
-
- //show the number of words
+ // Add a custom button
+ //ed.addButton('more', {
+ // title : 'more',
+ // image : '<?php echo $vars['url']; ?>mod/tinymce/graphics/more.gif',
+ // onclick : function() {
+ // ed.selection.setContent('{{more}}');
+ // }
+ //});
+
+ //show the number of words
ed.onLoadContent.add(function(ed, o) {
var strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,"");
var text = " Word count:" + strip.split(' ').length;
tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);
});
-
+
ed.onKeyUp.add(function(ed, e) {
var strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,"");
var text = " Word count:" + strip.split(' ').length;
tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);
});
- }
+ }
});
function toggleEditor(id) {
if (!tinyMCE.get(id))
?>
<!-- show the textarea -->
-<textarea class="input_textarea" name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], null, 'UTF-8'); ?></textarea>
+<textarea class="input_textarea" name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], null, 'UTF-8'); ?></textarea>
<div class="toggle_editor_container"><a class="toggle_editor" href="javascript:toggleEditor('<?php echo $vars['internalname']; ?>');"><?php echo elgg_echo('tinymce:remove'); ?></a></div>
<script type="text/javascript">
$vars['value'] = get_default_access();
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
if ((!isset($vars['options'])) || (!is_array($vars['options']))) {
$vars['options'] = array();
$strippedname = sanitise_string($vars['internalname']);
$js = "cal" . $strippedname;
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
if ($vars['value'] > 86400) {
$val = date("F j, Y",$vars['value']);
} else {
$class = "input_checkboxes";
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
foreach($vars['options'] as $label => $option) {
//if (!in_array($option,$vars['value'])) {
if (is_array($vars['value'])) {
if (!$class) {
$class = "input_text";
}
+
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
?>
<input type="text" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?>value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>"/>
\ No newline at end of file
* @uses $vars['internalname'] The name of the input field
*
*/
+
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
?>
<input type="hidden" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" />
\ No newline at end of file
$disabled = $vars['disabled'];
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
$value = '';
if (isset($vars['value'])) {
$value = $vars['value'];
$class = "input_textarea";
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
?>
<textarea class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?></textarea>
\ No newline at end of file
$class = "input_pulldown";
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
?>
<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
$class = "input_radio";
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
foreach($vars['options'] as $label => $option) {
if (strtolower($option) != strtolower($vars['value'])) {
$selected = "";
$disabled = $vars['disabled'];
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
$tags = "";
if (!empty($vars['value'])) {
if (is_array($vars['value'])) {
$disabled = $vars['disabled'];
}
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
+$value = htmlentities($vars['value'], ENT_QUOTES, 'UTF-8');
+
?>
-<input type="text" <?php if ($disabled) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/>
\ No newline at end of file
+<input type="text" <?php if ($disabled) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo $value; ?>" class="<?php echo $class ?>"/>
\ No newline at end of file
if (!$class) {
$class = "input_url";
}
+
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
?>
<input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>"/>
\ No newline at end of file
global $user_picker_js_sent;
+if (!isset($vars['value']) || $vars['value'] === FALSE) {
+ $vars['value'] = elgg_get_sticky_value($vars['internalname']);
+}
+
if (!$user_picker_js_sent) {
?>
<!-- User picker JS -->