<?php $params = elgg_clean_vars($vars); echo hj_framework_view_form('edit:object:hjforumpost', $params);
/** * Converts an associative array into a string of well-formed attributes * * @note usually for HTML, but could be useful for XML too... * * @param array $attrs An associative array of attr => val pairs * * @return string HTML attributes to be inserted into a tag (e.g., <tag $attrs>) */ function elgg_format_attributes(array $attrs) { $attrs = elgg_clean_vars($attrs); $attributes = array(); if (isset($attrs['js'])) { //@todo deprecated notice? if (!empty($attrs['js'])) { $attributes[] = $attrs['js']; } unset($attrs['js']); } foreach ($attrs as $attr => $val) { $attr = strtolower($attr); if ($val === TRUE) { $val = $attr; //e.g. checked => TRUE ==> checked="checked" } // ignore $vars['entity'] => ElggEntity stuff if ($val !== NULL && $val !== false && (is_array($val) || !is_object($val))) { // allow $vars['class'] => array('one', 'two'); // @todo what about $vars['style']? Needs to be semi-colon separated... if (is_array($val)) { $val = implode(' ', $val); } $val = htmlspecialchars($val, ENT_QUOTES, 'UTF-8', false); $attributes[] = "{$attr}=\"{$val}\""; } } return implode(' ', $attributes); }
* Tab navigation * * @uses string $vars['type'] horizontal || vertical - Defaults to horizontal * @uses string $vars['class'] Additional class to add to ul * @uses array $vars['tabs'] A multi-dimensional array of tab entries in the format array( * 'text' => string, // The string between the <a></a> tags * 'href' => string, // URL for the link * 'class' => string // Class of the li element * 'id' => string, // ID of the li element * 'selected' => bool // if this tab is currently selected (applied to li element) * 'link_class' => string, // Class to pass to the link * 'link_id' => string, // ID to pass to the link * ) */ $vars['class'] = "nav nav-tabs"; $options = elgg_clean_vars($vars); $type = elgg_extract('type', $vars, 'horizontal'); if ($type == 'horizontal') { $options['class'] = "elgg-tabs elgg-htabs"; } else { $options['class'] = "elgg-tabs elgg-vtabs"; } if (isset($vars['class'])) { $options['class'] = "{$options['class']} {$vars['class']}"; } unset($options['tabs']); unset($options['type']); $attributes = elgg_format_attributes($options); if (isset($vars['tabs']) && is_array($vars['tabs']) && !empty($vars['tabs'])) { ?> <ul <?php
<?php /** * Elgg Input Hint View * * @uses $vars['hint'] Hint options */ if (!isset($vars['text'])) { return true; } $vars['title'] = $text = $vars['text']; unset($vars['text']); //$text = elgg_view_icon('info'); if (isset($vars['class'])) { $vars['class'] = "elgg-text-help elgg-input-hint {$vars['class']}"; } else { $vars['class'] = "elgg-text-help elgg-input-hint"; } echo '<span ' . elgg_format_attributes(elgg_clean_vars($vars)) . '>' . $text . '</span>';
/** * Unset values from vars * @param array $vars * @return array */ function hj_framework_clean_vars($vars) { if (!is_array($vars)) { return $vars; } $vars = elgg_clean_vars($vars); $clean = array('entity_guid', 'subject_guid', 'container_guid', 'owner_guid', 'form_guid', 'widget_guid', 'subtype', 'context', 'handler', 'event', 'form_name'); foreach ($clean as $key) { unset($vars[$key]); } return $vars; }
<?php $system_messages = $vars['sysmessages']; unset($vars['sysmessages']); $output = elgg_clean_vars($vars); function hj_framework_decode_xhr_view_outputs($val) { if (is_array($val)) { foreach ($val as $k => $v) { $output[$k] = hj_framework_decode_xhr_view_outputs($v); } } else { if (is_string($val) && ($json = json_decode($val, true))) { if (is_array($json)) { $output = hj_framework_decode_xhr_view_outputs($json); } else { $output = $json; } } else { $output = $val; } } return $output; } $output = hj_framework_decode_xhr_view_outputs($output); $js = elgg_get_loaded_js(); $js_foot = elgg_get_loaded_js('footer'); $js = array_merge($js, $js_foot); $css = elgg_get_loaded_css(); $resources = array('js' => array(), 'css' => array()); /** @hack Prevent js/css from loading again if cached in default viewtype * */
/** * Converts an associative array into a string of well-formed attributes * * @note usually for HTML, but could be useful for XML too... * * @param array $attrs An associative array of attr => val pairs * * @return string HTML attributes to be inserted into a tag (e.g., <tag $attrs>) */ function elgg_format_attributes(array $attrs = array()) { if (!is_array($attrs) || !count($attrs)) { return ''; } $attrs = elgg_clean_vars($attrs); $attributes = array(); if (isset($attrs['js'])) { elgg_deprecated_notice('Use associative array of attr => val pairs instead of $vars[\'js\']', 1.8); if (!empty($attrs['js'])) { $attributes[] = $attrs['js']; } unset($attrs['js']); } foreach ($attrs as $attr => $val) { $attr = strtolower($attr); if ($val === TRUE) { $val = $attr; //e.g. checked => TRUE ==> checked="checked" } /** * Ignore non-array values and allow attribute values to be an array * <code> * $attrs = array( * 'entity' => <ElggObject>, // will be ignored * 'class' => array('elgg-input', 'elgg-input-text'), // will be imploded with spaces * 'style' => array('margin-left:10px;', 'color: #666;'), // will be imploded with spaces * 'alt' => 'Alt text', // will be left as is * ); * </code> */ if ($val !== NULL && $val !== false && (is_array($val) || !is_object($val))) { if (is_array($val)) { $val = implode(' ', $val); } $val = htmlspecialchars($val, ENT_QUOTES, 'UTF-8', false); $attributes[] = "{$attr}=\"{$val}\""; } } return implode(' ', $attributes); }
switch ($endpoint) { default: case 'pageshell': // output an entire page without encoding its elements return false; break; case 'content': // output only page content echo json_encode(array('content' => $vars['content'])); break; case 'layout': // output encoded layout $vars['nav'] = elgg_extract('nav', $vars, elgg_view('navigation/breadcrumbs')); $vars['sidebar'] = elgg_view('page/elements/sidebar', $vars); $vars['sidebar_alt'] = elgg_view('page/elements/sidebar_alt', $vars); echo json_encode(elgg_clean_vars($vars)); break; case 'list': // output encoded contents of a specific list by its id global $XHR_GLOBAL; $list_id = get_input('list_id', false); if ($list_id) { $output['lists'][$list_id] = $XHR_GLOBAL['lists'][$list_id]; } echo json_encode($output); break; case 'xhr_global': // output encoded contents of a global xhr variable global $XHR_GLOBAL; echo json_encode($XHR_GLOBAL); break;
<?php $vars['rel'] = 'placeholder'; $attributes = elgg_format_attributes(elgg_clean_vars($vars)); $item_view = elgg_echo("hj:framework:list:empty"); $colspan = $vars['colspan'] > 1 ? "colspan={$vars['colspan']}" : ''; echo "<tr {$attributes}><td {$colspan}>{$item_view}</td></tr>";