getFriendlyCategory() публичный статический Метод

Returns a category's friendly name. This can be localized by defining the string 'admin:plugins:category:'. If no localization is found, returns the category with _ and - converted to ' ' and then ucwords()'d.
public static getFriendlyCategory ( string $category ) : string
$category string The category as defined in the manifest.
Результат string A human-readable category
Пример #1
0
// @todo this could be cached somewhere after have the manifest loaded
$categories = array();
foreach ($installed_plugins as $id => $plugin) {
    if (!$plugin->isValid()) {
        if ($plugin->isActive()) {
            // force disable and warn
            elgg_add_admin_notice('invalid_and_deactivated_' . $plugin->getID(), elgg_echo('ElggPlugin:InvalidAndDeactivated', array($plugin->getId())));
            $plugin->deactivate();
        }
        continue;
    }
    $plugin_categories = $plugin->getManifest()->getCategories();
    if (isset($plugin_categories)) {
        foreach ($plugin_categories as $category) {
            if (!array_key_exists($category, $categories)) {
                $categories[$category] = ElggPluginManifest::getFriendlyCategory($category);
            }
        }
    }
}
asort($categories);
// we want bundled/nonbundled pulled to be at the top of the list
unset($categories['bundled']);
unset($categories['nonbundled']);
$common_categories = ['all' => elgg_echo('admin:plugins:category:all'), 'active' => elgg_echo('admin:plugins:category:active'), 'inactive' => elgg_echo('admin:plugins:category:inactive'), 'bundled' => elgg_echo('admin:plugins:category:bundled'), 'nonbundled' => elgg_echo('admin:plugins:category:nonbundled')];
$categories = array_merge($common_categories, $categories);
$category_form = elgg_view("admin/plugins/filter", ['category' => "all", 'category_options' => $categories]);
$activate_all = elgg_view('output/url', ['href' => 'action/admin/plugins/activate_all', 'text' => elgg_echo('admin:plugins:activate_all'), 'class' => 'elgg-button elgg-button-submit', 'confirm' => true]);
$deactivate_all = elgg_view('output/url', ['href' => 'action/admin/plugins/deactivate_all', 'text' => elgg_echo('admin:plugins:deactivate_all'), 'class' => 'elgg-button elgg-button-submit', 'confirm' => true]);
$buttons = elgg_format_element('div', ['class' => 'float-alt'], $activate_all . $deactivate_all);
echo elgg_format_element('div', ['class' => 'mbm'], $buttons . $category_form);
Пример #2
0
}
if ($action) {
    $url = elgg_http_add_url_query_elements($actions_base . $action, array('plugin_guids[]' => $plugin->guid));
    $options['href'] = $url;
}
$action_button = elgg_view('output/url', $options);
// Display categories and make category classes
$categories = $plugin->getManifest()->getCategories();
$categories_html = '';
if ($categories) {
    $base_url = elgg_get_site_url() . "admin/plugins?category=";
    foreach ($categories as $category) {
        $css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
        $classes[] = "elgg-plugin-category-{$css_class}";
        $url = $base_url . urlencode($category);
        $friendly_category = htmlspecialchars(ElggPluginManifest::getFriendlyCategory($category));
        $categories_html .= "<li class=\"elgg-plugin-category prm\"><a href=\"{$url}\">{$friendly_category}</a></li>";
    }
}
$screenshots_html = '';
$screenshots = $plugin->getManifest()->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_img = elgg_view('output/img', array('src' => "admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}", 'alt' => $alt));
        $screenshot_link = elgg_view('output/url', array('href' => "admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}", 'text' => $screenshot_img, 'class' => 'elgg-lightbox'));
        $screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\">{$screenshot_link}</li>";
    }
}
Пример #3
0
$info[elgg_echo('admin:plugins:label:author')] = elgg_view('output/text', array('value' => $plugin->getManifest()->getAuthor()));
$url = $plugin->getManifest()->getWebsite();
if ($url) {
    $info[elgg_echo('admin:plugins:label:website')] = elgg_view('output/url', array('href' => $plugin->getManifest()->getWebsite(), 'text' => $plugin->getManifest()->getWebsite(), 'is_trusted' => true));
}
$info[elgg_echo('admin:plugins:label:copyright')] = elgg_view('output/text', array('value' => $plugin->getManifest()->getCopyright()));
$info[elgg_echo('admin:plugins:label:licence')] = elgg_view('output/text', array('value' => $plugin->getManifest()->getLicense()));
$site_path = elgg_get_root_path();
$path = $plugin->getPath();
if (0 === strpos($path, $site_path)) {
    $path = substr($path, strlen($site_path));
}
$info[elgg_echo('admin:plugins:label:location')] = htmlspecialchars($path);
$categories = (array) $plugin->getManifest()->getCategories();
array_walk($categories, function (&$value) {
    $value = htmlspecialchars(ElggPluginManifest::getFriendlyCategory($value));
});
$info[elgg_echo('admin:plugins:label:categories')] = implode(', ', $categories);
// assemble table
$rows = '';
foreach ($info as $name => $value) {
    if (trim($value) === '') {
        continue;
    }
    $rows .= "<tr><th>{$name}</th><td>{$value}</td></tr>";
}
$info_html = elgg_format_element('table', ['class' => 'elgg-table'], $rows);
$extra_info = elgg_echo("admin:plugins:info:" . $plugin->getID());
if ($extra_info !== "admin:plugins:info:" . $plugin->getID()) {
    $info_html .= "<div class='mtm'>" . $extra_info . "</div>";
}