diff options
Diffstat (limited to 'views/default/admin/components')
-rw-r--r-- | views/default/admin/components/admin_page_layout.php | 36 | ||||
-rw-r--r-- | views/default/admin/components/plugin.php | 155 | ||||
-rw-r--r-- | views/default/admin/components/plugin_settings.php | 21 | ||||
-rw-r--r-- | views/default/admin/components/sidemenu.php | 105 |
4 files changed, 317 insertions, 0 deletions
diff --git a/views/default/admin/components/admin_page_layout.php b/views/default/admin/components/admin_page_layout.php new file mode 100644 index 000000000..4f2a67d48 --- /dev/null +++ b/views/default/admin/components/admin_page_layout.php @@ -0,0 +1,36 @@ +<?php +/** + * Elgg admin page layout. Includes the admin sidebar and the ownerblock (for legacy support) + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ + +$notices_html = ''; +if ($notices = elgg_get_admin_notices()) { + foreach ($notices as $notice) { + $notices_html .= elgg_view_entity($notice); + } +} + +?> +<div id="elgg_content" class="clearfloat sidebar"> + <div id="elgg_sidebar"> + <?php + echo elgg_view('admin/components/sidemenu', $vars); + echo '<hr />'; + echo elgg_view('page_elements/owner_block'); + ?> + </div> + + <div id="elgg_page_contents" class="clearfloat"> + <?php + if ($notices) { + echo "<div class=\"admin_notices\">$notices_html</div>"; + } + echo $vars['content']; + ?> + </div> +</div> diff --git a/views/default/admin/components/plugin.php b/views/default/admin/components/plugin.php new file mode 100644 index 000000000..e56cdd4ef --- /dev/null +++ b/views/default/admin/components/plugin.php @@ -0,0 +1,155 @@ +<?php +/** + * Elgg plugin manifest class + * + * This file renders a plugin for the admin screen, including active/deactive, manifest details & display plugin + * settings. + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ + +$plugin = $vars['plugin']; +$details = $vars['details']; + +$active = $details['active']; +$manifest = $details['manifest']; + +$plugin_pretty_name = (isset($manifest['name'])) ? $manifest['name'] : $plugin; + +// Check elgg version if available +$version_check_valid = false; +if ($manifest['elgg_version']) { + $version_check_valid = check_plugin_compatibility($manifest['elgg_version']); +} + +$ts = time(); +$token = generate_action_token($ts); +$active_class = ($active) ? 'active' : 'not_active'; + +$top_url = $up_url = $down_url = $bottom_url = ''; +if ($vars['order'] > 10) { + $top_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=1&__elgg_token=$token&__elgg_ts=$ts"; + $top_link = '<a href="' . elgg_format_url($top_url) . '">' . elgg_echo('top') . '</a>'; + + $order = $vars['order'] - 11; + + $up_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts"; + $up_link = '<a href="' . elgg_format_url($up_url) . '">' . elgg_echo('up') . '</a>'; +} + +if ($vars['order'] < $vars['maxorder']) { + $order = $vars['order'] + 11; + $down_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts"; + $down_link = '<a href="' . elgg_format_url($down_url) . '">' . elgg_echo('down') . '</a>'; + + $order = $vars['maxorder'] + 11; + $bottom_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts"; + $bottom_link = '<a href="' . elgg_format_url($bottom_url) . '">' . elgg_echo('bottom') . '</a>'; +} + +if ($active) { + $url = "{$vars['url']}action/admin/plugins/disable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts"; + $enable_disable = '<a class="cancel_button" href="' . elgg_format_url($url) . '">' . elgg_echo('disable') . '</a>'; +} else { + $url = "{$vars['url']}action/admin/plugins/enable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts"; + $enable_disable = '<a class="submit_button" href="' . elgg_format_url($url) . '">' . elgg_echo('enable') . '</a>'; +} + + +$categories_list = ''; +if ($manifest['category']) { + $categories_arr = array(); + $base_url = "{$vars['url']}pg/admin/plugins?category="; + + foreach($manifest['category'] as $category) { + $url = $base_url . urlencode($category); + $categories_arr[] = "<a href=\"$url\">" . htmlspecialchars($category) . '</a>'; + } + + $categories_list = implode(', ', $categories_arr); +} + +$screenshots = ''; +if ($manifest['screenshot']) { + $base_url = "{$vars['url']}mod/"; + + $limit = 4; + foreach ($manifest['screenshot'] as $screenshot) { + if ($limit <= 0) { + break; + } + + $screenshot_src = $base_url . $plugin . "/$screenshot"; + $screenshots .= "<li class=\"plugin_screenshot\"><a href=\"$screenshot_src\"><img src=\"$screenshot_src\"></a></li>"; + + $limit--; + } +} + +?> + +<div class="plugin_details <?php echo $active_class ?>"> + <div class="admin_plugin_reorder"> + <?php echo "$top_link $up_link $down_link $bottom_link"; ?> + </div><div class="clearfloat"></div> + + <div class="admin_plugin_enable_disable"><?php echo $enable_disable; ?></div> + + <?php + if (elgg_view_exists("settings/{$plugin}/edit")) { + $link = "{$vars['url']}pg/admin/plugin_settings/$plugin"; + $settings_link = "<a class='plugin_settings small link' href='$link'>[". elgg_echo('settings') ."]</a>"; + } + ?> + <h3><?php echo "$plugin_pretty_name $settings_link"; ?></h3> + <?php + echo $settings_panel; + + if ($manifest) { + ?> + <div class="plugin_description"><?php echo elgg_view('output/longtext',array('value' => $manifest['description'])); ?></div> + <div><span class="plugin_label"><?php echo elgg_echo('admin:plugins:label:author') . "</span>: ". htmlspecialchars($manifest['author']) ?></div> + <div><span class="plugin_label"><?php echo elgg_echo('admin:plugins:label:version') . "</span>: ". htmlspecialchars($manifest['version']) ?></div> + + <p><a class="manifest_details small link"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p> + + <div class="manifest_file hidden"> + + <?php + if ((!$version_check_valid) || (!isset($manifest['elgg_version']))) { + ?> + <div id="version_check"> + <?php + if (!isset($manifest['elgg_version'])) { + echo elgg_echo('admin:plugins:warning:elggversionunknown'); + } else { + echo elgg_echo('admin:plugins:warning:elggtoolow'); + } + ?> + </div> + <?php + } + + ?> + <div><?php echo elgg_echo('admin:plugins:label:directory') . ": ". htmlspecialchars($plugin) ?></div> + <?php + if ($categories_list) { + ?> + <div><?php echo elgg_echo('admin:plugins:label:categories') . ": ". $categories_list ?></div> + <?php + } + if ($screenshots) { + ?> + <div><ul><?php echo $screenshots; ?></ul></div> + <?php + } + ?> + <div><?php echo elgg_echo('admin:plugins:label:copyright') . ": ". htmlspecialchars($manifest['copyright']) ?></div> + <div><?php echo elgg_echo('admin:plugins:label:licence') . ": ". htmlspecialchars($manifest['licence'] . $manifest['license']) ?></div> + <div><?php echo elgg_echo('admin:plugins:label:website') . ": "; ?><a href="<?php echo $manifest['website']; ?>"><?php echo $manifest['website']; ?></a></div> + <?php } ?> + </div> +</div>
\ No newline at end of file diff --git a/views/default/admin/components/plugin_settings.php b/views/default/admin/components/plugin_settings.php new file mode 100644 index 000000000..22544e45f --- /dev/null +++ b/views/default/admin/components/plugin_settings.php @@ -0,0 +1,21 @@ +<?php +/** + * Elgg plugin settings + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ + +$plugin = $vars['plugin']; +$plugin_info = load_plugin_manifest($plugin); + +$form_body = elgg_view("settings/{$plugin}/edit", $vars); +$form_body .= elgg_view('input/hidden', array('internalname' => 'plugin', 'value' => $plugin)); +$form_body .= '<p>' . elgg_view('input/submit', array('value' => elgg_echo('save'))); +$form_body .= elgg_view('input/reset', array('value' => elgg_echo('reset'))) . '</p>'; + +echo elgg_view_title($plugin_info['name']); + +echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$vars['url']}action/plugins/settings/save"));
\ No newline at end of file diff --git a/views/default/admin/components/sidemenu.php b/views/default/admin/components/sidemenu.php new file mode 100644 index 000000000..4e02eecd9 --- /dev/null +++ b/views/default/admin/components/sidemenu.php @@ -0,0 +1,105 @@ +<?php +/** + * Elgg admin sidebar + * + * @package Elgg + * @subpackage Core + * @author Curverider Ltd + * @link http://elgg.org/ + */ + +$sections = $vars['config']->admin_sections; +$current_section = $vars['page'][0]; +$child_section = (isset($vars['page'][1])) ? $vars['page'][1] : NULL; + +// "Plugin Settings" is a special sidemenu item that is added automatically +// it's calculated here instead of in admin_init() because of preformance concerns. +$installed_plugins = get_installed_plugins(); +$plugin_settings_children = $sort = array(); +foreach ($installed_plugins as $plugin_id => $info) { + if (!$info['active']) { + continue; + } + + // @todo might not need to check if plugin is enabled here because + // this view wouldn't exist if it's not. right? + if (is_plugin_enabled($plugin_id) && elgg_view_exists("settings/{$plugin_id}/edit")) { + $plugin_settings_children[$plugin_id] = array( + 'title' => $info['manifest']['name'] + ); + $sort[] = elgg_strtolower($info['manifest']['name']); + } +} + +array_multisort($sort, SORT_ASC, SORT_STRING, $plugin_settings_children); + +if ($plugin_settings_children) { + // merge in legacy support with new support. + if (!isset($sections['plugin_settings'])) { + $sections['plugin_settings'] = array( + 'title' => elgg_echo('admin:plugin_settings'), + 'children' => $plugin_settings_children + ); + } else { + $sections['plugin_settings']['title'] = elgg_echo('admin:plugin_settings'); + if (isset($sections['plugin_settings']['children'])) { + $children = array_merge($plugin_settings_children, $sections['plugin_settings']['children']); + $sections['plugin_settings']['children'] = $children; + } + } +} + +?> + +<ul class="admin submenu"> + <?php foreach ($sections as $id => $info) { + $parent_class = ($current_section == $id) ? 'selected' : ''; + $link = "{$vars['url']}pg/admin/$id"; + + $expand_child = $children_menu = $expanded = ''; + // parent menu items with children default to the first child element. + if (isset($info['children']) && $info['children']) { + $link = ''; + if ($current_section == $id) { + $hidden = ''; + $expanded = '-'; + } else { + $hidden = 'style="display: none;"'; + $expanded = '+'; + } + $expand_child = "<span class=\"expand_child\">$expanded</span> "; + $children_menu = "<ul class=\"admin child_submenu\" $hidden>"; + foreach ($info['children'] as $child_id => $child_info) { + $child_selected = ($child_section == $child_id) ? "class=\"selected\"" : ''; + $child_link = "{$vars['url']}pg/admin/$id/$child_id"; + if (!$link) { + $link = $child_link; + } + $children_menu .= "<li $child_selected><a href=\"$child_link\">{$child_info['title']}</a></li>"; + } + $children_menu .= '</ul>'; + } + + $parent_class = ($parent_class) ? "class=\"$parent_class\"" : ''; + + echo "<li $parent_class><a href=\"$link\">$expand_child{$info['title']}</a> + $children_menu + </li>"; + } + ?> +</ul> + +<script type="text/javascript"> + $('a span.expand_child').click(function() { + var submenu = $(this).parent().parent().find('ul.child_submenu'); + submenu.slideToggle(); + + if ($(this).html() == '+') { + $(this).html('-'); + } else { + $(this).html('+'); + } + + return false; + }); +</script>
\ No newline at end of file |