示例#1
0
文件: list.php 项目: tjcaverly/Elgg
$list_class = 'elgg-list';
if (isset($vars['list_class'])) {
    $list_class = "{$list_class} {$vars['list_class']}";
}
$item_class = 'elgg-item';
if (isset($vars['item_class'])) {
    $item_class = "{$item_class} {$vars['item_class']}";
}
$html = "";
$nav = "";
if ($pagination && $count) {
    $nav .= elgg_view('navigation/pagination', array('base_url' => $base_url, 'offset' => $offset, 'count' => $count, 'limit' => $limit, 'offset_key' => $offset_key));
}
$html .= "<ul class=\"{$list_class}\">";
foreach ($items as $item) {
    $li = elgg_view_list_item($item, $vars);
    if ($li) {
        if (elgg_instanceof($item)) {
            $id = "elgg-{$item->getType()}-{$item->getGUID()}";
        } else {
            $id = "item-{$item->getType()}-{$item->id}";
        }
        $html .= "<li id=\"{$id}\" class=\"{$item_class}\">{$li}</li>";
    }
}
$html .= '</ul>';
if ($position == 'before' || $position == 'both') {
    $html = $nav . $html;
}
if ($position == 'after' || $position == 'both') {
    $html .= $nav;
示例#2
0
}
if ($pagination && $count) {
    $nav = elgg_view('navigation/pagination', array('base_url' => $base_url, 'offset' => $offset, 'count' => $count, 'limit' => $limit, 'offset_key' => $offset_key));
}
echo '<div class="maps-container maps-list">';
$mapbox_attrs = $map->getMapboxAttributes();
$mapbox_attrs = elgg_format_attributes($mapbox_attrs);
echo elgg_view('output/url', array('href' => 'javascript:void(0);', 'text' => elgg_echo('maps:findme'), 'class' => 'maps-find-me'));
echo "<div {$mapbox_attrs}></div>";
if ($position == 'before' || $position == 'both') {
    echo $nav;
}
echo "<ul class=\"{$list_class}\">";
foreach ($items as $item) {
    $has_items = true;
    $view = elgg_view_list_item($item, $options);
    if (!$view) {
        continue;
    }
    $item_attrs = $map->getItemAttributes($item);
    $proximity = '';
    if (!is_null($item_attrs['data-proximity'])) {
        $proximity = elgg_view('output/maps/proximity', array('value' => $item_attrs['data-proximity'], 'class' => 'elgg-text-help maps-item-proximity'));
        $view .= $proximity;
    }
    $pin = '&nbsp;';
    if ($item_attrs['data-pin']) {
        $pin = elgg_view('output/maps/pin', array('value' => $item_attrs['data-pin'], 'class' => 'maps-item-pin', 'alt' => $item_attrs['data-title'], 'title' => $proximity ? elgg_echo('maps:proximity:info', array(strip_tags($proximity), $map->getLocation())) : $item_attrs['data-title']));
    }
    $view = elgg_view_image_block($pin, $view, array('class' => 'maps-item-pin-block'));
    $id = elgg_instanceof($item) ? "elgg-{$item->getType()}-{$item->getGUID()}" : "item-{$item->getType()}-{$item->id}";
示例#3
0
文件: gallery.php 项目: elgg/elgg
elgg_push_context('gallery');
$list_classes = ['elgg-gallery'];
if (isset($vars['gallery_class'])) {
    $list_classes[] = $vars['gallery_class'];
}
$item_classes = ['elgg-item'];
if (isset($vars['item_class'])) {
    $item_classes[] = $vars['item_class'];
}
$nav = $pagination ? elgg_view('navigation/pagination', $vars) : '';
$index = 0;
$list_items = '';
foreach ($items as $item) {
    $item_view_vars = $vars;
    $item_view_vars['list_item_index'] = $index;
    $item_view = elgg_view_list_item($item, $item_view_vars);
    if (!$item_view) {
        continue;
    }
    $li_attrs = ['class' => $item_classes];
    if ($item instanceof \ElggEntity) {
        $li_attrs['id'] = "elgg-{$item->getType()}-{$item->getGUID()}";
    } else {
        if (is_callable(array($item, 'getType'))) {
            $li_attrs['id'] = "item-{$item->getType()}-{$item->id}";
        }
    }
    $list_items .= elgg_format_element('li', $li_attrs, $item_view);
    $index++;
}
if ($position == 'before' || $position == 'both') {
示例#4
0
文件: list.php 项目: rasul/Elgg
}
$item_class = 'elgg-list-item';
if (isset($vars['item_class'])) {
    $item_class = "{$vars['item_class']} {$item_class}";
}
$html = "";
$nav = "";
if ($pagination && $count) {
    $nav .= elgg_view('navigation/pagination', array('baseurl' => $base_url, 'offset' => $offset, 'count' => $count, 'limit' => $limit, 'offset_key' => $offset_key));
}
if (is_array($items) && count($items) > 0) {
    $html .= "<ul class=\"{$list_class}\">";
    foreach ($items as $item) {
        if (elgg_instanceof($item)) {
            $id = "elgg-{$item->getType()}-{$item->getGUID()}";
        } else {
            $id = "item-{$item->getType()}-{$item->id}";
        }
        $html .= "<li id=\"{$id}\" class=\"{$item_class}\">";
        $html .= elgg_view_list_item($item, $vars);
        $html .= '</li>';
    }
    $html .= '</ul>';
}
if ($position == 'before' || $position == 'both') {
    $html = $nav . $html;
}
if ($position == 'after' || $position == 'both') {
    $html .= $nav;
}
echo $html;
示例#5
0
 /**
  * Display an html list of the entities
  * @param string $class		CSS class to attach to the table
  * @return string
  */
 public function viewList()
 {
     $context = isset($this->options['list_type']) ? $this->options['list_type'] : 'list';
     elgg_push_context($context);
     $items = $this->getItems();
     $options = $this->getOptions();
     $count = $this->getCount();
     $offset = elgg_extract('offset', $options);
     $limit = elgg_extract('limit', $options);
     $base_url = elgg_extract('base_url', $options, '');
     $pagination = elgg_extract('pagination', $options, true);
     $offset_key = elgg_extract('offset_key', $options, 'offset');
     $position = elgg_extract('position', $options, 'after');
     if ($pagination && $count) {
         $nav = elgg_view('navigation/pagination', array('base_url' => $base_url, 'offset' => $offset, 'count' => $count, 'limit' => $limit, 'offset_key' => $offset_key));
     }
     $html .= '<div class="elgg-list-container">';
     if ($position == 'before' || $position == 'both') {
         $html .= $nav;
     }
     $list_attrs = elgg_format_attributes($this->getListAttributes());
     $html .= "<ul {$list_attrs}>";
     foreach ($items as $item) {
         $view = elgg_view_list_item($item, $options);
         if (!$view) {
             continue;
         }
         $has_items = true;
         $item_attrs = elgg_format_attributes($this->getItemAttributes($item));
         $html .= "<li {$item_attrs}>{$view}</li>";
     }
     if (!$has_items) {
         $html .= '<li class="elgg-list-placeholder">' . elgg_echo('list:empty') . '</li>';
     }
     $html .= '</ul>';
     if ($position == 'after' || $position == 'both') {
         $html .= $nav;
     }
     $html .= '</div>';
     elgg_pop_context();
     return $html;
 }
示例#6
0
    $content = elgg_view('core/river/filter', array('selector' => $selector));
    $sidebar = elgg_view('core/river/sidebar');
    $params = array('content' => $content . $activity, 'sidebar' => $sidebar, 'filter_context' => $page_filter, 'class' => 'elgg-river-layout');
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page($title, $body);
} else {
    $sync = get_input('sync');
    $ts = (int) get_input('time');
    if (!$ts) {
        $ts = time();
    }
    $options = get_input('options');
    if ($sync == 'new') {
        $options['wheres'] = array("rv.posted > {$ts}");
        $options['order_by'] = 'rv.posted asc';
        $options['limit'] = 0;
    }
    $items = elgg_get_river($options);
    if (is_array($items) && count($items) > 0) {
        foreach ($items as $key => $item) {
            $id = "item-{$item->getType()}-{$item->id}";
            $time = $item->posted;
            $html = "<li id=\"{$id}\" class=\"elgg-item\" data-timestamp=\"{$time}\">";
            $html .= elgg_view_list_item($item, $vars = array());
            $html .= '</li>';
            $output[] = $html;
        }
    }
    print json_encode($output);
    exit;
}
示例#7
0
文件: item.php 项目: elgg/elgg
<?php

