示例#1
0
 /**
  * Add menu items to the site menu
  *
  * @param string          $hook   the name of the hook
  * @param string          $type   the type of the hook
  * @param \ElggMenuItem[] $return current menu items
  * @param array           $params provided params
  *
  * @return void|\ElggMenuItem[]
  */
 public static function register($hook, $type, $return, $params)
 {
     if (!translation_editor_is_translation_editor()) {
         return;
     }
     $return[] = \ElggMenuItem::factory(array('name' => 'translation_editor', 'text' => elgg_echo('translation_editor:menu:title'), 'href' => 'translation_editor'));
     return $return;
 }
示例#2
0
function translation_editor_user_hover_menu($hook, $type, $return, $params)
{
    $user = $params['entity'];
    if (elgg_is_admin_logged_in() && !$user->isAdmin()) {
        // TODO: replace with a single toggle editor action?
        if (translation_editor_is_translation_editor($user->getGUID())) {
            $url = "action/translation_editor/unmake_translation_editor?user="******"translation_editor:action:unmake_translation_editor");
        } else {
            $url = "action/translation_editor/make_translation_editor?user="******"translation_editor:action:make_translation_editor");
        }
        $item = new ElggMenuItem('translation_editor', $title, $url);
        $item->setSection('admin');
        $item->setConfirmText(elgg_echo("question:areyousure"));
        $return[] = $item;
        return $return;
    }
}
示例#3
0
function translation_editor_init()
{
    global $CONFIG;
    elgg_extend_view("css/elgg", "translation_editor/css/site");
    elgg_extend_view("js/elgg", "translation_editor/js/site");
    elgg_register_page_handler('translation_editor', 'translation_editor_page_handler');
    // add to site menu
    if (translation_editor_is_translation_editor(elgg_get_logged_in_user_guid())) {
        $menu_item = new ElggMenuItem("translation_editor", elgg_echo('translation_editor:menu:title'), "translation_editor");
        elgg_register_menu_item("site", $menu_item);
    }
    if (elgg_is_admin_logged_in()) {
        // Extend context menu with admin links
        elgg_extend_view('profile/menu/adminlinks', 'translation_editor/adminlinks');
        // add to admin menu
        elgg_register_menu_item('page', array('name' => "translation_editor", 'href' => "translation_editor", 'text' => elgg_echo("translation_editor:menu:title"), 'context' => "admin", 'parent_name' => "appearance", 'section' => "configure"));
    }
    elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'translation_editor_user_hover_menu');
}
<?php

/**
 * Add translations for the current plugin
 */
global $CONFIG;
// make sure all languages are loaded
translation_editor_reload_all_translations();
// Fixes for KSES filtering
// fix to allow javascript in href
$CONFIG->allowedprotocols[] = 'javascript';
// fix allowed tags
$CONFIG->allowedtags['a']['onclick'] = array();
$CONFIG->allowedtags['span']['id'] = array();
$translation = get_input('translation');
if (!translation_editor_is_translation_editor()) {
    register_error(elgg_echo('translation_editor:action:translate:error:not_authorized'));
    forward();
}
if (!is_array($translation)) {
    register_error(elgg_echo('translation_editor:action:translate:error:input'));
    forward(REFERER);
}
$trans = get_installed_translations();
foreach ($translation as $language => $plugins) {
    if (!array_key_exists($language, $trans)) {
        continue;
    }
    if (!is_array($plugins)) {
        continue;
    }
/**
 * Protect pages for only translation editor
 *
 * @return void
 */
function translation_editor_gatekeeper()
{
    elgg_gatekeeper();
    if (translation_editor_is_translation_editor()) {
        return;
    }
    register_error(elgg_echo("translation_editor:gatekeeper"));
    forward();
}