コード例 #1
0
ファイル: hooks.php プロジェクト: n8b/VMN
/**
 * hook called on view, all
 * check if there is an internal link using an old handler
 * convert it to a new handler
 * 
 * @param type $hook
 * @param type $type
 * @param type $returnvalue
 * @param type $params
 * @return array
 */
function linkfix($hook, $type, $returnvalue, $params)
{
    if (elgg_get_viewtype() == 'failsafe') {
        return $returnvalue;
    }
    return handler_replace($returnvalue);
}
コード例 #2
0
ファイル: start.php プロジェクト: elgg/elgg
/**
 * Redirect the requestor to the new URL
 * Checks the plugin setting to determine the course of action:
 * a) Displays an error page with the new URL
 * b) Forwards to the new URL and displays an error message
 * c) Silently forwards to the new URL
 *
 * @param string $url Relative or absolute URL
 * @return mixed
 */
function legacy_urls_redirect($url)
{
    $method = elgg_get_plugin_setting('redirect_method', 'legacy_urls');
    // we only show landing page or queue warning if html generating page
    $viewtype = elgg_get_viewtype();
    if ($viewtype != 'default' && !elgg_does_viewtype_fallback($viewtype)) {
        $method = 'immediate';
    }
    switch ($method) {
        case 'landing':
            $content = elgg_view('legacy_urls/message', array('url' => $url));
            $body = elgg_view_layout('error', array('content' => $content));
            echo elgg_view_page('', $body, 'error');
            return true;
            break;
        case 'immediate_error':
            // drop through after setting error message
            register_error(elgg_echo('changebookmark'));
        case 'immediate':
        default:
            $url = elgg_normalize_url($url);
            header("HTTP/1.1 301 Moved Permanently");
            header("Location: {$url}");
            exit;
            break;
    }
}
コード例 #3
0
ファイル: start.php プロジェクト: epsylon/Hydra-dev
/**
 * Markup function
 *
 * Detect linkup patterns and make links where needed.
 *
 * Matches a marker character followed by printable characters, and
 * prefixed to avoid matching CSS DOM IDs. First match is the prefix,
 * second the marker, and third is the subject.
 */
function linkup_event_handler($hook, $type, $returnvalue, $params)
{
    if (elgg_get_viewtype() != 'default') {
        // only mess with html views
        return $returnvalue;
    }
    $html = mb_convert_encoding($returnvalue['content'], 'HTML-ENTITIES', 'UTF-8');
    if (empty($html)) {
        return $returnvalue;
    }
    libxml_use_internal_errors(TRUE);
    try {
        $dom = new DOMDocument();
        $dom->loadHTML($html);
        foreach ($dom->childNodes as $node) {
            linkup_dom_recurse($node, 'linkup_dom_replace');
        }
        // Remove tags added by DOMDocument
        $matches = array('/^\\<\\!DOCTYPE.*?<html[^>]*><body[^>]*>/isu', '|</body></html>$|isu');
        $content = preg_replace($matches, '', $dom->saveHTML());
        // convert back to original encoding
        $returnvalue['content'] = mb_convert_encoding($content, 'UTF-8', 'HTML-ENTITIES');
    } catch (Exception $e) {
        error_log("===== linkup error {$e->class} {$e->message}");
    }
    return $returnvalue;
}
コード例 #4
0
 public function testElggGetViewtype()
 {
     $this->assertEquals('default', elgg_get_viewtype());
     set_input('view', 'foo');
     $this->assertEquals('foo', elgg_get_viewtype());
     set_input('view', 'a;b');
     $this->assertEquals('default', elgg_get_viewtype());
 }
コード例 #5
0
 public function testSettingConfigDoesNotChangeViewtype()
 {
     global $CONFIG;
     $this->assertEquals('default', elgg_get_viewtype());
     $CONFIG->view = 'foo';
     $this->assertEquals('default', elgg_get_viewtype());
     unset($CONFIG->view);
 }
コード例 #6
0
ファイル: start.php プロジェクト: amcfarlane1251/ongarde
/**
 * Elgg Mobile
 * A Mobile Client For Elgg
 *
 * @package Elgg
 * @subpackage Core
 * @author kramnorth (Mark Harding)
 * @link http://kramnorth.com
 *
 */
function mobile_init()
{
    //elgg_extend_view('page/elements/head','mobile/metatags');
    mobile_detect();
    elgg_extend_view('css/elgg', 'mobile/css');
    //set our default index page
    if (elgg_get_viewtype() == "mobile") {
        elgg_register_plugin_hook_handler('index', 'system', 'main_handler');
    }
}
コード例 #7
0
ファイル: SimpleCache.php プロジェクト: ibou77/elgg
 /**
  * Get the base url for simple cache requests
  * 
  * @return string The simplecache root url for the current viewtype.
  * @access private
  */
 function getRoot()
 {
     $viewtype = elgg_get_viewtype();
     if (elgg_is_simplecache_enabled()) {
         // stored in datalist as 'simplecache_lastupdate'
         $lastcache = (int) _elgg_services()->config->get('lastcache');
     } else {
         $lastcache = 0;
     }
     return elgg_normalize_url("/cache/{$lastcache}/{$viewtype}/");
 }
