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


PHP Themes::get_theme_dir方法代码示例

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


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

示例1: get_preview_theme

 /**
  * Configures a theme to be active for the current user's session.
  */
 public function get_preview_theme()
 {
     $theme_name = $this->handler_vars['theme_name'];
     $theme_dir = $this->handler_vars['theme_dir'];
     if (isset($theme_name) && isset($theme_dir)) {
         if (Themes::get_theme_dir() == $theme_dir) {
             Themes::cancel_preview();
             Session::notice(_t("Ended the preview of the theme '%s'", array($theme_name)));
         } else {
             if (Themes::preview_theme($theme_name, $theme_dir)) {
                 Session::notice(_t("Previewing theme '%s'", array($theme_name)));
             }
         }
     }
     Utils::redirect(URL::get('admin', 'page=themes'));
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:19,代码来源:adminthemeshandler.php

示例2: get_dir

 /**
  * get_dir returns a complete filesystem path to the requested item
  *	'config_file' returns the complete path to the config.php file, including the filename
  *	'config' returns the path of the directory containing config.php
  *	'user' returns the path of the user directory
  *	'theme' returns the path of the site's active theme
  *  'admin_theme' returns the path to the admin directory
  *  'vendor' returns the path to the vendor directory
  * @param string $name the name of the path item to return
  * @param bool|string $trail whether to include a trailing slash, or a string to use as the trailing value.  Default: false
  * @return string Path
  */
 public static function get_dir($name, $trail = false)
 {
     $path = '';
     switch (strtolower($name)) {
         case 'config_file':
             $path = Site::get_dir('config') . '/config.php';
             break;
         case 'config':
             if (self::$config_path) {
                 return self::$config_path;
             }
             self::$config_path = HABARI_PATH;
             $config_dirs = preg_replace('/^' . preg_quote(HABARI_PATH, '/') . '\\/user\\/sites\\/(.*)/', '$1', Utils::glob(HABARI_PATH . '/user/sites/*', GLOB_ONLYDIR));
             if (empty($config_dirs)) {
                 return self::$config_path;
             }
             // Collect host parts
             $server = InputFilter::parse_url(Site::get_url('habari'));
             $request = array();
             if (isset($server['port']) && $server['port'] != '' && $server['port'] != '80') {
                 $request[] = $server['port'];
             }
             $request = array_merge($request, explode('.', $server['host']));
             // Collect the subdirectory(s) the core is located in to determine the base path later
             // Don't add them to $request, they will be added with $_SERVER['REQUEST_URI']
             $basesegments = count($request);
             if (!empty($server['path'])) {
                 $coresubdir = explode('/', trim($server['path'], '/'));
                 $basesegments += count($coresubdir);
             }
             // Preserve $request without directories for fallback
             $request_base = $request;
             // Add directory part
             if (!empty(trim($_SERVER['REQUEST_URI'], '/'))) {
                 $subdirectories = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
                 $request = array_merge($request, $subdirectories);
             }
             // Now cut parts until we found a matching site directory
             $cuts = 0;
             $dir_cuts = 0;
             do {
                 $match = implode('.', $request);
                 if (in_array($match, $config_dirs)) {
                     self::$config_dir = $match;
                     self::$config_path = HABARI_PATH . '/user/sites/' . self::$config_dir;
                     self::$config_type = isset($subdirectories) && array_intersect($subdirectories, $request) == $subdirectories ? Site::CONFIG_SUBDIR : Site::CONFIG_SUBDOMAIN;
                     self::$config_urldir = implode('/', array_slice($request, $basesegments + $cuts));
                     break;
                 }
                 // Cut a part from the beginning
                 array_shift($request);
                 $cuts--;
                 // Do not fallback to only the directory part, instead, cut one and start over
                 if ($basesegments + $cuts <= 0 && isset($subdirectories) && $dir_cuts < count($subdirectories)) {
                     $cuts = 0;
                     $dir_cuts++;
                     $request = array_merge($request_base, array_slice($subdirectories, 0, count($subdirectories) - $dir_cuts));
                 }
                 // What does the following check do?!
                 if ($cuts < -10) {
                     echo $cuts;
                     var_dump($request);
                     die('too many ');
                 }
             } while (count($request) > 0);
             $path = self::$config_path;
             break;
         case 'user':
             if (Site::get_dir('config') == HABARI_PATH) {
                 $path = HABARI_PATH . '/user';
             } else {
                 $path = Site::get_dir('config');
             }
             break;
         case 'theme':
             $theme = Themes::get_theme_dir();
             if (file_exists(Site::get_dir('config') . '/themes/' . $theme)) {
                 $path = Site::get_dir('user') . '/themes/' . $theme;
             } elseif (file_exists(HABARI_PATH . '/user/themes/' . $theme)) {
                 $path = HABARI_PATH . '/user/themes/' . $theme;
             } elseif (file_exists(HABARI_PATH . '/3rdparty/themes/' . $theme)) {
                 $path = Site::get_dir('habari') . '/3rdparty/themes/' . $theme;
             } else {
                 $path = HABARI_PATH . '/system/themes/' . $theme;
             }
             break;
         case 'admin_theme':
             $path = HABARI_PATH . '/system/admin';
//.........这里部分代码省略.........
开发者ID:habari,项目名称:system,代码行数:101,代码来源:site.php

示例3: get_dir

	/**
	 * get_dir returns a complete filesystem path to the requested item
	 *	'config_file' returns the complete path to the config.php file, including the filename
	 *	'config' returns the path of the directory containing config.php
	 *	'user' returns the path of the user directory
	 *	'theme' returns the path of the site's active theme
	 * @param string the name of the path item to return
	 * @param bool whether to include a trailing slash.  Default: No
	 * @return string Path
	 */
	public static function get_dir( $name, $trail = false )
	{
		$path = '';

		switch ( strtolower( $name ) ) {
			case 'config_file':
				$path = Site::get_dir( 'config' ) . '/config.php';
				break;
			case 'config':
				if ( self::$config_path ) {
					return self::$config_path;
				}

				self::$config_path = HABARI_PATH;

				$config_dirs = preg_replace( '/^' . preg_quote( HABARI_PATH, '/' ) . '\/user\/sites\/(.*)\/config.php/', '$1', Utils::glob( HABARI_PATH . '/user/sites/*/config.php' ) );

				if ( empty( $config_dirs ) ) {
					return self::$config_path;
				}

				$server = InputFilter::parse_url( Site::get_url( 'habari' ) );
				$server = ( isset( $server['port'] ) ) ? $server['port'] . '.' . $server['host'] . '.' : $server['host'] . '.';

				$request = explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) );
				$match = trim( $server, '.' );
				$x = count( $request );
				do {
					if ( in_array( $match, $config_dirs ) ) {
						self::$config_dir = $match;
						self::$config_path = HABARI_PATH . '/user/sites/' . self::$config_dir;
						self::$config_type = ( $x > 0 ) ? Site::CONFIG_SUBDOMAIN : Site::CONFIG_SUBDIR;
						break;
					}

					$match = MultiByte::substr( $match, MultiByte::strpos( $match, '.' ) + 1 );
					$x--;
				} while ( MultiByte::strpos( $match, '.' ) !== false );

				$path = self::$config_path;
				break;
			case 'user':
				if ( Site::get_dir( 'config' ) == HABARI_PATH ) {
					$path = HABARI_PATH . '/user';
				}
				else {
					$path = Site::get_dir( 'config' );
				}
				break;
			case 'theme':
				$theme = Themes::get_theme_dir();
				if ( file_exists( Site::get_dir( 'config' ) . '/themes/' . $theme ) ) {
					$path = Site::get_dir( 'user' ) . '/themes/' . $theme;
				}
				elseif ( file_exists( HABARI_PATH . '/user/themes/' . $theme ) ) {
					$path = HABARI_PATH . '/user/themes/' . $theme;
				}
				elseif ( file_exists( HABARI_PATH . '/3rdparty/themes/' . $theme ) ) {
					$url = Site::get_url( 'habari' ) . '/3rdparty/themes/' . $theme;
				}
				else {
					$path = HABARI_PATH . '/system/themes/' . $theme;
				}
				break;
			case 'admin_theme':
				$path = HABARI_PATH . '/system/admin';
				break;
			case 'vendor':
				$path = HABARI_PATH . '/system/vendor';
				break;
		}
		$path .= Utils::trail( $trail );
		$path = Plugins::filter( 'site_dir_' . $name, $path );
		return $path;
	}
开发者ID:nerdfiles,项目名称:habari_boilerplate,代码行数:85,代码来源:site.php

示例4: get_dir

 /**
  * get_dir returns a complete filesystem path to the requested item
  *	'config_file' returns the complete path to the config.php file, including the filename
  *	'config' returns the path of the directory containing config.php
  *	'user' returns the path of the user directory
  *	'theme' returns the path of the site's active theme
  *  'admin_theme' returns the path to the admin directory
  *  'vendor' returns the path to the vendor directory
  * @param string the name of the path item to return
  * @param bool whether to include a trailing slash.  Default: No
  * @return string Path
  */
 public static function get_dir($name, $trail = false)
 {
     $path = '';
     switch (strtolower($name)) {
         case 'config_file':
             $path = Site::get_dir('config') . '/config.php';
             break;
         case 'config':
             if (self::$config_path) {
                 return self::$config_path;
             }
             self::$config_path = HABARI_PATH;
             $config_dirs = preg_replace('/^' . preg_quote(HABARI_PATH, '/') . '\\/user\\/sites\\/(.*)/', '$1', Utils::glob(HABARI_PATH . '/user/sites/*', GLOB_ONLYDIR));
             if (empty($config_dirs)) {
                 return self::$config_path;
             }
             $server = InputFilter::parse_url(Site::get_url('habari'));
             $request = array();
             if (isset($server['port']) && $server['port'] != '' && $server['port'] != '80') {
                 $request[] = $server['port'];
             }
             $request = array_merge($request, explode('.', $server['host']));
             $basesegments = count($request);
             $request = array_merge($request, explode('/', trim($_SERVER['REQUEST_URI'], '/')));
             $x = 0;
             do {
                 $match = implode('.', $request);
                 if (in_array($match, $config_dirs)) {
                     self::$config_dir = $match;
                     self::$config_path = HABARI_PATH . '/user/sites/' . self::$config_dir;
                     self::$config_type = $basesegments > count($request) ? Site::CONFIG_SUBDOMAIN : Site::CONFIG_SUBDIR;
                     self::$config_urldir = implode('/', array_slice($request, $basesegments));
                     break;
                 }
                 array_pop($request);
                 $x--;
                 if ($x < -10) {
                     echo $x;
                     var_dump($request);
                     die('too many ');
                 }
             } while (count($request) > 0);
             $path = self::$config_path;
             break;
         case 'user':
             if (Site::get_dir('config') == HABARI_PATH) {
                 $path = HABARI_PATH . '/user';
             } else {
                 $path = Site::get_dir('config');
             }
             break;
         case 'theme':
             $theme = Themes::get_theme_dir();
             if (file_exists(Site::get_dir('config') . '/themes/' . $theme)) {
                 $path = Site::get_dir('user') . '/themes/' . $theme;
             } elseif (file_exists(HABARI_PATH . '/user/themes/' . $theme)) {
                 $path = HABARI_PATH . '/user/themes/' . $theme;
             } elseif (file_exists(HABARI_PATH . '/3rdparty/themes/' . $theme)) {
                 $url = Site::get_url('habari') . '/3rdparty/themes/' . $theme;
             } else {
                 $path = HABARI_PATH . '/system/themes/' . $theme;
             }
             break;
         case 'admin_theme':
             $path = HABARI_PATH . '/system/admin';
             break;
         case 'vendor':
             $path = HABARI_PATH . '/system/vendor';
             break;
     }
     $path .= Utils::trail($trail);
     $path = Plugins::filter('site_dir_' . $name, $path);
     return $path;
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:86,代码来源:site.php


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