diff options
Diffstat (limited to 'views/default/object/plugin')
-rw-r--r-- | views/default/object/plugin/advanced.php | 223 | ||||
-rw-r--r-- | views/default/object/plugin/elements/dependencies.php | 49 | ||||
-rw-r--r-- | views/default/object/plugin/invalid.php | 24 | ||||
-rw-r--r-- | views/default/object/plugin/simple.php | 63 |
4 files changed, 359 insertions, 0 deletions
diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php new file mode 100644 index 000000000..f6a760af4 --- /dev/null +++ b/views/default/object/plugin/advanced.php @@ -0,0 +1,223 @@ +<?php +/** + * Displays a plugin on the admin screen. + * + * This file renders a plugin for the admin screen, including active/deactive, + * manifest details & display plugin settings. + * + * @package Elgg.Core + * @subpackage Plugins + */ + +$plugin = $vars['entity']; +$priority = $plugin->getPriority(); +$active = $plugin->isActive(); + +$name = $plugin->manifest->getName(); +$can_activate = $plugin->canActivate(); +$max_priority = elgg_get_max_plugin_priority(); +$actions_base = '/action/admin/plugins/'; + +$ts = time(); +$token = generate_action_token($ts); +$active_class = ($active && $can_activate) ? 'elgg-state-active' : 'elgg-state-inactive'; + +// build reordering links +$links = ''; + +// top and up link only if not at top +if ($priority > 1) { + $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => 'first', + 'is_action' => true + )); + + $links .= "<li>" . elgg_view('output/url', array( + 'href' => $top_url, + 'text' => elgg_echo('top'), + 'is_action' => true + )) . "</li>"; + + $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => '-1', + 'is_action' => true + )); + + $links .= "<li>" . elgg_view('output/url', array( + 'href' => $up_url, + 'text' => elgg_echo('up'), + 'is_action' => true + )) . "</li>"; +} + +// down and bottom links only if not at bottom +if ($priority < $max_priority) { + $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => '+1', + 'is_action' => true + )); + + $links .= "<li>" . elgg_view('output/url', array( + 'href' => $down_url, + 'text' => elgg_echo('down'), + 'is_action' => true + )) . "</li>"; + + $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => 'last', + 'is_action' => true + )); + + $links .= "<li>" . elgg_view('output/url', array( + 'href' => $bottom_url, + 'text' => elgg_echo('bottom'), + 'is_action' => true + )) . "</li>"; +} + +// activate / deactivate links +if ($can_activate) { + if ($active) { + $action = 'deactivate'; + $class = 'elgg-button-cancel'; + } else { + $action = 'activate'; + $class = 'elgg-button-submit'; + } + + $url = elgg_http_add_url_query_elements($actions_base . $action, array( + 'plugin_guids[]' => $plugin->guid, + 'is_action' => true + )); + + $action_button = elgg_view('output/url', array( + 'href' => $url, + 'text' => elgg_echo($action), + 'is_action' => true, + 'class' => "elgg-button $class" + )); +} else { + $action_button = elgg_view('output/url', array( + 'text' => elgg_echo('admin:plugins:cannot_activate'), + 'disabled' => 'disabled', + 'class' => "elgg-button-action elgg-state-disabled" + )); +} + +// Display categories +$categories_html = ''; +if ($categories) { + $categories_arr = array(); + $base_url = elgg_get_site_url() . "pg/admin/plugins?category="; + + foreach ($categories as $category) { + $url = $base_url . urlencode($category); + $categories_arr[] = "<a href=\"$url\">" . htmlspecialchars($category) . '</a>'; + } + + $categories_html = implode(', ', $categories_arr); +} + +$screenshots_html = ''; +$screenshots = $plugin->manifest->getScreenshots(); +if ($screenshots) { + $base_url = elgg_get_plugins_path() . $plugin->getID() . '/'; + foreach ($screenshots as $screenshot) { + $desc = elgg_echo($screenshot['description']); + $alt = htmlentities($desc, ENT_QUOTES, 'UTF-8'); + $screenshot_full = "{$vars['url']}pg/admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}"; + $screenshot_src = "{$vars['url']}pg/admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}"; + + $screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\"><a href=\"$screenshot_full\">" + . "<img src=\"$screenshot_src\" alt=\"$alt\"></a></li>"; + } +} + +// metadata +$description = elgg_view('output/longtext', array('value' => $plugin->manifest->getDescription())); +$author = '<span>' . elgg_echo('admin:plugins:label:author') . '</span>: ' + . elgg_view('output/text', array('value' => $plugin->manifest->getAuthor())); +$version = htmlspecialchars($plugin->manifest->getVersion()); +$website = elgg_view('output/url', array( + 'href' => $plugin->manifest->getWebsite(), + 'text' => $plugin->manifest->getWebsite() +)); + +$copyright = elgg_view('output/text', array('value' => $plugin->manifest->getCopyright())); +$license = elgg_view('output/text', array('value' => $plugin->manifest->getLicense())); + +?> + +<div class="elgg-state-draggable elgg-plugin <?php echo $active_class ?>" id="elgg-plugin-<?php echo $plugin->guid; ?>"> + <div class="elgg-image-block"> + <div class="elgg-image-alt"> + <ul class="elgg-list-metadata"> + <?php echo "$links"; ?> + </ul> + <div class="clearfloat right mtm"> + <?php echo $action_button; ?> + </div> + </div> + <div class="elgg-body"> +<?php +$settings_view = 'settings/' . $plugin->getID() . '/edit'; +if (elgg_view_exists($settings_view)) { + $link = elgg_get_site_url() . "pg/admin/plugin_settings/" . $plugin->getID(); + $settings_link = "<a class='plugin_settings small link' href='$link'>[" . elgg_echo('settings') . "]</a>"; +} +?> + <div class="elgg-head"> + <h3><?php echo $plugin->manifest->getName(). " $version $settings_link"; ?></h3> + </div> + <?php + if ($plugin->manifest->getApiVersion() < 1.8) { + $reqs = $plugin->manifest->getRequires(); + if (!$reqs) { + $message = elgg_echo('admin:plugins:warning:elgg_version_unknown'); + echo "<p class=\"elgg-state-error\">$message</p>"; + } + } + + if (!$can_activate) { + $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); + echo "<p class=\"elgg-state-error\">$message</p>"; + } + ?> + + <div class="plugin_description"><?php echo $description; ?></div> + <p class="plugin_author"><?php echo $author . ' - ' . $website; ?></p> + + <div class="pts"><a class="elgg-toggler elgg-toggles-elgg-plugin-manifest-<?php echo $plugin->getID(); ?>"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></div> + </div> + </div> + <div class="hidden manifest_file" id="elgg-plugin-manifest-<?php echo $plugin->getID(); ?>"> + + <?php + if ($screenshots_html) { + ?> + <div><ul><?php echo $screenshots_html; ?></ul></div> + <?php + } + + if ($categories_html) { + ?> + <div><?php echo elgg_echo('admin:plugins:label:categories') . ": " . $categories_html; ?></div> + <?php + } + + ?> + <div><?php echo elgg_echo('admin:plugins:label:copyright') . ": " . $copyright; ?></div> + <div><?php echo elgg_echo('admin:plugins:label:licence') . ": " . $license; ?></div> + <div><?php echo elgg_echo('admin:plugins:label:location') . ": " . htmlspecialchars($plugin->getPath()) ?></div> + + <div><?php echo elgg_echo('admin:plugins:label:dependencies'); ?>: + <?php + echo elgg_view('admin/components/plugin_dependencies', array('plugin' => $plugin)); + ?> + </div> + </div> +</div>
\ No newline at end of file diff --git a/views/default/object/plugin/elements/dependencies.php b/views/default/object/plugin/elements/dependencies.php new file mode 100644 index 000000000..ea2b3a188 --- /dev/null +++ b/views/default/object/plugin/elements/dependencies.php @@ -0,0 +1,49 @@ +<?php +/** + * Shows a table of plugin dependecies for ElggPlugin in $vars['plugin']. + * + * This uses a table because it's a table of data. + * + * @package Elgg.Core + * @subpackage Admin.Plugins + */ + +$plugin = elgg_extract('plugin', $vars, false); +$deps = $plugin->package->checkDependencies(true); + +$columns = array('type', 'name', 'expected_value', 'local_value', 'comment'); + +echo '<table class="elgg-plugins-dependencies styled"> + <tr> +'; + +foreach ($columns as $column) { + $column = elgg_echo("admin:plugins:dependencies:$column"); + echo "<th class=\"pas\">$column</th>"; +} + +echo '<tr/>'; + +$row = 'odd'; +foreach ($deps as $dep) { + $fields = elgg_get_plugin_dependency_strings($dep); + $type = $dep['type']; + + if ($dep['status']) { + $class = "elgg-state-success elgg-dependency-$type"; + } else { + $class = "elgg-state-error elgg-dependency-$type"; + } + + echo "<tr class=\"$row\">"; + + foreach ($columns as $column) { + echo "<td class=\"pas $class\">{$fields[$column]}</td>"; + } + + echo '</tr>'; + + $row = ($row == 'odd') ? 'even' : 'odd'; +} + +echo '</table>';
\ No newline at end of file diff --git a/views/default/object/plugin/invalid.php b/views/default/object/plugin/invalid.php new file mode 100644 index 000000000..7fd5d6f5e --- /dev/null +++ b/views/default/object/plugin/invalid.php @@ -0,0 +1,24 @@ +<?php +/** + * Displays an invalid plugin on the admin screen. + * + * An invalid plugin is a plugin whose isValid() method returns false. + * This usually means there are required files missing, unreadable or in the + * wrong format. + * + * @package Elgg.Core + * @subpackage Plugins + */ + +$plugin = $vars['entity']; + +$id = $plugin->getID(); +$path = htmlspecialchars($plugin->getPath()); +$message = elgg_echo('admin:plugins:warning:invalid', array($id)); + +?> + +<div class="elgg-plugin elgg-state-inactive elgg-state-error"> + <p><?php echo $message; ?></p> + <p><?php echo elgg_echo('admin:plugins:label:location') . ": " . $path; ?></p> +</div> diff --git a/views/default/object/plugin/simple.php b/views/default/object/plugin/simple.php new file mode 100644 index 000000000..49ef58313 --- /dev/null +++ b/views/default/object/plugin/simple.php @@ -0,0 +1,63 @@ +<?php +$plugin = $vars['entity']; + +$plugin_guid = $plugin->guid; +$plugin_id = $plugin->getID(); +$active = $plugin->isActive(); +$can_activate = $plugin->canActivate(); +$name = $plugin->manifest->getName(); +$author = $plugin->manifest->getAuthor(); +$version = $plugin->manifest->getVersion(); +$website = $plugin->manifest->getWebsite(); +$description = $plugin->manifest->getDescription(); + +if ($active) { + $active_class = 'elgg-state-active'; + $checked = 'checked="checked"'; +} else { + $active_class = 'elgg-state-inactive'; + $checked = ''; +} + +if ($can_activate) { + $disabled = ''; +} else { + $disabled = 'disabled="disabled"'; + $description .= '<p>' . elgg_echo('admin:plugins:simple:cannot_activate') . '</p>'; +} + +$description = elgg_view('output/longtext', array('value' => $description)); + +$plugin_footer = '<ul class="elgg-menu elgg-menu-footer">'; + +if ($author) { + $plugin_footer .= '<li>' . elgg_echo('admin:plugins:author', array($author)) . '</li>'; +} + +if ($version) { + $plugin_footer .= '<li>' . elgg_echo('admin:plugins:version', array($version)) . '</li>'; +} + +if ($website) { + $plugin_footer .= "<li><a href=\"$website\">" . elgg_echo('admin:plugins:plugin_website') . '</a></li>'; +} + +if (elgg_view_exists("settings/$plugin_id/edit")) { + $settings_href = elgg_get_site_url() . "pg/admin/plugin_settings/$plugin_id"; + $plugin_footer .= "<li><a class='plugin_settings link' href='$settings_href'>" . elgg_echo('settings') . "</a></li>"; +} + +$plugin_footer .= "</ul>"; + +echo <<<___END + <div class="elgg-plugin $active_class elgg-grid"> + <div class="elgg-col elgg-col-1of5"> + <input type="checkbox" id="$plugin_guid" $checked $disabled name="active_plugin_guids[]" value="$plugin_guid"/> + <label for="$plugin_guid">$name</label> + </div> + <div class="elgg-col elgg-col-4of5"> + $description + $plugin_footer + </div> + </div> +___END; |