コード例 #8
0
ファイル: start.php プロジェクト: pingwangcs/51zhaohu
/**
 * Add report user link to hover menu
 */
function reportedcontent_user_hover_menu($hook, $type, $return, $params)
{
    $user = $params['entity'];
    $profile_url = urlencode($user->getURL());
    $name = urlencode($user->name);
    $url = "reportedcontent/add?address={$profile_url}&title={$name}";
    if (elgg_is_logged_in() && elgg_get_logged_in_user_guid() != $user->guid && elgg_get_viewtype() == 'default') {
        $item = new ElggMenuItem('reportuser', elgg_echo('reportedcontent:user'), $url);
        $item->setSection('action');
        $return[] = $item;
    }
    return $return;
}
コード例 #9
0
ファイル: hooks.php プロジェクト: mrclay/elgg_recaptcha
function view_hook($h, $t, $r, $p)
{
    if (elgg_get_viewtype() != 'default') {
        return $r;
    }
    if (strpos($t, 'forms/') !== 0) {
        return $r;
    }
    $actions = get_recaptcha_actions();
    $formname = substr($t, 6);
    if (in_array($formname, $actions)) {
        $r .= elgg_view('input/recaptcha', array('form' => '.elgg-form-' . str_replace('_', '-', str_replace('/', '-', $formname))));
    }
    return $r;
}
コード例 #10
0
/**
 * Post-process a view to add a wrapper div
 */
function elgg_dev_tools_outline_views($hook, $entity_type, $returnvalue, $params)
{
    global $CONFIG;
    if (elgg_get_viewtype() != "default") {
        return;
    }
    $excluded_bases = array('css', 'js', 'input', 'output', 'embed', 'pageshells', 'metatags', 'icon');
    $excluded_views = array('page_elements/header', 'page_elements/header_contents', 'page_elements/footer', 'riverdashboard/js');
    $view = $params['view'];
    $view_hierarchy = explode('/', $view);
    if (in_array($view_hierarchy[0], $excluded_bases)) {
        return;
    }
    if (in_array($view, $excluded_views)) {
        return;
    }
    $return_data = "<div id=\"view-{$view}\">{$returnvalue}</div>";
    return $return_data;
}
コード例 #11
0
ファイル: start.php プロジェクト: tjcaverly/Elgg
/**
 * Post-process a view to add wrapper comments to it
 * 
 * 1. Only process views served with the 'default' viewtype.
 * 2. Does not wrap views that begin with js/ or css/ as they are not HTML.
 * 3. Does not wrap views that are images (start with icon/). Is this still true?
 * 4. Does not wrap input and output views (why?).
 * 5. Does not wrap html head or the primary page shells
 * 
 * @warning this will break views in the default viewtype that return non-HTML data
 * that do not match the above restrictions.
 */
function developers_wrap_views($hook, $type, $result, $params)
{
    if (elgg_get_viewtype() != "default") {
        return;
    }
    $excluded_bases = array('css', 'js', 'input', 'output', 'embed', 'icon');
    $excluded_views = array('page/default', 'page/admin', 'page/elements/head');
    $view = $params['view'];
    $view_hierarchy = explode('/', $view);
    if (in_array($view_hierarchy[0], $excluded_bases)) {
        return;
    }
    if (in_array($view, $excluded_views)) {
        return;
    }
    if ($result) {
        $result = "<!-- developers:begin {$view} -->{$result}<!-- developers:end {$view} -->";
    }
    return $result;
}
コード例 #12
0
ファイル: start.php プロジェクト: pingwangcs/51zhaohu
function zhaohu_theme_init()
{
    // check mobile view
    check_mobile_mode();
    // include css files of this mod
    elgg_extend_view('css/elgg', 'zhaohu_theme/css');
    elgg_register_css('elgg.mobile', '/css/mobile.css');
    elgg_register_css('elgg.mobilize', '/css/mobilize.css');
    elgg_register_action("zhaohu/switch_view", dirname(__FILE__) . "/actions/zhaohu/switch_view.php", "public");
    if (elgg_get_viewtype() == "mobile") {
        zhaohu_mobile_theme_init();
    } else {
        // TODO: this needs to be changed to zhaohu_desktop_theme_init() after development is done.
        // 		zhaohu_mobile_theme_init();
        // 		elgg_set_viewtype('mobile');
        //      Real code
        zhaohu_desktop_theme_init();
        elgg_set_viewtype('default');
    }
}
コード例 #13
0
ファイル: start.php プロジェクト: pingwangcs/51zhaohu
/**
 * The Wire initialization
 */
