Ejemplo n.º 1
0
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['value']    The current value, if any - will be html encoded
 * @uses $vars['disabled'] Is the input field disabled?
 * @uses $vars['class']    Additional CSS class
 * @uses $vars['visual']   Activate WYSIWYG editor immediately
 *                         If disabled, will display a plaintext input with
 *                         a link to activate the visual editor
 * @uses $vars['editor']         Enable WYSIWYG support
 *                               Requires a plugin that implements a WYWIWYG library
 *                               (e.g. bundled ckeditor plugin)
 * @uses $vars['editor_type']    The type of editor eg. 'simple'. It determines the style of the editor (if supported).
 * @uses $vars['editor_options'] Additional options to pass to the editor
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-longtext');
$defaults = array('value' => '', 'rows' => '10', 'cols' => '50', 'id' => "elgg-input-" . base_convert(mt_rand(), 10, 36));
$vars = array_merge($defaults, $vars);
$editor_opts = (array) elgg_extract('editor_options', $vars, []);
$editor_opts['disabled'] = !elgg_extract('editor', $vars, true);
$editor_opts['state'] = elgg_extract('visual', $vars, true) ? 'visual' : 'html';
unset($vars['editor']);
unset($vars['editor_options']);
unset($vars['editor_type']);
unset($vars['visual']);
$vars['data-editor-opts'] = json_encode($editor_opts);
$value = htmlspecialchars($vars['value'], ENT_QUOTES, 'UTF-8');
unset($vars['value']);
echo elgg_view_menu('longtext', array('sort_by' => 'priority', 'class' => 'elgg-menu-hz', 'id' => $vars['id']));
echo elgg_format_element('textarea', $vars, $value);
Ejemplo n.º 2
0
Archivo: date.php Proyecto: elgg/elgg
 * Displays a text field with a popup date picker.
 *
 * The elgg.ui JavaScript library initializes the jQueryUI datepicker based
 * on the CSS class .elgg-input-date. It uses the ISO 8601 standard for date
 * representation: yyyy-mm-dd.
 *
 * Unix timestamps are supported by setting the 'timestamp' parameter to true.
 * The date is still displayed to the user in a text format but is submitted as
 * a unix timestamp in seconds.
 *
 * @uses $vars['value']     The current value, if any (as a unix timestamp)
 * @uses $vars['class']     Additional CSS class
 * @uses $vars['timestamp'] Store as a Unix timestamp in seconds. Default = false
 * @uses $vars['datepicker_options'] An array of options to pass to the jQuery UI datepicker
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-date');
$defaults = array('value' => '', 'disabled' => false, 'timestamp' => false, 'type' => 'text');
$vars = array_merge($defaults, $vars);
$timestamp = $vars['timestamp'];
unset($vars['timestamp']);
if ($timestamp) {
    if (!isset($vars['id'])) {
        $vars['id'] = $vars['name'];
    }
    echo elgg_view('input/hidden', ['name' => $vars['name'], 'value' => $vars['value'], 'rel' => $vars['id']]);
    $vars['class'][] = 'elgg-input-timestamp';
    unset($vars['name']);
}
// convert timestamps to text for display
if (is_numeric($vars['value'])) {
    $vars['value'] = gmdate('Y-m-d', $vars['value']);
Ejemplo n.º 3
0
Archivo: tag.php Proyecto: elgg/elgg
<?php

/**
 * Elgg tag input
 *
 * Accepts a single tag value
 *
 * @uses $vars['value'] The default value for the tag
 * @uses $vars['class'] Additional CSS class
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-tag');
$defaults = array('value' => '', 'disabled' => false, 'autocapitalize' => 'off', 'type' => 'text');
$vars = array_merge($defaults, $vars);
echo elgg_format_element('input', $vars);
Ejemplo n.º 4
0
Archivo: form.php Proyecto: elgg/elgg
<?php

/**
 * Create a form for data submission.
 * Use this view for forms as it provides protection against CSRF attacks.
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['body'] The body of the form (made up of other input/xxx views and html
 * @uses $vars['action'] The action URL of the form
 * @uses $vars['action_name'] The name of the action (for targeting particular forms while extending)
 * @uses $vars['method'] The submit method: post (default) or get
 * @uses $vars['enctype'] Set to 'multipart/form-data' if uploading a file
 * @uses $vars['disable_security'] turn off CSRF security by setting to true
 * @uses $vars['class'] Additional class for the form
 */
$defaults = array('method' => 'post', 'disable_security' => FALSE);
$vars = array_merge($defaults, $vars);
$vars['class'] = elgg_extract_class($vars, 'elgg-form');
$vars['action'] = elgg_normalize_url($vars['action']);
$vars['method'] = strtolower($vars['method']);
$body = $vars['body'];
unset($vars['body']);
// Generate a security header
if (!$vars['disable_security']) {
    $body = elgg_view('input/securitytoken') . $body;
}
unset($vars['disable_security']);
unset($vars['action_name']);
echo elgg_format_element('form', $vars, "<fieldset>{$body}</fieldset>");
Ejemplo n.º 5
0
Archivo: email.php Proyecto: elgg/elgg
<?php

/**
 * Elgg email input
 * Displays an email input field
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['class'] Additional CSS class
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-email');
$defaults = array('disabled' => false, 'autocapitalize' => 'off', 'autocorrect' => 'off', 'type' => 'email');
$vars = array_merge($defaults, $vars);
echo elgg_format_element('input', $vars);
Ejemplo n.º 6
0
Archivo: button.php Proyecto: elgg/elgg
<?php

/**
 * Renders a <button>
 *
 * @uses $vars['type']  Button type (submit|reset|image)
 * @uses $vars['class'] Additional CSS class
 * @uses $vars['text']  Text to include between <button> tags
 * @uses $vars['icon']  Optional icon name
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-button');
if (!isset($vars['text']) && isset($vars['value'])) {
    // Keeping this to ease the transition to 3.0
    $vars['text'] = $vars['value'];
}
$type = elgg_extract('type', $vars, 'button', false);
$vars['type'] = $type;
$text = elgg_extract('text', $vars);
unset($vars['text']);
$text = elgg_format_element('span', ['class' => 'elgg-button-label'], $text);
$icon = elgg_extract('icon', $vars, '');
unset($vars['icon']);
if ($icon && !preg_match('/^</', $icon)) {
    $icon = elgg_view_icon($icon, ['class' => 'elgg-button-icon']);
}
switch ($type) {
    case 'submit':
        $vars['class'][] = 'elgg-button-submit';
        break;
    case 'reset':
        $vars['class'][] = 'elgg-button-cancel';
Ejemplo n.º 7
0
Archivo: error.php Proyecto: elgg/elgg
<?php

/**
 * Error layout
 *
 * @uses $vars['content'] Main content area
 * @uses $vars['title']   Optional title string
 * @uses $vars['class']   Additional class for the layout
 */
$class = elgg_extract_class($vars, ['elgg-layout', 'elgg-layout-one-column', 'clearfix']);
unset($vars['class']);
$vars['breadcrumbs'] = false;
$body = elgg_view('page/layouts/elements/body', $vars);
echo elgg_format_element('div', ['class' => $class], $body);
Ejemplo n.º 8
0
<?php

/**
 * Displays HTML, with new lines converted to line breaks
 *
 * @uses $vars['value'] HTML to display
 * @uses $vars['class']
 * @uses $vars['parse_urls'] Turn urls into links? Default is true.
 * @uses $vars['parse_emails'] Turn email addresses into mailto links? Default is true.
 * @uses $vars['sanitize'] Sanitize HTML? (highly recommended) Default is true.
 * @uses $vars['autop'] Convert line breaks to paragraphs? Default is true.
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-output');
$parse_urls = elgg_extract('parse_urls', $vars, true);
unset($vars['parse_urls']);
$parse_emails = elgg_extract('parse_emails', $vars, true);
unset($vars['parse_emails']);
$sanitize = elgg_extract('sanitize', $vars, true);
unset($vars['sanitize']);
$autop = elgg_extract('autop', $vars, true);
unset($vars['autop']);
$text = $vars['value'];
unset($vars['value']);
if ($parse_urls) {
    $text = parse_urls($text);
}
if ($parse_emails) {
    $text = elgg_parse_emails($text);
}
if ($sanitize) {
    $text = filter_tags($text);
Ejemplo n.º 9
0
Archivo: number.php Proyecto: elgg/elgg
<?php

/**
 * Elgg number input
 * Displays a number input field
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['class'] Additional CSS class
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-number');
$defaults = array('value' => '', 'disabled' => false, 'type' => 'number');
$vars = array_merge($defaults, $vars);
echo elgg_format_element('input', $vars);
Ejemplo n.º 10
0
Archivo: access.php Proyecto: elgg/elgg
 *
 * @uses $vars['entity_type']            Optional. Type of the entity
 * @uses $vars['entity_subtype']         Optional. Subtype of the entity
 * @uses $vars['container_guid']         Optional. Container GUID of the entity
 * @usee $vars['entity_allows_comments'] Optional. (bool) whether the entity uses comments - used for UI display of access change warnings
 *
 */
// bail if set to a unusable value
if (isset($vars['options_values'])) {
    if (!is_array($vars['options_values']) || empty($vars['options_values'])) {
        return;
    }
}
$entity_allows_comments = elgg_extract('entity_allows_comments', $vars, true);
unset($vars['entity_allows_comments']);
$vars['class'] = elgg_extract_class($vars, 'elgg-input-access');
// this will be passed to plugin hooks ['access:collections:write', 'user'] and ['default', 'access']
$params = array();
$keys = array('entity' => null, 'entity_type' => null, 'entity_subtype' => null, 'container_guid' => null, 'purpose' => 'read');
foreach ($keys as $key => $default_value) {
    $params[$key] = elgg_extract($key, $vars, $default_value);
    unset($vars[$key]);
}
/* @var ElggEntity $entity */
$entity = $params['entity'];
if ($entity) {
    $params['value'] = $entity->access_id;
    $params['entity_type'] = $entity->type;
    $params['entity_subtype'] = $entity->getSubtype();
    $params['container_guid'] = $entity->container_guid;
    if ($entity_allows_comments && $entity->access_id != ACCESS_PUBLIC) {
Ejemplo n.º 11
0
Archivo: select.php Proyecto: elgg/elgg
 *
 * @uses $vars['value']          The current value or an array of current values if multiple is true
 * @uses $vars['options']        An array of strings or arrays representing the options
 *                               for the dropdown field. If an array is passed,
 *                               the "text" key is used as its text, all other
 *                               elements in the array are used as attributes.
 * @uses $vars['options_values'] An associative array of "value" => "option"
 *                               where "value" is the name and "option" is
 *                               the value displayed on the button. Replaces
 *                               $vars['options'] when defined. When "option"
 *                               is passed as an array, the same behaviour is used
 *                               as when the $vars['options'] is passed an array to.
 * @uses $vars['multiple']       If true, multiselect of values will be allowed in the select box
 * @uses $vars['class']          Additional CSS class
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-dropdown');
$defaults = array('disabled' => false, 'value' => '', 'options_values' => array(), 'options' => array());
$vars = array_merge($defaults, $vars);
$options_values = $vars['options_values'];
unset($vars['options_values']);
$options = $vars['options'];
unset($vars['options']);
$value = is_array($vars['value']) ? $vars['value'] : array($vars['value']);
$value = array_map('strval', $value);
unset($vars['value']);
$vars['multiple'] = !empty($vars['multiple']);
// Add trailing [] to name if multiple is enabled to allow the form to send multiple values
if ($vars['multiple'] && !empty($vars['name']) && is_string($vars['name'])) {
    if (substr($vars['name'], -2) != '[]') {
        $vars['name'] = $vars['name'] . '[]';
    }
Ejemplo n.º 12
0
Archivo: module.php Proyecto: elgg/elgg
 *
 * @uses $vars['type']         The type of module (main, info, popup, aside, etc.)
 * @uses $vars['title']        Optional title text (do not pass header with this option)
 * @uses $vars['header']       Optional HTML content of the header
 * @uses $vars['body']         HTML content of the body
 * @uses $vars['footer']       Optional HTML content of the footer
 * @uses $vars['class']        Optional additional class for module
 * @uses $vars['id']           Optional id for module
 * @uses $vars['show_inner']   Optional flag to leave out inner div (default: false)
 */
$type = elgg_extract('type', $vars, false);
$title = elgg_extract('title', $vars, '');
$body = elgg_extract('body', $vars, '');
$footer = elgg_extract('footer', $vars, '');
$show_inner = elgg_extract('show_inner', $vars, false);
$attrs = ['id' => elgg_extract('id', $vars), 'class' => elgg_extract_class($vars, 'elgg-module')];
if ($type) {
    $attrs['class'][] = "elgg-module-{$type}";
}
$header = elgg_extract('header', $vars);
if ($title) {
    $header = elgg_format_element('h3', [], $title);
}
if ($header !== null) {
    $header = elgg_format_element('div', ['class' => 'elgg-head'], $header);
}
$body = elgg_format_element('div', ['class' => 'elgg-body'], $body);
if ($footer) {
    $footer = elgg_format_element('div', ['class' => 'elgg-foot'], $footer);
}
$contents = $header . $body . $footer;
Ejemplo n.º 13
0
Archivo: full.php Proyecto: elgg/elgg
<?php

/**
 * Object full view
 *
 * @uses $vars['entity']        ElggEntity
 * @uses $vars['icon']          HTML for the content icon
 * @uses $vars['summary']       HTML for the content summary
 * @uses $vars['body']          HTML for the content body
 * @uses $vars['class']         Optional additional class for the content wrapper
 * @uses $vars['header_params'] Vars to pass to the header image block wrapper
 */
$entity = elgg_extract('entity', $vars);
if (!$entity instanceof ElggEntity) {
    elgg_log("object/elements/full expects an ElggEntity in \$vars['entity']", 'ERROR');
}
$class = elgg_extract_class($vars, ['elgg-listing-full', 'elgg-content', 'clearfix']);
unset($vars['class']);
$header = elgg_view('object/elements/full/header', $vars);
$body = elgg_view('object/elements/full/body', $vars);
echo elgg_format_element('div', ['class' => $class, 'data-guid' => $entity->guid], $header . $body);
Ejemplo n.º 14
0
<?php

/**
 * Renders a set of fields wrapped in a <fieldset> tag
 *
 * @uses $vars['class']   Additional CSS classes
 * @uses $vars['align']   Field alignment (vertical|horizontal)
 *                        If set to horizontal, fields will be rendered
 *                        with inline display
 * @uses $vars['justify'] Text justification (left|right|center)
 * @uses $vars['legend']  Optional fieldset legend
 * @uses $vars['fields']  An array of field options
 *                        Field options should be suitable for use in
 *                        elgg_view_field()
 */
$vars['class'] = elgg_extract_class($vars, ['elgg-fieldset', 'clearfix']);
$align = elgg_extract('align', $vars, 'vertical');
unset($vars['align']);
$vars['class'][] = "elgg-fieldset-{$align}";
$justify = elgg_extract('justify', $vars, '');
unset($vars['justify']);
if ($justify) {
    $vars['class'][] = "elgg-justify-{$justify}";
}
$legend = elgg_extract('legend', $vars);
unset($vars['legend']);
$fields = (array) elgg_extract('fields', $vars, []);
unset($vars['fields']);
$fieldset = '';
if ($legend) {
    $vars['class'] = 'elgg-fieldset-has-legend';
Ejemplo n.º 15
0
<?php

/**
 * Menu group
 *
 * @uses $vars['items']                Array of menu items
 * @uses $vars['class']                Additional CSS class for the section
 * @uses $vars['name']                 Name of the menu
 * @uses $vars['section']              The section name
 * @uses $vars['item_class']           Additional CSS class for each menu item
 * @uses $vars['show_section_headers'] Do we show headers for each section
 */
$items = elgg_extract('items', $vars, array());
$headers = elgg_extract('show_section_headers', $vars, false);
$attrs['class'] = elgg_extract_class($vars);
$item_class = elgg_extract('item_class', $vars, '');
if ($headers) {
    $name = elgg_extract('name', $vars);
    $section = elgg_extract('section', $vars);
    echo '<h2>' . elgg_echo("menu:{$name}:header:{$section}") . '</h2>';
}
$lis = '';
if (is_array($items)) {
    foreach ($items as $menu_item) {
        $lis .= elgg_view('navigation/menu/elements/item', array('item' => $menu_item, 'item_class' => $item_class));
    }
}
echo elgg_format_element('ul', $attrs, $lis);
Ejemplo n.º 16
0
<?php

/**
 * Location input field
 *
 * @uses $vars['entity'] The ElggEntity that has a location
 * @uses $vars['value']  The default value for the location
 * @uses $vars['class']  Additional CSS class
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-location');
$defaults = array('disabled' => false);
if (isset($vars['entity'])) {
    $defaults['value'] = $vars['entity']->location;
    unset($vars['entity']);
}
$vars = array_merge($defaults, $vars);
echo elgg_view('input/tag', $vars);
Ejemplo n.º 17
0
Archivo: tabs.php Proyecto: elgg/elgg
 *                        <code>
 *                        [
 *                           ['text' => 'Tab 1', 'href' => '/dynamic', 'data-ajax-reload' => true],
 *                           ['text' => 'Tab 2', 'href' => '/static', 'data-ajax-reload' => false],
 *                           ['text' => 'Tab 3', 'href' => '/static', 'data-ajax-reload' => false, 'data-ajax-query' => json_encode($data)],
 *                           ['text' => 'Tab 3', 'href' => '/page', 'data-ajax-href' => '/ajax/page'],
 *                           ['text' => 'Tab 4', 'href' => 'Tab content'],
 *                        ]
 *                        </code>
 */
$id = elgg_extract('id', $vars);
if (!isset($vars['id'])) {
    $id = "elgg-tabs-" . base_convert(mt_rand(), 10, 36);
}
$vars['id'] = $id;
$vars['class'] = elgg_extract_class($vars, 'elgg-tabs-component');
$tabs = (array) elgg_extract('tabs', $vars, []);
unset($vars['tabs']);
if (empty($tabs)) {
    return;
}
$content = '';
foreach ($tabs as $index => $tab) {
    if (!isset($tab['href']) && !isset($tab['content'])) {
        elgg_log('Tab configuration in "page/components/tabs"
			requires either a "href" or "content" parameter', 'ERROR');
        continue;
    }
    $selected = elgg_extract('selected', $tab);
    if (isset($tab['content'])) {
        $class = ['elgg-content'];
Ejemplo n.º 18
0
Archivo: title.php Proyecto: elgg/elgg
<?php

/**
 * Elgg title element
 *
 * @uses $vars['tag']   The tag name to wrap the title (default: h2)
 * @uses $vars['title'] The page title
 * @uses $vars['class'] Optional class for heading
 */
$title = elgg_extract('title', $vars);
if (!is_string($title) || $title === '') {
    return;
}
$attributes = ['class' => elgg_extract_class($vars)];
$tag = elgg_extract('tag', $vars, 'h2', false);
echo elgg_format_element($tag, $attributes, $title);
Ejemplo n.º 19
0
<?php

/**
 * Elgg password input
 * Displays a password input field
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['value'] The current value, if any
 * @uses $vars['name']  The name of the input field
 * @uses $vars['class'] Additional CSS class
 * @uses $vars['always_empty'] If for some reason you want to set a value to a password field, set this field to false. Best practice is to not populate password fields.
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-password');
$defaults = array('disabled' => false, 'autocapitalize' => 'off', 'autocorrect' => 'off', 'type' => 'password');
$vars = array_merge($defaults, $vars);
$always_empty = elgg_extract('always_empty', $vars, true);
unset($vars['always_empty']);
if ($always_empty) {
    unset($vars['value']);
}
echo elgg_format_element('input', $vars);
Ejemplo n.º 20
0
Archivo: url.php Proyecto: elgg/elgg
                $site_url = elgg_get_site_url();
                $site_url_host = parse_url($site_url, PHP_URL_HOST);
                $is_trusted = $url_host == $site_url_host;
            }
            if ($is_trusted === false) {
                // this is an external URL, which we do not want to be indexed by crawlers
                $vars['rel'] = 'nofollow';
            }
        }
    }
    $vars['href'] = $url;
}
if (!isset($vars['title']) && isset($vars['data-confirm'])) {
    $vars['title'] = $vars['data-confirm'];
}
unset($vars['is_action']);
unset($vars['is_trusted']);
unset($vars['confirm']);
$vars['class'] = elgg_extract_class($vars, 'elgg-anchor');
$text = elgg_format_element('span', ['class' => 'elgg-anchor-label'], $text);
$icon = elgg_extract('icon', $vars, '');
unset($vars['icon']);
if ($icon && !preg_match('/^</', $icon)) {
    $icon = elgg_view_icon($icon, ['class' => 'elgg-anchor-icon']);
}
$badge = elgg_extract('badge', $vars);
unset($vars['badge']);
if (!is_null($badge)) {
    $badge = elgg_format_element(['#tag_name' => 'span', '#text' => $badge, 'class' => 'elgg-badge']);
}
echo elgg_format_element('a', $vars, $icon . $text . $badge);
Ejemplo n.º 21
0
Archivo: widget.php Proyecto: elgg/elgg
<?php

/**
 * Widget object
 *
 * @uses $vars['entity']      ElggWidget
 * @uses $vars['show_access'] Show the access control in edit area? (true)
 * @uses $vars['class']       Optional additional CSS class
 */
$widget = elgg_extract('entity', $vars);
if (!$widget instanceof \ElggWidget) {
    return;
}
$handler = $widget->handler;
$widget_instance = preg_replace('/[^a-z0-9-]/i', '-', "elgg-widget-instance-{$handler}");
$widget_class = elgg_extract_class($vars, $widget_instance);
$widget_class[] = $widget->canEdit() ? 'elgg-state-draggable' : 'elgg-state-fixed';
echo elgg_view_module('widget', '', elgg_view('object/widget/body', $vars), ['class' => $widget_class, 'id' => "elgg-widget-{$widget->guid}", 'header' => elgg_view('object/widget/header', $vars)]);
Ejemplo n.º 22
0
Archivo: icon.php Proyecto: elgg/elgg
<?php

/**
* Display an icon from the FontAwesome library.
*
* @package Elgg
* @subpackage Core
*
* @uses $vars['class']   Class of elgg-icon
* @uses $vars['convert'] Convert an elgg-icon class to a FontAwesome class (default: true)
*/
// these 'old' Elgg 1.x sprite icons will be converted to the FontAwesome version
$translated_icons = array("arrow-two-head" => "arrows-h", "attention" => "exclamation-triangle", "cell-phone" => "mobile", "checkmark" => "check", "clip" => "paperclip", "cursor-drag-arrow" => "arrows", "drag-arrow" => "arrows", "delete-alt" => "times-circle", "delete" => "times", "facebook" => "facebook-square", "grid" => "th", "hover-menu" => "caret-down", "info" => "info-circle", "lock-closed" => "lock", "lock-open" => "unlock", "mail" => "envelope-o", "mail-alt" => "envelope", "print-alt" => "print", "push-pin" => "thumb-tack", "push-pin-alt" => "thumb-tack", "redo" => "share", "round-arrow-left" => "arrow-circle-left", "round-arrow-right" => "arrow-circle-right", "round-checkmark" => "check-circle", "round-minus" => "minus-circle", "round-plus" => "plus-circle", "rss" => "rss-square", "search-focus" => "search", "settings" => "wrench", "settings-alt" => "cog", "share" => "share-alt-square", "shop-cart" => "shopping-cart", "speech-bubble" => "comment", "speech-bubble-alt" => "comments", "star-alt" => "star", "star-empty" => "star-o", "thumbs-down-alt" => "thumbs-down", "thumbs-up-alt" => "thumbs-up", "trash" => "trash-o", "twitter" => "twitter-square", "undo" => "reply", "video" => "film");
$convert = (bool) elgg_extract('convert', $vars, true);
unset($vars['convert']);
$class = elgg_extract_class($vars, ["elgg-icon", "fa"]);
foreach ($class as $index => $c) {
    if (preg_match_all('/^elgg-icon-(.+)/i', $c)) {
        // convert
        $base_icon = preg_replace('/^elgg-icon-(.+)/i', '$1', $c);
        if ($convert) {
            $base_icon = elgg_extract($base_icon, $translated_icons, $base_icon);
        }
        $class[] = "fa-{$base_icon}";
    }
}
$vars["class"] = array_unique($class);
echo elgg_format_element('span', $vars, '');
Ejemplo n.º 23
0
Archivo: field.php Proyecto: elgg/elgg
<?php

/**
 * Form field view
 *
 * @uses $vars['input'] Form input element
 * @uses $vars['id'] ID attribute of the input element
 * @uses $vars['required'] Required or optional input
 * @uses $vars['label'] HTML content of the label element
 * @uses $vars['help'] HTML content of the help element
 */
$input = elgg_extract('input', $vars);
if (!$input) {
    return;
}
$label = elgg_extract('label', $vars, '');
$help = elgg_extract('help', $vars, '');
$class = elgg_extract_class($vars, 'elgg-field');
if (elgg_extract('required', $vars)) {
    $class[] = "elgg-field-required";
}
$field = $label . $input . $help;
echo elgg_format_element('div', ['class' => $class], $field);
Ejemplo n.º 24
0
 *
 * @uses $vars['sidebar']      Sidebar HTML (default: empty string)
 *                             Will not be rendered if the value is 'false'
 * @uses $vars['sidebar_alt']  Second sidebar HTML (default: false)
 *                             Will not be rendered if the value is 'false'
 *
 * @uses $vars['filter']       An optional array of filter tabs
 *                             Array items should be suitable for usage with
 *                             elgg_register_menu_item()
 * @uses $vars['filter_id']    An optional ID of the filter
 *                             If provided, plugins can adjust filter tabs menu
 *                             via 'register, menu:filter:$filter_id' hook
 * @uses $vars['filter_value'] Optional name of the selected filter tab
 *                             If not provided, will be determined by the current page's URL
 */
$class = elgg_extract_class($vars, ['elgg-layout', 'clearfix']);
unset($vars['class']);
// Prepare layout sidebar
$vars['sidebar'] = elgg_extract('sidebar', $vars, '');
if ($vars['sidebar'] !== false) {
    // In a default layout, we want to make sure we render
    // sidebar navigation items
    $vars['sidebar'] = elgg_view('page/elements/sidebar', $vars);
}
$sidebar = elgg_view('page/layouts/elements/sidebar', $vars);
// Prepare second layout sidebar
$sidebar_alt = '';
if ($sidebar) {
    $vars['sidebar_alt'] = elgg_extract('sidebar_alt', $vars, false);
    if ($vars['sidebar_alt'] !== false) {
        // In a default layout, we want to make sure we render
Ejemplo n.º 25
0
Archivo: admin.php Proyecto: elgg/elgg
<?php

/**
 * Elgg Admin Area Canvas
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['content'] Content string
 * @uses $vars['sidebar'] Optional sidebar content
 * @uses $vars['title']   Optional title string
 */
$class = elgg_extract_class($vars, ['elgg-layout', 'elgg-layout-one-sidebar', 'elgg-layout-admin', 'clearfix']);
unset($vars['class']);
$vars['breadcrumbs'] = false;
$vars['sidebar'] = elgg_view('admin/sidebar', $vars);
$sidebar = elgg_view('page/layouts/elements/sidebar', $vars);
$body = elgg_view('page/layouts/elements/body', $vars);
echo elgg_format_element('div', ['class' => $class], $sidebar . $body);
Ejemplo n.º 26
0
<?php

/**
 * List comments with optional add form
 *
 * @uses $vars['entity']        ElggEntity
 * @uses $vars['show_add_form'] Display add form or not
 * @uses $vars['id']            Optional id for the div
 * @uses $vars['class']         Optional additional class for the div
 * @uses $vars['limit']         Optional limit value (default is 25)
 *
 * @todo look into restructuring this so we are not calling elgg_list_entities()
 * in this view
 */
$show_add_form = elgg_extract('show_add_form', $vars, true);
$full_view = elgg_extract('full_view', $vars, true);
$limit = elgg_extract('limit', $vars, get_input('limit', 0));
if (!$limit) {
    $limit = elgg_trigger_plugin_hook('config', 'comments_per_page', [], 25);
}
$attr = ['id' => elgg_extract('id', $vars, 'comments'), 'class' => elgg_extract_class($vars, 'elgg-comments')];
// work around for deprecation code in elgg_view()
unset($vars['internalid']);
$content = elgg_list_entities(array('type' => 'object', 'subtype' => 'comment', 'container_guid' => $vars['entity']->guid, 'reverse_order_by' => true, 'full_view' => true, 'limit' => $limit, 'preload_owners' => true, 'distinct' => false, 'url_fragment' => $attr['id']));
if ($show_add_form) {
    $content .= elgg_view_form('comment/save', array(), $vars);
}
echo elgg_format_element('div', $attr, $content);
Ejemplo n.º 27
0
 *
 *
 * Pass input tag attributes as key value pairs. For a list of allowable
 * attributes, see http://www.w3schools.com/tags/tag_input.asp
 * 
 * @uses $vars['name']        Name of the checkbox
 * @uses $vars['value']       Value of the checkbox
 * @uses $vars['default']     The default value to submit if not checked.
 *                            Optional, defaults to 0. Set to false for no default.
 * @uses $vars['checked']     Whether this checkbox is checked
 * @uses $vars['label']       Optional label string
 * @uses $vars['class']       Additional CSS class
 * @uses $vars['label_class'] Optional class for the label
 * @uses $vars['label_tag']   HTML tag that wraps concatinated label and input. Defaults to 'label'.
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-checkbox');
$defaults = array('default' => 0, 'disabled' => false, 'type' => 'checkbox');
$vars = array_merge($defaults, $vars);
$default = $vars['default'];
unset($vars['default']);
if (isset($vars['name']) && $default !== false) {
    echo elgg_view('input/hidden', ['name' => $vars['name'], 'value' => $default]);
}
$label = elgg_extract('label', $vars, false);
$label_class = (array) elgg_extract('label_class', $vars, []);
$label_class[] = 'elgg-input-single-checkbox';
unset($vars['label']);
unset($vars['label_class']);
$input = elgg_format_element('input', $vars);
if (!empty($label)) {
    $html_tag = elgg_extract('label_tag', $vars, 'label', false);
Ejemplo n.º 28
0
<?php

/**
 * Elgg long text input (plaintext)
 * Displays a long text input field that should not be overridden by wysiwyg editors.
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['value']    The current value, if any
 * @uses $vars['name']     The name of the input field
 * @uses $vars['class']    Additional CSS class
 * @uses $vars['disabled']
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-input-plaintext');
$defaults = array('value' => '', 'rows' => '10', 'cols' => '50', 'disabled' => false);
$vars = array_merge($defaults, $vars);
$value = htmlspecialchars($vars['value'], ENT_QUOTES, 'UTF-8');
unset($vars['value']);
echo elgg_format_element('textarea', $vars, $value);
Ejemplo n.º 29
0
 * @uses $vars['image_block_vars'] Attributes for the image block wrapper
 */
$entity = elgg_extract('entity', $vars);
if (!$entity instanceof ElggEntity) {
    elgg_log("object/elements/summary expects an ElggEntity in \$vars['entity']", 'ERROR');
}
$title = elgg_extract('title', $vars, '');
if ($title === '' && $entity instanceof ElggEntity) {
    $vars['title'] = elgg_view('output/url', ['text' => elgg_get_excerpt($entity->getDisplayName(), 100), 'href' => $entity->getURL()]);
}
$tags = elgg_extract('tags', $vars, '');
if ($tags === '') {
    $tags = elgg_view('output/tags', ['entity' => $entity]);
}
$metadata = elgg_view('object/elements/summary/metadata', $vars);
$title = elgg_view('object/elements/summary/title', $vars);
$subtitle = elgg_view('object/elements/summary/subtitle', $vars);
$extensions = elgg_view('object/summary/extend', $vars);
$content = elgg_view('object/elements/summary/content', $vars);
$summary = $metadata . $title . $subtitle . $tags . $extensions . $content;
$icon = elgg_extract('icon', $vars);
if (isset($icon)) {
    $params = (array) elgg_extract('image_block_vars', $vars, []);
    $class = elgg_extract_class($params);
    $class = elgg_extract_class($vars, $class);
    $params['class'] = $class;
    $params['data-guid'] = $entity->guid;
    echo elgg_view_image_block($icon, $summary, $params);
} else {
    echo $summary;
}
Ejemplo n.º 30
0
 * ---------------------------------------------------------------
 * |          |                                      |    alt    |
 * |  image   |               body                   |   image   |
 * |  block   |               block                  |   block   |
 * |          |                                      | (optional)|
 * ---------------------------------------------------------------
 *
 * @uses $vars['body']        HTML content of the body block
 * @uses $vars['image']       HTML content of the image block
 * @uses $vars['image_alt']   HTML content of the alternate image block
 * @uses $vars['class']       Optional additional class (or an array of classes) for media element
 * @uses $vars['id']          Optional id for the media element
 */
$body = elgg_extract('body', $vars, '');
unset($vars['body']);
$image = elgg_extract('image', $vars, '');
unset($vars['image']);
$alt_image = elgg_extract('image_alt', $vars, '');
unset($vars['image_alt']);
$class = elgg_extract_class($vars, ['elgg-image-block', 'clearfix']);
unset($vars['class']);
$body = elgg_format_element('div', ['class' => 'elgg-body'], $body);
if ($image) {
    $image = elgg_format_element('div', ['class' => 'elgg-image'], $image);
}
if ($alt_image) {
    $alt_image = elgg_format_element('div', ['class' => 'elgg-image-alt'], $alt_image);
}
$params = $vars;
$params['class'] = $class;
echo elgg_format_element('div', $params, $image . $alt_image . $body);