Example #1
0
/**
 * This function is executed during the 'plugins_boot' event, before most plugins are initialized
 *
 * @return void
 */
function translation_editor_plugins_boot_event()
{
    // add the custom_keys_locations to language paths
    $custom_keys_path = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . 'custom_keys' . DIRECTORY_SEPARATOR;
    if (is_dir($custom_keys_path)) {
        register_translations($custom_keys_path);
    }
    // force creation of static to prevent reload of unwanted translations
    reload_all_translations();
    if (elgg_in_context('translation_editor') || elgg_in_context('settings') || elgg_in_context('admin')) {
        translation_editor_reload_all_translations();
    }
    translation_editor_load_custom_languages();
    if (!elgg_in_context('translation_editor')) {
        // remove disabled languages
        translation_editor_unregister_translations();
    }
    // load custom translations
    $user_language = get_current_language();
    $elgg_default_language = 'en';
    $load_languages = [$user_language, $elgg_default_language];
    $load_languages = array_unique($load_languages);
    $disabled_languages = translation_editor_get_disabled_languages();
    foreach ($load_languages as $language) {
        if (empty($disabled_languages) || !in_array($language, $disabled_languages)) {
            // add custom translations
            translation_editor_load_translations($language);
        }
    }
}
/**
 * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
 * add and delete fields.
 *
 * Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all
 * other plugins have initialised.
 */
function profile_fields_setup()
{
    global $CONFIG;
    $profile_defaults = array('description' => 'longtext', 'briefdescription' => 'text', 'location' => 'tags', 'interests' => 'tags', 'skills' => 'tags', 'contactemail' => 'email', 'phone' => 'text', 'mobile' => 'text', 'website' => 'url');
    // TODO: Have an admin interface for this
    $n = 0;
    $loaded_defaults = array();
    while ($translation = get_plugin_setting("admin_defined_profile_{$n}", 'profile')) {
        // Add a translation
        add_translation(get_current_language(), array("profile:admin_defined_profile_{$n}" => $translation));
        // Detect type
        $type = get_plugin_setting("admin_defined_profile_type_{$n}", 'profile');
        if (!$type) {
            $type = 'text';
        }
        // Set array
        $loaded_defaults["admin_defined_profile_{$n}"] = $type;
        $n++;
    }
    if (count($loaded_defaults)) {
        $CONFIG->profile_using_custom = true;
        $profile_defaults = $loaded_defaults;
    }
    $CONFIG->profile = trigger_plugin_hook('profile:fields', 'profile', NULL, $profile_defaults);
}
Example #3
0
function translation_editor_plugins_boot_event()
{
    global $CONFIG;
    run_function_once("translation_editor_version_053");
    // add the custom_keys_locations to language paths
    $custom_keys_path = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR . "custom_keys" . DIRECTORY_SEPARATOR;
    if (is_dir($custom_keys_path)) {
        $CONFIG->language_paths[$custom_keys_path] = true;
    }
    // force creation of static to prevent reload of unwanted translations
    reload_all_translations();
    translation_editor_load_custom_languages();
    if (elgg_get_context() != "translation_editor") {
        // remove disabled languages
        translation_editor_unregister_translations();
    }
    // load custom translations
    $user_language = get_current_language();
    $elgg_default_language = "en";
    $load_languages = array($user_language, $elgg_default_language);
    $load_languages = array_unique($load_languages);
    $disabled_languages = translation_editor_get_disabled_languages();
    foreach ($load_languages as $language) {
        if (empty($disabled_languages) || !in_array($language, $disabled_languages)) {
            // add custom translations
            translation_editor_load_translations($language);
        }
    }
}
Example #4
0
/**
 * Initializes the plugin
 *
 * @return void
 */
function search_advanced_init()
{
    // page handler for search actions and results
    elgg_register_page_handler("search_advanced", "search_advanced_page_handler");
    elgg_register_page_handler("search", "search_advanced_search_page_handler");
    // search hooks
    search_advanced_unregister_default_search_hooks();
    search_advanced_register_search_hooks();
    // unregister object:page from search
    elgg_unregister_entity_type("object", "page_top");
    // views
    elgg_extend_view("css/elgg", "css/search_advanced/site");
    elgg_extend_view("js/elgg", "js/search_advanced/site");
    // widgets
    elgg_register_widget_type("search", elgg_echo("search"), elgg_echo("search"), array("profile", "dashboard", "index", "groups"), true);
    elgg_register_widget_type("search_user", elgg_echo("search_advanced:widgets:search_user:title"), elgg_echo("search_advanced:widgets:search_user:description"), array("dashboard", "index"));
    if (elgg_is_active_plugin("categories")) {
        // make universal categories searchable
        add_translation(get_current_language(), array("tag_names:universal_categories" => elgg_echo("categories")));
        elgg_register_tag_metadata_name("universal_categories");
    }
    // hooks and events to clear cache
    // register hooks
    elgg_register_plugin_hook_handler("action", "admin/plugins/activate", "search_advanced_clear_keywords_cache");
    elgg_register_plugin_hook_handler("action", "admin/plugins/deactivate", "search_advanced_clear_keywords_cache");
    elgg_register_plugin_hook_handler("action", "admin/plugins/activate_all", "search_advanced_clear_keywords_cache");
    elgg_register_plugin_hook_handler("action", "admin/plugins/deactivate_all", "search_advanced_clear_keywords_cache");
    elgg_register_plugin_hook_handler("action", "plugins/settings/save", "search_advanced_clear_keywords_cache");
    elgg_register_plugin_hook_handler("register", "menu:search_type_selection", "search_advanced_register_menu_type_selection");
    // register events
    elgg_register_event_handler("upgrade", "system", "search_advanced_clear_keywords_cache");
    // actions
    elgg_register_action("search_advanced/settings/save", dirname(__FILE__) . "/actions/plugins/settings/save.php", "admin");
}
/**
 * Hook to replace the profile fields
 * 
 * @param $hook_name
 * @param $entity_type
 * @param $return_value
 * @param $parameters
 * @return unknown_type
 */