/**
 * Render a regular list item
 *
 * @uses $vars['item']      The item being rendered
 * @uses $vars['item_vars'] Vars received from the page/components/table view
 * @uses $vars['type']      The item type or ""
 */
$item = $vars['item'];
if ($vars['type']) {
    // recognized type
    echo elgg_view_list_item($item, $vars['item_vars']);
}
示例#8
0
文件: hooks.php 项目: lorea/Hydra-dev
/**
 * Take over the livesearch pagehandler in case of group search
 *
 * @param string $hook         'route'
 * @param string $type         'livessearch'
 * @param array  $return_value the current params for the pagehandler
 * @param null   $params       null
 *
 * @return bool|void
 */
function group_tools_route_livesearch_handler($hook, $type, $return_value, $params)
{
    // only return results to logged in users.
    if (!($user = elgg_get_logged_in_user_entity())) {
        exit;
    }
    if (!($q = get_input("term", get_input("q")))) {
        exit;
    }
    $input_name = get_input("name", "groups");
    $q = sanitise_string($q);
    // replace mysql vars with escaped strings
    $q = str_replace(array("_", "%"), array("\\_", "\\%"), $q);
    $match_on = get_input("match_on", "all");
    if (!is_array($match_on)) {
        $match_on = array($match_on);
    }
    // only take over groups search
    if (count($match_on) > 1 || !in_array("groups", $match_on)) {
        return $return_value;
    }
    if (get_input("match_owner", false)) {
        $owner_guid = $user->getGUID();
    } else {
        $owner_guid = ELGG_ENTITIES_ANY_VALUE;
    }
    $limit = sanitise_int(get_input("limit", 10));
    // grab a list of entities and send them in json.
    $results = array();
    $options = array("type" => "group", "limit" => $limit, "owner_guid" => $owner_guid, "joins" => array("JOIN " . elgg_get_config("dbprefix") . "groups_entity ge ON e.guid = ge.guid"), "wheres" => array("(ge.name LIKE '%" . $q . "%' OR ge.description LIKE '%" . $q . "%')"));
    $entities = elgg_get_entities($options);
    if (!empty($entities)) {
        foreach ($entities as $entity) {
            $output = elgg_view_list_item($entity, array("use_hover" => false, "class" => "elgg-autocomplete-item", "full_view" => false));
            $icon = elgg_view_entity_icon($entity, "tiny", array("use_hover" => false));
            $result = array("type" => "group", "name" => $entity->name, "desc" => $entity->description, "guid" => $entity->getGUID(), "label" => $output, "value" => $entity->getGUID(), "icon" => $icon, "url" => $entity->getURL(), "html" => elgg_view("input/grouppicker/item", array("entity" => $entity, "input_name" => $input_name)));
            $results[$entity->name . rand(1, 100)] = $result;
        }
    }
    ksort($results);
    header("Content-Type: application/json");
    echo json_encode(array_values($results));
    exit;
}
示例#9
0
$nav = '';
if ($pagination && $count) {
    $nav .= elgg_view('navigation/pagination', array('offset' => $offset, 'count' => $count, 'limit' => $limit, 'offset_key' => $offset_key));
}
if ($position == 'before' || $position == 'both') {
    echo $nav;
}
?>
<ul class="<?php 
echo $gallery_class;
?>
">
	<?php 
