• 2009年4月 5日(日) 03:52 JST
  • 投稿者:
    augebang
  • 閲覧数
    1,518

管理画面表示をテーマprofessional固定にする1.5系

Geeklog1.4系列で使えていた
「管理画面表示をテーマprofessional固定にする」が
1.5系列でも使えるとGeeklogSNSであいび~さんが紹介されてました。

このハックを使うとテーマに依存することなく管理画面はprofessionalに
固定されるので管理がしやすくなります。
方法はGeeklogWikiにも書かれてますが

lib-common.phpに以下の記述を書き加えます。

// 管理画面ならprofessionalテーマに ---->
if( strpos( $_SERVER['PHP_SELF'], '/admin/' ) !== false ){
$_CONF['theme'] = 'professional';
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
// 管理画面ならprofessionalテーマに <---- 

場所の目安としては

// Set theme

を探してください、それは以下のコードでひとくくりです。

// Set theme
// Need to modify this code to check if theme was cached in user cookie.  That
// way if user logged in and set theme and then logged out we would still know
// which theme to show them.

$usetheme = '';
if( isset( $_POST['usetheme'] ))
{
    $usetheme = COM_sanitizeFilename($_POST['usetheme'], true);
}
if( !empty( $usetheme ) && is_dir( $_CONF['path_themes'] . $usetheme ))
{
    $_CONF['theme'] = $usetheme;
    $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
    $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
else if( $_CONF['allow_user_themes'] == 1 )
{
    if( isset( $_COOKIE[$_CONF['cookie_theme']] ) && empty( $_USER['theme'] ))
    {
        $theme = COM_sanitizeFilename($_COOKIE[$_CONF['cookie_theme']], true);
        if( is_dir( $_CONF['path_themes'] . $theme ))
        {
            $_USER['theme'] = $theme;
        }
    }

    if( !empty( $_USER['theme'] ))
    {
        if( is_dir( $_CONF['path_themes'] . $_USER['theme'] ))
        {
            $_CONF['theme'] = $_USER['theme'];
            $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
            $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
        }
        else
        {
            $_USER['theme'] = $_CONF['theme'];
        }
    }
}

この下に先のコードを書き加えます、すると以下のようになります。

// Set theme
// Need to modify this code to check if theme was cached in user cookie.  That
// way if user logged in and set theme and then logged out we would still know
// which theme to show them.

$usetheme = '';
if( isset( $_POST['usetheme'] ))
{
    $usetheme = COM_sanitizeFilename($_POST['usetheme'], true);
}
if( !empty( $usetheme ) && is_dir( $_CONF['path_themes'] . $usetheme ))
{
    $_CONF['theme'] = $usetheme;
    $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
    $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
else if( $_CONF['allow_user_themes'] == 1 )
{
    if( isset( $_COOKIE[$_CONF['cookie_theme']] ) && empty( $_USER['theme'] ))
    {
        $theme = COM_sanitizeFilename($_COOKIE[$_CONF['cookie_theme']], true);
        if( is_dir( $_CONF['path_themes'] . $theme ))
        {
            $_USER['theme'] = $theme;
        }
    }

    if( !empty( $_USER['theme'] ))
    {
        if( is_dir( $_CONF['path_themes'] . $_USER['theme'] ))
        {
            $_CONF['theme'] = $_USER['theme'];
            $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
            $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
        }
        else
        {
            $_USER['theme'] = $_CONF['theme'];
        }
    }
}
// 管理画面ならprofessionalテーマに ---->
   if( strpos( $_SERVER['PHP_SELF'], '/admin/' ) !== false ){
           $_CONF['theme'] = 'professional';
           $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
           $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
   }
// 管理画面ならprofessionalテーマに <---- 

修正したものをアップロードすれば完了です。

トラックバック

このエントリのトラックバックURL:
http://gltmatrix.com/trackback.php/professionakotei15

サイト管理者はコメントに関する責任を負いません。