function profile_manager_profile_override($hook_name, $entity_type, $return_value, $parameters)
{
    global $CONFIG;
    // Get all the custom profile fields
    $options = array("type" => "object", "subtype" => CUSTOM_PROFILE_FIELDS_PROFILE_SUBTYPE, "limit" => false, "owner_guid" => $CONFIG->site_guid);
    if ($entities = elgg_get_entities($options)) {
        $result = array();
        $translations = array();
        $context = elgg_get_context();
        // Make new result
        foreach ($entities as $entity) {
            if ($entity->admin_only != "yes" || elgg_is_admin_logged_in()) {
                $result[$entity->metadata_name] = $entity->metadata_type;
                // should it be handled as tags? TODO: is this still needed? Yes it is, it handles presentation of these fields in listing mode
                if ($context == "search" && ($entity->output_as_tags == "yes" || $entity->metadata_type == "multiselect")) {
                    $result[$entity->metadata_name] = "tags";
                }
            }
            $translations["profile:" . $entity->metadata_name] = $entity->getTitle();
        }
        add_translation(get_current_language(), $translations);
        if (count($result) > 0) {
            $result["custom_profile_type"] = "non_editable";
        }
    }
    return $result;
}
Example #6
0
/**
 * Change the default notification message for comments
 *
 * @param string                          $hook         the name of the hook
 * @param stirng                          $type         the type of the hook
 * @param Elgg_Notifications_Notification $return_value the current return value
 * @param array                           $params       supplied values
 *
 * @return Elgg_Notifications_Notification
 */
function content_subscriptions_prepare_comment_notification($hook, $type, $return_value, $params)
{
    if (empty($return_value) || !$return_value instanceof \Elgg\Notifications\Notification) {
        return $return_value;
    }
    if (empty($params) || !is_array($params)) {
        return $return_value;
    }
    $event = elgg_extract("event", $params);
    if (empty($event) || !$event instanceof \Elgg\Notifications\Event) {
        return $return_value;
    }
    // ignore access for now
    $ia = elgg_set_ignore_access(true);
    $comment = $event->getObject();
    $actor = $event->getActor();
    $object = $comment->getContainerEntity();
    $language = elgg_extract("language", $params, get_current_language());
    $recipient = elgg_extract("recipient", $params);
    $return_value->subject = elgg_echo("content_subscriptions:create:comment:subject", array($object->title), $language);
    $return_value->body = elgg_echo("content_subscriptions:create:comment:message", array($recipient->name, $actor->name, $object->title, $comment->description, $object->getURL()), $language);
    $return_value->summary = elgg_echo("content_subscriptions:create:comment:summary", array($object->title), $language);
    // restore access
    elgg_set_ignore_access($ia);
    return $return_value;
}
/**
 * Returns prototyped fields
 *
 * @param string $hook   "prototype"
 * @param string $type   "groups/edit"
 * @param array  $return Fields
 * @param array  $params Hook params
 * @return array
 */
