コード例 #1
0
ファイル: views.php プロジェクト: gzachos/elgg_ellak
/**
 * Registers deprecated views to avoid making some pages from older plugins
 * completely empty.
 *
 * @access private
 */
function elgg_views_handle_deprecated_views()
{
    $location = elgg_get_view_location('page_elements/contentwrapper');
    if ($location === "/var/www/views/") {
        elgg_extend_view('page_elements/contentwrapper', 'page/elements/wrapper');
    }
}
コード例 #2
0
ファイル: elgg.php プロジェクト: lorea/Hydra-dev
/**
 * Elgg primary CSS view
 *
 * @package Elgg.Core
 * @subpackage UI
 * 
 * @override views/default/css/elgg.php
 */
/* 
 * Colors:
 *  #ff4c12 - n-1 light orange
 *  #d86c2c - n-1 dark orange
 *  #e4ecf5 - n-1 very light orange
 */
// check if there is a theme overriding the old css view and use it, if it exists
$old_css_view = elgg_get_view_location('css');
if ($old_css_view != elgg_get_config('viewpath')) {
    echo elgg_view('css', $vars);
    return true;
}
/*******************************************************************************

Base CSS
 * CSS reset
 * core
 * helpers (moved to end to have a higher priority)
 * grid

*******************************************************************************/
echo elgg_view('css/elements/reset', $vars);
echo elgg_view('css/elements/core', $vars);
コード例 #3
0
ファイル: views.php プロジェクト: rasul/Elgg
/**
 * Return a parsed view.
 *
 * Views are rendered by a template handler and returned as strings.
 *
 * Views are called with a special $vars variable set,
 * which includes any variables passed as the second parameter.
 * For backward compatbility, the following variables are also set but we
 * recommend that you do not use them:
 *  - $vars['config'] The $CONFIG global. (Use {@link elgg_get_config()} instead).
 *  - $vars['url'] The site URL. (use {@link elgg_get_site_url()} instead).
 *  - $vars['user'] The logged in user. (use {@link elgg_get_logged_in_user_entity()} instead).
 *
 * Custom template handlers can be set with {@link set_template_handler()}.
 *
 * The output of views can be intercepted by registering for the
 * view, $view_name plugin hook.
 *
 * @warning Any variables in $_SESSION will override passed vars
 * upon name collision.  See {@trac #2124}.
 *
 * @param string  $view     The name and location of the view to use
 * @param array   $vars     Variables to pass to the view.
 * @param boolean $bypass   If set to true, elgg_view will bypass any specified
 *                          alternative template handler; by default, it will
 *                          hand off to this if requested (see set_template_handler)
 * @param boolean $debug    If set to true, the viewer will complain if it can't find a view
 * @param string  $viewtype If set, forces the viewtype for the elgg_view call to be
 *                          this value (default: standard detection)
 *
 * @return string The parsed view
 * @see set_template_handler()
 * @example views/elgg_view.php
 * @link http://docs.elgg.org/View
 * @todo $debug isn't used.
 * @todo $usercache is redundant.
 */