function wire_init()
{
    // register the wire's JavaScript
    $wire_js = elgg_get_simplecache_url('js', 'wire');
    elgg_register_simplecache_view('js/wire');
    elgg_register_js('elgg.wire', $wire_js);
    elgg_register_ajax_view('wire/previous');
    elgg_register_ajax_view('wire/replyinline');
    // add a site navigation item
    $item = new ElggMenuItem('wire', elgg_echo('wire'), 'wire/all');
    elgg_register_menu_item('site', $item);
    // owner block menu
    if (elgg_get_viewtype() == 'default') {
        elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'wire_owner_block_menu');
    }
    // remove edit and access and add thread, reply, view previous
    elgg_register_plugin_hook_handler('register', 'menu:entity', 'wire_setup_entity_menu_items');
    // Extend system CSS with our own styles, which are defined in the wire/css view
    elgg_extend_view('css/elgg', 'wire/css');
    //extend views
    elgg_extend_view('activity/wire', 'wire/activity_view');
    //elgg_extend_view('profile/status', 'wire/profile_status');
    elgg_extend_view('js/initialise_elgg', 'wire/js/textcounter');
    // Register a page handler, so we can have nice URLs
    elgg_register_page_handler('wire', 'wire_page_handler');
    // Register a URL handler for wire posts
    elgg_register_entity_url_handler('object', 'wire', 'wire_url');
    elgg_register_widget_type('wire', elgg_echo('wire'), elgg_echo("wire:widget:desc"));
    // Register for search
    elgg_register_entity_type('object', 'wire');
    // Register granular notification for this type
    register_notification_object('object', 'wire', elgg_echo('wire:notify:subject'));
    // Listen to notification events and supply a more useful message
    elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'wire_notify_message');
    // Register actions
    $action_base = elgg_get_plugins_path() . 'wire/actions';
    elgg_register_action("wire/add", "{$action_base}/add.php");
    elgg_register_action("wire/delete", "{$action_base}/delete.php");
    elgg_register_plugin_hook_handler('unit_test', 'system', 'wire_test');
}
コード例 #14
0
ファイル: ViewsService.php プロジェクト: elgg/elgg
 /**
  * @access private
  */
 public function isCacheableView($view)
 {
     $view = $this->canonicalizeViewName($view);
     if (isset($this->simplecache_views[$view])) {
         return true;
     }
     // build list of viewtypes to check
     $current_viewtype = elgg_get_viewtype();
     $viewtypes = array($current_viewtype);
     if ($this->doesViewtypeFallback($current_viewtype) && $current_viewtype != 'default') {
         $viewtypes[] = 'default';
     }
     // If a static view file is found in any viewtype, it's considered cacheable
     foreach ($viewtypes as $viewtype) {
         $file = $this->findViewFile($view, $viewtype);
         if ($file && pathinfo($file, PATHINFO_EXTENSION) !== 'php') {
             $this->simplecache_views[$view] = true;
             return true;
         }
     }
     // Assume not-cacheable by default
     return false;
 }