function prototyper_group_get_prototype_fields($hook, $type, $return, $params)
{
    $entity = elgg_extract('entity', $params);
    $subtype = $entity->getSubtype() ?: 'default';
    $prototype = elgg_get_plugin_setting("prototype:{$subtype}", 'prototyper_group');
    if (!$prototype && $subtype != 'default') {
        $prototype = elgg_get_plugin_setting('prototype:default', 'prototyper_group');
    }
    if ($prototype) {
        $prototype_fields = unserialize($prototype);
        $return = array_merge($return, $prototype_fields);
    } else {
        $fields = elgg_get_config('group');
        $return['icon'] = ['type' => 'icon', 'data_type' => 'file', 'label' => [get_current_language() => elgg_echo('groups:icon')], 'help' => false];
        $return['description'] = ['type' => 'description', 'data_type' => 'attribute', 'label' => [get_current_language() => elgg_echo('groups:description')], 'help' => false];
        foreach ($fields as $shortname => $input_type) {
            $return[$shortname] = ['type' => $input_type, 'data_type' => 'metadata', 'label' => [get_current_language() => elgg_echo("groups:{$shortname}")], 'help' => false];
        }
    }
    // Not adding these above, as we want them to persist, even if they are deleted from the UI
    $return['name'] = ['type' => 'name', 'data_type' => 'attribute', 'class_name' => \hypeJunction\Prototyper\Groups\NameField::class, 'label' => [get_current_language() => elgg_echo('groups:name')], 'help' => false, 'priority' => 1];
    $return['membership'] = ['type' => 'membership', 'data_type' => 'metadata', 'id' => 'groups-membership', 'input_view' => 'input/groups/membership', 'output_view' => false, 'class_name' => hypeJunction\Prototyper\Groups\MembershipField::class, 'label' => [get_current_language() => elgg_echo("groups:membership")], 'help' => false, 'priority' => 900];
    // treating this as metadata so that it gets handled after the entity has been saved once and group_acl has been created
    $return['vis'] = ['type' => 'access', 'data_type' => 'metadata', 'id' => 'groups-vis', 'input_view' => 'input/groups/visibility', 'output_view' => false, 'class_name' => hypeJunction\Prototyper\Groups\VisibilityField::class, 'label' => [get_current_language() => elgg_echo("groups:visibility")], 'help' => false, 'priority' => 900];
    $return['content_access_mode'] = ['type' => 'content_access_mode', 'data_type' => 'metadata', 'id' => 'groups-content-access-mode', 'input_view' => 'input/groups/content_access_mode', 'output_view' => false, 'class_name' => hypeJunction\Prototyper\Groups\ContentAccessModeField::class, 'label' => [get_current_language() => elgg_echo("groups:content_access_mode")], 'help' => false, 'priority' => 900];
    $return['owner_guid'] = ['type' => 'select', 'data_type' => 'attribute', 'input_view' => 'input/groups/owner', 'output_view' => false, 'class_name' => hypeJunction\Prototyper\Groups\OwnerField::class, 'label' => [get_current_language() => elgg_echo("groups:owner")], 'help' => false, 'priority' => 900];
    $return['tools'] = ['type' => 'checkboxes', 'data_type' => 'metadata', 'input_view' => 'input/groups/tools', 'output_view' => false, 'class_name' => hypeJunction\Prototyper\Groups\ToolsField::class, 'label' => false, 'help' => false, 'priority' => 900];
    return $return;
}
Example #8
0
function extended_tinymce_get_user_language()
{
    $user_language = get_current_language();
    $path = elgg_get_plugins_path() . "extended_tinymce/vendor/tinymce/js/tinymce/langs";
    if (!file_exists("{$path}/{$user_language}.js")) {
        return extended_tinymce_get_site_language();
    }
    return $user_language;
}
Example #9
0
function recaptcha_init()
{
    if (!is_recaptcha_enabled()) {
        return;
    }
    elgg_register_js('recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . get_current_language());
    elgg_register_plugin_hook_handler('actionlist', 'captcha', 'image_captcha_actionlist_hook');
    $actions = array('register', 'user/requestnewpassword');
    foreach ($actions as $action) {
        elgg_register_plugin_hook_handler('action', $action, 'recaptcha_action_hook');
    }
}
Example #10
0
/**
 * Initialize the plugin
 * @return void
 */
function init()
{
    // Register actions
    $actions_path = dirname(__FILE__) . "/actions/db_explorer/";
    elgg_register_action('db_explorer/entities', $actions_path . 'entities.php', 'admin');
    elgg_register_action('db_explorer/users_entity', $actions_path . 'users_entity.php', 'admin');
    elgg_register_action('db_explorer/objects_entity', $actions_path . 'objects_entity.php', 'admin');
    elgg_register_action('db_explorer/groups_entity', $actions_path . 'groups_entity.php', 'admin');
    elgg_register_action('db_explorer/sites_entity', $actions_path . 'sites_entity.php', 'admin');
    elgg_register_action('db_explorer/owned_entities', $actions_path . 'owned_entities.php', 'admin');
    elgg_register_action('db_explorer/contained_entities', $actions_path . 'contained_entities.php', 'admin');
    elgg_register_action('db_explorer/river_items', $actions_path . 'river_items.php', 'admin');
    elgg_register_action('db_explorer/metadata', $actions_path . 'metadata.php', 'admin');
    elgg_register_action('db_explorer/metadata_ownership', $actions_path . 'metadata_ownership.php', 'admin');
    elgg_register_action('db_explorer/annotations', $actions_path . 'annotations.php', 'admin');
    elgg_register_action('db_explorer/annotations_ownership', $actions_path . 'annotations_ownership.php', 'admin');
    elgg_register_action('db_explorer/private_settings', $actions_path . 'private_settings.php', 'admin');
    elgg_register_action('db_explorer/access_collections_ownership', $actions_path . 'access_collections_ownership.php', 'admin');
    elgg_register_action('db_explorer/access_collections_membership', $actions_path . 'access_collections_membership.php', 'admin');
    elgg_register_action('db_explorer/entity_relationships', $actions_path . 'entity_relationships.php', 'admin');
    elgg_register_action('db_explorer/batch', $actions_path . 'batch.php');
    elgg_register_action('db_explorer/user/validate', $actions_path . 'user/validate.php');
    elgg_register_action('db_explorer/user/ban', $actions_path . 'user/ban.php');
    elgg_register_action('db_explorer/user/unban', $actions_path . 'user/unban.php');
    elgg_register_action('db_explorer/user/enable', $actions_path . 'user/enable.php');
    elgg_register_action('db_explorer/user/disable', $actions_path . 'user/disable.php');
    elgg_register_action('db_explorer/user/delete', $actions_path . 'user/delete.php');
    elgg_register_action('db_explorer/content/enable', $actions_path . 'content/enable.php');
    elgg_register_action('db_explorer/content/disable', $actions_path . 'content/disable.php');
    elgg_register_action('db_explorer/content/delete', $actions_path . 'content/delete.php');
    // Register javascripts
    elgg_define_js('jqgrid', array('src' => '/mod/hypeDBExplorer/vendors/jqgrid/js/minified/jquery.jqGrid.min.js', 'deps' => array('jquery', 'jqgrid.locale')));
    $locale = get_current_language();
    elgg_define_js('jqgrid.locale', array('src' => "/mod/hypeDBExplorer/vendors/jqgrid/js/i18n/grid.locale-{$locale}.js", 'deps' => array('jquery')));
    // Register stylesheets
    //elgg_register_css('jquery.jqgrid', '/mod/hypeDBExplorer/vendor/jqgrid/css/ui.jqgrid.css');
    elgg_register_css('db_explorer.jquery-ui', '/mod/hypeDBExplorer/vendors/jquery-ui/themes/smoothness/jquery-ui.min.css');
    elgg_register_css('db_explorer.stylesheet', elgg_get_simplecache_url('css', 'framework/db_explorer/stylesheet.css'));
    if (elgg_is_admin_logged_in()) {
        if (elgg_get_config('debug')) {
            // Register menu items to quickly navigate to the DB explorer for the given user/entity
            elgg_register_plugin_hook_handler('register', 'menu:user_hover', __NAMESPACE__ . '\\user_hover_menu_setup');
            elgg_register_plugin_hook_handler('register', 'menu:entity', __NAMESPACE__ . '\\entity_menu_setup');
        }
        // Register ajax views
        elgg_register_ajax_view('admin/developers/db_explorer');
        // Add an admin menu item
        elgg_register_menu_item('page', array('name' => 'db_explorer', 'href' => 'admin/developers/db_explorer', 'text' => elgg_echo('admin:developers:db_explorer'), 'context' => 'admin', 'section' => 'develop'));
    }
}
Example #11
0
/**
 * Handles the extra contexts page
 *
 * @param array  $page    page elements
 * @param string $handler handler of the current page
 * 
 * @return boolean
 */
function widget_manager_extra_contexts_page_handler($page, $handler)
{
    $result = false;
    $extra_contexts = elgg_get_plugin_setting("extra_contexts", "widget_manager");
    if (widget_manager_is_extra_context($handler)) {
        $result = true;
        // make nice lightbox popup title
        add_translation(get_current_language(), array("widget_manager:widgets:lightbox:title:" . strtolower($handler) => $handler));
        // backwards compatibility
        set_input("handler", $handler);
        include dirname(dirname(__FILE__)) . "/pages/extra_contexts.php";
    }
    return $result;
}
Example #12
0
function zhgroups_fields_setup()
{
    $profile_defaults = array('description' => 'longtext', 'interests' => 'tags', 'country' => 'dropdown', 'state' => 'dropdown', 'city' => 'text');
    $profile_defaults = elgg_trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults);
    elgg_set_config('group', $profile_defaults);
    // register any tag metadata names
    foreach ($profile_defaults as $name => $type) {
        if ($type == 'tags') {
            elgg_register_tag_metadata_name($name);
            // only shows up in search but why not just set this in en.php as doing it here
            // means you cannot override it in a plugin
            add_translation(get_current_language(), array("tag_names:{$name}" => elgg_echo("groups:{$name}")));
        }
    }
}
Example #13
0
/**
 * Format the friendly time
 * 
 * @param type $hook
 * @param type $type
 * @param type $return
 * @param type $params
 * @return type
 */