function elgg_view($view, $vars = array(), $bypass = false, $debug = false, $viewtype = '')
{
    global $CONFIG;
    static $usercache;
    $view = (string) $view;
    // basic checking for bad paths
    if (strpos($view, '..') !== false) {
        return false;
    }
    $view_orig = $view;
    // Trigger the pagesetup event
    if (!isset($CONFIG->pagesetupdone)) {
        elgg_trigger_event('pagesetup', 'system');
        $CONFIG->pagesetupdone = true;
    }
    if (!is_array($usercache)) {
        $usercache = array();
    }
    if (!is_array($vars)) {
        elgg_log("Vars in views must be an array: {$view}", 'ERROR');
        $vars = array();
    }
    if (empty($vars)) {
        $vars = array();
    }
    // @warning - plugin authors: do not expect user, config, and url to be
    // set by elgg_view() in the future. Instead, use elgg_get_logged_in_user_entity(),
    // elgg_get_config(), and elgg_get_site_url() in your views.
    if (!isset($vars['user'])) {
        $vars['user'] = elgg_get_logged_in_user_entity();
    }
    if (!isset($vars['config'])) {
        $vars['config'] = $CONFIG;
    }
    if (!isset($vars['url'])) {
        $vars['url'] = elgg_get_site_url();
    }
    // full_view is the new preferred key for full view on entities @see elgg_view_entity()
    if (isset($vars['full'])) {
        elgg_deprecated_notice("Use \$vars['full_view'] instead of \$vars['full']", 1.8);
        $vars['full_view'] = $vars['full'];
    }
    if (isset($vars['full_view'])) {
        $vars['full'] = $vars['full_view'];
    }
    // internalname => name (1.8)
    if (isset($vars['internalname'])) {
        elgg_deprecated_notice('You should pass $vars[\'name\'] now instead of $vars[\'internalname\']', 1.8);
        $vars['name'] = $vars['internalname'];
    } elseif (isset($vars['name'])) {
        $vars['internalname'] = $vars['name'];
    }
    // internalid => id (1.8)
    if (isset($vars['internalid'])) {
        elgg_deprecated_notice('You should pass $vars[\'id\'] now instead of $vars[\'internalid\']', 1.8);
        $vars['id'] = $vars['internalid'];
    } elseif (isset($vars['id'])) {
        $vars['internalid'] = $vars['id'];
    }
    // If it's been requested, pass off to a template handler instead
    if ($bypass == false && isset($CONFIG->template_handler) && !empty($CONFIG->template_handler)) {
        $template_handler = $CONFIG->template_handler;
        if (is_callable($template_handler)) {
            return call_user_func($template_handler, $view, $vars);
        }
    }
    // Get the current viewtype
    if (empty($viewtype)) {
        $viewtype = elgg_get_viewtype();
    }
    // Viewtypes can only be alphanumeric
    if (preg_match('[\\W]', $viewtype)) {
        return '';
    }
    // Set up any extensions to the requested view
    if (isset($CONFIG->views->extensions[$view])) {
        $viewlist = $CONFIG->views->extensions[$view];
    } else {
        $viewlist = array(500 => $view);
    }
    // Start the output buffer, find the requested view file, and execute it
    ob_start();
    foreach ($viewlist as $priority => $view) {
        $view_location = elgg_get_view_location($view, $viewtype);
        $view_file = "{$view_location}{$viewtype}/{$view}.php";
        $default_location = elgg_get_view_location($view, 'default');
        $default_view_file = "{$default_location}default/{$view}.php";
        // try to include view
        if (!file_exists($view_file) || !(include $view_file)) {
            // requested view does not exist
            $error = "{$viewtype}/{$view} view does not exist.";
            // attempt to load default view
            if ($viewtype != 'default' && elgg_does_viewtype_fallback($viewtype)) {
                if (file_exists($default_view_file) && (include $default_view_file)) {
                    // default view found
                    $error .= " Using default/{$view} instead.";
                } else {
                    // no view found at all
                    $error = "Neither {$viewtype}/{$view} nor default/{$view} view exists.";
                }
            }
            // log warning
            elgg_log($error, 'NOTICE');
        }
    }
    // Save the output buffer into the $content variable
    $content = ob_get_clean();
    // Plugin hook
    $params = array('view' => $view_orig, 'vars' => $vars, 'viewtype' => $viewtype);
    $content = elgg_trigger_plugin_hook('view', $view_orig, $params, $content);
    // backward compatibility with less granular hook will be gone in 2.0
    $content_tmp = elgg_trigger_plugin_hook('display', 'view', $params, $content);
    if ($content_tmp != $content) {
        $content = $content_tmp;
        elgg_deprecated_notice('The display:view plugin hook is deprecated by view:view_name', 1.8);
    }
    return $content;
}
コード例 #4
0
ファイル: icons.php プロジェクト: redvabel/Deyan-Shell
/**
 * Get the dirname of an icon library.
 *
 * @param string $iconlib	The name of the iconlib.
 *
 * @return string	The dirname of the icon library
*/
function deyan_get_iconlib_dir($iconlib) {

	 return elgg_get_view_location("icon_libraries/$iconlib/preview") . "default/icon_libraries/$iconlib/";
}
コード例 #5
0
ファイル: elgglib.php プロジェクト: eokyere/elgg
/**
 * Handles templating views
 *
 * @see set_template_handler
 * 
 * @param string $view The name and location of the view to use
 * @param array $vars Any variables that the view requires, passed as an array
 * @param boolean $bypass If set to true, elgg_view will bypass any specified alternative template handler; by default, it will hand off to this if requested (see set_template_handler)
 * @param boolean $debug If set to true, the viewer will complain if it can't find a view
 * @param string $viewtype If set, forces the viewtype for the elgg_view call to be this value (default: standard detection) 
 * @return string The HTML content
 */