コード例 #15
0
ファイル: list.php プロジェクト: amcfarlane1251/ongarde
 if (!$draw_page) {
     echo elgg_view("bookmark_tools/list/bookmarks", array("bmfolder" => $folder, "bookmarks" => $bookmarks, 'sort_by' => $sort_by, 'direction' => $direction));
 } else {
     // build breadcrumb
     elgg_push_breadcrumb(elgg_echo('bookmarks'), "bookmarks/all");
     elgg_push_breadcrumb($page_owner->name);
     // register title button to add a new bookmark
     elgg_register_title_button();
     // get data for tree
     $folders = bookmark_tools_get_folders($page_owner_guid);
     // build page elements
     $title_text = elgg_echo("bookmarks:owner", array($page_owner->name));
     $body = elgg_view("bookmark_tools/list/bookmarks", array("bmfolder" => $folder, "bookmarks" => $bookmarks, 'sort_by' => $sort_by, 'direction' => $direction));
     //$body = "<div id='bookmark_tools_list_bookmarks_container'>" . elgg_view("graphics/ajax_loader", array("hidden" => false)) . "</div>";
     //$body = "<div id='bookmark_tools_list_bookmarks_container'>" . elgg_view("bookmark_tools/list/bookmarks", array("bmfolder" => $folder, "bookmarks" => $bookmarks, 'sort_by' => $sort_by, 'direction' => $direction)) . "</div>";
     if (elgg_get_viewtype() == 'default') {
         $body = "<div id='bookmark_tools_list_bookmarks_container'>" . $body . "</div>";
     }
     // make sidebar
     $sidebar = elgg_view("bookmark_tools/list/tree", array("bmfolder" => $folder, "bmfolders" => $folders));
     $sidebar .= elgg_view("bookmark_tools/sidebar/sort_options");
     $sidebar .= elgg_view("bookmark_tools/sidebar/info");
     $sidebar .= elgg_view('page/elements/tagcloud_block', array('subtypes' => 'bookmarks', 'owner_guid' => elgg_get_page_owner_guid()));
     // build page params
     $params = array('title' => $title_text, 'content' => $body, 'sidebar' => $sidebar);
     if (elgg_instanceof($page_owner, "user")) {
         if ($page_owner->guid == elgg_get_logged_in_user_guid()) {
             $params["filter_context"] = "mine";
         } else {
             $params["filter_context"] = $page_owner->username;
         }
コード例 #16
0
ファイル: cache.php プロジェクト: redvabel/Vabelgg
/**
 * Regenerates the simple cache.
 *
 * @warning This does not invalidate the cache, but actively resets it.
 *
 * @param string $viewtype Optional viewtype to regenerate
 *
 * @return void
 * @see elgg_register_simplecache_view()
 * @since 1.8.0
 */
function elgg_regenerate_simplecache($viewtype = NULL)
{
    global $CONFIG;
    if (!isset($CONFIG->views->simplecache) || !is_array($CONFIG->views->simplecache)) {
        return;
    }
    $lastcached = time();
    // @todo elgg_view() checks if the page set is done (isset($CONFIG->pagesetupdone)) and
    // triggers an event if it's not. Calling elgg_view() here breaks submenus
    // (at least) because the page setup hook is called before any
    // contexts can be correctly set (since this is called before page_handler()).
    // To avoid this, lie about $CONFIG->pagehandlerdone to force
    // the trigger correctly when the first view is actually being output.
    $CONFIG->pagesetupdone = TRUE;
    if (!file_exists($CONFIG->dataroot . 'views_simplecache')) {
        mkdir($CONFIG->dataroot . 'views_simplecache');
    }
    if (isset($viewtype)) {
        $viewtypes = array($viewtype);
    } else {
        $viewtypes = $CONFIG->view_types;
    }
    $original_viewtype = elgg_get_viewtype();
    // disable error reporting so we don't cache problems
    $old_debug = elgg_get_config('debug');
    elgg_set_config('debug', null);
    foreach ($viewtypes as $viewtype) {
        elgg_set_viewtype($viewtype);
        foreach ($CONFIG->views->simplecache as $view) {
            $viewcontents = elgg_view($view);
            $viewname = md5(elgg_get_viewtype() . $view);
            if ($handle = fopen($CONFIG->dataroot . 'views_simplecache/' . $viewname, 'w')) {
                fwrite($handle, $viewcontents);
                fclose($handle);
            }
        }
        datalist_set("simplecache_lastupdate_{$viewtype}", $lastcached);
        datalist_set("simplecache_lastcached_{$viewtype}", $lastcached);
    }
    elgg_set_config('debug', $old_debug);
    elgg_set_viewtype($original_viewtype);
    // needs to be set for links in html head
    $CONFIG->lastcache = $lastcached;
    unset($CONFIG->pagesetupdone);
}
コード例 #17
0
ファイル: deprecated-1.9.php プロジェクト: gzachos/elgg_ellak
/**
 * Returns all views below a partial view.
 *
 * Settings $view_root = 'profile' will show all available views under
 * the "profile" namespace.
 *
 * @param string $view_root The root view
 * @param string $viewtype  Optionally specify a view type
 *                          other than the current one.
 *
 * @return array A list of view names underneath that root view
 * @todo This is used once in the deprecated get_activity_stream_data() function.
 * @access private
 * @deprecated 1.9
 */
function elgg_view_tree($view_root, $viewtype = "")
{
    global $CONFIG;
    static $treecache = array();
    // Get viewtype
    if (!$viewtype) {
        $viewtype = elgg_get_viewtype();
    }
    // A little light internal caching
    if (!empty($treecache[$view_root])) {
        return $treecache[$view_root];
    }
    // Examine $CONFIG->views->locations
    if (isset($CONFIG->views->locations[$viewtype])) {
        foreach ($CONFIG->views->locations[$viewtype] as $view => $path) {
            $pos = strpos($view, $view_root);
            if ($pos === 0) {
                $treecache[$view_root][] = $view;
            }
        }
    }
    // Now examine core
    $location = $CONFIG->viewpath;
    $viewtype = elgg_get_viewtype();
    $root = $location . $viewtype . '/' . $view_root;
    if (file_exists($root) && is_dir($root)) {
        $val = elgg_get_views($root, $view_root);
        if (!is_array($treecache[$view_root])) {
            $treecache[$view_root] = array();
        }
        $treecache[$view_root] = array_merge($treecache[$view_root], $val);
    }
    return $treecache[$view_root];
}
コード例 #18
0
ファイル: extender.php プロジェクト: elainenaomi/labxp2014
/**
 * Get the URL of a given elgg extender.
 * Used by get_annotation_url and get_metadata_url.
 *
 * @param ElggExtender $extender An extender object
 *
 * @return string
 */
function get_extender_url(ElggExtender $extender)
{
    global $CONFIG;
    $view = elgg_get_viewtype();
    $guid = $extender->entity_guid;
    $type = $extender->type;
    $url = "";
    $function = "";
    if (isset($CONFIG->extender_url_handler[$type][$extender->name])) {
        $function = $CONFIG->extender_url_handler[$type][$extender->name];
    }
    if (isset($CONFIG->extender_url_handler[$type]['all'])) {
        $function = $CONFIG->extender_url_handler[$type]['all'];
    }
    if (isset($CONFIG->extender_url_handler['all']['all'])) {
        $function = $CONFIG->extender_url_handler['all']['all'];
    }
    if (is_callable($function)) {
        $url = call_user_func($function, $extender);
    }
    if ($url == "") {
        $nameid = $extender->id;
        if ($type == 'volatile') {
            $nameid = $extender->name;
        }
        $url = "export/{$view}/{$guid}/{$type}/{$nameid}/";
    }
    return elgg_normalize_url($url);
}
コード例 #19
0
ファイル: start.php プロジェクト: pleio/subsite_manager
        $msg = "Could not load {$file}";
        throw new InstallationException($msg);
    }
}
// include subsite manager
require_once dirname(dirname(__FILE__)) . "/mod/subsite_manager/system.php";
// Connect to database, load language files, load configuration, init session
// Plugins can't use this event because they haven't been loaded yet.
elgg_trigger_event('boot', 'system');
// needs to be set for links in html head
$viewtype = get_input('view', 'default');
$site_guid = elgg_get_site_entity()->getGUID();
// Subsite Manager - simple cache prefix
$lastcached = datalist_get("sc_lastcached_" . $viewtype . "_" . $site_guid);
$CONFIG->lastcache = $lastcached;
// Load the plugins that are active
elgg_load_plugins();
// @todo move loading plugins into a single boot function that replaces 'boot', 'system' event
// and then move this code in there.
// This validates the view type - first opportunity to do it is after plugins load.
$view_type = elgg_get_viewtype();
if (!elgg_is_valid_view_type($view_type)) {
    elgg_set_viewtype('default');
}
// @todo deprecate as plugins can use 'init', 'system' event
elgg_trigger_event('plugins_boot', 'system');
// Complete the boot process for both engine and plugins
elgg_trigger_event('init', 'system');
$CONFIG->boot_complete = true;
// System loaded and ready
elgg_trigger_event('ready', 'system');
コード例 #20
0
 /**
  * @access private
  */
 public function isCacheableView($view)
 {
     global $CONFIG;
     if (!isset($CONFIG->views)) {
         $CONFIG->views = new stdClass();
     }
     if (!isset($CONFIG->views->simplecache)) {
         $CONFIG->views->simplecache = array();
     }
     if (isset($CONFIG->views->simplecache[$view])) {
         return true;
     } else {
         $currentViewtype = elgg_get_viewtype();
         $viewtypes = array($currentViewtype);
         if ($this->doesViewtypeFallback($currentViewtype) && $currentViewtype != 'default') {
             $viewtypes[] = 'defaut';
         }
         // If a static view file is found in any viewtype, it's considered cacheable
         foreach ($viewtypes as $viewtype) {
             $view_file = $this->getViewLocation($view, $viewtype) . "{$viewtype}/{$view}";
             if ($this->fileExists($view_file)) {
                 return true;
             }
         }
         // Assume not-cacheable by default
         return false;
     }
 }