function format_friendlytime($hook, $type, $return, $params)
{
    $language = get_current_language();
    // get our language dependent settings
    $format1 = elgg_get_plugin_setting('format1' . $language, PLUGIN_ID);
    $format1override = elgg_get_plugin_setting('format1override' . $language, PLUGIN_ID);
    $format2 = elgg_get_plugin_setting('format2' . $language, PLUGIN_ID);
    $format2override = elgg_get_plugin_setting('format2override' . $language, PLUGIN_ID);
    $breaktime = (int) elgg_get_plugin_setting('breaktime' . $language, PLUGIN_ID);
    $offset = (int) elgg_get_plugin_setting('offset' . $language, PLUGIN_ID);
    // use regular time for elgg default, modtime otherwise
    $time = $params['time'];
    $modtime = $time + 60 * 60 * $offset;
    $format = 1;
    if (!empty($breaktime) && $params['time'] < time() - 60 * 60 * $breaktime) {
        $format = 2;
    }
    if ($format == 1) {
        if (empty($format1override)) {
            $check = $format1;
        } else {
            return translate_friendlytime($format1override, $modtime);
        }
    }
    if ($format == 2) {
        if (empty($format2override)) {
            $check = $format2;
        } else {
            return translate_friendlytime($format2override, $modtime);
        }
    }
    // nothing set, keep as elgg default
    if (empty($check)) {
        $check = 1;
    }
    switch ($check) {
        case 1:
            // default, leave $return alone
            break;
        case 2:
            $return = elgg_echo('flexible_friendlytime:format:1', array(translate_friendlytime('M j, Y', $modtime), translate_friendlytime('g:ia', $modtime)));
            break;
        default:
            $return = translate_friendlytime($check, $modtime);
            break;
    }
    return $return;
}
Example #14
0
/**
 * When an (admin) user is updating any customized email message,
 * this function is doing the work
 * 
 * @param $message_key: The key for the language file (e.g. email:validate:body )
 * @param $message_value: The new value for that key
 * @param $plugin_name: The plugin name of which we are updating the language file
 */