foreach ($items as $item) {
    if (elgg_instanceof($item)) {
        $id = "elgg-{$item->getType()}-{$item->getGUID()}";
    } else {
        $id = "item-{$item->getType()}-{$item->id}";
    }
    echo "<li id=\"{$id}\" class=\"{$item_class}\">";
    echo elgg_view_list_item($item, $vars);
    echo "</li>";
}
?>
</ul>

<?php 
if ($position == 'after' || $position == 'both') {
    echo $nav;
}
elgg_pop_context();
示例#10
0
/**
 * Page handler for autocomplete endpoint.
 *
 * @todo split this into functions/objects, this is way too big
 *
 * /livesearch?q=<query>
 *
 * Other options include:
 *     match_on	   string all or array(groups|users|friends)
 *     match_owner int    0/1
 *     limit       int    default is 10
 *     name        string default "members"
 *
 * @param array $page
 * @return string JSON string is returned and then exit
 * @access private
 */
function input_livesearch_page_handler($page)
{
    $dbprefix = elgg_get_config('dbprefix');
    // only return results to logged in users.
    if (!($user = elgg_get_logged_in_user_entity())) {
        exit;
    }
    if (!($q = get_input('term', get_input('q')))) {
        exit;
    }
    $input_name = get_input('name', 'members');
    $q = sanitise_string($q);
    // replace mysql vars with escaped strings
    $q = str_replace(array('_', '%'), array('\\_', '\\%'), $q);
    $match_on = get_input('match_on', 'all');
    if (!is_array($match_on)) {
        $match_on = array($match_on);
    }
    // all = users and groups
    if (in_array('all', $match_on)) {
        $match_on = array('users', 'groups');
    }
    $owner_guid = ELGG_ENTITIES_ANY_VALUE;
    if (get_input('match_owner', false)) {
        $owner_guid = $user->getGUID();
    }
    $limit = sanitise_int(get_input('limit', elgg_get_config('default_limit')));
    // grab a list of entities and send them in json.
    $results = array();
    foreach ($match_on as $match_type) {
        switch ($match_type) {
            case 'users':
                $options = array('type' => 'user', 'limit' => $limit, 'joins' => array("JOIN {$dbprefix}users_entity ue ON e.guid = ue.guid"), 'wheres' => array("ue.banned = 'no'", "(ue.name LIKE '{$q}%' OR ue.name LIKE '% {$q}%' OR ue.username LIKE '{$q}%')"));
                $entities = elgg_get_entities($options);
                if (!empty($entities)) {
                    foreach ($entities as $entity) {
                        if (in_array('groups', $match_on)) {
                            $value = $entity->guid;
                        } else {
                            $value = $entity->username;
                        }
                        $output = elgg_view_list_item($entity, array('use_hover' => false, 'use_link' => false, 'class' => 'elgg-autocomplete-item', 'title' => $entity->name));
                        $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                        $result = array('type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'guid' => $entity->guid, 'label' => $output, 'value' => $value, 'icon' => $icon, 'url' => $entity->getURL(), 'html' => elgg_view('input/userpicker/item', array('entity' => $entity, 'input_name' => $input_name)));
                        $results[$entity->name . rand(1, 100)] = $result;
                    }
                }
                break;
            case 'groups':
                // don't return results if groups aren't enabled.
                if (!elgg_is_active_plugin('groups')) {
                    continue;
                }
                $options = array('type' => 'group', 'limit' => $limit, 'owner_guid' => $owner_guid, 'joins' => array("JOIN {$dbprefix}groups_entity ge ON e.guid = ge.guid"), 'wheres' => array("(ge.name LIKE '{$q}%' OR ge.name LIKE '% {$q}%' OR ge.description LIKE '% {$q}%')"));
                $entities = elgg_get_entities($options);
                if (!empty($entities)) {
                    foreach ($entities as $entity) {
                        $output = elgg_view_list_item($entity, array('use_hover' => false, 'class' => 'elgg-autocomplete-item', 'full_view' => false, 'href' => false, 'title' => $entity->name));
                        $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                        $result = array('type' => 'group', 'name' => $entity->name, 'desc' => strip_tags($entity->description), 'guid' => $entity->guid, 'label' => $output, 'value' => $entity->guid, 'icon' => $icon, 'url' => $entity->getURL());
                        $results[$entity->name . rand(1, 100)] = $result;
                    }
                }
                break;
            case 'friends':
                $options = array('type' => 'user', 'limit' => $limit, 'relationship' => 'friend', 'relationship_guid' => $user->getGUID(), 'joins' => array("JOIN {$dbprefix}users_entity ue ON e.guid = ue.guid"), 'wheres' => array("ue.banned = 'no'", "(ue.name LIKE '{$q}%' OR ue.name LIKE '% {$q}%' OR ue.username LIKE '{$q}%')"));
                $entities = elgg_get_entities_from_relationship($options);
                if (!empty($entities)) {
                    foreach ($entities as $entity) {
                        $output = elgg_view_list_item($entity, array('use_hover' => false, 'use_link' => false, 'class' => 'elgg-autocomplete-item', 'title' => $entity->name));
                        $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                        $result = array('type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'guid' => $entity->guid, 'label' => $output, 'value' => $entity->username, 'icon' => $icon, 'url' => $entity->getURL(), 'html' => elgg_view('input/userpicker/item', array('entity' => $entity, 'input_name' => $input_name)));
                        $results[$entity->name . rand(1, 100)] = $result;
                    }
                }
                break;
            default:
                header("HTTP/1.0 400 Bad Request", true);
                echo "livesearch: unknown match_on of {$match_type}";
                exit;
                break;
        }
    }
    ksort($results);
    header("Content-Type: application/json;charset=utf-8");
    echo json_encode(array_values($results));
    exit;
}
示例#11
0
文件: start.php 项目: lorea/Hydra-dev
/**
 * Messages page handler
 *
 * @param array $page Array of URL components for routing
 * @return bool
 */
function messages_page_handler($page)
{
    global $CONFIG;
    elgg_load_library('elgg:messages');
    elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . elgg_get_logged_in_user_entity()->username);
    if (!isset($page[0])) {
        $page[0] = 'inbox';
    }
    // supporting the old inbox url /messages/<username>
    $user = get_user_by_username($page[0]);
    if ($user) {
        $page[1] = $page[0];
        $page[0] = 'inbox';
    }
    if (!isset($page[1])) {
        $page[1] = elgg_get_logged_in_user_entity()->username;
    }
    $base_dir = elgg_get_plugins_path() . 'messages/pages/messages';
    switch ($page[0]) {
        case 'inbox':
            set_input('username', $page[1]);
            include "{$base_dir}/inbox.php";
            break;
        case 'sent':
            set_input('username', $page[1]);
            include "{$base_dir}/sent.php";
            break;
        case 'read':
            set_input('guid', $page[1]);
            include "{$base_dir}/read.php";
            break;
        case 'compose':
        case 'add':
            include "{$base_dir}/send.php";
            break;
        case 'forward':
            set_input('guid', $page[1]);
            include "{$base_dir}/forward.php";
            break;
        case 'download':
            set_input('file_guid', $page[1]);
            include "{$base_dir}/download.php";
            break;
        case 'search':
            if (!($q = get_input('term', get_input('q')))) {
                exit;
            }
            $q = sanitise_string($q);
            $limit = sanitise_int(get_input('limit', 10));
            // grab a list of entities and send them in json.
            $results = array();
            $query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as ue, {$CONFIG->dbprefix}entities as e\n\t\t\t\t\tWHERE e.guid = ue.guid\n\t\t\t\t\t\tAND e.enabled = 'yes'\n\t\t\t\t\t\tAND ue.banned = 'no'\n\t\t\t\t\t\tAND (ue.name LIKE '{$q}%' OR ue.username LIKE '{$q}%')\n\t\t\t\t\tLIMIT {$limit}\n\t\t\t";
            if ($entities = get_data($query)) {
                foreach ($entities as $entity) {
                    $entity = get_entity($entity->guid);
                    if (!$entity) {
                        continue;
                    }
                    if (in_array('groups', $match_on)) {
                        $value = $entity->guid;
                    } else {
                        $value = $entity->username;
                    }
                    $output = elgg_view_list_item($entity, array('use_hover' => false, 'class' => 'elgg-autocomplete-item'));
                    $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                    $results = array('type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'guid' => $entity->guid, 'label' => $entity->name, 'value' => $value, 'icon' => $icon, 'url' => $entity->getURL());
                    $results[$entity->name . rand(1, 100)] = $results;
                }
            }
            ksort($results);
            header("Content-Type: application/json");
            echo json_encode(array_values($results));
            exit;
            break;
        case 'find':
            set_input('username', $page[1]);
            include "{$base_dir}/find.php";
            break;
        case 'label':
            if (!$page[1]) {
                forward(REFERER);
            }
            set_input('label', $page[1]);
            include "{$base_dir}/label.php";
            break;
        default:
            return false;
    }
    return true;
}
示例#12
0
$user = elgg_get_logged_in_user_entity();
$time_created = get_input('time_created');
$guid = get_input('guid');
$chat = get_entity($guid);
if (!elgg_instanceof($chat, 'object', 'chat') || !$chat->isMember()) {
    echo false;
    exit;
}
$options = array('type' => 'object', 'subtype' => 'chat_message', 'container_guid' => $guid, 'order_by' => 'e.time_created asc');
$pagination = get_input('pagination', false);
if ($pagination) {
    // Get old messages
    $options['wheres'] = array("time_created < {$time_created}");
    $options['limit'] = 6;
} else {
    // Get the newest messages
    $options['wheres'] = array("time_created > {$time_created}");
    $options['limit'] = false;
}
$messages = elgg_get_entities($options);
$html = '';
if ($messages) {
    elgg_load_library('chat');
    foreach ($messages as $message) {
        $id = "elgg-object-{$message->getGUID()}";
        $item = elgg_view_list_item($message);
        $html .= "<li id=\"{$id}\" class=\"elgg-item\">{$item}</li>";
    }
    $chat->resetUnreadMessageCount();
}
echo $html;
示例#13
0
 /**
  * Take over the livesearch when searching for groups
  *
  * @param string $hook         the name of the hook
  * @param string $type         the type of the hook
  * @param array  $return_value current return value
  * @param null   $params       supplied params
  *
  * @see input_livesearch_page_handler()
  *
  * @return void|false
  */
 public static function livesearch($hook, $type, $return_value, $params)
 {
     // only return results to logged in users.
     $user = elgg_get_logged_in_user_entity();
     if (empty($user)) {
         exit;
     }
     $q = get_input('term', get_input('q'));
     if (empty($q)) {
         exit;
     }
     // sanitise search query
     $q = sanitise_string($q);
     // replace mysql vars with escaped strings
     $q = str_replace(['_', '%'], ['\\_', '\\%'], $q);
     $match_on = get_input('match_on', 'all');
     if (!is_array($match_on)) {
         $match_on = [$match_on];
     }
     // only take over groups search
     if (count($match_on) > 1 || !in_array('groups', $match_on)) {
         return;
     }
     $owner_guid = ELGG_ENTITIES_ANY_VALUE;
     if (get_input('match_owner', false)) {
         $owner_guid = $user->getGUID();
     }
     $input_name = get_input('name', 'groups');
     $limit = sanitise_int(get_input('limit', elgg_get_config('default_limit')));
     // fetch groups
     $results = [];
     $dbprefix = elgg_get_config('dbprefix');
     $options = ['type' => 'group', 'limit' => $limit, 'owner_guid' => $owner_guid, 'joins' => ["JOIN {$dbprefix}groups_entity ge ON e.guid = ge.guid"], 'wheres' => ["(ge.name LIKE '%{$q}%' OR ge.description LIKE '%{$q}%')"]];
     $entities = elgg_get_entities($options);
     if (!empty($entities)) {
         foreach ($entities as $entity) {
             $output = elgg_view_list_item($entity, ['use_hover' => false, 'class' => 'elgg-autocomplete-item', 'full_view' => false, 'href' => false, 'title' => $entity->name]);
             $icon = elgg_view_entity_icon($entity, 'tiny', ['use_hover' => false]);
             $result = ['type' => 'group', 'name' => $entity->name, 'desc' => strip_tags($entity->description), 'guid' => $entity->getGUID(), 'label' => $output, 'value' => $entity->getGUID(), 'icon' => $icon, 'url' => $entity->getURL(), 'html' => elgg_view('input/grouppicker/item', ['entity' => $entity, 'input_name' => $input_name])];
             $results[$entity->name . rand(1, 100)] = $result;
         }
     }
     ksort($results);
     header('Content-Type: application/json;charset=utf-8');
     echo json_encode(array_values($results));
     exit;
 }
示例#14
0
                            if (!$col_options) {
                                continue;
                            }
                            if (isset($col_options['override_view']) && elgg_view_exists($col_options['override_view'])) {
                                $cell = elgg_view($col_options['override_view'], $vars);
                            } else {
                                if (elgg_view_exists("{$type}/{$subtype}/elements/{$col_header}")) {
                                    $cell .= elgg_view("{$type}/{$subtype}/elements/{$col_header}", $vars);
                                } else {
                                    if (elgg_view_exists("framework/bootstrap/{$type}/elements/{$col_header}")) {
                                        $cell .= elgg_view("framework/bootstrap/{$type}/elements/{$col_header}", $vars);
                                    } else {
                                        $cell .= '<div>' . $item->{$col_header} . '</div>';
                                    }
                                }
                            }
                        }
                        //$colspan = ' colspan="' . count($options['colspan']) . '"';
                    } else {
                        $cell = '<div>' . $item->{$header} . '</div>';
                    }
                }
            }
        }
        $header_ns = preg_replace('/[^a-z0-9\\-]/i', '-', $header);
        $item_view .= "<td {$colspan} class=\"table-cell-{$header_ns}\">{$cell}</td>";
    }
} else {
    $item_view .= elgg_view_list_item($entity, $vars);
}
echo "<tr {$attributes}>{$item_view}</tr>";
示例#15
0
if (!elgg_is_logged_in()) {
    exit;
}
$q = sanitise_string(get_input('term'));
// replace mysql vars with escaped strings
$q = str_replace(array('_', '%'), array('\\_', '\\%'), $q);
$user_guid = elgg_get_logged_in_user_guid();
$entities = elgg_get_entities(array('type' => 'group', 'owner_guid' => $user_guid, 'limit' => 0));
$entities = array_merge($entities, elgg_get_entities_from_relationship(array('type' => 'group', 'relationship' => 'operator', 'relationship_guid' => $user_guid, 'limit' => 0)));
$all_entities = array();
while (!empty($entities)) {
    $entity = array_pop($entities);
    $childs = elgg_get_entities(array('type' => 'group', 'container_guid' => $entity->guid));
    foreach ($childs as $child) {
        array_push($entities, $child);
    }
    $all_entities[] = $entity;
}
$results = array();
foreach ($all_entities as $entity) {
    if (!preg_match("/^{$q}/i", $entity->name)) {
        continue;
    }
    $output = elgg_view_list_item($entity, array('use_hover' => false, 'class' => 'elgg-autocomplete-item'));
    $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
    $results[$entity->name . $entity->guid] = array('type' => 'group', 'name' => $entity->name, 'desc' => strip_tags($entity->description), 'guid' => $entity->guid, 'label' => $output, 'value' => $entity->guid, 'icon' => $icon, 'url' => $entity->getURL());
}
ksort($results);
header("Content-Type: application/json");
echo json_encode(array_values($results));
exit;
示例#16
0
/**
 * Listen to /livesearc for special mentions search
 *
 * @param string $hook         the name of the hook
 * @param string $type         the type of the hook
 * @param array  $return_value current return value
 * @param array  $params       supplied params
 *
 * @return array
 */