コード例 #21
0
ファイル: news.php プロジェクト: hypeJunction/news
/**
 * Forward to the new style of URLs
 *
 * Pre-1.7.5
 * Group news page: /news/group:<container_guid>/
 * Group news view:  /news/group:<container_guid>/read/<guid>/<title>
 * 1.7.5-1.8
 * Group news page: /news/owner/group:<container_guid>/
 * Group news view:  /news/read/<guid>
 *
 *
 * @param string $page
 */
function news_url_forwarder($page)
{
    $viewtype = elgg_get_viewtype();
    $qs = $viewtype === 'default' ? "" : "?view={$viewtype}";
    $url = "news/all";
    // easier to work with & no notices
    $page = array_pad($page, 4, "");
    // group usernames
    if (preg_match('~/group\\:([0-9]+)/~', "/{$page[0]}/{$page[1]}/", $matches)) {
        $guid = $matches[1];
        $entity = get_entity($guid);
        if (elgg_instanceof($entity, 'group')) {
            if (!empty($page[2])) {
                $url = "news/view/{$page['2']}/";
            } else {
                $url = "news/group/{$guid}/all";
            }
            register_error(elgg_echo("changebookmark"));
            forward($url . $qs);
        }
    }
    if (empty($page[0])) {
        return;
    }
    // user usernames
    $user = get_user_by_username($page[0]);
    if (!$user) {
        return;
    }
    if (empty($page[1])) {
        $page[1] = 'owner';
    }
    switch ($page[1]) {
        case "read":
            $url = "news/view/{$page[2]}/{$page[3]}";
            break;
        case "archive":
            $url = "news/archive/{$page[0]}/{$page[2]}/{$page[3]}";
            break;
        case "new":
            $url = "news/add/{$user->guid}";
            break;
        case "owner":
            $url = "news/owner/{$page[0]}";
            break;
    }
    register_error(elgg_echo("changebookmark"));
    forward($url . $qs);
}
コード例 #22
0
ファイル: Application.php プロジェクト: 007arunwilson/Elgg
 /**
  * Bootstrap the Elgg engine, loads plugins, and calls initial system events
  *
  * This method loads the full Elgg engine, checks the installation
  * state, and triggers a series of events to finish booting Elgg:
  * 	- {@elgg_event boot system}
  * 	- {@elgg_event init system}
  * 	- {@elgg_event ready system}
  *
  * If Elgg is not fully installed, the browser will be redirected to an installation page.
  *
  * @return void
  */
 public function bootCore()
 {
     $config = $this->services->config;
     if ($config->getVolatile('boot_complete')) {
         return;
     }
     $this->loadSettings();
     $config->set('boot_complete', false);
     // This will be overridden by the DB value but may be needed before the upgrade script can be run.
     $config->set('default_limit', 10);
     // in case not loaded already
     $this->loadCore();
     $events = $this->services->events;
     // Connect to database, load language files, load configuration, init session
     // Plugins can't use this event because they haven't been loaded yet.
     $events->trigger('boot', 'system');
     // Load the plugins that are active
     $this->services->plugins->load();
     if (Directory\Local::root()->getPath() != self::elggDir()->getPath()) {
         // Elgg is installed as a composer dep, so try to treat the root directory
         // as a custom plugin that is always loaded last and can't be disabled...
         if (!elgg_get_config('system_cache_loaded')) {
             $viewsFile = Directory\Local::root()->getFile('views.php');
             if ($viewsFile->exists()) {
                 $viewsSpec = $viewsFile->includeFile();
                 if (is_array($viewsSpec)) {
                     _elgg_services()->views->mergeViewsSpec($viewsSpec);
                 }
             }
             _elgg_services()->views->registerPluginViews(Directory\Local::root()->getPath());
         }
         if (!elgg_get_config('i18n_loaded_from_cache')) {
             _elgg_services()->translator->registerPluginTranslations(Directory\Local::root()->getPath());
         }
         // This is root directory start.php, not elgg/engine/start.php
         @(include_once Directory\Local::root()->getPath("start.php"));
     }
     // @todo move loading plugins into a single boot function that replaces 'boot', 'system' event
     // and then move this code in there.
     // This validates the view type - first opportunity to do it is after plugins load.
     $viewtype = elgg_get_viewtype();
     if (!elgg_is_registered_viewtype($viewtype)) {
         elgg_set_viewtype('default');
     }
     // @todo deprecate as plugins can use 'init', 'system' event
     $events->trigger('plugins_boot', 'system');
     // Complete the boot process for both engine and plugins
     $events->trigger('init', 'system');
     $config->set('boot_complete', true);
     // System loaded and ready
     $events->trigger('ready', 'system');
 }