function set_new_notification_message($message_key, $message_value, $plugin_name)
{
    //If the $message_key is invalid, nothing to do
    if ($message_key === null || $message_key == "") {
        error_log("dreamfish_admin::start.php::set_new_notification_message: message_key invalid!");
        return false;
    }
    //Not going to update an entry with an invalid message
    if ($message_value === null || $message_value == "") {
        error_log("dreamfish_admin::start.php::set_new_notification_message: message_value invalid!");
        return false;
    }
    // Load configuration
    global $CONFIG;
    //get the current language, exchanging values in language file dependent on language
    $language = get_current_language();
    //construct the path to the language file
    //if there is a plugin name prepend /mod/<plugin-name>/ to the language file name
    $root = $CONFIG->path;
    if ($plugin_name !== null) {
        $root = $CONFIG->pluginspath . $plugin_name . "/";
    }
    $language_file = $root . "languages/" . $language . ".php";
    if (!file_exists($language_file)) {
        error_log(elgg_echo('dreamfish_admin:file_not_saved'));
        error_log(elgg_echo('dreamfish_admin:lang_not_found'));
        register_error(elgg_echo('dreamfish_admin:file_not_saved'));
        register_error(elgg_echo('dreamfish_admin:lang_not_found'));
        forward($_SERVER['HTTP_REFERER']);
        return false;
    }
    //read the file into a string
    $content = file_get_contents($language_file, FILE_TEXT);
    //the message value shall not contain undesired characters
    $message_value = df_sanitize_string($message_value);
    //we exchange the values through a regular expression
    $pattern = "/" . $message_key . "(.*?)(\"|'),/s";
    $replacement = $message_key . "' => \"" . $message_value . "\",";
    //error_log("pattern: " .$pattern . " replacement: " . $replacement);
    //apply the regex
    $new_file = preg_replace($pattern, $replacement, $content);
    //write new language file
    file_put_contents($language_file, $new_file);
    return true;
}
Example #15
0
function init()
{
    /**
     * Pages and URLs
     */
    elgg_register_page_handler(PAGEHANDLER, __NAMESPACE__ . '\\page_handler');
    /**
     * Actions
     */
    elgg_register_action(PLUGIN_ID . '/settings/save', __DIR__ . '/actions/settings/maps.php', 'admin');
    elgg_register_action('maps/geopositioning/update', __DIR__ . '/actions/geopositioning/update.php', 'public');
    /**
     * JS and CSS
     */
    $libs = array_filter(elgg_get_config('google_maps_libraries'));
    $gmaps_lib = elgg_http_add_url_query_elements('//maps.googleapis.com/maps/api/js', array('key' => elgg_get_plugin_setting('google_api_key', PLUGIN_ID), 'libraries' => implode(',', $libs), 'language' => get_current_language(), 'output' => 'svembed'));
    elgg_register_js('google.maps', $gmaps_lib);
    elgg_register_simplecache_view('css/framework/maps/stylesheet');
    elgg_register_css('maps', elgg_get_simplecache_url('css', 'framework/maps/stylesheet'));
    $plugin_root = __DIR__;
    if (file_exists("{$plugin_root}/vendor/autoload.php")) {
        $path = '/mod/' . PLUGIN_ID;
    } else {
        $path = '';
    }
    elgg_register_js('jquery.sticky-kit', $path . '/vendor/bower-asset/sticky-kit/jquery.sticky-kit.min.js', 'footer', 500);
    elgg_register_simplecache_view('js/framework/maps/mapbox');
    elgg_register_js('maps.mapbox', elgg_get_simplecache_url('js', 'framework/maps/mapbox'), 'footer', 550);
    // Add User Location to config
    elgg_extend_view('js/initialize_elgg', 'js/framework/maps/config');
    /**
     * Hooks
     */
    elgg_register_plugin_hook_handler('search:site', 'maps', __NAMESPACE__ . '\\setup_site_search_maps');
    // Replace a list with a map when ?list_type=mapbox
    elgg_register_plugin_hook_handler('view', 'page/components/list', __NAMESPACE__ . '\\list_type_map_view');
    elgg_register_plugin_hook_handler('view', 'page/components/gallery', __NAMESPACE__ . '\\list_type_map_view');
    // Filter out views when loading map items via ajax
    elgg_register_plugin_hook_handler('view', 'all', __NAMESPACE__ . '\\ajax_list_view');
    // Map Markers
    elgg_register_plugin_hook_handler('entity:icon:url', 'user', __NAMESPACE__ . '\\get_marker_url', 600);
    elgg_register_plugin_hook_handler('entity:icon:url', 'object', __NAMESPACE__ . '\\get_marker_url', 600);
    elgg_register_widget_type('staticmap', elgg_echo('maps:widget:staticmap'), elgg_echo('maps:widget:staticmap:desc'), array('all'), true);
}
Example #16
0
 public function calculate_price()
 {
     $paypals = $this->fee_price_model->fetch_all_paypal_cost();
     $pay_options = object_to_key_value_array($paypals, 'formula', 'name');
     $eshop_code_object = $this->fee_price_model->fetch_all_eshop_code();
     $eshop_codes = object_to_key_value_array($eshop_code_object, 'code', 'name');
     $sale_mode_object = $this->fee_price_model->fetch_all_sale_mode();
     $sale_modes = object_to_key_value_array($sale_mode_object, 'mode', 'name');
     $shipping_code_object = $this->shipping_code_model->fetch_all_shipping_codes();
     $shipping_types = array();
     $field = get_current_language() == 'english' ? 'name_en' : 'name_cn';
     foreach ($shipping_code_object as $item) {
         $shipping_types[$item->code] = $item->{$field};
     }
     $data = array('pay_options' => $pay_options, 'eshop_codes' => $eshop_codes, 'sale_modes' => $sale_modes, 'shipping_types' => $shipping_types);
     $this->template->write_view('content', 'sale/price/calculate_price', $data);
     $this->template->add_js('static/js/ajax/sale.js');
     $this->template->render();
 }
 /**
  * The page handler for the nice url's of this plugin
  *
  * @param array $segments the url elements
  *
  * @return bool
  */
 public static function translationEditor($segments)
 {
     $page = array_shift($segments);
     switch ($page) {
         case 'search':
             echo elgg_view_resource('translation_editor/search');
             return true;
         default:
             if (empty($page)) {
                 $language = get_current_language();
                 $plugin_id = null;
             } else {
                 $language = $page;
                 $plugin_id = array_shift($segments);
                 set_input('current_language', $language);
                 set_input('plugin', $plugin_id);
             }
             echo elgg_view_resource('translation_editor/index', ['current_language' => $language, 'plugin_id' => $plugin_id]);
             return true;
     }
 }