function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype = '')
{
    global $CONFIG;
    static $usercache;
    // Trigger the pagesetup event
    if (!isset($CONFIG->pagesetupdone)) {
        trigger_elgg_event('pagesetup', 'system');
        $CONFIG->pagesetupdone = true;
    }
    if (!is_array($usercache)) {
        $usercache = array();
    }
    if (empty($vars)) {
        $vars = array();
    }
    // Load session and configuration variables into $vars
    if (isset($_SESSION)) {
        // $_SESSION will always be an array if it is set
        $vars += $_SESSION;
        //= array_merge($vars, $_SESSION);
    }
    $vars['config'] = array();
    if (!empty($CONFIG)) {
        $vars['config'] = $CONFIG;
    }
    $vars['url'] = $CONFIG->url;
    // Load page owner variables into $vars
    if (is_callable('page_owner')) {
        $vars['page_owner'] = page_owner();
    } else {
        $vars['page_owner'] = -1;
    }
    if ($vars['page_owner'] != -1 && is_installed()) {
        if (!isset($usercache[$vars['page_owner']])) {
            $vars['page_owner_user'] = get_entity($vars['page_owner']);
            $usercache[$vars['page_owner']] = $vars['page_owner_user'];
        } else {
            $vars['page_owner_user'] = $usercache[$vars['page_owner']];
        }
    }
    if (!isset($vars['js'])) {
        $vars['js'] = "";
    }
    // If it's been requested, pass off to a template handler instead
    if ($bypass == false && isset($CONFIG->template_handler) && !empty($CONFIG->template_handler)) {
        $template_handler = $CONFIG->template_handler;
        if (is_callable($template_handler)) {
            return $template_handler($view, $vars);
        }
    }
    // Get the current viewtype
    if (empty($viewtype)) {
        $viewtype = elgg_get_viewtype();
    }
    // Set up any extensions to the requested view
    if (isset($CONFIG->views->extensions[$view])) {
        $viewlist = $CONFIG->views->extensions[$view];
    } else {
        $viewlist = array(500 => $view);
    }
    // Start the output buffer, find the requested view file, and execute it
    ob_start();
    // Attempt to cache views [EXPERIMENTAL]
    /*if (ob_get_level()==1) {
    		    $view_hash = elgg_get_viewhash($view, $vars); 
    		    $view_cache = elgg_get_filepath_cache();
    		    $cached_view = $view_cache->load($view_hash);
    		    
    		    if ($cached_view) {
    		    	ob_get_clean();
    		    	return $cached_view;
    		    }
    		}*/
    $success = false;
    foreach ($viewlist as $priority => $view) {
        $view_location = elgg_get_view_location($view, $viewtype);
        if (file_exists($view_location . "{$viewtype}/{$view}.php") && !(include $view_location . "{$viewtype}/{$view}.php")) {
            $success = false;
            if ($viewtype != "default") {
                if (include $view_location . "default/{$view}.php") {
                    $success = true;
                }
            }
            if (!$success && isset($CONFIG->debug) && $CONFIG->debug == true) {
                error_log(" [This view ({$view}) does not exist] ");
            }
        } else {
            if (isset($CONFIG->debug) && $CONFIG->debug == true && !file_exists($view_location . "{$viewtype}/{$view}.php")) {
                error_log($view_location . "{$viewtype}/{$view}.php");
                error_log(" [This view ({$view}) does not exist] ");
            }
        }
    }
    // Cache view [EXPERIMENTAL]
    //if (ob_get_level()==1) // Only cache top level view
    //	$view_cache->save($view_hash, $content);
    // Save the output buffer into the $content variable
    $content = ob_get_clean();
    // Plugin hook
    $content = trigger_plugin_hook('display', 'view', array('view' => $view), $content);
    // Return $content
    return $content;
}
コード例 #6
0
ファイル: themes.php プロジェクト: redvabel/Deyan-Shell
/**
 * Get the dirname of one theme.
 *
 * @param string $theme		The name of the theme wich obtain the dirname from.
 *
 * @return string	The dirname of the theme
*/
function deyan_get_theme_dir($theme) {
		
	 return elgg_get_view_location("themes/$theme/constants") . "default/themes/$theme/";
		 
}
コード例 #7
0
ファイル: elgglib.php プロジェクト: adamboardman/Elgg
/**
 * Handles templating views
 *
 * @see set_template_handler
 *
 * @param string $view The name and location of the view to use
 * @param array $vars Any variables that the view requires, passed as an array
 * @param boolean $bypass If set to true, elgg_view will bypass any specified alternative template handler; by default, it will hand off to this if requested (see set_template_handler)
 * @param boolean $debug If set to true, the viewer will complain if it can't find a view
 * @param string $viewtype If set, forces the viewtype for the elgg_view call to be this value (default: standard detection)
 * @return string The HTML content
 */
