/** * Initialize the plugin * * @return void */ function notifier_init() { notifier_set_view_listener(); // Add hidden popup module to topbar elgg_extend_view('page/elements/topbar', 'notifier/popup'); elgg_require_js('notifier/notifier'); elgg_register_page_handler('notifier', 'notifier_page_handler'); // Add css elgg_extend_view('elgg.css', 'notifier/notifier.css'); elgg_register_notification_method('notifier'); elgg_register_plugin_hook_handler('send', 'notification:notifier', 'notifier_notification_send'); elgg_register_plugin_hook_handler('route', 'friendsof', 'notifier_read_friends_notification'); elgg_register_event_handler('create', 'relationship', 'notifier_relationship_notifications'); elgg_register_event_handler('delete', 'relationship', 'notifier_read_group_invitation_notification'); // Hook handler for cron that removes old messages elgg_register_plugin_hook_handler('cron', 'daily', 'notifier_cron'); elgg_register_plugin_hook_handler('register', 'menu:topbar', 'notifier_topbar_menu_setup'); elgg_register_event_handler('create', 'user', 'notifier_enable_for_new_user'); elgg_register_event_handler('join', 'group', 'notifier_enable_for_new_group_member'); $action_path = elgg_get_plugins_path() . 'notifier/actions/notifier/'; elgg_register_action('notifier/dismiss', $action_path . 'dismiss.php'); elgg_register_action('notifier/dismiss_one', $action_path . 'dismiss_one.php'); elgg_register_action('notifier/clear', $action_path . 'clear.php'); elgg_register_action('notifier/delete', $action_path . 'delete.php'); }
/** * parse allowable views and set classes on links for video rendering * * @staticvar type $allowable_views * @param type $hook * @param type $type * @param type $return * @param type $params * @return type */ function views_parse($hook, $type, $return, $params) { static $allowable_views, $allow_internal; if (!is_array($allowable_views)) { $allowable_views = get_allowable_views(); } if (!in_array($type, $allowable_views)) { return $return; } if (is_null($allow_internal)) { $allow_internal = elgg_get_plugin_setting('internal_urls', PLUGIN_ID, 0); } // we're potentially adding items elgg_require_js('embedly_cards/embedly_cards'); // mark all links as embedly-video and let embedly sort it out libxml_use_internal_errors(true); $doc = new \DOMDocument(); $doc->loadHTML($return); foreach ($doc->getElementsByTagName('a') as $tag) { $href = $tag->hasAttribute('href') ? $tag->getAttribute('href') : null; if (!$href || strpos($href, 'http') !== 0) { continue; } if (strpos($href, elgg_get_site_url()) === 0 && !$allow_internal) { continue; } $tag->setAttribute('class', ($tag->hasAttribute('class') ? $tag->getAttribute('class') . ' ' : '') . 'embedly-video'); } libxml_clear_errors(); return $doc->saveHTML(); }
function stripe_init() { // Register Stripe js //elgg_register_js('stripe.js', 'https://js.stripe.com/v2/', 'head', 50); //elgg_load_js('stripe.js'); elgg_define_js('stripe', ['src' => 'https://js.stripe.com/v2/stripe.js']); elgg_require_js('stripe'); elgg_extend_view('js/initialize_elgg', 'js/stripe/config'); elgg_extend_view('js/elgg', 'js/stripe/cards'); elgg_extend_view('css/elgg', 'css/stripe/css'); elgg_extend_view('css/admin', 'css/stripe/css'); // Registering actions elgg_register_action('stripe/customers/sync', __DIR__ . '/actions/stripe/customers/sync.php', 'admin'); elgg_register_action('stripe/cards/add', __DIR__ . '/actions/stripe/cards/add.php', 'public'); elgg_register_action('stripe/cards/remove', __DIR__ . '/actions/stripe/cards/remove.php'); elgg_register_action('stripe/cards/set_default', __DIR__ . '/actions/stripe/cards/make_default.php'); elgg_register_action('stripe/subscriptions/cancel', __DIR__ . '/actions/stripe/subscriptions/cancel.php'); // Page handler elgg_register_page_handler('billing', 'stripe_page_handler'); elgg_register_plugin_hook_handler('register', 'menu:stripe-actions', 'stripe_actions_menu'); elgg_register_plugin_hook_handler('ping', 'stripe.events', 'stripe_ping_event'); elgg_register_plugin_hook_handler('customer.created', 'stripe.events', 'stripe_customer_created_event'); elgg_register_plugin_hook_handler('customer.deleted', 'stripe.events', 'stripe_customer_deleted_event'); elgg_register_plugin_hook_handler('charge.succeeded', 'stripe.events', 'stripe_charge_succeeded_event'); elgg_register_plugin_hook_handler('charge.failed', 'stripe.events', 'stripe_charge_failed_event'); elgg_register_plugin_hook_handler('charge.refunded', 'stripe.events', 'stripe_charge_refunded_event'); // Stripe Webhooks elgg_ws_expose_function('stripe.webhooks', 'stripe_webhook_handler', array('environment' => array('type' => 'string', 'required' => true)), 'Handles webhooks received from Stripe', 'POST', false, false); // Map newly registered users to their Stripe profiles if any elgg_register_event_handler('create', 'user', 'stripe_register_user'); }
/** * Initialize the plugin. */ function tour_init() { $js_lib = elgg_get_plugin_setting('js_library', 'tour'); if ($js_lib == 'joyride') { elgg_register_css('joyride', '/mod/tour/vendors/joyride/joyride-2.1.css'); elgg_load_css('joyride'); elgg_define_js('joyride', array('src' => '/mod/tour/vendors/joyride/jquery.joyride-2.1.js', 'exports' => 'joyride')); } else { elgg_register_css('hopscotch', '/mod/tour/vendors/hopscotch/css/hopscotch.min.css'); elgg_load_css('hopscotch'); elgg_define_js('hopscotch', array('src' => '/mod/tour/vendors/hopscotch/hopscotch.min.js', 'exports' => 'hopscotch')); } elgg_require_js('elgg/tour/display'); //elgg_require_js('elgg/tour/edit'); elgg_register_ajax_view('ajax/tour_stop/save'); elgg_extend_view('page/elements/footer', 'tour/outline'); elgg_extend_view('css/elgg', 'css/tour'); elgg_extend_view('css/admin', 'css/tour_admin'); elgg_register_action('tour_page/save', __DIR__ . '/actions/tour_page/save.php', 'admin'); elgg_register_action('tour_page/reorder', __DIR__ . '/actions/tour_page/reorder.php', 'admin'); elgg_register_action('tour_page/delete', __DIR__ . '/actions/tour_page/delete.php', 'admin'); elgg_register_action('tour_stop/save', __DIR__ . '/actions/tour_stop/save.php', 'admin'); elgg_register_action('tour_stop/delete', __DIR__ . '/actions/tour_stop/delete.php', 'admin'); elgg_register_page_handler('tour', 'tour_page_handler'); elgg_register_page_handler('tour_stop', 'tour_page_handler'); // For convenience elgg_register_admin_menu_item('administer', 'tour', 'administer_utilities'); elgg_register_menu_item('topbar', array('name' => 'tour', 'href' => '', 'text' => elgg_echo('tour:start'), 'id' => 'tour-start', 'section' => 'alt', 'data-library' => $js_lib)); elgg_register_plugin_hook_handler('register', 'menu:entity', array('Tour\\Page\\EntityMenu', 'setUp')); elgg_register_plugin_hook_handler('register', 'menu:entity', array('Tour\\Stop\\EntityMenu', 'setUp')); elgg_register_viewtype('json'); }
function uservalidationbyemail_init() { require_once dirname(__FILE__) . '/lib/functions.php'; // Register page handler to validate users // This doesn't need to be an action because security is handled by the validation codes. elgg_register_page_handler('uservalidationbyemail', 'uservalidationbyemail_page_handler'); // mark users as unvalidated and disable when they register elgg_register_plugin_hook_handler('register', 'user', 'uservalidationbyemail_disable_new_user'); // forward to uservalidationbyemail/emailsent page after register elgg_register_plugin_hook_handler('forward', 'system', 'uservalidationbyemail_after_registration_url'); // canEdit override to allow not logged in code to disable a user elgg_register_plugin_hook_handler('permissions_check', 'user', 'uservalidationbyemail_allow_new_user_can_edit'); // prevent users from logging in if they aren't validated register_pam_handler('uservalidationbyemail_check_auth_attempt', "required"); // prevent the engine from logging in users via login() elgg_register_event_handler('login:before', 'user', 'uservalidationbyemail_check_manual_login'); // make admin users always validated elgg_register_event_handler('make_admin', 'user', 'uservalidationbyemail_validate_new_admin_user'); // register Walled Garden public pages elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'uservalidationbyemail_public_pages'); // admin interface to manually validate users elgg_register_admin_menu_item('administer', 'unvalidated', 'users'); elgg_extend_view('admin.css', 'uservalidationbyemail/css'); // inline module elgg_extend_view('elgg.js', 'elgg/uservalidationbyemail.js'); elgg_require_js('elgg/uservalidationbyemail'); }
function hydra_theme_init() { elgg_unextend_view('page/elements/header', 'search/header'); elgg_extend_view('page/elements/sidebar', 'search/header', 0); if (elgg_get_context() != "admin") { elgg_require_js("lorea_hydra/js"); } $bower = elgg_get_site_url() . "mod/lorea_hydra/vendors/bower_components/"; elgg_register_css("bootstrap", "{$bower}bootstrap/dist/css/bootstrap.css", 0); elgg_register_css("bootstrap-select", "{$bower}bootstrap-select/dist/css/bootstrap-select.min.css"); elgg_register_css("jasny", "{$bower}jasny-bootstrap/dist/css/jasny-bootstrap.min.css"); elgg_register_css("lorea_hydra", elgg_get_site_url() . "mod/hydra_theme/css/lorea_hydra.css", 10000); elgg_define_js("bootstrap", array("src" => "{$bower}bootstrap/dist/js/bootstrap.min.js")); //elgg_register_js("bootstrap", "{$bower}bootstrap/dist/js/bootstrap.min.js"); elgg_register_js("bootstrap-select", "{$bower}bootstrap-select/dist/js/bootstrap-select.min.js"); elgg_register_js("jasny", "{$bower}jasny-bootstrap/dist/js/jasny-bootstrap.min.js"); elgg_register_js("lorea_hydra", elgg_get_site_url() . "mod/hydra_theme/css/lorea_hydra.css", 10000); if (elgg_get_context() != "admin") { elgg_load_css("bootstrap"); elgg_load_css("bootstrap-select"); elgg_load_css("lorea_hydra"); elgg_load_css("jasny"); elgg_load_js("bootstrap"); elgg_load_js("jasny"); elgg_load_js("bootstrap-select"); elgg_load_js("lorea_hydra"); } }
function elgg_clean_init() { elgg_unextend_view('page/elements/header', 'search/header'); elgg_extend_view('page/elements/sidebar', 'search/header', 0); if (elgg_get_context() != "admin") { elgg_require_js("elgg_clean/js"); } elgg_register_event_handler('pagesetup', 'system', 'elgg_clean_pagesetup', 1000); elgg_register_plugin_hook_handler('head', 'page', 'elgg_clean_setup_head'); $bower = elgg_get_site_url() . "mod/elgg_clean/vendors/bower_components/"; elgg_register_css("bootstrap", "{$bower}bootstrap/dist/css/bootstrap.css", 0); elgg_register_css("open", "http://fonts.googleapis.com/css?family=Open+Sans:400,700,700italic,400italic"); elgg_register_css("passion", "http://fonts.googleapis.com/css?family=Passion+One"); elgg_register_css("elgg_clean", elgg_get_site_url() . "mod/elgg_clean/css/elgg_clean.css", 10000); elgg_register_css("font-awesome", "{$bower}fontawesome/css/font-awesome.min.css"); elgg_register_css("bootstrap-select", "{$bower}bootstrap-select/dist/css/bootstrap-select.min.css"); elgg_register_css("jasny", "{$bower}jasny-bootstrap/dist/css/jasny-bootstrap.min.css"); elgg_register_css("fuelux", "{$bower}fuelux/dist/css/fuelux.min.css"); elgg_register_css("agency", elgg_get_site_url() . "mod/elgg_clean/css/agency.css", 20000); elgg_register_css("home", elgg_get_site_url() . "mod/elgg_clean/css/home.css", 30000); elgg_register_js('respond', '{$bower}respond/src/respond.js'); elgg_define_js("bootstrap", array("src" => "{$bower}bootstrap/dist/js/bootstrap.min.js")); elgg_register_js("bootstrap-select", "{$bower}bootstrap-select/dist/js/bootstrap-select.min.js"); elgg_register_js("jasny", "{$bower}jasny-bootstrap/dist/js/jasny-bootstrap.min.js"); elgg_register_js("agency", elgg_get_site_url() . "mod/elgg_clean/js/agency.js"); elgg_register_js("cbpAnimatedHeader", elgg_get_site_url() . "mod/elgg_clean/js/cbpAnimatedHeader.js"); elgg_register_js("classie", elgg_get_site_url() . "mod/elgg_clean/js/classie.js"); elgg_register_js("contact_me", elgg_get_site_url() . "mod/elgg_clean/js/contact_me.js"); elgg_register_js("scrollspy", "{$bower}scrollspy/jquery.scrollspy.js"); elgg_register_js("parallax", "{$boder}jquery-parallax/scripts/jquery.parallax-1.13.js"); elgg_register_js("scrollto", "{$bower}jquery-parallax/scripts/jquery.scrollTo-1.4.2-min.js"); elgg_define_js('fuelux', array('src' => "{$bower}fuelux/dist/js/fuelux.min.js")); if (elgg_get_context() != "admin") { elgg_load_js('respond'); elgg_load_js("bootstrap"); elgg_load_js("jscolor"); elgg_load_js("elgg_clean"); elgg_load_js("bootstrap-select"); elgg_load_js("jasny"); elgg_load_js("agency"); elgg_load_js("parallax"); elgg_load_js("scrollto"); elgg_require_js("fuelux"); elgg_load_css("bootstrap"); elgg_load_css("open"); elgg_load_css("passion"); elgg_load_css("font-awesome"); elgg_load_css("bootstrap-select"); elgg_load_css("elgg_clean"); elgg_load_css("jasny"); elgg_load_css("fuelux"); elgg_load_css("agency"); } // non-members do not get visible links to RSS feeds if (!elgg_is_logged_in()) { elgg_unregister_plugin_hook_handler('output:before', 'layout', 'elgg_views_add_rss_link'); } elgg_register_action("elgg_clean/contact", elgg_get_plugins_path() . "elgg_clean/actions/contact.php", "public"); }
function elgg_cookieconsent_init() { if (!elgg_in_context('admin')) { elgg_require_js('elgg_cookieconsent/cookieconsent_init'); } elgg_register_simplecache_view('js/elgg_cookieconsent/settings.js'); elgg_extend_view('css/elgg', 'css/cookieconsent.css'); }
/** * Inits the plugin * * @return void */ function target_blank_init() { elgg_require_js('target_blank/target_blank'); // this cached view uses PHP to provide settings from database to javascript elgg_register_simplecache_view('js/target_blank/settings.js'); elgg_register_action('target_blank/settings/save', dirname(__FILE__) . '/actions/settings/save.php', 'admin'); elgg_register_page_handler('target_blank', function () { echo elgg_view_resource('target_blank/test'); }); }
function xoxco_tags_init() { elgg_extend_view('css/elgg', 'xoxco_tags/css/elgg_after', 501); elgg_extend_view('css/admin', 'xoxco_tags/css/elgg_after', 501); elgg_define_js('jquery.tagsinput', array('src' => '/mod/xoxco_tags/js/lib/jquery.tagsinput.min.js')); // Include the feature only if Elgg is displaying the tags input elgg_register_plugin_hook_handler('view', 'input/tags', function () { elgg_require_js('xoxco_tags'); }); }
/** * Initialize the plugin */ function elgg_tokeninput_init() { elgg_register_library('elgg.tokeninput', elgg_get_plugins_path() . 'elgg_tokeninput/lib/tokeninput.php'); elgg_define_js('jquery.tokeninput', array('src' => 'mod/elgg_tokeninput/vendors/jquery-tokeninput/build/jquery.tokeninput.min.js', 'deps' => array('jquery'))); elgg_require_js('tokeninput/init'); elgg_extend_view('css/elgg', 'css/tokeninput/stylesheet.css'); elgg_extend_view('css/admin', 'css/tokeninput/stylesheet.css'); elgg_register_plugin_hook_handler('action', 'all', 'elgg_tokeninput_explode_field_values', 1); elgg_register_page_handler(ELGG_TOKENINPUT_PAGEHANDLER, 'elgg_tokeninput_page_handler'); elgg_extend_view('theme_sandbox/forms', 'theme_sandbox/forms/elgg_tokeninput'); }
/** * Initialize the plugin * @return void */ function elgg_lightbox_init() { if (!elgg_is_active_plugin('mrclay_combiner')) { elgg_unregister_js('lightbox'); } elgg_unregister_css('lightbox'); elgg_extend_view('elgg.css', 'colorbox.css'); elgg_extend_view('admin.css', 'colorbox.css'); if (version_compare(elgg_get_version(true), '2.2', '<')) { elgg_extend_view('elgg.js', 'elgg/lightbox.js'); elgg_require_js('elgg/lightbox'); } }
function jssor_page_handler($page) { if (!isset($page[0])) { return false; } if ($page[0] == 'album') { elgg_require_js('jssor/settings'); elgg_require_js('jssor/gallery'); include elgg_get_plugins_path() . 'jssor/pages/jssor/album.php'; return true; } return false; }
function developers_init() { elgg_register_event_handler('pagesetup', 'system', 'developers_setup_menu'); elgg_extend_view('css/admin', 'developers/css'); elgg_extend_view('css/elgg', 'developers/css'); elgg_register_page_handler('theme_preview', 'developers_theme_preview_controller'); elgg_register_external_view('developers/ajax'); // for lightbox in sandbox $action_base = elgg_get_plugins_path() . 'developers/actions/developers'; elgg_register_action('developers/settings', "{$action_base}/settings.php", 'admin'); elgg_register_action('developers/inspect', "{$action_base}/inspect.php", 'admin'); elgg_register_js('jquery.jstree', array('src' => '/mod/developers/vendors/jsTree/jquery.jstree.js', 'location' => 'footer', 'exports' => 'jQuery.fn.jstree', 'deps' => array('jquery'))); elgg_register_css('jquery.jstree', '/mod/developers/vendors/jsTree/themes/default/style.css'); elgg_require_js('elgg/dev'); }
function my_plugin_init() { // Rename this function based on the name of your plugin and update the // elgg_register_event_handler() call accordingly // Register a script to handle (usually) a POST request (an action) $base_dir = elgg_get_plugins_path() . 'my_plugin/actions/my_plugin'; elgg_register_action('my_plugin', "{$base_dir}/my_action.php"); // Extend the main CSS file elgg_extend_view('css/elgg', 'css/my_plugin.css'); // Require your JavaScript AMD module (view "js/my_plugin.js") on every page elgg_require_js('my_plugin'); // Add a menu item to the main site menu $item = new ElggMenuItem('my_plugin', elgg_echo('my_plugin:menu'), 'my_url'); elgg_register_menu_item('site', $item); }
function activity_page_handler($page) { global $CONFIG; elgg_load_library('elgg:activity'); elgg_require_js('elgg/activity/create'); elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); // make a URL segment available in page handler script $page_type = elgg_extract(0, $page, 'all'); $page_type = preg_replace('[\\W]', '', $page_type); if ($page_type == 'owner') { $page_type = 'mine'; } set_input('page_type', $page_type); echo activity_view_page(); return true; }
/** * Add a menu item in the long text inputs (like embed and tinymce) * * @param string $hook name of the hook * @param string $type type of the hook * @param array $returnvalue Default menu items * @param array $params params for the hook * * @return array Menu items */ public static function longtextRegister($hook, $type, $returnvalue, $params) { $id = elgg_extract('id', $params); if (strpos($id, 'newsletter-edit-content-') !== 0) { return; } if (!newsletter_embed_available()) { return; } $guid = str_replace('newsletter-edit-content-', '', $id); $returnvalue[] = \ElggMenuItem::factory(['name' => 'newsletter-embed-content', 'href' => "newsletter/embed/{$guid}", 'text' => elgg_echo('newsletter:menu:longtext:embed_content'), 'link_class' => 'elgg-longtext-control elgg-lightbox', 'priority' => 5]); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_require_js('newsletter/embed'); return $returnvalue; }
/** * Add quick status change items * * @param string $hook the name of the hook * @param string $type the type of the hook * @param \ElggMenuItem[] $return_value current return vaue * @param array $params supplied params * * @return void|\ElggMenuItem[] */ public static function discussionStatus($hook, $type, $return_value, $params) { $entity = elgg_extract('entity', $params); if (!elgg_instanceof($entity, 'object', 'discussion')) { return; } if (!$entity->canEdit()) { return; } // load js elgg_require_js('discussions_tools/status_toggle'); // add menu items $return_value[] = \ElggMenuItem::factory(['name' => 'status_change_open', 'text' => elgg_echo('open'), 'confirm' => elgg_echo('discussions_tools:discussion:confirm:open'), 'href' => "action/discussions/toggle_status?guid={$entity->getGUID()}", 'priority' => 200, 'item_class' => $entity->status == 'closed' ? '' : 'hidden']); $return_value[] = \ElggMenuItem::factory(['name' => 'status_change_close', 'text' => elgg_echo('close'), 'confirm' => elgg_echo('discussions_tools:discussion:confirm:close'), 'href' => "action/discussions/toggle_status?guid={$entity->getGUID()}", 'priority' => 201, 'item_class' => $entity->status == 'closed' ? 'hidden' : '']); return $return_value; }
function mentions_init() { elgg_extend_view('css/elgg', 'css/mentions'); elgg_require_js('mentions/autocomplete'); elgg_extend_view('input/longtext', 'mentions/popup'); elgg_extend_view('input/plaintext', 'mentions/popup'); elgg_register_event_handler('pagesetup', 'system', 'mentions_get_views'); // can't use notification hooks here because of many reasons elgg_register_event_handler('create', 'object', 'mentions_notification_handler'); elgg_register_event_handler('create', 'annotation', 'mentions_notification_handler'); // @todo This will result in multiple notifications for an edited entity so we don't do this //register_elgg_event_handler('update', 'all', 'mentions_notification_handler'); // add option to the personal notifications form elgg_extend_view('notifications/subscriptions/personal', 'mentions/notification_settings'); elgg_register_plugin_hook_handler('action', 'notificationsettings/save', 'mentions_save_settings'); }
/** * Setup categories tree using Elgg menu * * @param string $hook Equals 'register' * @param string $type Equals 'menu:categories' * @param array $return An array of category menu items * @param array $params Additional parameters passed to elgg_view_menu() * 'entity' Entity * 'depth' Depth of the tree * 'limit' Number of subcategories to display * 'icons' Show icons * 'collapse' Collapse by default * * @return array */ public function setupCategoriesMenu($hook, $type, $return, $params) { elgg_require_js('framework/categories/menu'); $entity = elgg_extract('entity', $params, elgg_get_site_entity()); // container group or site or category if (!$entity instanceof ElggEntity) { return $return; } unset($params['name']); $defaults = array('depth' => false, 'icons' => true, 'collapse' => true, 'limit' => false, 'badge' => true); $params = array_merge($defaults, $params); $root_nodes = array($entity->guid); $tree = new TreeNode($entity, null, null, $params); $nodes = $tree->toArray($params['depth']); if (!$entity instanceof ElggSite) { if (!elgg_in_context('categories-manage')) { if ($entity instanceof ElggGroup && $this->config->allowsGroupCategories() || $entity instanceof ElggObject) { // Add site wide categories if we are in a group context with group categories enabled // or we are in an object context $site = elgg_get_site_entity(); $root_nodes[] = $site->guid; $site_tree = new TreeNode($site, null, null, $params); $site_nodes = $site_tree->toArray($params['depth']); $nodes = array_merge($site_nodes, $nodes); } } } if (!empty($nodes)) { foreach ($nodes as $node_opts) { $node_guid = elgg_extract('node_guid', $node_opts); $parent_guid = elgg_extract('parent_guid', $node_opts); $node = get_entity($node_guid); $parent = get_entity($parent_guid); if (!$node instanceof ElggEntity || in_array($node->guid, $root_nodes)) { continue; } $has_children = elgg_extract('has_children', $node_opts); $item_params = array_merge($params, array('entity' => $node, 'has_children' => $has_children)); $return[] = ElggMenuItem::factory(array('name' => "category:{$node->guid}", 'parent_name' => $parent && !in_array($parent->guid, $root_nodes) ? "category:{$parent->guid}" : null, 'text' => elgg_view('framework/categories/node', $item_params), 'href' => false, 'priority' => $node->priority ? (int) $node->priority : 999, 'data' => $item_params)); } } if (elgg_in_context('categories-manage')) { // Adds an empty subcategory form $return[] = ElggMenuItem::factory(array('name' => 'placeholder', 'text' => elgg_view('framework/categories/placeholder', array('container' => $entity->guid)), 'href' => false, 'priority' => 1000, 'data-guid' => $node->guid)); } return $return; }
/** * Add the embed menu item to the long text menu * * @param string $hook * @param string $type * @param array $items * @param array $vars * @return array */ function embed_longtext_menu($hook, $type, $items, $vars) { if (elgg_get_context() == 'embed') { return $items; } $url = 'embed'; $page_owner = elgg_get_page_owner_entity(); if (elgg_instanceof($page_owner, 'group') && $page_owner->isMember()) { $url = 'embed?container_guid=' . $page_owner->getGUID(); } $items[] = ElggMenuItem::factory(array('name' => 'embed', 'href' => $url, 'text' => elgg_echo('embed:media'), 'rel' => "embed-lightbox-{$vars['id']}", 'link_class' => "elgg-longtext-control elgg-lightbox embed-control embed-control-{$vars['id']}", 'priority' => 10)); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_require_js('jquery.form'); elgg_load_js('elgg.embed'); return $items; }
function developers_process_settings() { $settings = elgg_get_plugin_from_id('developers')->getAllSettings(); ini_set('display_errors', (int) (!empty($settings['display_errors']))); if (!empty($settings['screen_log'])) { // don't show in action/simplecache $path = substr(current_page_url(), strlen(elgg_get_site_url())); if (!preg_match('~^(cache|action)/~', $path)) { $cache = new ElggLogCache(); elgg_set_config('log_cache', $cache); elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump')); elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function ($hook, $type, $vars, $params) { $vars['body'] .= elgg_view('developers/log'); return $vars; }); } } if (!empty($settings['show_strings'])) { // Beginning and end to make sure both early-rendered and late-loaded translations get included elgg_register_event_handler('init', 'system', 'developers_decorate_all_translations', 1); elgg_register_event_handler('init', 'system', 'developers_decorate_all_translations', 1000); } if (!empty($settings['show_modules'])) { elgg_require_js('elgg/dev/amd_monitor'); } if (!empty($settings['wrap_views'])) { elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views', 600); } if (!empty($settings['log_events'])) { elgg_register_event_handler('all', 'all', 'developers_log_events', 1); elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1); } if (!empty($settings['show_gear']) && elgg_is_admin_logged_in() && !elgg_in_context('admin')) { elgg_require_js('elgg/dev/gear'); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_register_ajax_view('developers/gear_popup'); elgg_register_simplecache_view('elgg/dev/gear.html'); // TODO use ::class in 2.0 $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSectionVars']; elgg_register_plugin_hook_handler('view_vars', 'navigation/menu/elements/section', $handler); $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSections']; elgg_register_plugin_hook_handler('view', 'navigation/menu/elements/section', $handler); } }
/** * Inicializacion */ function init() { // Extendemos el CSS elgg_extend_view('css/elgg', 'evaluationcontent/css'); elgg_extend_view('css/admin', 'evaluationcontent/admin_css'); elgg_extend_view('css/elgg', 'css/trip_companions'); // Registra las URLs de las paginas que se van a usar elgg_register_page_handler('trip_companions', 'trip_companions_page_handler'); // Ahora quito trip companions del menu de usuarios //elgg_register_event_handler('pagesetup', 'system', 'trip_companions_pagesetup'); elgg_register_widget_type('trip_companions', elgg_echo('trip_companions:people:you:may:know'), elgg_echo('trip_companions:widget:description'), array('dashboard', 'profile')); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_register_ajax_view('trip_companions/groups'); if (elgg_is_logged_in()) { elgg_require_js('elgg/evaluationcontent'); } //que un usuario valore a otro, encontrando en el menu desplegable del avatar la opción correspondiente elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'evaluationcontent_user_hover_menu'); //Funciones para admin en Administración > zona Teranga > menuitems elgg_register_admin_menu_item('teranga', 'evaluationcontent', 'teranga'); elgg_register_admin_menu_item('teranga', 'overview', 'teranga'); elgg_register_admin_menu_item('teranga', 'assign', 'teranga'); elgg_register_admin_menu_item('teranga', 'import', 'teranga'); //..y tambien como un widget elgg_register_widget_type('evaluationcontent', elgg_echo('evaluationcontent'), elgg_echo('evaluationcontent:widget:description'), array('admin')); // Acciones sobre las valoraciones $action_path = elgg_get_plugins_path() . "trip_companions/actions/evaluationcontent"; $base_path = elgg_get_plugins_path() . "trip_companions/actions"; elgg_register_action('evaluationcontent/add', "{$action_path}/add.php"); elgg_register_action('evaluationcontent/delete', "{$action_path}/delete.php", 'admin'); elgg_register_action('evaluationcontent/archive', "{$action_path}/archive.php", 'admin'); elgg_register_action('evaluationcontent/reset', "{$action_path}/reset.php", 'admin'); elgg_register_action("evaluationcontent/assign", "{$action_path}/assign.php", 'admin'); //asign karma directly elgg_register_action('trip_companions/export', "{$base_path}/export.php", 'admin'); elgg_register_action('evaluationcontent/import', "{$base_path}/import.php", 'admin'); //Teranga hook between trip_companions and groups elgg_register_library('elgg:trip_companions', elgg_get_plugins_path() . 'trip_companions/lib/trip_companions.php'); elgg_register_plugin_hook_handler('evaluationcontent:add', 'system', 'evaluation_change_grade'); elgg_register_plugin_hook_handler('evaluationcontent:delete', 'system', 'evaluation_change_ungrade'); // Groups add_group_tool_option('trip_companions', elgg_echo('evaluationcontent:enablecomments'), true); elgg_extend_view('groups/tool_latest', 'trip_companions/group_module'); }
function developers_process_settings() { $settings = elgg_get_plugin_from_id('developers')->getAllSettings(); ini_set('display_errors', (int) (!empty($settings['display_errors']))); if (!empty($settings['screen_log'])) { $cache = new ElggLogCache(); elgg_set_config('log_cache', $cache); elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump')); elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function ($hook, $type, $vars, $params) { $vars['body'] .= elgg_view('developers/log'); return $vars; }); } if (!empty($settings['show_strings'])) { // first and last in case a plugin registers a translation in an init method elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1000); elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1); } if (!empty($settings['show_modules'])) { elgg_require_js('elgg/dev/amd_monitor'); } if (!empty($settings['wrap_views'])) { elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views', 600); } if (!empty($settings['log_events'])) { elgg_register_event_handler('all', 'all', 'developers_log_events', 1); elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1); } if (!empty($settings['show_gear']) && elgg_is_admin_logged_in() && !elgg_in_context('admin')) { elgg_require_js('elgg/dev/gear'); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_register_ajax_view('developers/gear_popup'); elgg_register_simplecache_view('elgg/dev/gear.html'); // TODO use ::class in 2.0 $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSectionVars']; elgg_register_plugin_hook_handler('view_vars', 'navigation/menu/elements/section', $handler); $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSections']; elgg_register_plugin_hook_handler('view', 'navigation/menu/elements/section', $handler); } }
/** * Add the embed menu item to the long text menu * * @param string $hook * @param string $type * @param array $items * @param array $vars * @return array */ function embed_longtext_menu($hook, $type, $items, $vars) { if (elgg_get_context() == 'embed') { return $items; } $url = 'embed'; $page_owner = elgg_get_page_owner_entity(); if (elgg_instanceof($page_owner, 'group') && $page_owner->isMember()) { $url = 'embed?container_guid=' . $page_owner->getGUID(); } elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_require_js('jquery.form'); elgg_load_js('elgg.embed'); $text = elgg_echo('embed:media'); // if loaded through ajax (like on /activity), pull in JS libs manually // hack for #6422 because we haven't converted everything to amd yet if (elgg_in_context('ajax')) { $externals = $GLOBALS['_ELGG']->externals_map; $embed = elgg_extract('elgg.embed', $externals['js']); $lightbox_js = elgg_extract('lightbox', $externals['js']); $lightbox_css = elgg_extract('lightbox', $externals['css']); $text .= <<<___JS <script> \trequire(['jquery.form']); \tif (typeof \$.fancybox === 'undefined') { \t\t\$.getScript('{$lightbox_js->url}'); \t\t\$('head').append('<link rel="stylesheet" href="{$lightbox_css->url}"></link>'); \t} \tif (typeof elgg.embed === 'undefined') { \t\t\$.getScript('{$embed->url}'); \t} </script> ___JS; } $items[] = ElggMenuItem::factory(array('name' => 'embed', 'href' => 'javascript:void()', 'data-colorbox-opts' => json_encode(['href' => elgg_normalize_url($url)]), 'text' => $text, 'rel' => "embed-lightbox-{$vars['id']}", 'link_class' => "elgg-longtext-control elgg-lightbox embed-control embed-control-{$vars['id']}", 'priority' => 10)); return $items; }
/** * Initialize the plugin. */ function chat_init() { global $CONFIG; $actionspath = $CONFIG->pluginspath . "chat/actions/chat"; elgg_register_action("chat/save", "{$actionspath}/save.php"); elgg_register_action("chat/addmembers", "{$actionspath}/addmembers.php"); elgg_register_action("chat/leave", "{$actionspath}/leave.php"); elgg_register_action("chat/delete", "{$actionspath}/delete.php"); elgg_register_action("chat/message/save", "{$actionspath}/message/save.php"); elgg_register_action("chat/message/delete", "{$actionspath}/message/delete.php"); elgg_register_action("chat/usersettings/save", "{$actionspath}/usersettings/save.php"); $libpath = elgg_get_plugins_path() . 'chat/lib/chat.php'; elgg_register_library('chat', $libpath); elgg_require_js('chat/chat'); // Add custom CSS elgg_extend_view('css/elgg', 'chat/css'); // Register on low priority so it's possible to remove items added by other plugins elgg_register_plugin_hook_handler('register', 'menu:entity', 'chat_entity_menu_setup', 600); elgg_register_plugin_hook_handler('permissions_check', 'object', 'chat_permissions_override'); elgg_register_plugin_hook_handler('entity:url', 'object', 'chat_url_handler'); elgg_register_event_handler('pagesetup', 'system', 'chat_notifier'); elgg_register_page_handler('chat', 'chat_page_handler'); }
/** * Initialize the plugin */ function reportedcontent_init() { // Register a page handler, so we can have nice URLs elgg_register_page_handler('reportedcontent', 'reportedcontent_page_handler'); // Extend CSS elgg_extend_view('css/elgg', 'reportedcontent/css'); elgg_extend_view('css/admin', 'reportedcontent/admin_css'); if (elgg_is_logged_in()) { elgg_require_js('elgg/reportedcontent'); // Extend footer with report content link elgg_register_menu_item('extras', array('name' => 'report_this', 'href' => 'reportedcontent/add', 'title' => elgg_echo('reportedcontent:this:tooltip'), 'text' => elgg_view_icon('report-this'), 'priority' => 500, 'section' => 'default', 'link_class' => 'elgg-lightbox')); } elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'reportedcontent_user_hover_menu'); // Add admin menu item // @todo Might want to move this to a 'feedback' section. something other than utils elgg_register_admin_menu_item('administer', 'reportedcontent', 'administer_utilities'); elgg_register_widget_type('reportedcontent', elgg_echo('reportedcontent'), elgg_echo('reportedcontent:widget:description'), array('admin')); // Register actions $action_path = elgg_get_plugins_path() . "reportedcontent/actions/reportedcontent"; elgg_register_action('reportedcontent/add', "{$action_path}/add.php"); elgg_register_action('reportedcontent/delete', "{$action_path}/delete.php", 'admin'); elgg_register_action('reportedcontent/archive', "{$action_path}/archive.php", 'admin'); }
function elgg_stars_init() { // Register valid annotaiton names $criteria = elgg_get_plugin_setting('criteria', 'elgg_stars'); if (!$criteria) { elgg_stars_register_rating_annotation_name('starrating'); } else { $criteria = string_to_tag_array($criteria); foreach ($criteria as $criterion) { elgg_stars_register_rating_annotation_name($criterion); } } $root = dirname(__FILE__); // Register actions elgg_register_action('elgg_stars/settings/save', "{$root}/actions/settings/elgg_stars.php", 'admin'); elgg_register_action('stars/rate', "{$root}/actions/stars/rate.php"); elgg_register_action('stars/delete', "{$root}/actions/stars/delete.php"); // Stars JS and CSS elgg_extend_view('css/elgg', 'stars/css'); elgg_define_js('jquery.rateit', array('src' => '/mod/elgg_stars/vendors/rateit/jquery.rateit.min.js', 'deps' => array('jquery'))); elgg_require_js('stars/init'); // Setup menus elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_stars_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_stars_annotation_menu_setup'); // Permissions elgg_register_plugin_hook_handler('permissions_check:annotate', 'all', 'elgg_stars_can_annotate'); // Add an annotation view for registered ratings elgg_register_plugin_hook_handler('view', 'annotation/default', 'elgg_stars_annotation_view_replacement'); // Extend the sidebar with the ratings module elgg_register_plugin_hook_handler('view', 'page/elements/comments', 'elgg_stars_comments_rating_addon', 900); elgg_register_plugin_hook_handler('comments', 'all', 'elgg_stars_comments_rating_addon', 900); // Get rating criteria that applies to an entity elgg_register_plugin_hook_handler('criteria', 'stars', 'elgg_stars_rating_criteria_hook'); // Setup widgets elgg_register_widget_type('highestrating', elgg_echo('stars:widget:highestrating'), elgg_echo('stars:widget:highestrating:desc'), array('all'), false); }
/** * Add some menu items to the entity menu * * @param string $hook 'register' * @param string $entity_type 'menu:entity' * @param ElggMenuItem[] $returnvalue the current menu items * @param array $params supplied params * * @return void|ElggMenuItem[] */ public static function register($hook, $entity_type, $returnvalue, $params) { $entity = elgg_extract('entity', $params); if (!$entity instanceof \ElggBlog) { return; } // only published blogs if ($entity->status === 'draft') { return; } if (!elgg_in_context('widgets') && elgg_is_admin_logged_in()) { elgg_require_js('blog_tools/site'); $returnvalue[] = \ElggMenuItem::factory(['name' => 'blog-feature', 'text' => elgg_echo('blog_tools:toggle:feature'), 'href' => "action/blog_tools/toggle_metadata?guid={$entity->getGUID()}&metadata=featured", 'item_class' => empty($entity->featured) ? '' : 'hidden', 'is_action' => true, 'priority' => 175]); $returnvalue[] = \ElggMenuItem::factory(['name' => 'blog-unfeature', 'text' => elgg_echo('blog_tools:toggle:unfeature'), 'href' => "action/blog_tools/toggle_metadata?guid={$entity->getGUID()}&metadata=featured", 'item_class' => empty($entity->featured) ? 'hidden' : '', 'is_action' => true, 'priority' => 176]); } if ($entity->canComment()) { $returnvalue[] = \ElggMenuItem::factory(['name' => 'comments', 'text' => elgg_view_icon('speech-bubble'), 'title' => elgg_echo('comment:this'), 'href' => "{$entity->getURL()}#comments"]); $comment_count = $entity->countComments(); if ($comment_count) { $returnvalue[] = \ElggMenuItem::factory(['name' => 'comments_count', 'text' => $comment_count, 'title' => elgg_echo('comments'), 'href' => "{$entity->getURL()}#comments"]); } } return $returnvalue; }
/** * Change menu item in the longtext menu * * @param string $hook 'prepare' * @param string $type 'menu:longtext' * @param ElggMenuItem[] $return_value the current menu items * @param array $params supplied params * * @return ElggMenuItem[] */ public static function longtextMenuPrepare($hook, $type, $return_value, $params) { if (!is_array($return_value)) { return; } foreach ($return_value as $section => $menu_items) { if (!is_array($menu_items)) { continue; } foreach ($menu_items as $menu_item) { if ($menu_item->getName() !== 'embed') { continue; } if (elgg_is_xhr()) { echo elgg_format_element('script', [], 'require(["embed_extended/site"]);'); } else { elgg_require_js('embed_extended/site'); } $link_class = $menu_item->getLinkClass(); $link_class = str_ireplace('elgg-lightbox', 'elgg-embed-lightbox', $link_class); $menu_item->setLinkClass($link_class); } } }