function cur_lang($arr, $key)
{
    if (!is_array($arr)) {
        return '';
    }
    $current_language = get_current_language();
    if (isset($arr[$key . '_' . $current_language]) && $arr[$key . '_' . $current_language] != '') {
        return $arr[$key . '_' . $current_language];
    }
    $ci = get_instance();
    $master_language = $ci->config->item('default_language');
    if (isset($arr[$key . '_' . $master_language]) && $arr[$key . '_' . $master_language] != '') {
        return $arr[$key . '_' . $master_language];
    }
    $languages = $ci->config->item('languages');
    foreach ($languages as $language) {
        if (isset($arr[$key . '_' . $language]) && $arr[$key . '_' . $language] != '') {
            return $arr[$key . '_' . $language];
        }
    }
    return '';
}
Example #19
0
function ws_pack_get_lang_file()
{
    $result = false;
    $user = elgg_get_logged_in_user_entity();
    $api_application = ws_pack_get_current_api_application();
    if (!empty($user) && !empty($api_application)) {
        $translations = [];
        //kinds of translations
        $fields = ['members', 'search', 'groups', 'friends', 'notifications', 'messages', 'messageboard', 'likes', 'invitefriends', 'discussion', 'profile', 'user', 'usersettings', 'date', 'email'];
        global $_ELGG;
        $elgg_translations = $_ELGG->translations['en'];
        $user_lang = get_current_language();
        if ($user_lang !== 'en') {
            if (array_key_exists($user_lang, $_ELGG->translations)) {
                $elgg_translations = array_merge($elgg_translations, $_ELGG->translations[$user_lang]);
            }
        }
        //load and iterate the language cached by the site
        foreach ($elgg_translations as $k => $v) {
            if (strpos($k, ':')) {
                $parts = explode(':', $k);
                $new_key = $parts[1];
                foreach ($fields as $field) {
                    if ($parts[0] == $field) {
                        $translations[$field][$new_key] = $v;
                    }
                }
            } else {
                $translations['general'][$k] = $v;
            }
        }
        $translations = json_encode($translations);
        $result = new SuccessResult($translations);
    }
    if ($result === false) {
        $result = new ErrorResult(elgg_echo('ws_pack:error:notfound'));
    }
    return $result;
}
/**
 * Returns prototyped fields
 *
 * @param string $hook   "prototype"
 * @param string $type   "profile/edit"
 * @param array  $return Fields
 * @param array  $params Hook params
 * @return array
 */
function prototyper_profile_get_prototype_fields($hook, $type, $return, $params)
{
    $entity = elgg_extract('entity', $params);
    $role = false;
    if (elgg_is_active_plugin('roles')) {
        $role = roles_get_role($entity);
    }
    $role_name = $role ? $role->name : 'default';
    $prototype = elgg_get_plugin_setting("prototype:{$role_name}", 'prototyper_profile');
    if (!$prototype && $role_name != 'default') {
        $prototype = elgg_get_plugin_setting('prototype:default', 'prototyper_profile');
    }
    if ($prototype) {
        $prototype_fields = unserialize($prototype);
        $return = array_merge($return, $prototype_fields);
    } else {
        $fields = elgg_get_config('profile_fields');
        $return['name'] = ['type' => 'name', 'data_type' => 'attribute', 'label' => [get_current_language() => elgg_echo('user:name:label')], 'help' => false, 'validation_rules' => ['maxlength' => 50]];
        foreach ($fields as $shortname => $input_type) {
            $return[$shortname] = ['type' => $input_type, 'data_type' => 'metadata', 'label' => [get_current_language() => elgg_echo("profile:{$shortname}")], 'help' => false];
        }
    }
    return $return;
}
Example #21
0
function theme_ffd_init()
{
    elgg_unextend_view("page/elements/header", "search/header");
    elgg_extend_view("css/elgg", "css/theme_ffd/site");
    elgg_extend_view('js/elgg', 'theme_ffd/js/site');
    // Replace the default index page
    elgg_register_plugin_hook_handler("index", "system", "theme_ffd_index");
    elgg_register_plugin_hook_handler("route", "questions", "theme_ffd_route_questions_hook");
    elgg_register_plugin_hook_handler("register", "menu:filter", "theme_ffd_category_filter_menu_hook_handler");
    elgg_register_plugin_hook_handler("register", "menu:ffd_questions_alt", "theme_ffd_questions_alt_menu_hook_handler");
    elgg_register_plugin_hook_handler("register", "menu:ffd_questions_body", "theme_ffd_questions_body_menu_hook_handler");
    elgg_register_plugin_hook_handler("register", "menu:entity", "theme_ffd_entity_hook");
    // pagehandlers
    elgg_register_page_handler("profile", "theme_ffd_profile_page_handler");
    elgg_register_page_handler("cafe", "theme_ffd_cafe_page_handler");
    elgg_register_page_handler("login", "theme_ffd_index");
    // actions
    $actions_base = dirname(__FILE__) . "/actions/cafe";
    elgg_register_action("cafe/save", "{$actions_base}/save.php");
    elgg_register_action("cafe/delete", "{$actions_base}/delete.php");
    // register objects
    elgg_register_menu_item("site", array("name" => 'cafe', "text" => elgg_echo('cafe'), "href" => 'cafe'));
    elgg_register_entity_type("object", "cafe");
    elgg_register_entity_url_handler("object", "cafe", "theme_ffd_cafe_url");
    elgg_register_plugin_hook_handler('register', 'menu:annotation', 'theme_ffd_annotation_menu_setup');
    elgg_register_plugin_hook_handler("register", 'menu:filter', 'theme_ffd_cafe_filter_menu_handler');
    //add a widget
    elgg_register_widget_type("ffd_stats", elgg_echo("ffd_theme:widgets:ffd_stats:title"), elgg_echo("ffd_theme:widgets:ffd_stats:description"), "index");
    elgg_register_widget_type("recent_questions", elgg_echo("ffd_theme:widgets:recent_questions:title"), elgg_echo("ffd_theme:widgets:recent_questions:description"), "index");
    elgg_register_widget_type("recent_cafe", elgg_echo("ffd_theme:widgets:recent_cafe:title"), elgg_echo("ffd_theme:widgets:recent_cafe:description"), "index");
    elgg_register_widget_type("ask_question", elgg_echo("ffd_theme:widgets:ask_question:title"), elgg_echo("ffd_theme:widgets:ask_question:description"), "index");
    elgg_register_widget_type("ffd_datetime", elgg_echo("date:month:" . date("m"), array(date("j"))), elgg_echo("ffd_theme:widgets:ffd_datetime:description"), "index");
    elgg_register_widget_type("ffd_videos", elgg_echo("ffd_theme:widgets:ffd_videos:title"), elgg_echo("ffd_theme:widgets:ffd_videos:description"), "index");
    // custom translations
    add_translation(get_current_language(), array("questions:add" => elgg_echo("theme_ffd:questions:add")));
}
Example #22
0
<?php