function theme_haarlem_intranet_livesearch_route_handler($hook, $type, $return_value, $params)
{
    $query = get_input('q', get_input('term'));
    if (empty($query)) {
        return $return_value;
    }
    $match_on = get_input('match_on');
    if (empty($match_on)) {
        return $return_value;
    }
    if (is_array($match_on) && count($match_on) > 1) {
        return $return_value;
    }
    if (is_array($match_on)) {
        $match_on = $match_on[0];
    }
    $overrule_cases = array('mentions', 'member_of_site');
    if (!in_array($match_on, $overrule_cases)) {
        return $return_value;
    }
    // backup search advanced mulitsite search setting
    $mulitsite = elgg_extract('search_advanced:multisite', $_SESSION);
    $_SESSION['search_advanced:multisite'] = false;
    $params = array('type' => 'user', 'limit' => 10, 'query' => sanitise_string($query));
    $users = trigger_plugin_hook('search', 'user', $params, array());
    if (empty($users) || !is_array($users)) {
        header("Content-Type: application/json");
        echo json_encode(array());
        return false;
    }
    $count = elgg_extract('count', $users);
    if (empty($count)) {
        header("Content-Type: application/json");
        echo json_encode(array());
        return false;
    }
    $users = elgg_extract('entities', $users);
    $results = array();
    foreach ($users as $user) {
        $output = elgg_view_list_item($user, array('use_hover' => false, 'class' => 'elgg-autocomplete-item'));
        $icon = elgg_view_entity_icon($user, 'tiny', array('use_hover' => false));
        $result = array('type' => 'user', 'name' => $user->name, 'desc' => $user->username, 'guid' => $user->guid, 'label' => $output, 'value' => $user->username, 'icon' => $icon, 'url' => $user->getURL());
        $results[$user->name . rand(1, 100)] = $result;
    }
    ksort($results);
    header("Content-Type: application/json");
    echo json_encode(array_values($results));
    // reset search advanced mulitsite search setting
    $_SESSION['search_advanced:multisite'] = $mulitsite;
    return false;
}
示例#17
0
/**
 * Page handler for autocomplete endpoint.
 *
 * @todo split this into functions/objects, this is way too big
 *
 * /livesearch?q=<query>
 *
 * Other options include:
 *     match_on	   string all or array(groups|users|friends)
 *     match_owner int    0/1
 *     limit       int    default is 10
 *
 * @param array $page
 * @return string JSON string is returned and then exit
 * @access private
 */
