Changeset 838
- Timestamp:
- 05/29/2007 11:48:11 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-admin/themes.php
r799 r838 29 29 function bb_admin_theme_row( $theme ) { 30 30 $theme_data = file_exists( $theme . 'style.css' ) ? bb_get_theme_data( $theme . 'style.css' ) : false; 31 $screen_shot = file_exists( $theme . 'screenshot.png' ) ? attribute_escape( bb_path_to_url( $theme . 'screenshot.png' ) ) : false;31 $screen_shot = file_exists( $theme . 'screenshot.png' ) ? clean_url( bb_get_theme_uri( $theme . 'screenshot.png' ) ) : false; 32 32 $activation_url = clean_url( bb_nonce_url( add_query_arg( 'theme', urlencode($theme), bb_get_option( 'uri' ) . 'bb-admin/themes.php' ), 'switch-theme' ) ); 33 33 ?> -
trunk/bb-includes/deprecated.php
r824 r838 297 297 endif; 298 298 299 // It's not omnipotent 300 function bb_path_to_url( $path ) { 301 return apply_filters( 'bb_path_to_url', bb_convert_path_base( $path, BBPATH, bb_get_option( 'uri' ) ), $path ); 302 } 303 304 // Neither is this one 305 function bb_url_to_path( $url ) { 306 return apply_filters( 'bb_url_to_path', bb_convert_path_base( $url, bb_get_option( 'uri' ), BBPATH ), $url ); 307 } 308 309 function bb_convert_path_base( $path, $from_base, $to_base ) { 310 $last_char = $path{strlen($path)-1}; 311 if ( '/' != $last_char && '\\' != $last_char ) 312 $last_char = ''; 313 314 list($from_base, $to_base) = bb_trim_common_path_right($from_base, $to_base); 315 316 if ( 0 === strpos( $path, $from_base ) ) 317 $r = $to_base . substr($path, strlen($from_base)) . $last_char; 318 else 319 return false; 320 321 $r = str_replace(array('//', '\\\\'), array('/', '\\'), $r); 322 $r = preg_replace('|:/([^/])|', '://$1', $r); 323 324 return $r; 325 } 326 327 function bb_trim_common_path_right( $one, $two ) { 328 $root_one = false; 329 $root_two = false; 330 331 while ( false === $root_one ) { 332 $base_one = basename($one); 333 $base_two = basename($two); 334 if ( !$base_one || !$base_two ) 335 break; 336 if ( $base_one == $base_two ) { 337 $one = dirname($one); 338 $two = dirname($two); 339 } else { 340 $root_one = $one; 341 $root_two = $two; 342 } 343 } 344 345 return array($root_one, $root_two); 346 } 347 299 348 ?> -
trunk/bb-includes/functions.php
r834 r838 1697 1697 } 1698 1698 1699 // It's not omnipotent1700 function bb_path_to_url( $path ) {1701 return apply_filters( 'bb_path_to_url', bb_convert_path_base( $path, BBPATH, bb_get_option( 'uri' ) ), $path );1702 }1703 1704 // Neither is this one1705 function bb_url_to_path( $url ) {1706 return apply_filters( 'bb_url_to_path', bb_convert_path_base( $url, bb_get_option( 'uri' ), BBPATH ), $url );1707 }1708 1709 function bb_convert_path_base( $path, $from_base, $to_base ) {1710 $last_char = $path{strlen($path)-1};1711 if ( '/' != $last_char && '\\' != $last_char )1712 $last_char = '';1713 1714 list($from_base, $to_base) = bb_trim_common_path_right($from_base, $to_base);1715 1716 if ( 0 === strpos( $path, $from_base ) )1717 $r = $to_base . substr($path, strlen($from_base)) . $last_char;1718 else1719 return false;1720 1721 $r = str_replace(array('//', '\\\\'), array('/', '\\'), $r);1722 $r = preg_replace('|:/([^/])|', '://$1', $r);1723 1724 return $r;1725 }1726 1727 function bb_trim_common_path_right( $one, $two ) {1728 $root_one = false;1729 $root_two = false;1730 1731 while ( false === $root_one ) {1732 $base_one = basename($one);1733 $base_two = basename($two);1734 if ( !$base_one || !$base_two )1735 break;1736 if ( $base_one == $base_two ) {1737 $one = dirname($one);1738 $two = dirname($two);1739 } else {1740 $root_one = $one;1741 $root_two = $two;1742 }1743 }1744 1745 return array($root_one, $root_two);1746 }1747 1748 1699 /* Profile/Admin */ 1749 1700 … … 2029 1980 } 2030 1981 1982 function bb_get_plugin_uri( $plugin = false ) { 1983 if ( !$plugin ) 1984 $r = BBPLUGINURL; 1985 elseif ( 0 === strpos($plugin, BBPLUGINDIR) ) 1986 $r = BBPLUGINURL . substr($plugin, strlen(BBPLUGINDIR)); 1987 else 1988 $r = false; 1989 1990 return apply_filters( 'bb_get_plugin_uri', $r, $plugin ); 1991 } 1992 2031 1993 /* Themes / Templates */ 2032 1994 -
trunk/bb-includes/template-functions.php
r836 r838 70 70 71 71 function bb_get_active_theme_uri() { 72 return apply_filters( 'bb_get_active_theme_uri', bb_path_to_url( bb_get_active_theme_folder() ) ); 72 if ( !$active_theme = bb_get_option( 'bb_active_theme' ) ) 73 $active_theme = BBPATH . 'bb-templates/kakumei/'; 74 return apply_filters( 'bb_get_active_theme_uri', bb_get_theme_uri( $active_theme ) ); 75 } 76 77 function bb_get_theme_uri( $theme = false ) { 78 if ( !$theme ) 79 $r = BBTHEMEURL; 80 elseif ( 0 === strpos($theme, BBTHEMEDIR) ) 81 $r = BBTHEMEURL . substr($theme, strlen(BBTHEMEDIR)); 82 elseif ( 0 === strpos($theme, BBPATH) ) 83 $r = bb_get_option( 'uri' ) . substr($theme, strlen(BBPATH)); 84 else 85 $r = false; 86 87 return apply_filters( 'bb_get_theme_uri', $r, $theme ); 73 88 } 74 89 -
trunk/bb-settings.php
r835 r838 58 58 error_reporting(E_ALL ^ E_NOTICE); 59 59 60 if ( isset($bb->uri) ) { 61 $bb->domain = preg_replace('|(?<!/)/(?!/).*$|', '', $bb->uri); 62 $bb->path = substr($bb->uri, strlen($bb->domain)); 63 } elseif ( isset($bb->path) && isset($bb->domain) ) { 64 $bb->domain = rtrim($bb->domain, '/'); 65 $bb->path = '/' . ltrim($bb->path, '/'); 66 } else { 67 bb_die( '<code>$bb->uri</cade> must be set in your <code>config.php</code> file.' ); 68 } 69 70 foreach ( array('wp_site_url', 'wp_home', 'path') as $p ) 71 if ( isset($bb->$p) && $bb->$p ) 72 $bb->$p = rtrim($bb->$p, '/'); 73 unset($p); 74 75 $bb->path = "$bb->path/"; 76 $bb->uri = $bb->domain . $bb->path; 77 60 78 define('BBINC', 'bb-includes/'); 61 79 if ( !defined('BBLANGDIR') ) … … 63 81 if ( !defined('BBPLUGINDIR') ) 64 82 define('BBPLUGINDIR', BBPATH . 'my-plugins/'); 83 if ( !defined('BBPLUGINURL') ) 84 define('BBPLUGINURL', $bb->uri . 'my-plugins/'); 65 85 if ( !defined('BBTHEMEDIR') ) 66 86 define('BBTHEMEDIR', BBPATH . 'my-templates/'); 87 if ( !defined('BBTHEMEURL') ) 88 define('BBTHEMEDIR', $bb->uri . 'my-templates/'); 67 89 68 90 if ( extension_loaded('mysqli') ) { … … 144 166 $bbdb->usermeta = CUSTOM_USER_META_TABLE; 145 167 146 if ( isset($bb->uri) ) {147 $bb->domain = preg_replace('|(?<!/)/(?!/).*$|', '', $bb->uri);148 $bb->path = substr($bb->uri, strlen($bb->domain));149 } elseif ( isset($bb->path) && isset($bb->domain) ) {150 $bb->domain = rtrim($bb->domain, '/');151 $bb->path = '/' . ltrim($bb->path, '/');152 } else {153 bb_die( '<code>$bb->uri</cade> must be set in your <code>config.php</code> file.' );154 }155 156 foreach ( array('wp_site_url', 'wp_home', 'path') as $p )157 if ( isset($bb->$p) && $bb->$p )158 $bb->$p = rtrim($bb->$p, '/');159 unset($p);160 161 $bb->path = "$bb->path/";162 $bb->uri = $bb->domain . $bb->path;163 164 168 define('BBHASH', $bb->wp_siteurl ? md5($bb->wp_siteurl) : md5($bb_table_prefix) ); 165 169
Note: See TracChangeset
for help on using the changeset viewer.