/**
 * Page shell for all HTML pages
 *
 * @uses $vars['head']        Parameters for the <head> element
 * @uses $vars['body_attrs']  Attributes of the <body> tag
 * @uses $vars['body']        The main content of the page
 */
// Set the content type
header("Content-type: text/html; charset=UTF-8");
$lang = get_current_language();
$attrs = " vocab='https://schema.org/' typeof='WebPage'";
if (isset($vars['body_attrs'])) {
    $attrs = elgg_format_attributes($vars['body_attrs']);
    if ($attrs) {
        $attrs = " {$attrs}";
    }
}
?>
<!DOCTYPE html><!--[if lt IE 9]><html class="no-js lt-ie9" lang="<?php 
echo $lang;
?>
" dir="ltr"><![endif]--><!--[if gt IE 8]><!-->
<html class="no-js" lang="<?php 
echo $lang;
?>
" dir="ltr">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!--<![endif]-->
<head>
Example #23
0
<?php

use Elgg\Filesystem\Directory;
$subject = elgg_extract("subject", $vars);
$message = nl2br(elgg_extract("body", $vars));
$language = elgg_extract("language", $vars, get_current_language());
$recipient = elgg_extract("recipient", $vars);
$site = elgg_get_site_entity();
$site_url = elgg_get_site_url();
$isElggAtRoot = Elgg\Application::elggDir()->getPath() === Directory\Local::root()->getPath();
$elggSubdir = $isElggAtRoot ? '' : 'vendor/elgg/elgg/';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
echo $language;
?>
" lang="<?php 
echo $language;
?>
">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<base target="_blank" />
		
		<?php 
if (!empty($subject)) {
    echo elgg_format_element('title', [], $subject);
}
?>
	</head>
	<body>
Example #24
0
function translation_editor_merge_translations($language = "", $update = false)
{
    global $CONFIG;
    $result = false;
    if (empty($language)) {
        $language = get_current_language();
    }
    if (!empty($language)) {
        $translations = array();
        if ($core = translation_editor_read_translation($language, "core")) {
            $translations = $core;
        }
        if ($custom_keys = translation_editor_read_translation($language, "custom_keys")) {
            $translations += $custom_keys;
        }
        if ($plugins = elgg_get_plugins()) {
            foreach ($plugins as $plugin) {
                if ($plugin_translation = translation_editor_read_translation($language, $plugin->title)) {
                    $translations += $plugin_translation;
                }
            }
        }
        if (!empty($translations)) {
            if (translation_editor_write_translation($language, "translation_editor_merged_" . $CONFIG->site_guid, $translations)) {
                $result = true;
            }
        } else {
            if (translation_editor_delete_translation($language, "translation_editor_merged_" . $CONFIG->site_guid)) {
                $result = true;
            }
        }
    }
    if ($result) {
        elgg_trigger_event("language:merge", "translation_editor", $language);
    }
    // reset language cache on all sites
    if ($update) {
        $ts = time();
        datalist_set("te_last_update_" . $language, $ts);
        set_private_setting($CONFIG->site_guid, "te_last_update_" . $language, $ts);
    }
    return $result;
}
Example #25
0
/**
 * Initialize the language library
 * @access private
 */