コード例 #23
0
ファイル: start.php プロジェクト: amcfarlane1251/ongarde
/**
 * Plugin hook handler intercept rss/page/default
 *
 * @param string $hook
 * @param string $type
 * @param bool   $value
 * @param array  $params
 * 
 * @return array
 */
function podcasts_rss_page_view_handelr($hook, $type, $value, $params)
{
    if (elgg_get_viewtype() == 'rss' && elgg_in_context('podcasts')) {
        $value = elgg_view('page/podcast', $params['vars']);
    }
    return $value;
}
コード例 #24
0
ファイル: footer.php プロジェクト: pingwangcs/51zhaohu
 * The standard footer that displays across the site
 *
 * @package zhaohu
 * @subpackage Core
 *
 */
//for 51zhaohu QQ login
echo '<html><head><meta property="qc:admins" content="1763573120017056375" /></head></html>';
//for 91zhaohu QQ login
echo '<html><head><meta property="qc:admins" content="1763573520017056375" /></head></html>';
echo '<div id="fb-root"></div>';
$footer_links = array(array('title' => elgg_echo('zhaohu:about_us'), 'href' => 'zhaohu_about/about_us'), array('title' => elgg_echo('zhaohu:service_terms'), 'href' => 'zhaohu_about/service_terms'), array('title' => elgg_echo('zhaohu:privacy_terms'), 'href' => 'zhaohu_about/privacy_terms'), array('title' => elgg_echo('zhaohu:contact_us'), 'href' => 'zhaohu_about/contact_us'), array('title' => elgg_echo('zhaohu:feedbacks'), 'href' => 'zhaohu_about/feedbacks'), array('title' => elgg_echo('zhaohu:help_center'), 'href' => 'zhaohu_about/help_center'), array('title' => elgg_echo('zhaohu:friend_links'), 'href' => 'zhaohu_about/friend_links'));
if (elgg_is_logged_in()) {
    $href = "javascript:elgg.forward('reportedcontent/add'";
    $href .= "+'?address='+encodeURIComponent(location.href)";
    $href .= "+'&title='+encodeURIComponent(document.title));";
    $report_this_link_array = array('title' => elgg_echo('reportedcontent:this:tooltip'), 'href' => $href);
    array_push($footer_links, $report_this_link_array);
}
echo "<div class=\"zhaohu-footer\">";
$switch_view_txt = elgg_get_viewtype() == 'default' ? 'zhaohu:switch2mobile' : 'zhaohu:switch2desktop';
echo elgg_view("output/url", array("is_action" => true, "class" => "switch-view-mobile", "href" => "action/zhaohu/switch_view", "text" => elgg_echo($switch_view_txt)));
echo '  |  ';
for ($i = 0, $size = count($footer_links); $i < $size; ++$i) {
    echo elgg_view('zhaohu_views/zhaohu_link', array('href' => $footer_links[$i]['href'], 'text' => $footer_links[$i]['title']));
    echo '  |  ';
}
echo "</div>";
?>

