当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::getRootDir方法代码示例

本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container::getRootDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getRootDir方法的具体用法?PHP Container::getRootDir怎么用?PHP Container::getRootDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chamilo\CoreBundle\Framework\Container的用法示例。


在下文中一共展示了Container::getRootDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: api_get_path


//.........这里部分代码省略.........
 * api_get_path(WEB_CSS_PATH)                   http://www.mychamilo.org/chamilo/web/css/
 * api_get_path(WEB_LIBRARY_PATH)               http://www.mychamilo.org/chamilo/main/inc/lib/
 * api_get_path(WEB_LIBRARY_JS_PATH)            http://www.mychamilo.org/chamilo/web/bundles/chamilocore/js
 * api_get_path(WEB_TEMPLATE_PATH)              http://www.mychamilo.org/chamilo/main/template/
 * api_get_path(WEB_UPLOAD_PATH)                http://www.mychamilo.org/chamilo/app/upload/
 * api_get_path(WEB_PUBLIC_PATH)                http://www.mychamilo.org/chamilo/web/
 *
 * This is how we retrieve paths of "registered" resource files (scripts, players, etc.):
 * api_get_path(TO_WEB, FLASH_PLAYER_AUDIO)     http://www.mychamilo.org/chamilo/main/inc/lib/mediaplayer/player.swf
 * api_get_path(TO_WEB, FLASH_PLAYER_VIDEO)     http://www.mychamilo.org/chamilo/main/inc/lib/mediaplayer/player.swf
 * api_get_path(TO_SYS, SCRIPT_SWFOBJECT)       /var/www/chamilo/main/inc/lib/swfobject/swfobject.js
 * api_get_path(TO_REL, SCRIPT_ASCIIMATHML)     /chamilo/main/inc/lib/asciimath/ASCIIMathML.js
 * ...
 *
 * We can convert arbitrary paths, that are not registered (no defined constant).
 * For guaranteed result, these paths should point inside the system Chamilo.
 * Some random examples:
 * api_get_path(TO_WEB, $_SERVER['REQUEST_URI'])
 * api_get_path(TO_SYS, $_SERVER['PHP_SELF'])
 * api_get_path(TO_REL, __FILE__)
 * ...
 */