function elgg_languages_init()
{
    $lang = get_current_language();
    elgg_register_simplecache_view("cache/js/languages/{$lang}");
}
Example #26
0
    	$vars['content'] .= "<span class='elgg-widget-more'>{$vars['add_link']}</span>";
    */
    if ($vars['add_link'] == 'discuss') {
        //Nick - if the user wants a dicsussion we change the add discussion
        $discuss_start = elgg_view('groups/profile/discuss_start', array('user' => $user_guid, 'group' => $group));
        $content = $discuss_start . $vars['content'];
    } else {
        //gather info from $vars['add_link'] to use in our button
        $buttonHREF = explode('"', $vars['add_link']);
        //seperate text from system genereated link
        $throwaway = explode('>', $vars['add_link']);
        $buttonText = explode('<', $throwaway[1]);
        //create button from gathered variables
        $addButton = elgg_view('output/url', array('text' => $buttonText[0], 'class' => 'btn btn-primary mrgn-bttm-sm', 'style' => 'color:white', 'href' => $buttonHREF[1]));
        $content = '<div class="text-right">' . $addButton . '</div>' . $vars['content'];
    }
}
//remove group from title to create an id for module
$id = explode(' ', $vars['title']);
if (get_current_language() == 'en') {
    if ($id[1] == 'calender') {
        $id[1] = 'events';
    }
    $modID = $id[1];
} else {
    $modID = strtolower($id[0]);
}
if ($vars['title'] == 'Most recent albums' || $vars['title'] == 'Most recent images') {
    $modID = $id[2];
}
echo elgg_view_module('GPmod', '', $content, array('class' => 'tab-pane fade-in', 'id' => $modID, 'footer' => $footer));
Example #27
0
 /**
  * Admin account controller
  *
  * Creates an admin user account
  *
  * @param array $submissionVars Submitted vars
  *
  * @return void
  */
 protected function admin($submissionVars)
 {
     $formVars = array('displayname' => array('type' => 'text', 'value' => '', 'required' => TRUE), 'email' => array('type' => 'text', 'value' => '', 'required' => TRUE), 'username' => array('type' => 'text', 'value' => '', 'required' => TRUE), 'password1' => array('type' => 'password', 'value' => '', 'required' => TRUE), 'password2' => array('type' => 'password', 'value' => '', 'required' => TRUE));
     if ($this->isAction) {
         do {
             if (!$this->validateAdminVars($submissionVars, $formVars)) {
                 break;
             }
             if (!$this->createAdminAccount($submissionVars, $this->autoLogin)) {
                 break;
             }
             system_message(elgg_echo('install:success:admin'));
             $this->continueToNextStep('admin');
         } while (FALSE);
         // PHP doesn't support breaking out of if statements
     }
     // bit of a hack to get the password help to show right number of characters
     global $CONFIG;
     $lang = get_current_language();
     $CONFIG->translations[$lang]['install:admin:help:password1'] = sprintf($CONFIG->translations[$lang]['install:admin:help:password1'], $CONFIG->min_password_length);
     $formVars = $this->makeFormSticky($formVars, $submissionVars);
     $this->render('admin', array('variables' => $formVars));
 }
Example #28
0
		
		$('#event_manager_address_route_search').submit(function(e) {
			frmAddress = $('#address_from').val();
			dstAddress = '<?php 
echo $event->location;
?>
';
			
			if(frmAddress == '') {
				alert('<?php 
echo elgg_echo('event_manager:action:event:edit:error_fields');
?>
');
			} else {
				link = 'http://maps.google.com/maps?f=d&source=s_d&saddr='+frmAddress+'&daddr='+dstAddress+'&hl=<?php 
echo get_current_language();
?>
';

				window.open(link);
			}
			e.preventDefault();
		});
	});

</script>
<div id="google_maps" style="width: 500px; height: 425px; overflow:hidden;">
	<div id="map_canvas" style="width: 500px; height: 300px;"></div>
	<?php 
$form_body .= '<label>' . elgg_echo('from') . ': *</label>' . elgg_view('input/text', array('name' => 'address_from', 'id' => 'address_from')) . '<br />';
$form_body .= '<label>' . elgg_echo('to') . ': </label><br />' . $event->location . '<br />';
Example #29
0
<?php 
$categories = elgg_view('input/categories', $vars);
if ($categories) {
    echo $categories;
}
?>

<div class="elgg-foot">
	<?php 
echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid));
if ($guid) {
    echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $guid));
}
echo elgg_view('input/submit', array('value' => elgg_echo("save"), 'class' => 'btn btn-primary mrgn-tp-md'));
echo '</div>';
if (get_current_language() == 'fr') {
    ?>
    <script>
        jQuery('.fr').show();
        jQuery('.en').hide();

    </script>
<?php 
} else {
    ?>
    <script>
        jQuery('.en').show();
        jQuery('.fr').hide();

    </script>
<?php 
Example #30
0
 protected function _set_translations()
 {
     $ci = get_instance();
     //$this->load->helper('my_language_helper');
     $this->data['current_language'] = get_current_language();
     if (is_readable(BASEPATH . '../' . $ci->config->item('multilanguage_object'))) {
         $this->translation_container = unserialize(BASEPATH . '../' . $ci->config->item('multilanguage_object'));
     } else {
         if (is_readable(BASEPATH . '../' . $ci->config->item('multilanguage_xml'))) {
             $ci->load->library('multilanguage/TMXParser');
             $ci->tmxparser->setXML(BASEPATH . '../' . $ci->config->item('multilanguage_xml'));
             $ci->tmxparser->setMasterLanguage($ci->config->item('master_language'));
             $tc = $ci->tmxparser->doParse();
             $this->translation_container = $tc;
         }
     }
 }