コード例 #25
0
<?php

/**
 * Initialize Elgg's js lib with the uncacheable data
 */
$elgg = array('config' => array('lastcache' => (int) elgg_get_config('lastcache'), 'viewtype' => elgg_get_viewtype(), 'simplecache_enabled' => (int) elgg_is_simplecache_enabled()), 'security' => array('token' => array('__elgg_ts' => $ts = time(), '__elgg_token' => generate_action_token($ts))), 'session' => array('user' => null));
$page_owner = elgg_get_page_owner_entity();
if ($page_owner instanceof ElggEntity) {
    $elgg['page_owner'] = $page_owner->toObject();
}
$user = elgg_get_logged_in_user_entity();
if ($user instanceof ElggUser) {
    $user_object = $user->toObject();
    $user_object->admin = $user->isAdmin();
    $elgg['session']['user'] = $user_object;
}
?>

var elgg = <?php 
echo json_encode($elgg);
?>
;
<?php 
// note: elgg.session.user needs to be wrapped with elgg.ElggUser, but this class isn't
// defined yet. So this is delayed until after the classes are defined, in js/lib/session.js
コード例 #26
0
ファイル: views.php プロジェクト: thehereward/Elgg
/**
 * Render a resource view. Use this in your page handler to hand off page rendering to
 * a view in "resources/". If not found in the current viewtype, we try the "default" viewtype.
 *
 * @param string $name The view name without the leading "resources/"
 * @param array  $vars Arguments passed to the view
 *
 * @return string
 * @throws SecurityException
 */
function elgg_view_resource($name, array $vars = [])
{
    $view = "resources/{$name}";
    if (elgg_view_exists($view)) {
        return _elgg_services()->views->renderView($view, $vars);
    }
    if (elgg_get_viewtype() !== 'default' && elgg_view_exists($view, 'default')) {
        return _elgg_services()->views->renderView($view, $vars, false, 'default');
    }
    _elgg_services()->logger->error("The view {$view} is missing.");
    if (elgg_get_viewtype() === 'default') {
        // only works for default viewtype
        forward('', '404');
    } else {
        register_error(elgg_echo('error:404:content'));
        forward('');
    }
}
コード例 #27
0
/**
 * Get the url for a given relationship.
 *
 * @param int $id Relationship ID
 *
 * @return string
 */
function get_relationship_url($id)
{
    global $CONFIG;
    $id = (int) $id;
    if ($relationship = get_relationship($id)) {
        $view = elgg_get_viewtype();
        $guid = $relationship->guid_one;
        $type = $relationship->relationship;
        $url = "";
        $function = "";
        if (isset($CONFIG->relationship_url_handler[$type])) {
            $function = $CONFIG->relationship_url_handler[$type];
        }
        if (isset($CONFIG->relationship_url_handler['all'])) {
            $function = $CONFIG->relationship_url_handler['all'];
        }
        if (is_callable($function)) {
            $url = call_user_func($function, $relationship);
        }
        if ($url == "") {
            $nameid = $relationship->id;
            $url = elgg_get_site_url() . "export/{$view}/{$guid}/relationship/{$nameid}/";
        }
        return $url;
    }
    return false;
}
コード例 #28
0
ファイル: custom_index.php プロジェクト: duanhv/mdg-social
<?php

/**
 * Elgg custom index layout
 * 
 * You can edit the layout of this page with your own layout and style. 
 * Whatever you put in this view will appear on the front page of your site.
 * 
 */