function elgg_view($view, $vars = array(), $bypass = false, $debug = false, $viewtype = '')
{
    global $CONFIG;
    static $usercache;
    $view = (string) $view;
    // basic checking for bad paths
    if (strpos($view, '..') !== false) {
        return false;
    }
    $view_orig = $view;
    // Trigger the pagesetup event
    if (!isset($CONFIG->pagesetupdone)) {
        trigger_elgg_event('pagesetup', 'system');
        $CONFIG->pagesetupdone = true;
    }
    if (!is_array($usercache)) {
        $usercache = array();
    }
    if (!is_array($vars)) {
        elgg_log('Vars in views must be an array!', 'ERROR');
        $vars = array();
    }
    if (empty($vars)) {
        $vars = array();
    }
    // Load session and configuration variables into $vars
    // $_SESSION will always be an array if it is set
    if (isset($_SESSION)) {
        //= array_merge($vars, $_SESSION);
        $vars += $_SESSION;
    }
    $vars['config'] = array();
    if (!empty($CONFIG)) {
        $vars['config'] = $CONFIG;
    }
    $vars['url'] = $CONFIG->url;
    // Load page owner variables into $vars
    if (is_callable('page_owner')) {
        $vars['page_owner'] = page_owner();
    } else {
        $vars['page_owner'] = -1;
    }
    if ($vars['page_owner'] != -1 && is_installed()) {
        if (!isset($usercache[$vars['page_owner']])) {
            $vars['page_owner_user'] = get_entity($vars['page_owner']);
            $usercache[$vars['page_owner']] = $vars['page_owner_user'];
        } else {
            $vars['page_owner_user'] = $usercache[$vars['page_owner']];
        }
    }
    if (!isset($vars['js'])) {
        $vars['js'] = "";
    }
    // If it's been requested, pass off to a template handler instead
    if ($bypass == false && isset($CONFIG->template_handler) && !empty($CONFIG->template_handler)) {
        $template_handler = $CONFIG->template_handler;
        if (is_callable($template_handler)) {
            return $template_handler($view, $vars);
        }
    }
    // Get the current viewtype
    if (empty($viewtype)) {
        $viewtype = elgg_get_viewtype();
    }
    // Set up any extensions to the requested view
    if (isset($CONFIG->views->extensions[$view])) {
        $viewlist = $CONFIG->views->extensions[$view];
    } else {
        $viewlist = array(500 => $view);
    }
    // Start the output buffer, find the requested view file, and execute it
    ob_start();
    foreach ($viewlist as $priority => $view) {
        $view_location = elgg_get_view_location($view, $viewtype);
        $view_file = "{$view_location}{$viewtype}/{$view}.php";
        $default_view_file = "{$view_location}default/{$view}.php";
        // try to include view
        if (!file_exists($view_file) || !(include $view_file)) {
            // requested view does not exist
            $error = "{$viewtype}/{$view} view does not exist.";
            // attempt to load default view
            if ($viewtype != 'default') {
                if (file_exists($default_view_file) && (include $default_view_file)) {
                    // default view found
                    $error .= " Using default/{$view} instead.";
                } else {
                    // no view found at all
                    $error = "Neither {$viewtype}/{$view} nor default/{$view} view exists.";
                }
            }
            // log warning
            elgg_log($error, 'WARNING');
        }
    }
    // Save the output buffer into the $content variable
    $content = ob_get_clean();
    // Plugin hook
    $content = trigger_plugin_hook('display', 'view', array('view' => $view_orig, 'vars' => $vars), $content);
    // Return $content
    return $content;
}