function rijkshuisstijl_site_menu_prepare($hook, $type, $value, $params) { $selected = false; foreach ($value as $section) { foreach ($section as $item) { if ($item->getSelected()) { $selected = true; break 2; } } } if (!$selected) { $current_url = current_page_url(); $site_url = elgg_get_site_url(); foreach ($value as $section_name => $section) { foreach ($section as $key => $item) { // do not highlight external links if (strpos($item->getHref(), $site_url) !== 0) { continue; } // do not highlight links to main site URL if ($item->getHref() == $site_url) { continue; } if (strpos($current_url, $item->getHref()) === 0) { $value[$section_name][$key]->setSelected(true); break 2; } } } } return $return; }
/** * CRUD page handler * * URLs take the form of * List crud objects in group: <crud_type>/owner/<guid> * View crud object: <crud_type>/view/<guid> * Add crud object: <crud_type>/add/<guid> * Edit crud object: <crud_type>/edit/<guid> * * @param array $page Array of url segments for routing * @return bool */ function crud_page_handler($page) { elgg_load_library('elgg:crud'); if (!isset($page[0])) { $page[0] = 'all'; } $page_url = current_page_url(); $site_url = elgg_get_site_url(); $current_url = str_replace($site_url, "", $page_url); $crud_type = current(explode('/', $current_url)); $crud_handler = crud_get_handler($crud_type); $crud_module = $crud_handler->module; elgg_push_breadcrumb(elgg_echo($crud_module), ''); switch ($page[0]) { case 'owner': case 'group': crud_handle_list_page($crud_handler, $page[1]); break; case 'add': crud_handle_edit_page($crud_handler, 'add', $page[1]); break; case 'edit': crud_handle_edit_page($crud_handler, 'edit', $page[1]); break; case 'view': crud_handle_view_page($crud_handler, $page[1]); break; case 'edit_general': crud_handle_edit_page($crud_handler, 'edit_general', $page[1]); break; default: return false; } return true; }
/** * hook called on route, all * check if $returnvalue['handler'] to see if we need to replace it * if the handler is an original handler, we want to foward it to the new url * * @param type $hook * @param type $type * @param type $returnvalue * @param type $params * @return array */ function router($hook, $type, $returnvalue, $params) { if (elgg_get_config('pagehandler_hijack')) { return $returnvalue; } $handlers = get_replacement_handlers(); if (in_array($returnvalue['handler'], array_keys($handlers))) { // we have been given an old handler -> we should forward to the replacement // probably from an old link or something $currenturl = current_page_url(); //get everything after the pagehandler $afterhandler = str_replace(elgg_get_site_url() . $returnvalue['handler'], "", $currenturl); $newurl = elgg_get_site_url() . $handlers[$returnvalue['handler']] . $afterhandler; // forward to the new url forward($newurl); } if (in_array($returnvalue['handler'], $handlers)) { // we need to do something about it // get the original handler $original = array_search($returnvalue['handler'], $handlers); if (!empty($original)) { // reset the context for non-hijack aware code elgg_set_context($original); // let the system load content for the original handler $returnvalue['handler'] = $original; $returnvalue['identifier'] = $original; // set a flag so we don't infinite loop ourselves in route hooks elgg_set_config('pagehandler_hijack', true); return elgg_trigger_plugin_hook('route', $original, null, $returnvalue); } } }
function elgg_modifications_pagesetup() { $user = elgg_get_logged_in_user_entity(); if (!$user) { return; } if (elgg_in_context("accept_terms")) { return; } $site = elgg_get_site_entity(); if ($site->isPublicPage()) { return; } if (!empty($_SESSION["terms_accepted"])) { return; } if (elgg_get_plugin_setting("accept_terms", "elgg_modifications") === "no") { return; } $user_ts = $user->getPrivateSetting("general_terms_accepted"); if (empty($user_ts)) { $_SESSION["terms_forward_from"] = current_page_url(); forward("accept_terms"); } else { // user has accepted the terms, so don't check again $_SESSION["terms_accepted"] = $user_ts; } }
function au_subgroups_pagehandler($page) { // dirty check to avoid duplicate page handlers // since this should only be called from the route, groups hook if (strpos(current_page_url(), elgg_get_site_url() . 'au_subgroups') === 0) { return false; } switch ($page[0]) { case 'add': set_input('au_subgroup', true); set_input('au_subgroup_parent_guid', $page[1]); elgg_set_page_owner_guid($page[1]); echo elgg_view('resources/au_subgroups/add'); return true; break; case 'list': elgg_set_page_owner_guid($page[1]); echo elgg_view('resources/au_subgroups/list'); break; case 'delete': elgg_set_page_owner_guid($page[1]); echo elgg_view('resources/au_subgroups/delete'); break; case 'openclosed': set_input('filter', $page[1]); echo elgg_view('resources/au_subgroups/openclosed'); return true; break; } return false; }
/** * Get the context for a page, for the help system * * @param string $url the (optional) url to get the context for * * @return bool|string */ function user_support_get_help_context($url = "") { if (empty($url)) { $url = current_page_url(); } if (empty($url)) { return false; } $path = parse_url($url, PHP_URL_PATH); if (empty($path)) { return false; } $parts = explode("/", $path); $page_owner = elgg_get_page_owner_entity(); if (empty($page_owner)) { $page_owner = elgg_get_logged_in_user_entity(); } $new_parts = array(); foreach ($parts as $index => $part) { if (empty($part)) { continue; } elseif (is_numeric($part) || !empty($page_owner) && $page_owner->username == $part) { break; } else { $new_parts[] = $part; } } if (empty($new_parts)) { return false; } return implode("/", $new_parts); }
/** * Listen to the delete of a membership request * * @param stirng $event the name of the event * @param stirng $type the type of the event * @param \ElggRelationship $relationship the relationship * * @return void */ public static function deleteRequest($event, $type, $relationship) { if (!$relationship instanceof \ElggRelationship) { return; } if ($relationship->relationship !== 'membership_request') { // not a membership request return; } $action_pattern = '/action\\/groups\\/killrequest/i'; if (!preg_match($action_pattern, current_page_url())) { // not in the action, so do nothing return; } $group = get_entity($relationship->guid_two); $user = get_user($relationship->guid_one); if (empty($user) || !$group instanceof \ElggGroup) { return; } if ($user->getGUID() === elgg_get_logged_in_user_guid()) { // user kills own request return; } $reason = get_input('reason'); if (empty($reason)) { $body = elgg_echo('group_tools:notify:membership:declined:message', [$user->name, $group->name, $group->getURL()]); } else { $body = elgg_echo('group_tools:notify:membership:declined:message:reason', [$user->name, $group->name, $reason, $group->getURL()]); } $subject = elgg_echo('group_tools:notify:membership:declined:subject', [$group->name]); $params = ['object' => $group, 'action' => 'delete']; notify_user($user->getGUID(), $group->getGUID(), $subject, $body, $params); }
/** * Bookmark init */ function bookmarks_init() { $root = dirname(__FILE__); elgg_register_library('elgg:bookmarks', "{$root}/lib/bookmarks.php"); // actions $action_path = "{$root}/actions/bookmarks"; elgg_register_action('bookmarks/save', "{$action_path}/save.php"); elgg_register_action('bookmarks/delete', "{$action_path}/delete.php"); elgg_register_action('bookmarks/share', "{$action_path}/share.php"); // menus elgg_register_menu_item('site', array('name' => 'bookmarks', 'text' => elgg_echo('bookmarks'), 'href' => 'bookmarks/all')); elgg_register_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu'); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'bookmarks_owner_block_menu'); elgg_register_page_handler('bookmarks', 'bookmarks_page_handler'); elgg_extend_view('css/elgg', 'bookmarks/css'); elgg_extend_view('js/elgg', 'bookmarks/js'); elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description')); if (elgg_is_logged_in()) { $user_guid = elgg_get_logged_in_user_guid(); $address = urlencode(current_page_url()); elgg_register_menu_item('extras', array('name' => 'bookmark', 'text' => elgg_view_icon('push-pin-alt'), 'href' => "bookmarks/add/{$user_guid}?address={$address}", 'title' => elgg_echo('bookmarks:this'), 'rel' => 'nofollow')); } // Register granular notification for this type register_notification_object('object', 'bookmarks', elgg_echo('bookmarks:new')); // Listen to notification events and supply a more useful message elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'bookmarks_notify_message'); // Register a URL handler for bookmarks elgg_register_entity_url_handler('object', 'bookmarks', 'bookmark_url'); // Register entity type for search elgg_register_entity_type('object', 'bookmarks'); // Groups add_group_tool_option('bookmarks', elgg_echo('bookmarks:enablebookmarks'), true); elgg_extend_view('groups/tool_latest', 'bookmarks/group_module'); }
/** * Get page components to view a blog post. * * @param int $guid GUID of a blog entity. * @return array */ function blog_get_page_content_read($guid = NULL) { $return = array(); $blog = get_entity($guid); // no header or tabs for viewing an individual blog $return['filter'] = ''; if (!elgg_instanceof($blog, 'object', 'blog')) { register_error(elgg_echo('noaccess')); $_SESSION['last_forward_from'] = current_page_url(); forward(''); } $return['title'] = $blog->title; $container = $blog->getContainerEntity(); $crumbs_title = $container->name; if (elgg_instanceof($container, 'group')) { elgg_push_breadcrumb($crumbs_title, "blog/group/{$container->guid}/all"); } else { elgg_push_breadcrumb($crumbs_title, "blog/owner/{$container->username}"); } elgg_push_breadcrumb($blog->title); $return['content'] = elgg_view_entity($blog, array('full_view' => true)); // check to see if we should allow comments if ($blog->comments_on != 'Off' && $blog->status == 'published') { $return['content'] .= elgg_view_comments($blog); } return $return; }
/** * Bookmark init */ function bookmarks_init() { $root = dirname(__FILE__); elgg_register_library('elgg:bookmarks', "{$root}/lib/bookmarks.php"); // actions $action_path = "{$root}/actions/bookmarks"; elgg_register_action('bookmarks/save', "{$action_path}/save.php"); elgg_register_action('bookmarks/delete', "{$action_path}/delete.php"); elgg_register_action('bookmarks/share', "{$action_path}/share.php"); // menus elgg_register_menu_item('site', array('name' => 'bookmarks', 'text' => elgg_echo('bookmarks'), 'href' => 'bookmarks/all')); elgg_register_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu'); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'bookmarks_owner_block_menu'); elgg_register_page_handler('bookmarks', 'bookmarks_page_handler'); elgg_extend_view('elgg.css', 'bookmarks/css'); elgg_extend_view('elgg.js', 'bookmarks/js'); elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description')); if (elgg_is_logged_in()) { $user_guid = elgg_get_logged_in_user_guid(); $address = urlencode(current_page_url()); elgg_register_menu_item('extras', array('name' => 'bookmark', 'text' => elgg_view_icon('push-pin-alt'), 'href' => "bookmarks/add/{$user_guid}?address={$address}", 'title' => elgg_echo('bookmarks:this'), 'rel' => 'nofollow')); } // Register for notifications elgg_register_notification_event('object', 'bookmarks', array('create')); elgg_register_plugin_hook_handler('prepare', 'notification:create:object:bookmarks', 'bookmarks_prepare_notification'); // Register bookmarks view for ecml parsing elgg_register_plugin_hook_handler('get_views', 'ecml', 'bookmarks_ecml_views_hook'); // Register a URL handler for bookmarks elgg_register_plugin_hook_handler('entity:url', 'object', 'bookmark_set_url'); // Register entity type for search elgg_register_entity_type('object', 'bookmarks'); // Groups add_group_tool_option('bookmarks', elgg_echo('bookmarks:enablebookmarks'), true); elgg_extend_view('groups/tool_latest', 'bookmarks/group_module'); }
function loginrequired_init() { global $CONFIG; // No need to do all the checking below if the user is already logged in... performance is key :) // if (elgg_is_logged_in()) return; elgg_extend_view('css/elgg', 'loginrequired/css'); // elgg_unextend_view('page/elements/header', 'search/header'); elgg_register_plugin_hook_handler('index', 'system', 'loginrequired_index', 1); elgg_register_plugin_hook_handler('login_required', 'login_required', 'login_required_default_allowed_list'); // Get the current page URL without any ? & parameters... this is required for the registration page to work properly $current_url = current_page_url(); $parameters_start = strrpos($current_url, '?'); if ($parameters_start) { $current_url = substr($current_url, 0, $parameters_start); } // Always allow index page if ($current_url == $CONFIG->url) { return; } $allow = array(); // Allow should have pages $allow[] = '_graphics'; $allow[] = 'action/login'; $allow[] = 'register'; $allow[] = 'action/register'; $allow[] = 'forgotpassword'; $allow[] = 'resetpassword'; $allow[] = 'action/user/requestnewpassword'; $allow[] = 'action/user/passwordreset'; $allow[] = 'action/security/refreshtoken'; $allow[] = 'ajax/view/js/languages'; $allow[] = 'upgrade\\.php'; $allow[] = 'xml-rpc\\.php'; $allow[] = 'mt/mt-xmlrpc\\.cgi'; $allow[] = 'css/.*'; $allow[] = 'js/.*'; $allow[] = 'cache/css/.*'; $allow[] = 'cache/js/.*'; // Allow other plugin developers to edit the array values $add_allow = elgg_trigger_plugin_hook('login_required', 'login_required'); // If more URL's are added... merge both with original list if (is_array($add_allow)) { $allow = array_merge($allow, $add_allow); } // Any public_pages defined via Elgg's walled garden plugin hook? $plugins = elgg_trigger_plugin_hook('public_pages', 'walled_garden', NULL, array()); // If more URL's are added... merge both with original list if (is_array($plugins)) { $allow = array_merge($allow, $plugins); } // Check if current page is in allowed list... otherwise redirect to login foreach ($allow as $public) { $pattern = "`^{$CONFIG->url}{$public}/*\$`i"; if (preg_match($pattern, $current_url)) { return; } } gatekeeper(); }
function walledgarden_pagesetup() { global $CONFIG; if (current_page_url() != $CONFIG->url && !defined('externalpage') && !isloggedin()) { forward(); exit; } }
/** * Setup menus at page setup */ function stripe_pagesetup() { elgg_register_menu_item('page', array('name' => 'stripe:customers', 'href' => 'admin/stripe/customers', 'text' => elgg_echo('admin:stripe:customers'), 'context' => 'admin', 'section' => 'stripe')); $user = elgg_get_page_owner_entity(); elgg_register_menu_item('page', array('name' => 'stripe:cards', 'href' => "billing/{$user->username}/cards/all", 'text' => elgg_echo('stripe:cards:all'), 'selected' => substr_count(current_page_url(), 'cards/all'), 'context' => 'settings', 'section' => 'stripe')); elgg_register_menu_item('page', array('name' => 'stripe:charges', 'href' => "billing/{$user->username}/charges/all", 'text' => elgg_echo('stripe:charges:all'), 'selected' => substr_count(current_page_url(), 'charges/all'), 'context' => 'settings', 'section' => 'stripe')); elgg_register_menu_item('page', array('name' => 'stripe:invoices', 'href' => "billing/{$user->username}/invoices/all", 'text' => elgg_echo('stripe:invoices:all'), 'selected' => substr_count(current_page_url(), 'invoices/all'), 'context' => 'settings', 'section' => 'stripe')); elgg_register_menu_item('page', array('name' => 'stripe:subscriptions', 'href' => "billing/{$user->username}/subscriptions/all", 'text' => elgg_echo('stripe:subscriptions:all'), 'selected' => substr_count(current_page_url(), 'subscriptions/all'), 'context' => 'settings', 'section' => 'stripe')); }
/** * Change the filter menu for the questions context * * @param string $hook the 'register' hook * @param string $type the 'menu:filter' type * @param array $items the current menu items * @param array $params the supplied parameters */ function questions_filter_menu_handler($hook, $type, $items, $params) { if (!empty($items) && is_array($items) && elgg_in_context("questions")) { $page_owner = elgg_get_page_owner_entity(); // change some menu items foreach ($items as $key => $item) { // remove friends if ($item->getName() == "friend") { unset($items[$key]); } // in group context if (elgg_instanceof($page_owner, "group")) { // remove mine if ($item->getName() == "mine") { unset($items[$key]); } // highlight all if ($item->getName() == "all") { $item->setHref("questions/group/" . $page_owner->getGUID() . "/all"); $current_page = current_page_url(); if (stristr($current_page, "questions/group/" . $page_owner->getGUID() . "/all")) { $item->setSelected(true); } } } } if (elgg_instanceof($page_owner, "group")) { $expertContainer = $page_owner; } else { $expertContainer = null; } if (questions_is_expert($expertContainer) && !questions_workflow_enabled($expertContainer)) { if (elgg_instanceof($page_owner, "group")) { $items[] = ElggMenuItem::factory(array("name" => "todo_group", "text" => elgg_echo("questions:menu:filter:todo_group"), "href" => "questions/todo/" . $page_owner->getGUID(), "priority" => 710)); } else { $items[] = ElggMenuItem::factory(array("name" => "todo", "text" => elgg_echo("questions:menu:filter:todo"), "href" => "questions/todo", "priority" => 700)); } } if (questions_is_expert() && questions_workflow_enabled($expertContainer)) { if (elgg_instanceof($page_owner, "group")) { $url = "questions/group/" . $page_owner->getGUID() . "/workflow"; } else { $url = "questions/workflow"; } $items[] = ElggMenuItem::factory(array("name" => "workflow", "text" => elgg_echo("questions:menu:workflow"), "href" => $url, "priority" => 705)); } if (elgg_is_admin_logged_in() | questions_is_expert($expertContainer) && questions_experts_enabled()) { $experts_href = "questions/experts"; if (elgg_instanceof($page_owner, "group")) { $experts_href .= "/" . elgg_get_page_owner_guid(); } $items[] = ElggMenuItem::factory(array("name" => "experts", "text" => elgg_echo("questions:menu:filter:experts"), "href" => $experts_href, "priority" => 800)); } } return $items; }
/** * Create a Stripe object menu * * @param string $hook Equals 'register' * @param string $type Equals 'stripe-actions' * @param array $return Current menu * @param array $params Additional params * @return array */ function stripe_actions_menu($hook, $type, $return, $params) { $object = elgg_extract('object', $params); switch ($object->object) { case 'card': $user = stripe_get_user_from_customer_id($object->customer); if (!elgg_instanceof($user) || !$user->canEdit()) { return $return; } $stripe = new StripeClient(); $default = $stripe->getDefaultCard($user->guid); if ($default->id == $object->id) { $return[] = ElggMenuItem::factory(array('name' => 'default', 'text' => elgg_echo('stripe:cards:default'), 'href' => false)); } else { $return[] = ElggMenuItem::factory(array('name' => 'default', 'text' => elgg_echo('stripe:cards:make_default'), 'href' => "action/stripe/cards/set_default?card_id={$object->id}&customer_id={$object->customer}", 'is_action' => 800, 'class' => 'elgg-requires-confirmation', 'rel' => elgg_echo('question:areyousure'))); $return[] = ElggMenuItem::factory(array('name' => 'remove', 'text' => elgg_echo('stripe:cards:remove'), 'href' => "action/stripe/cards/set_default?card_id={$object->id}&customer_id={$object->customer}", 'is_action' => true, 'priority' => 900, 'class' => 'elgg-requires-confirmation', 'rel' => elgg_echo('question:areyousure'))); } break; case 'charge': $user = stripe_get_user_from_customer_id($object->customer); if (!elgg_instanceof($user) || !$user->canEdit()) { return $return; } $full = elgg_normalize_url("billing/{$user->username}/charges/view/{$object->id}"); if (current_page_url() !== $full) { $return[] = ElggMenuItem::factory(array('name' => 'details', 'text' => elgg_echo('stripe:charges:view'), 'href' => $full)); } break; case 'invoice': $user = stripe_get_user_from_customer_id($object->customer); if (!elgg_instanceof($user) || !$user->canEdit()) { return $return; } if (isset($object->id)) { $full = elgg_normalize_url("billing/{$user->username}/invoices/view/{$object->id}"); if (current_page_url() !== $full) { $return[] = ElggMenuItem::factory(array('name' => 'details', 'text' => elgg_echo('stripe:invoices:view'), 'href' => $full)); } } break; case 'subscription': $user = stripe_get_user_from_customer_id($object->customer); if (!elgg_instanceof($user) || !$user->canEdit()) { return $return; } $upcoming = elgg_normalize_url("billing/{$user->username}/invoices/upcoming/{$object->id}"); if (current_page_url() !== $upcoming) { $return[] = ElggMenuItem::factory(array('name' => 'details', 'text' => elgg_echo('stripe:invoices:upcoming'), 'href' => $upcoming)); } if (!$object->cancel_at_period_end) { $return[] = ElggMenuItem::factory(array('name' => 'cancel', 'text' => elgg_echo('subscriptions:cancel'), 'href' => "action/stripe/subscriptions/cancel?subscription_id={$object->id}&customer_id={$object->customer}", 'is_action' => 800, 'class' => 'elgg-requires-confirmation', 'rel' => elgg_echo('question:areyousure'))); } break; } return $return; }
function widget($args, $instance) { $before_widget = $before_title = $after_title = $after_widget = ''; extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $facebook = empty($instance['facebook']) ? '' : $instance['facebook']; $twitter = empty($instance['twitter']) ? '' : $instance['twitter']; $gplus = empty($instance['gplus']) ? '' : $instance['gplus']; $pinterest = empty($instance['pinterest']) ? '' : $instance['pinterest']; $facebook_page = empty($instance['facebook_page']) ? '' : $instance['facebook_page']; $twitter_username = empty($instance['twitter_username']) ? '' : $instance['twitter_username']; $twitter_text = empty($instance['twitter_text']) ? '' : $instance['twitter_text']; $twitter_hastag = empty($instance['twitter_hastag']) ? '' : $instance['twitter_hastag']; $pin_image = empty($instance['pin_image']) ? '' : urlencode($instance['pin_image']); $pin_desc = empty($instance['pin_desc']) ? '' : urlencode($instance['pin_desc']); $pin_url = urlencode(current_page_url()); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } ?> <ul class="social-share fixclear"> <?php if (!empty($facebook) && !empty($facebook_page)) { echo '<li class="social-share-item sc-facebook">'; echo '<div class="fb-like" data-href="http://facebook.com/' . $facebook_page . '" data-send="false" data-layout="button_count" data-width="120" data-show-faces="false" data-font="lucida grande"></div>'; echo '</li><!-- facebook like -->'; } if (!empty($twitter) && !empty($twitter_username) && !empty($twitter_text) && !empty($twitter_hastag)) { $url = 'https://twitter.com/share'; echo '<li class="social-share-item sc-twitter">'; echo '<a href="' . $url . '" class="twitter-share-button" data-text="' . $twitter_text . '" data-via="' . $twitter_username . '" data-hashtags="' . $twitter_hastag . '">Tweet</a>'; echo '</li><!-- twitter -->'; echo "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>"; } if (!empty($gplus)) { echo '<li class="social-share-item sc-gplus">'; echo '<script type="text/javascript">'; echo ";(function() {\n\t\t\tvar po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;\n\t\t\tpo.src = 'https://apis.google.com/js/plusone.js';\n\t\t\tvar s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);\n\t\t\t})();"; echo '</script>'; echo '<div class="g-plusone" data-size="medium"></div>'; echo '</li><!-- Gplus like -->'; } if (!empty($pinterest) && !empty($pin_image) && !empty($pin_desc)) { echo '<li class="social-share-item sc-pinterest">'; echo '<a href="http://pinterest.com/pin/create/button/?url=' . $pin_url . '&media=' . $pin_image . '&description=' . $pin_desc . '" class="pin-it-button" count-layout="horizontal"><img src="http://assets.pinterest.com/images/PinExt.png" title="' . __('Pin It', 'zn_framework') . '" alt="' . __('Pin It', 'zn_framework') . '" /></a>'; echo '<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>'; echo '</li><!-- pinterest like -->'; } ?> </ul> <?php echo $after_widget; }
function zhgroups_site_menu_setup($hook, $type, $return, $params) { $group = elgg_get_page_owner_entity(); // Check for valid group if (!elgg_instanceof($group, 'group')) { return $return; } foreach ($return as $index => $item) { unset($return[$index]); } // $return['default'] // $return['more'] = array_splice($return['default'], $max_display_items); $return['default'][] = ElggMenuItem::factory(array('name' => 'home', 'href' => $group->getURL(), 'text' => elgg_echo('Home'))); $return['default'][] = ElggMenuItem::factory(array('name' => 'gm', 'href' => 'zhgroups/members/' . $group->guid, 'text' => elgg_echo('Group Members'))); $return['default'][] = ElggMenuItem::factory(array('name' => 'photos', 'href' => 'photos/group/' . $group->guid . '/all', 'text' => elgg_echo('Photos'))); // group members if ($group->isMember(elgg_get_logged_in_user_entity())) { $return['more'] = zhgroups_register_action_buttons($group); } elseif (elgg_is_logged_in()) { $url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}"; $url = elgg_add_action_tokens_to_url($url); $return['default'][] = ElggMenuItem::factory(array('name' => 'join', 'href' => $url, 'text' => elgg_echo('groups:join'), 'class' => 'zhaohu-action')); } // check if we have anything selected $selected = false; foreach ($return as $section) { foreach ($section as $item) { if ($item->getSelected()) { $selected = true; break 2; } } } if (!$selected) { // nothing selected, match name to context or match url $current_url = current_page_url(); foreach ($return as $section_name => $section) { foreach ($section as $key => $item) { // only highlight internal links if (strpos($item->getHref(), elgg_get_site_url()) === 0) { if ($item->getName() == elgg_get_context()) { $return[$section_name][$key]->setSelected(true); break 2; } if ($item->getHref() == $current_url) { $return[$section_name][$key]->setSelected(true); break 2; } } } } } return $return; }
function build_page_url($page) { $us = explode('/', current_page_url()); $idx = count($us) - 1; if ((strlen(trim($us[$idx])) == 0 || !is_numeric(trim($us[$idx]))) && is_numeric(trim($us[$idx - 1]))) { $idx--; } $us[$idx] = $page; if (strlen(trim($us[count($us) - 1])) > 0 && is_numeric(trim($us[count($us) - 1]))) { array_push($us, ''); } return implode('/', $us); }
function sched_conf_pagesetup() { // a bit of a kludge to check if we are on a listing page $url = current_page_url(); if (strpos($url, 'event_calendar/list') !== FALSE) { elgg_register_menu_item('title', array('name' => 'add_conference', 'href' => 'sched_conf/add/', 'text' => elgg_echo('sched_conf:add_conf_title'), 'class' => 'elgg-button elgg-button-action')); } else { if (strpos($url, 'event_calendar/group') !== FALSE) { $group_guid = elgg_get_page_owner_guid(); elgg_register_menu_item('title', array('name' => 'add_conference', 'href' => "sched_conf/add/" . $group_guid, 'text' => elgg_echo('sched_conf:add_conf_title'), 'class' => 'elgg-button elgg-button-action')); } } }
/** * @param array $breadcrumbs * * @return void */ function ufcoe_crumbs_alter_breadcrumbs(&$breadcrumbs) { // normalize keys, just in case $breadcrumbs = array_values($breadcrumbs); // remove trailing non-link crumbs (the title is already in the current page) for ($i = count($breadcrumbs) - 1; $i >= 0; --$i) { if (!$breadcrumbs[$i]['link']) { unset($breadcrumbs[$i]); } else { break; } } // User > Files instead of Files > User // Groups > My Group > Files instead of Files > My Group $page_owner = elgg_get_page_owner_entity(); if (!$page_owner) { return; } $page_owner_url = $page_owner->getURL(); if ($page_owner_url === preg_replace('~\\?.*~', '', current_page_url())) { // this is the profile page return; } // find the first ".../all" crumb $all_index = -1; $all_title = ''; foreach ($breadcrumbs as $i => $crumb) { if (preg_match('~/all$~', $crumb['link'])) { $all_index = $i; $all_title = $crumb['title']; break; } } if ($all_index > -1) { $breadcrumbs[$all_index] = array('link' => $page_owner_url, 'title' => $page_owner->name); // insert the all Groups link before the group if ($page_owner instanceof ElggGroup) { array_splice($breadcrumbs, $all_index, 0, array(array('link' => 'groups/all', 'title' => elgg_echo('groups')))); $all_index += 1; } if (isset($breadcrumbs[$all_index + 1]) && $breadcrumbs[$all_index + 1]['title'] === $page_owner->name) { if ($breadcrumbs[$all_index + 1]['link'] == $page_owner_url) { // duplicate array_splice($breadcrumbs, $all_index + 1, 1); } else { $breadcrumbs[$all_index + 1]['title'] = $all_title; } } } }
function widget_favorites_is_linked($url = "") { $result = false; if (empty($url)) { $url = current_page_url(); } if (!empty($url)) { $options = array("type" => "object", "subtype" => "widget_favorite", "joins" => array("JOIN " . elgg_get_config("dbprefix") . "objects_entity oe ON e.guid = oe.guid"), "wheres" => array("oe.description = '" . sanitise_string($url) . "'"), "limit" => 1); if ($entities = elgg_get_entities($options)) { $result = $entities[0]; } } return $result; }
function widget_manager_init() { // check valid WidgetManagerWidget class if (get_subtype_class("object", "widget") == "ElggWidget") { update_subtype("object", "widget", "WidgetManagerWidget"); } elgg_trigger_event("widgets_init", "widget_manager"); if (elgg_is_active_plugin("groups") && elgg_get_plugin_setting("group_enable", "widget_manager") == "yes") { // add the widget manager tool option $group_option_enabled = false; if (elgg_get_plugin_setting("group_option_default_enabled", "widget_manager") == "yes") { $group_option_enabled = true; } if (elgg_get_plugin_setting("group_option_admin_only", "widget_manager") != "yes") { // add the tool option for group admins add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled); } elseif (elgg_is_admin_logged_in()) { add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled); } elseif ($group_option_enabled) { // register event to make sure newly created groups have the group option enabled elgg_register_event_handler("create", "group", "widget_manager_create_group_event_handler"); elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'widget_manager_group_widgets_default_list'); } } // extend CSS elgg_extend_view("css/elgg", "widget_manager/css/global"); elgg_extend_view("css/admin", "widget_manager/css/global"); elgg_extend_view("js/elgg", "widget_manager/js/site"); elgg_extend_view("js/admin", "widget_manager/js/admin"); // register a widget title url handler elgg_register_entity_url_handler("object", "widget", "widget_manager_widget_url_handler"); // multi dashboard support add_subtype("object", MultiDashboard::SUBTYPE, "MultiDashboard"); if (elgg_is_logged_in() && widget_manager_multi_dashboard_enabled()) { elgg_register_page_handler("multi_dashboard", "widget_manager_multi_dashboard_page_handler"); $options = array("type" => "object", "subtype" => MultiDashboard::SUBTYPE, "owner_guid" => elgg_get_logged_in_user_guid(), "count" => true); $tab_count = elgg_get_entities($options); if ($tab_count < MULTI_DASHBOARD_MAX_TABS) { elgg_register_menu_item("extras", array("name" => "multi_dashboard", "text" => elgg_view_icon("home"), "href" => "multi_dashboard/edit/?internal_url=" . urlencode(current_page_url()), "title" => elgg_echo("widget_manager:multi_dashboard:extras"), "rel" => "nofollow", "id" => "widget-manager-multi_dashboard-extras")); } elgg_extend_view("page/elements/sidebar", "widget_manager/multi_dashboard/sidebar", 400); elgg_register_event_handler("create", "object", "widget_manager_create_object_handler"); elgg_register_plugin_hook_handler("route", "dashboard", "widget_manager_dashboard_route_handler"); elgg_register_plugin_hook_handler("action", "widgets/add", "widget_manager_widgets_add_action_handler"); elgg_register_action("multi_dashboard/edit", dirname(__FILE__) . "/actions/multi_dashboard/edit.php"); elgg_register_action("multi_dashboard/delete", dirname(__FILE__) . "/actions/multi_dashboard/delete.php"); elgg_register_action("multi_dashboard/drop", dirname(__FILE__) . "/actions/multi_dashboard/drop.php"); elgg_register_action("multi_dashboard/reorder", dirname(__FILE__) . "/actions/multi_dashboard/reorder.php"); } }
/** * Handle a standard OpenID server request */ function action_default() { global $store; $server =& getServer(); $method = $_SERVER['REQUEST_METHOD']; /*$request = null; if ($method == 'GET') { $request = $_GET; } else { $request = $_POST; } */ $request = $server->decodeRequest(); if (!$request) { return ""; //about_render(); } setRequestInfo($request); if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) { $identity = getLoggedInUser(); if (isTrusted($identity, $request->trust_root, $request->return_to)) { if ($request->message->isOpenID1()) { $response =& $request->answer(true); } else { $response =& $request->answer(true, false, getServerURL(), $identity); } } else { if ($request->immediate) { $response =& $request->answer(false, getServerURL()); } else { if (!getLoggedInUser()) { $_SESSION['last_forward_from'] = current_page_url() . '?' . http_build_query(Auth_OpenID::getQuery()); system_message(elgg_echo('openid_server:not_logged_in')); forward('login'); } return trust_render($request); } } addSregFields(&$response); } else { $response =& $server->handleRequest($request); } $webresponse =& $server->encodeResponse($response); foreach ($webresponse->headers as $k => $v) { header("{$k}: {$v}"); } header(header_connection_close); print $webresponse->body; exit(0); }
function leave_group($e, $t, $params) { // save for the shutdown handler to process remember_leave_group($params['group'], $params['user']); // is this a cron script? $uri = str_replace(elgg_get_site_url(), '', current_page_url()); $is_cron = strpos($uri, 'cron/') === 0; if (!$GLOBALS['shutdown_flag'] && !$is_cron) { // unregister first so we don't end up with multiple firings of the event elgg_unregister_event_handler('shutdown', 'system', __NAMESPACE__ . '\\process_group_leaves'); elgg_register_event_handler('shutdown', 'system', __NAMESPACE__ . '\\process_group_leaves'); } else { process_group_leaves(); } }
/** * Adds messages to the session so they'll be carried over, and forwards the browser. * Returns false if headers have already been sent and the browser cannot be moved. * * @param string $location URL to forward to browser to * @return nothing|false */ function forward($location = "") { global $CONFIG; if (!headers_sent()) { $current_page = current_page_url(); // What is this meant to do? //if (strpos($current_page, $CONFIG->wwwroot . "action") ===false) $_SESSION['msg'] = array_merge($_SESSION['msg'], system_messages()); if (substr_count($location, 'http://') == 0 && substr_count($location, 'https://') == 0) { $location = $CONFIG->url . $location; } header("Location: {$location}"); exit; } return false; }
/** * Adds messages to the session so they'll be carried over, and forwards the browser. * Returns false if headers have already been sent and the browser cannot be moved. * * @param string $location URL to forward to browser to * @return nothing|false */ function forward($location = "") { global $CONFIG; if (!headers_sent()) { $current_page = current_page_url(); if (strpos($current_page, $CONFIG->wwwroot . "action") === false) { $_SESSION['messages'] = system_messages(); } if (substr_count($location, 'http://') == 0 && substr_count($location, 'https://') == 0) { $location = $CONFIG->url . $location; } header("Location: {$location}"); exit; } return false; }
/** * Add a menu item to the filter menu * * @param string $hook the name of the hook * @param string $type the type of the hook * @param \ElggMenuItem[] $return_value current return value * @param mixed $params supplied params * * @return void|\ElggMenuItem[] */ public static function registerActivityTab($hook, $type, $return_value, $params) { if (!elgg_is_logged_in() || !elgg_in_context('activity')) { return; } $tags = tag_tools_get_user_following_tags(); if (empty($tags)) { return; } $selected = false; if (strpos(current_page_url(), elgg_normalize_url('activity/tags')) === 0) { $selected = true; } $return_value[] = \ElggMenuItem::factory(['name' => 'tags', 'text' => elgg_echo('tags'), 'href' => 'activity/tags', 'selected' => $selected, 'priority' => 9999]); return $return_value; }
/** * Messages page handler * * @param array $page Array of URL components for routing * @return bool */ function messages_page_handler($page) { $current_user = elgg_get_logged_in_user_entity(); if (!$current_user) { register_error(elgg_echo('noaccess')); elgg_get_session()->set('last_forward_from', current_page_url()); forward(''); } elgg_load_library('elgg:messages'); elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username); if (!isset($page[0])) { $page[0] = 'inbox'; } // Support the old inbox url /messages/<username>, but only if it matches the logged in user. // Otherwise having a username like "read" on the system could confuse this function. if ($current_user->username === $page[0]) { $page[1] = $page[0]; $page[0] = 'inbox'; } if (!isset($page[1])) { $page[1] = $current_user->username; } $base_dir = elgg_get_plugins_path() . 'messages/pages/messages'; switch ($page[0]) { case 'inbox': set_input('username', $page[1]); include "{$base_dir}/inbox.php"; break; case 'sent': set_input('username', $page[1]); include "{$base_dir}/sent.php"; break; case 'read': set_input('guid', $page[1]); include "{$base_dir}/read.php"; break; case 'compose': case 'add': include "{$base_dir}/send.php"; break; default: return false; } return true; }
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); } }
/** * Forward to $location. * * Sends a 'Location: $location' header and exists. If headers have * already been sent, throws an exception. * * @param string $location URL to forward to browser to. This can be a path * relative to the network's URL. * @param string $reason Short explanation for why we're forwarding. Set to * '404' to forward to error page. Default message is * 'system'. * * @return void * @throws SecurityException */ function forward($location = "", $reason = 'system') { if (!headers_sent($file, $line)) { if ($location === REFERER) { $location = _elgg_services()->request->headers->get('Referer'); } $location = elgg_normalize_url($location); // return new forward location or false to stop the forward or empty string to exit $current_page = current_page_url(); $params = array('current_url' => $current_page, 'forward_url' => $location); $location = elgg_trigger_plugin_hook('forward', $reason, $params, $location); if ($location) { header("Location: {$location}"); } exit; } else { throw new \SecurityException("Redirect could not be issued due to headers already being sent. Halting execution for security. " . "Output started in file {$file} at line {$line}. Search http://learn.elgg.org/ for more information."); } }