$mod_params = array('class' => 'elgg-module-highlight');
/* if (elgg_is_logged_in()) {
	forward('dashboard');
} */
if (elgg_get_viewtype() == "mobile") {
    ?>

	<div class="custom-index elgg-main elgg-grid clearfix">
		<div class="elgg-col elgg-col-1of1">
			<div class="elgg-inner pvm prl">
				<?php 
    /**SCORE**/
    $golf_scores = elgg_view('golfscore/sidebar');
    echo $golf_scores;
    ?>
			</div>
		</div>
	</div>
<?php 
} else {
    ?>
コード例 #29
0
/**
 * Return the icon URL for an entity.
 *
 * @tip Can be overridden by registering a plugin hook for entity:icon:url, $entity_type.
 *
 * @internal This is passed an entity rather than a guid to handle non-created entities.
 *
 * @param ElggEntity $entity The entity
 * @param string     $size   Icon size
 *
 * @return string URL to the entity icon.
 * @deprecated 1.8 Use $entity->getIconURL()
 */
function get_entity_icon_url(ElggEntity $entity, $size = 'medium')
{
    elgg_deprecated_notice("get_entity_icon_url() deprecated for getIconURL()", 1.8);
    global $CONFIG;
    $size = sanitise_string($size);
    switch (strtolower($size)) {
        case 'master':
            $size = 'master';
            break;
        case 'large':
            $size = 'large';
            break;
        case 'topbar':
            $size = 'topbar';
            break;
        case 'tiny':
            $size = 'tiny';
            break;
        case 'small':
            $size = 'small';
            break;
        case 'medium':
        default:
            $size = 'medium';
    }
    $url = false;
    $viewtype = elgg_get_viewtype();
    // Step one, see if anyone knows how to render this in the current view
    $params = array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size);
    $url = elgg_trigger_plugin_hook('entity:icon:url', $entity->getType(), $params, $url);
    // Fail, so use default
    if (!$url) {
        $type = $entity->getType();
        $subtype = $entity->getSubtype();
        if (!empty($subtype)) {
            $overrideurl = elgg_view("icon/{$type}/{$subtype}/{$size}", array('entity' => $entity));
            if (!empty($overrideurl)) {
                return $overrideurl;
            }
        }
        $overrideurl = elgg_view("icon/{$type}/default/{$size}", array('entity' => $entity));
        if (!empty($overrideurl)) {
            return $overrideurl;
        }
        $url = "_graphics/icons/default/{$size}.png";
    }
    return elgg_normalize_url($url);
}
コード例 #30
0
ファイル: elgglib.php プロジェクト: elgg/elgg
/**
 * Serve individual views for Ajax.
 *
 * /ajax/view/<view_name>?<key/value params>
 * /ajax/form/<action_name>?<key/value params>
 *
 * @param string[] $segments URL segments (not including "ajax")
 * @return ResponseBuilder
 *
 * @see elgg_register_ajax_view()
 * @elgg_pagehandler ajax
 * @access private
 */
function _elgg_ajax_page_handler($segments)
{
    elgg_ajax_gatekeeper();
    if (count($segments) < 2) {
        return false;
    }
    if ($segments[0] === 'view' || $segments[0] === 'form') {
        if ($segments[0] === 'view') {
            // ignore 'view/'
            $view = implode('/', array_slice($segments, 1));
        } else {
            // form views start with "forms", not "form"
            $view = 'forms/' . implode('/', array_slice($segments, 1));
        }
        $ajax_api = _elgg_services()->ajax;
        $allowed_views = $ajax_api->getViews();
        // cacheable views are always allowed
        if (!in_array($view, $allowed_views) && !_elgg_services()->views->isCacheableView($view)) {
            return elgg_error_response("Ajax view '{$view}' was not registered", REFERRER, ELGG_HTTP_FORBIDDEN);
        }
        // pull out GET parameters through filter
        $vars = array();
        foreach (_elgg_services()->request->query->keys() as $name) {
            $vars[$name] = get_input($name);
        }
        if (isset($vars['guid'])) {
            $vars['entity'] = get_entity($vars['guid']);
        }
        $content_type = '';
        if ($segments[0] === 'view') {
            $output = elgg_view($view, $vars);
            // Try to guess the mime-type
            switch ($segments[1]) {
                case "js":
                    $content_type = 'text/javascript;charset=utf-8';
                    break;
                case "css":
                    $content_type = 'text/css;charset=utf-8';
                    break;
                default:
                    if (_elgg_services()->views->isCacheableView($view)) {
                        $file = _elgg_services()->views->findViewFile($view, elgg_get_viewtype());
                        $content_type = (new \Elgg\Filesystem\MimeTypeDetector())->getType($file, 'text/html');
                    }
                    break;
            }
        } else {
            $action = implode('/', array_slice($segments, 1));
            $output = elgg_view_form($action, array(), $vars);
        }
        if ($content_type) {
            elgg_set_http_header("Content-Type: {$content_type}");
        }
        return elgg_ok_response($output);
    }
    return false;
}