function input_livesearch_page_handler($page)
{
    global $CONFIG;
    // only return results to logged in users.
    if (!($user = elgg_get_logged_in_user_entity())) {
        exit;
    }
    if (!($q = get_input('term', get_input('q')))) {
        exit;
    }
    $q = sanitise_string($q);
    // replace mysql vars with escaped strings
    $q = str_replace(array('_', '%'), array('\\_', '\\%'), $q);
    $match_on = get_input('match_on', 'all');
    if (!is_array($match_on)) {
        $match_on = array($match_on);
    }
    // all = users and groups
    if (in_array('all', $match_on)) {
        $match_on = array('users', 'groups');
    }
    if (get_input('match_owner', false)) {
        $owner_where = 'AND e.owner_guid = ' . $user->getGUID();
    } else {
        $owner_where = '';
    }
    $limit = sanitise_int(get_input('limit', 10));
    // grab a list of entities and send them in json.
    $results = array();
    foreach ($match_on as $match_type) {
        switch ($match_type) {
            case 'users':
                $query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as ue, {$CONFIG->dbprefix}entities as e\n\t\t\t\t\tWHERE e.guid = ue.guid\n\t\t\t\t\t\tAND e.enabled = 'yes'\n\t\t\t\t\t\tAND ue.banned = 'no'\n\t\t\t\t\t\tAND (ue.name LIKE '{$q}%' OR ue.name LIKE '% {$q}%' OR ue.username LIKE '{$q}%')\n\t\t\t\t\tLIMIT {$limit}\n\t\t\t\t";
                if ($entities = get_data($query)) {
                    foreach ($entities as $entity) {
                        // @todo use elgg_get_entities (don't query in a loop!)
                        $entity = get_entity($entity->guid);
                        /* @var ElggUser $entity */
                        if (!$entity) {
                            continue;
                        }
                        if (in_array('groups', $match_on)) {
                            $value = $entity->guid;
                        } else {
                            $value = $entity->username;
                        }
                        $output = elgg_view_list_item($entity, array('use_hover' => false, 'class' => 'elgg-autocomplete-item'));
                        $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                        $result = array('type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'guid' => $entity->guid, 'label' => $output, 'value' => $value, 'icon' => $icon, 'url' => $entity->getURL());
                        $results[$entity->name . rand(1, 100)] = $result;
                    }
                }
                break;
            case 'groups':
                // don't return results if groups aren't enabled.
                if (!elgg_is_active_plugin('groups')) {
                    continue;
                }
                $query = "SELECT * FROM {$CONFIG->dbprefix}groups_entity as ge, {$CONFIG->dbprefix}entities as e\n\t\t\t\t\tWHERE e.guid = ge.guid\n\t\t\t\t\t\tAND e.enabled = 'yes'\n\t\t\t\t\t\t{$owner_where}\n\t\t\t\t\t\tAND (ge.name LIKE '{$q}%' OR ge.name LIKE '% {$q}%' OR ge.description LIKE '% {$q}%')\n\t\t\t\t\tLIMIT {$limit}\n\t\t\t\t";
                if ($entities = get_data($query)) {
                    foreach ($entities as $entity) {
                        // @todo use elgg_get_entities (don't query in a loop!)
                        $entity = get_entity($entity->guid);
                        /* @var ElggGroup $entity */
                        if (!$entity) {
                            continue;
                        }
                        $output = elgg_view_list_item($entity, array('use_hover' => false, 'class' => 'elgg-autocomplete-item'));
                        $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                        $result = array('type' => 'group', 'name' => $entity->name, 'desc' => strip_tags($entity->description), 'guid' => $entity->guid, 'label' => $output, 'value' => $entity->guid, 'icon' => $icon, 'url' => $entity->getURL());
                        $results[$entity->name . rand(1, 100)] = $result;
                    }
                }
                break;
            case 'friends':
                $query = "SELECT * FROM\n\t\t\t\t\t\t{$CONFIG->dbprefix}users_entity as ue,\n\t\t\t\t\t\t{$CONFIG->dbprefix}entity_relationships as er,\n\t\t\t\t\t\t{$CONFIG->dbprefix}entities as e\n\t\t\t\t\tWHERE er.relationship = 'friend'\n\t\t\t\t\t\tAND er.guid_one = {$user->getGUID()}\n\t\t\t\t\t\tAND er.guid_two = ue.guid\n\t\t\t\t\t\tAND e.guid = ue.guid\n\t\t\t\t\t\tAND e.enabled = 'yes'\n\t\t\t\t\t\tAND ue.banned = 'no'\n\t\t\t\t\t\tAND (ue.name LIKE '{$q}%' OR ue.name LIKE '% {$q}%' OR ue.username LIKE '{$q}%')\n\t\t\t\t\tLIMIT {$limit}\n\t\t\t\t";
                if ($entities = get_data($query)) {
                    foreach ($entities as $entity) {
                        // @todo use elgg_get_entities (don't query in a loop!)
                        $entity = get_entity($entity->guid);
                        /* @var ElggUser $entity */
                        if (!$entity) {
                            continue;
                        }
                        $output = elgg_view_list_item($entity, array('use_hover' => false, 'class' => 'elgg-autocomplete-item'));
                        $icon = elgg_view_entity_icon($entity, 'tiny', array('use_hover' => false));
                        $result = array('type' => 'user', 'name' => $entity->name, 'desc' => $entity->username, 'guid' => $entity->guid, 'label' => $output, 'value' => $entity->username, 'icon' => $icon, 'url' => $entity->getURL());
                        $results[$entity->name . rand(1, 100)] = $result;
                    }
                }
                break;
            default:
                header("HTTP/1.0 400 Bad Request", true);
                echo "livesearch: unknown match_on of {$match_type}";
                exit;
                break;
        }
    }
    ksort($results);
    header("Content-Type: application/json");
    echo json_encode(array_values($results));
    exit;
}
示例#18
0
<?php

/**
 * Display a notifications list that can be added to the notifications popup.
 */
$notifications = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'notification', 'owner_guid' => elgg_get_logged_in_user_guid(), 'order_by_metadata' => array('name' => 'status', 'direction' => 'DESC')));
if ($notifications) {
    // Use "widgets" context to tell that we're displaying the popup instead of a full list
    elgg_push_context('widgets');
    $list = '';
    foreach ($notifications as $notification) {
        $list_item = elgg_view_list_item($notification, array('full_view' => false));
        $list .= "<li id=\"elgg-object-{$notification->guid}\" class=\"elgg-item elgg-item-object elgg-item-object-notification\">{$list_item}</li>";
    }
    elgg_pop_context();
} else {
    $list = null;
}
echo $list;