function api_get_path($path_type, $path = null)
{
    static $paths = array(WEB_PATH => '', SYS_PATH => '', REL_PATH => '', WEB_SERVER_ROOT_PATH => '', SYS_SERVER_ROOT_PATH => '', WEB_COURSE_PATH => '', SYS_COURSE_PATH => '', REL_COURSE_PATH => '', REL_CODE_PATH => '', WEB_CODE_PATH => '', SYS_CODE_PATH => '', SYS_LANG_PATH => 'lang/', WEB_IMG_PATH => 'web/bundles/chamilocore/img/', SYS_IMG_PATH => 'web/bundles/chamilocore/img/', WEB_CSS_PATH => 'web/css/', SYS_CSS_PATH => 'app/Resources/public/css/', SYS_PLUGIN_PATH => 'plugin/', WEB_PLUGIN_PATH => 'plugin/', SYS_ARCHIVE_PATH => 'app/cache/', WEB_ARCHIVE_PATH => 'app/cache/', SYS_APP_PATH => 'app/', WEB_APP_PATH => 'app/', SYS_UPLOAD_PATH => 'app/upload/', REL_UPLOAD_PATH => 'app/upload/', INCLUDE_PATH => 'inc/', LIBRARY_PATH => 'inc/lib/', CONFIGURATION_PATH => 'app/config/', WEB_LIBRARY_PATH => 'inc/lib/', WEB_LIBRARY_JS_PATH => 'web/bundles/chamilocore/js/', WEB_AJAX_PATH => 'inc/ajax/', SYS_TEST_PATH => 'tests/', WEB_TEMPLATE_PATH => 'template/', WEB_UPLOAD_PATH => 'app/upload/', WEB_PUBLIC_PATH => 'web/', SYS_TEMPLATE_PATH => 'template/', SYS_PUBLIC_PATH => 'web/', WEB_FONTS_PATH => 'fonts/', SYS_FONTS_PATH => 'fonts/');
    static $resource_paths = array(FLASH_PLAYER_AUDIO => 'inc/lib/mediaplayer/player.swf', FLASH_PLAYER_VIDEO => 'inc/lib/mediaplayer/player.swf', SCRIPT_SWFOBJECT => 'inc/lib/swfobject/swfobject.js', SCRIPT_ASCIIMATHML => 'inc/lib/javascript/asciimath/ASCIIMathML.js', DRAWING_ASCIISVG => 'inc/lib/javascript/asciimath/d.svg');
    static $is_this_function_initialized;
    static $server_base_web;
    // No trailing slash.
    static $server_base_sys;
    // No trailing slash.
    static $root_rel;
    $root_web = Container::getUrlGenerator()->generate('home', [], \Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL);
    $rootDir = Container::getRootDir();
    // Configuration data for already installed system.
    $root_sys = $rootDir;
    $code_folder = 'main/';
    $course_folder = 'courses/';
    // Configuration data for already installed system.
    $load_new_config = false;
    // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
    if ($path_type == WEB_PATH) {
        if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) {
            //we look into the DB the function api_get_access_url
            $url_info = api_get_access_url($_configuration['access_url']);
            $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web'];
            $load_new_config = true;
        }
    }
    if (!$is_this_function_initialized) {
        $root_rel = Container::getUrlAppend();
        // Dealing with trailing slashes.
        $root_web = api_add_trailing_slash($root_web);
        $root_sys = api_add_trailing_slash($root_sys);
        $root_rel = api_add_trailing_slash($root_rel);
        $code_folder = api_add_trailing_slash($code_folder);
        $course_folder = api_add_trailing_slash($course_folder);
        // Web server base and system server base.
        $server_base_web = preg_replace('@' . $root_rel . '$@', '', $root_web);
        // No trailing slash.
        $server_base_sys = preg_replace('@' . $root_rel . '$@', '', $root_sys);
        // No trailing slash.
        // Initialization of a table that contains common-purpose paths.
        $paths[WEB_PATH] = $root_web;
        $paths[SYS_PATH] = $root_sys;
        $paths[REL_PATH] = $root_rel;
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:67,代码来源:api.lib.php

示例2: api_get_path

/**
 * Returns a path to a certain resource within the Chamilo area, specifyed through a parameter.
 * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too.
 *
 * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
 * @param string $type              The requested path type (a defined constant), see the examples.
 * @param string $path (optional)   A path which type is to be converted. Also, it may be a defined constant for a path.
 * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored.
 * @return string                   The requested path or the converted path.
 *
 * A terminology note:
 * The defined constants used by this function contain the abbreviations WEB, REL, SYS with the following meaning for types:
 * WEB - an absolute URL (we often call it web-path),
 * example: http://www.mychamilo.org/chamilo/courses/COURSE01/document/lesson01.html;
 *
 * REL - represents a semi-absolute URL - a web-path, which is relative to the root web-path of the server, without server's base,
 * example: /chamilo/courses/COURSE01/document/lesson01.html;
 *
 * SYS - represents an absolute path inside the scope of server's file system,
 * /var/www/chamilo/courses/COURSE01/document/lesson01.html or
 * C:/Inetpub/wwwroot/chamilo/courses/COURSE01/document/lesson01.html.
 *
 * In some abstract sense we can consider these three path types as absolute.
 *
 * Notes about the current behaviour model:
 * 1. Windows back-slashes are converted to slashes in the result.
 * 2. A semi-absolute web-path is detected by its leading slash. On Linux systems, absolute system paths start with
 * a slash too, so an additional check about presense of leading system server base is implemented. For example, the function is
 * able to distinguish type difference between /var/www/chamilo/courses/ (SYS) and /chamilo/courses/ (REL).
 * 3. The function api_get_path() returns only these three types of paths, which in some sense are absolute. The function has
 * no a mechanism for processing relative web/system paths, such as: lesson01.html, ./lesson01.html, ../css/my_styles.css.
 * It has not been identified as needed yet.
 * 4. Also, resolving the meta-symbols "." and ".." withiin paths has not been implemented, it is to be identified as needed.
 *
 * Example:
 * Assume that your server root is /var/www/ , Chamilo is installed in a subfolder chamilo/ and the URL of your campus is http://www.mychamilo.org
 * The other configuration paramaters have not been changed.
 *
 * This is how we can retireve mosth used paths, for common purpose:
 * api_get_path(REL_PATH)                       /chamilo/
 * api_get_path(REL_COURSE_PATH)                /chamilo/courses/
 * api_get_path(REL_CODE_PATH)                  /chamilo/main/
 * api_get_path(SYS_SERVER_ROOT_PATH)           /var/www/ - This is the physical folder where the system Chamilo has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
 * api_get_path(SYS_PATH)                       /var/www/chamilo/
 *
 * api_get_path(SYS_ARCHIVE_PATH)               /var/www/chamilo/temp/
 * api_get_path(SYS_LOG_PATH)                   /var/www/chamilo/logs/
 * api_get_path(SYS_DATA_PATH)                  /var/www/chamilo/data/
 * api_get_path(SYS_CONFIG_PATH)                /var/www/chamilo/config/
 * api_get_path(SYS_WEB_PATH)                   /var/www/chamilo/web/
 *
 * api_get_path(SYS_COURSE_PATH)                /var/www/chamilo/data/courses/
 * api_get_path(SYS_CODE_PATH)                  /var/www/chamilo/main/
 * api_get_path(SYS_CSS_PATH)                   /var/www/chamilo/main/css
 * api_get_path(INCLUDE_PATH)                   /var/www/chamilo/main/inc/
 * api_get_path(LIBRARY_PATH)                   /var/www/chamilo/main/inc/lib/
 * api_get_path(SYS_LIBRARY_JS_PATH)            /var/www/chamilo/web/Chamilo/js
 * api_get_path(CONFIGURATION_PATH)             /var/www/chamilo/main/inc/conf/
 * api_get_path(SYS_LANG_PATH)                  /var/www/chamilo/main/lang/
 * api_get_path(SYS_PLUGIN_PATH)                /var/www/chamilo/plugin/
 * api_get_path(SYS_TEST_PATH)                  /var/www/chamilo/tests/
 * api_get_path(SYS_TEMPLATE_PATH)              /var/www/chamilo/main/template/
 *
 * api_get_path(WEB_SERVER_ROOT_PATH)           http://www.mychamilo.org/
 *
 * api_get_path(WEB_PUBLIC_PATH)                http://www.mychamilo.org/chamilo/web/
 * api_get_path(WEB_PATH)                       http://www.mychamilo.org/chamilo/
 * api_get_path(WEB_COURSE_PATH)                http://www.mychamilo.org/chamilo/courses/
 * api_get_path(WEB_CODE_PATH)                  http://www.mychamilo.org/chamilo/main/
 * api_get_path(WEB_PLUGIN_PATH)                http://www.mychamilo.org/chamilo/plugin/
 * api_get_path(WEB_ARCHIVE_PATH)               http://www.mychamilo.org/chamilo/archive/
 * api_get_path(WEB_IMG_PATH)                   http://www.mychamilo.org/chamilo/web/chamilo/img/
 * api_get_path(SYS_IMG_PATH)                   /var/www/chamilo/web/bundles/chamilocore/img/
 *
 * api_get_path(WEB_CSS_PATH)                   http://www.mychamilo.org/chamilo/main/css/
 * api_get_path(WEB_LIBRARY_PATH)               http://www.mychamilo.org/chamilo/main/inc/lib/
 * api_get_path(WEB_LIBRARY_JS_PATH)            http://www.mychamilo.org/chamilo/web/Chamilo/javascript
 * api_get_path(WEB_TEMPLATE_PATH)              http://www.mychamilo.org/chamilo/main/template/
 *
 *
 * We can convert arbitrary paths, that are not registered (no defined constant).
 * For guaranteed result, these paths should point inside the system Chamilo.
 * Some random examples:
 * api_get_path(TO_WEB, $_SERVER['REQUEST_URI'])
 * api_get_path(TO_SYS, $_SERVER['PHP_SELF'])
 * api_get_path(TO_REL, __FILE__)
 * ...
 */
function api_get_path($path_type, $path = null)
{
    $paths = array(SYS_DATA_PATH => 'data/', SYS_WEB_PATH => 'web/', SYS_CONFIG_PATH => 'config/', SYS_LOG_PATH => 'logs/', WEB_DATA_COURSE_PATH => 'courses/', WEB_DATA_PATH => '/', SYS_COURSE_PATH => 'data/', SYS_CSS_PATH => 'bundles/chamilocore/css/', SYS_LANG_PATH => 'lang/', WEB_IMG_PATH => 'bundles/chamilocore/img/', SYS_IMG_PATH => 'web/bundles/chamilocore/img/', WEB_CSS_PATH => 'bundles/chamilocore/css/', SYS_PLUGIN_PATH => 'plugin/', WEB_PLUGIN_PATH => 'plugin/', WEB_ARCHIVE_PATH => 'temp/', INCLUDE_PATH => 'inc/', LIBRARY_PATH => 'inc/lib/', SYS_LIBRARY_JS_PATH => 'bundles/chamilocore/js/', CONFIGURATION_PATH => 'inc/conf/', WEB_LIBRARY_PATH => 'inc/lib/', WEB_LIBRARY_JS_PATH => 'bundles/chamilocore/js/', WEB_AJAX_PATH => 'inc/ajax/', SYS_TEST_PATH => 'tests/', WEB_TEMPLATE_PATH => 'template/', SYS_TEMPLATE_PATH => 'template/');
    $root_web = Container::getUrlGenerator()->generate('home');
    $rootDir = Container::getRootDir();
    // Configuration data for already installed system.
    $root_sys = $rootDir;
    $code_folder = 'main/';
    //$course_folder  = isset($_configuration['course_folder']) ? $_configuration['course_folder'] : null;
    $course_folder = "courses/";
    // Dealing with trailing slashes.
    $root_web = api_add_trailing_slash($root_web);
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:api.lib.php


注:本文中的Chamilo\CoreBundle\Framework\Container::getRootDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。