本文整理汇总了PHP中elgg_get_widget_types函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_widget_types函数的具体用法?PHP elgg_get_widget_types怎么用?PHP elgg_get_widget_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_widget_types函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_widget_types
/**
* Returns an array of stdClass objects representing the defined widget types
*
* @return array A list of types defined (if any)
* @deprecated 1.8 Use elgg_get_widget_types
*/
function get_widget_types()
{
elgg_deprecated_notice("get_widget_types deprecrated for elgg_get_widget_types", 1.8);
return elgg_get_widget_types();
}
示例2: elgg_get_widget_types
<?php
$widget_context = $vars["widget_context"];
// get widgets
$exact = false;
if ($widget_context == "groups") {
$exact = true;
}
$widgets = elgg_get_widget_types($widget_context, $exact);
widget_manager_sort_widgets($widgets);
// sort alphabetically
if (!empty($widgets)) {
$list = "<table class='elgg-table'>";
$list .= "<tr>";
$list .= "<th>" . elgg_echo("widget") . "</th>";
$list .= "<th class='center'>" . elgg_echo("widget_manager:forms:settings:can_add") . "</th>";
$list .= "<th class='center'>" . elgg_echo("hide") . "</th>";
$list .= "</tr>";
foreach ($widgets as $handler => $widget) {
$check_add = "";
$check_hide = "";
if (widget_manager_get_widget_setting($handler, "can_add", $widget_context)) {
$check_add = "checked='checked'";
}
if (widget_manager_get_widget_setting($handler, "hide", $widget_context)) {
$check_hide = "checked='checked'";
}
$list .= "<tr>";
$list .= "<td><span title='[" . $handler . "] " . $widget->description . "'>" . $widget->name . "</span></td>";
$list .= "<td class='center'><input type='checkbox' name='" . $widget_context . "_" . $handler . "_can_add' value='yes' " . $check_add . " /></td>";
$list .= "<td class='center'><input type='checkbox' name='" . $widget_context . "_" . $handler . "_hide' value='yes' " . $check_hide . "/></td>";
示例3: elgg_extract
/**
* Elgg widgets layout
*
* @uses $vars['content'] Optional display box at the top of layout
* @uses $vars['num_columns'] Number of widget columns for this layout (3)
* @uses $vars['show_add_widgets'] Display the add widgets button and panel (true)
* @uses $vars['exact_match'] Widgets must match the current context (false)
* @uses $vars['show_access'] Show the access control (true)
*/
$num_columns = elgg_extract('num_columns', $vars, 2);
$show_add_widgets = elgg_extract('show_add_widgets', $vars, true);
$exact_match = elgg_extract('exact_match', $vars, false);
$show_access = elgg_extract('show_access', $vars, true);
$owner = elgg_get_page_owner_entity();
$widget_types = elgg_get_widget_types();
$context = elgg_get_context();
elgg_push_context('widgets');
$widgets = elgg_get_widgets($owner->guid, $context);
echo '<div class="elgg-layout-widgets">';
if (elgg_can_edit_widget_layout($context)) {
if ($show_add_widgets) {
echo elgg_view('page/layouts/widgets/add_button');
}
$params = array('widgets' => $widgets, 'context' => $context, 'exact_match' => $exact_match, 'show_access' => $show_access, 'class' => 'btn btn-primary mrgn-bttm-sm');
echo elgg_view('page/layouts/widgets/add_panel', $params);
}
/*
if (isset($vars['content'])) {
echo $vars['content'];
}
示例4: elgg_extract
* Elgg widgets layout
*
* @uses $vars['content'] Optional display box at the top of layout
* @uses $vars['num_columns'] Number of widget columns for this layout (3)
* @uses $vars['show_add_widgets'] Display the add widgets button and panel (true)
* @uses $vars['exact_match'] Widgets must match the current context (false)
* @uses $vars['show_access'] Show the access control (true)
*/
$num_columns = elgg_extract('num_columns', $vars, 3);
$show_add_widgets = elgg_extract('show_add_widgets', $vars, true);
$exact_match = elgg_extract('exact_match', $vars, false);
$show_access = elgg_extract('show_access', $vars, true);
$owner = elgg_get_page_owner_entity();
$context = elgg_get_context();
$available_widgets_context = elgg_trigger_plugin_hook("available_widgets_context", "widget_manager", array(), $context);
$widget_types = elgg_get_widget_types($available_widgets_context);
elgg_push_context('widgets');
if ($context == "dashboard" && widget_manager_multi_dashboard_enabled() && !elgg_in_context("admin")) {
$md_guid = get_input("multi_dashboard_guid");
if (!empty($md_guid)) {
$md_object = get_entity($md_guid);
if ($md_object) {
$md_type = $md_object->getDashboardType();
if (in_array($md_type, array("iframe", "internal"))) {
elgg_push_context("iframe_dashboard");
} else {
$num_columns = $md_object->getNumColumns();
}
}
}
$options = array("type" => "object", "subtype" => MultiDashboard::SUBTYPE, "limit" => false, "owner_guid" => elgg_get_logged_in_user_guid(), "order_by" => "e.time_created ASC");
示例5: elgg_extract
<?php
/**
* Widget object
*
* @uses $vars['entity'] ElggWidget
* @uses $vars['show_access'] Show the access control in edit area? (true)
*/
$widget = $vars['entity'];
if (!elgg_instanceof($widget, 'object', 'widget')) {
return true;
}
$show_access = elgg_extract('show_access', $vars, true);
// @todo catch for disabled plugins
$widget_types = elgg_get_widget_types('all');
$handler = $widget->handler;
$title = $widget->getTitle();
$edit_area = '';
$can_edit = $widget->canEdit();
if ($can_edit) {
$edit_area = elgg_view('object/widget/elements/settings', array('widget' => $widget, 'show_access' => $show_access));
}
$controls = elgg_view('object/widget/elements/controls', array('widget' => $widget, 'show_edit' => $edit_area != ''));
// don't show content for default widgets
if (elgg_in_context('default_widgets')) {
$content = '';
} else {
if (elgg_view_exists("widgets/{$handler}/content")) {
$content = elgg_view("widgets/{$handler}/content", $vars);
} else {
elgg_deprecated_notice("widgets use content as the display view", 1.8);
示例6: str_replace
position: index
}
});
}
}
});
}
elgg.register_hook_handler('init', 'system', widget_manager_widget_add_init);
</script>
<?php
$widget_context = str_replace("default_", "", $context);
$available_widgets_context = elgg_trigger_plugin_hook("available_widgets_context", "widget_manager", array(), $widget_context);
$widgets = elgg_get_widget_types($available_widgets_context, $vars["exact_match"]);
widget_manager_sort_widgets($widgets);
$current_handlers = array();
if (!empty($vars["widgets"])) {
// check for already used widgets
foreach ($vars["widgets"] as $column_widgets) {
// foreach column
foreach ($column_widgets as $widget) {
// for each widgets
$current_handlers[] = $widget->handler;
}
}
}
$title = "<div id='widget_manager_widgets_search'>";
$title .= "<input title='" . elgg_echo("search") . "' type='text' value='" . elgg_echo("search") . "' onfocus='if(\$(this).val() == \"" . elgg_echo("search") . "\"){ \$(this).val(\"\"); }' onkeyup='widget_manager_widgets_search(\$(this).val());'></input>";
$title .= "</div>";
示例7: move
/**
* Move the widget
*
* @param int $column The widget column
* @param int $rank Zero-based rank from the top of the column
* @return void
* @since 1.8.0
*/
public function move($column, $rank)
{
$options = array('type' => 'object', 'subtype' => 'widget', 'container_guid' => $this->container_guid, 'limit' => false, 'private_setting_name_value_pairs' => array(array('name' => 'context', 'value' => $this->getContext()), array('name' => 'column', 'value' => $column)));
$widgets = elgg_get_entities_from_private_settings($options);
if (!$widgets) {
$this->column = (int) $column;
$this->order = 0;
return;
}
usort($widgets, create_function('$a,$b', 'return (int)$a->order > (int)$b->order;'));
// remove widgets from inactive plugins
$widget_types = elgg_get_widget_types($this->context);
$inactive_widgets = array();
foreach ($widgets as $index => $widget) {
if (!array_key_exists($widget->handler, $widget_types)) {
$inactive_widgets[] = $widget;
unset($widgets[$index]);
}
}
if ($rank == 0) {
// top of the column
$this->order = reset($widgets)->order - 10;
} elseif ($rank == count($widgets) - 1) {
// bottom of the column of active widgets
$this->order = end($widgets)->order + 10;
} else {
// reorder widgets
// remove the widget that's being moved from the array
foreach ($widgets as $index => $widget) {
if ($widget->guid == $this->guid) {
unset($widgets[$index]);
}
}
// split the array in two and recombine with the moved widget in middle
$before = array_slice($widgets, 0, $rank);
array_push($before, $this);
$after = array_slice($widgets, $rank);
$widgets = array_merge($before, $after);
ksort($widgets);
$order = 0;
foreach ($widgets as $widget) {
$widget->order = $order;
$order += 10;
}
}
// put inactive widgets at the bottom
if ($inactive_widgets) {
$bottom = 0;
foreach ($widgets as $widget) {
if ($widget->order > $bottom) {
$bottom = $widget->order;
}
}
$bottom += 10;
foreach ($inactive_widgets as $widget) {
$widget->order = $bottom;
$bottom += 10;
}
}
$this->column = $column;
}
示例8: elseif
$style .= "#elgg-widget-col-" . $col_index . " { width: " . $col_width . "%; }";
}
// determine top row width
if ($index_top_row == "two_column_left") {
$top_row_width = 100 - $columns[0];
}
break;
}
if ($index_top_row == "full_row" || $num_columns === 2) {
$top_row_width = 100;
} elseif ($index_top_row == "two_column_left") {
$float = "float: left;";
}
$top_row_used = false;
if (!empty($index_top_row) && $index_top_row != "none") {
$widget_types = elgg_get_widget_types("index", false);
elgg_push_context('widgets');
$widgets = elgg_get_widgets(elgg_get_page_owner_entity()->getGUID(), "index");
$widget_content = "";
if (isset($widgets[4])) {
$column_widgets = $widgets[4];
if (sizeof($column_widgets) > 0) {
foreach ($column_widgets as $widget) {
if (array_key_exists($widget->handler, $widget_types)) {
$widget_content .= elgg_view_entity($widget, array('show_access' => true));
}
}
}
}
$top_row = "<div id='elgg-widget-col-4' class='elgg-widgets'>" . $widget_content . "</div>";
if (elgg_is_admin_logged_in()) {
示例9: get_input
<?php
$widget_context = get_input("widget_context");
if (!empty($widget_context)) {
$error_count = 0;
if ($widgets = elgg_get_widget_types($widget_context)) {
$toggle_settings = array("can_add", "hide");
foreach ($widgets as $handler => $widget) {
foreach ($toggle_settings as $setting) {
$input_name = $widget_context . "_" . $handler . "_" . $setting;
$value = get_input($input_name, "no");
if (!widget_manager_set_widget_setting($handler, $setting, $widget_context, $value)) {
$error_count++;
register_error(elgg_echo("widget_manager:action:manage:error:save_setting", array($setting, $widget->name)));
}
}
}
elgg_get_system_cache()->delete("widget_manager_widget_settings");
}
if ($error_count == 0) {
system_message(elgg_echo("widget_manager:action:manage:success"));
}
} else {
register_error(elgg_echo("widget_manager:action:manage:error:context"));
}
forward(REFERER);
示例10: get_input
<?php
$widgets_config = get_input('widgets_config');
$contexts = ['index'];
// Use contexts defined for default widgets
$list = elgg_trigger_plugin_hook('get_list', 'default_widgets', null, []);
foreach ($list as $context_opts) {
$contexts[] = $context_opts['widget_context'];
}
$configured_widgets = [];
foreach ($contexts as $context) {
$configured_widgets += elgg_get_widget_types($context);
}
foreach ($widgets_config as $widget_id => $widget_config) {
$configured_widget = elgg_extract($widget_id, $configured_widgets);
if (empty($configured_widget)) {
continue;
}
// only store if different
if ((bool) $widget_config['multiple'] == (bool) $configured_widget->originals['multiple']) {
unset($widgets_config[$widget_id]['multiple']);
}
$configured_contexts = $configured_widget->originals['context'];
foreach ($widget_config['contexts'] as $context => $context_config) {
if ($context_config['enabled']) {
if (in_array($context, $configured_contexts)) {
unset($widgets_config[$widget_id]['contexts'][$context]['enabled']);
}
} elseif (!in_array($context, $configured_contexts)) {
unset($widgets_config[$widget_id]['contexts'][$context]['enabled']);
}
示例11: elgg_extract
$show_access = (int) elgg_extract('show_access', $vars);
$exact = elgg_extract('exact_match', $vars, false);
$owner_guid = (int) elgg_extract('owner_guid', $vars);
$context_stack = elgg_extract('context_stack', $vars);
if (!empty($context_stack)) {
elgg_set_context_stack($context_stack);
}
elgg_set_page_owner_guid($owner_guid);
$owner = elgg_get_page_owner_entity();
$container = elgg_extract('container', $vars, elgg_get_page_owner_entity());
echo elgg_view('input/hidden', ['name' => 'widget_context', 'value' => $widget_context]);
echo elgg_view('input/hidden', ['name' => 'show_access', 'value' => $show_access]);
$widget_context = str_replace('default_', '', $context);
$available_widgets_context = elgg_trigger_plugin_hook('available_widgets_context', 'widget_manager', [], $widget_context);
$widgets = elgg_get_widget_types($available_widgets_context, $exact);
$widgets = elgg_get_widget_types(['context' => $available_widgets_context, 'exact' => $exact, 'container' => $container]);
widget_manager_sort_widgets($widgets);
$user_widgets = elgg_extract('user_widgets', $vars);
if (!isset($vars['user_widgets'])) {
$user_widgets = elgg_get_widgets($owner->guid, $context);
}
$current_handlers = [];
if (!empty($user_widgets)) {
// check for already used widgets
foreach ($user_widgets as $column_widgets) {
// foreach column
foreach ($column_widgets as $column_widget) {
// for each widgets
$current_handlers[] = $column_widget->handler;
}
}
示例12: elgg_extract
$result = '';
$no_widgets = elgg_extract('no_widgets', $vars);
if (empty($widgets) && !empty($no_widgets)) {
if ($no_widgets instanceof \Closure) {
echo $no_widgets();
} else {
$result .= $no_widgets;
}
}
if ($show_add_widgets && elgg_can_edit_widget_layout($context)) {
$result .= elgg_view('page/layouts/widgets/add_button', $vars);
}
// push context after the add_button as add button uses current context
elgg_push_context('widgets');
if ($widgets) {
$widget_types = elgg_get_widget_types(['context' => $context, 'container' => $owner]);
}
$widget_class = "elgg-col-1of{$num_columns}";
// move hidden columns widgets to last visible column
if (!isset($widgets[$num_columns])) {
$widgets[$num_columns] = [];
}
foreach ($widgets as $index => $column_widgets) {
if ($index <= $num_columns) {
continue;
}
// append widgets to last column and retain order
foreach ($column_widgets as $column_widget) {
$widgets[$num_columns][] = $column_widget;
}
unset($widgets[$index]);
示例13: widget_manager_widgets_action_hook_handler
/**
* Registers the extra context permissions check hook
*
* @param string $hook_name name of the hook
* @param string $entity_type type of the hook
* @param string $return_value current return value
* @param array $params hook parameters
*
* @return void
*/
function widget_manager_widgets_action_hook_handler($hook_name, $entity_type, $return_value, $params)
{
if ($entity_type == 'widgets/move') {
$widget_guid = (int) get_input('widget_guid');
if (empty($widget_guid)) {
return;
}
$widget = get_entity($widget_guid);
if (!elgg_instanceof($widget, 'object', 'widget')) {
return;
}
$widget_context = $widget->context;
$index_widgets = elgg_get_widget_types('index');
foreach ($index_widgets as $handler => $index_widget) {
$contexts = $index_widget->context;
$contexts[] = $widget_context;
elgg_register_widget_type($handler, $index_widget->name, $index_widget->description, $contexts, $index_widget->multiple);
}
} elseif ($entity_type == 'widgets/add') {
elgg_register_plugin_hook_handler('permissions_check', 'site', 'widget_manager_permissions_check_site_hook_handler');
}
}
示例14: widget_manager_widgets_action_hook_handler
/**
* Registers the extra context permissions check hook
*
* @param string $hook_name name of the hook
* @param string $entity_type type of the hook
* @param string $return_value current return value
* @param array $params hook parameters
*
* @return void
*/
function widget_manager_widgets_action_hook_handler($hook_name, $entity_type, $return_value, $params)
{
if ($entity_type == "widgets/move") {
$widget_guid = get_input("widget_guid");
if ($widget_guid) {
$widget = get_entity($widget_guid);
if ($widget && $widget instanceof ElggWidget) {
$widget_context = $widget->context;
$index_widgets = elgg_get_widget_types("index");
foreach ($index_widgets as $handler => $index_widget) {
$contexts = $index_widget->context;
$contexts[] = $widget_context;
elgg_register_widget_type($handler, $index_widget->name, $index_widget->description, $contexts, $index_widget->multiple);
}
}
}
} elseif ($entity_type == "widgets/add") {
elgg_register_plugin_hook_handler("permissions_check", "site", "widget_manager_permissions_check_site_hook_handler");
}
}