記事カテゴリ

ユーザー機能


 2024年4月30日(火) 12:33 JST

フッタに左ブロックを書こう!

  • 投稿者:
  • 表示回数
    5,100

Geeklog Japan で左ブロックをフッタに記載する方法について、昨年から掲示板に書いていたのですが

結局 Geeklog ってまだまだなのよ♪
安定性、堅牢性、機能、熟成度いずれも及第点は上げられません。
今回の問題は一言で言うと Geeklog の熟成度の不足、作者の考慮不足って所でしょうか?
熟成度が上がっていくと今回のような問題点は次第になくなっていくかと思います。

具体的には、ヘッダ出力関数とフッタ出力関数で左右のブロックの取扱が非対称であると言うこと。
Geeklog は左ブロックをヘッダ側テンプレート、フッタ側テンプレートのいずれにも配置することが出来るのですが、作者は左側に配置するものという固定概念がどこかに残っているようです。このためフッタ側に左ブロックを配置したときの動きがおかしくなっています。

標準のプラグインも本体に合わせて作られているためか、静的ページプラグインもこれに対応していません。というか、本体が悪くてどうしようもないというところでしょうか?

そこで、くろねこは静的ページプラグインと、lib-common.php を修正することになったのですが、最終的には lib-common.php は変更しなくてもテーマ別カスタム関数をいじれば対応可能でした。
方法は Geeklog Japan Wikiに書いたのでLeftblockinFooterを参照してください。

出来た functions.php を以下に転載します。
また、くろねこ研究所ダウンロードからもダウンロードできるようにしておきます。

テーマ別 funtions.php

    global $HTTP_POST_VARS, $HTTP_GET_VARS,$LANG_JPN;
    //@@@@@ 20050705,20060207 add youkoso xxx san  <-----

    // >>> 2006/12/27 BlackCat for staticpages noblocks
    global $g_what;
    $g_what = $what;
    // <<< 2006/12/27 BlackCat for staticpages noblocks

    // send out the charset header

    if( empty( $LANG_CHARSET )) {
        $charset = $_CONF['default_charset'];
        if( empty( $charset )) {
            $charset = 'iso-8859-1';
        }
    } else {
        $charset = $LANG_CHARSET;
    }
    header ('Content-Type: text/html; charset=' . $charset);

    // If we reach here then either we have the default theme OR
    // the current theme only needs the default variable substitutions

    $header = new Template( $_CONF['path_layout'] );
    $header->set_file( array(
        'header'        => 'header.thtml',
        'menuitem'      => 'menuitem.thtml',
        'menuitem_last' => 'menuitem_last.thtml',
        'menuitem_none' => 'menuitem_none.thtml',
        'leftblocks'    => 'leftblocks.thtml'
        ));

    // get topic if not on home page
    if( !isset( $_GET['topic'] ))
    {
        if( isset( $_GET['story'] ))
        {
            $sid = COM_applyFilter( $_GET['story'] );
        }
        elseif( isset( $_GET['sid'] ))
        {
            $sid = COM_applyFilter( $_GET['sid'] );
        }
        elseif( isset( $_POST['story'] ))
        {
            $sid = COM_applyFilter( $_POST['story'] );
        }
        if( empty( $sid ) && $_CONF['url_rewrite'] &&
                ( strpos( $_SERVER['PHP_SELF'], 'article.php' ) !== false ))
        {
            COM_setArgNames( array( 'story', 'mode' ));
            $sid = COM_applyFilter( COM_getArgument( 'story' ));
        }
        if( !empty( $sid ))
        {
            $topic = DB_getItem( $_TABLES['stories'], 'tid', "sid='$sid'" );
        }
    }
    else
    {
        $topic = COM_applyFilter( $_GET['topic'] );
    }

    $feed_url = '';
    if( $_CONF['backend'] == 1 ) // add feed-link to header if applicable
    {
        $baseurl = SYND_getFeedUrl();

        $sql = 'SELECT format, filename, title FROM '
             . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
        if( !empty( $topic ))
        {
            $sql .= " OR (header_tid = '" . addslashes( $topic ) . "')";
        }
        $result = DB_query( $sql );
        $numRows = DB_numRows( $result );
        for( $i = 0; $i < $numRows; $i++ )
        {
            $A = DB_fetchArray( $result );
            if ( !empty( $A['filename'] ))
            {
                $format = explode( '-', $A['format'] );
                $format_type = strtolower( $format[0] );
                $format_name = ucwords( $format[0] );

                $feed_url .= '' . LB;
            }
        }
    }
    $header->set_var( 'feed_url', $feed_url );

    if( empty( $pagetitle ) && isset( $_CONF['pagetitle'] ))
    {
        $pagetitle = $_CONF['pagetitle'];
    }
    if( empty( $pagetitle ))
    {
        if( empty( $topic ))
        {
            $pagetitle = $_CONF['site_slogan'];
        }
        else
        {
            $pagetitle = stripslashes( DB_getItem( $_TABLES['topics'], 'topic',
                                                   "tid = '$topic'" ));
        }
    }
    if( !empty( $pagetitle ))
    {
        $pagetitle = ' - ' . $pagetitle;
    }
    $header->set_var( 'page_title', $_CONF['site_name'] . $pagetitle );

    if( isset( $_CONF['advanced_editor'] ) && ( $_CONF['advanced_editor'] == 1 )
            && file_exists( $_CONF['path_layout']
                            . 'advanced_editor_header.thtml' ))
    {
        $header->set_file( 'editor'  , 'advanced_editor_header.thtml');
        $header->parse( 'advanced_editor', 'editor' );

    }
    else
    {
         $header->set_var( 'advanced_editor', '' );
    }

    $header->set_var( 'background_image', $_CONF['layout_url']
                                          . '/images/bg.' . $_IMAGE_TYPE );
    $header->set_var( 'site_url', $_CONF['site_url'] );
    $header->set_var( 'layout_url', $_CONF['layout_url'] );
    $header->set_var( 'site_mail', "mailto:{$_CONF['site_mail']}" );
    $header->set_var( 'site_name', $_CONF['site_name'] );
    $header->set_var( 'site_slogan', $_CONF['site_slogan'] );
    $rdf = substr_replace( $_CONF['rdf_file'], $_CONF['site_url'], 0,
                           strlen( $_CONF['path_html'] ) - 1 );
    $header->set_var( 'rdf_file', $rdf );
    $header->set_var( 'rss_url', $rdf );

    //@@@@@ 20050805,20060207 update youkoso xxx san  ----->
    //               youkoso xxxx san
    //$msg = $LANG01[67] . ' ' . $_CONF['site_name'];
    //if( !empty( $_USER['username'] ))
    //{
    //    $msg .= ', ' . $_USER['username'];
    //}

    //@@@@@ 20060513 update youkoso xxx san by komma Geeklog Japanese ----->

    //@@@@@ 2006/05/13 mystral_kk added -->
	if ($_USER['uid'] >= 2) {
	    $prof_url = "{$_CONF['site_url']}/users.php?mode=profile&uid={$_USER['uid']}";
	} else {
	    $prof_url = "{$_CONF['site_url']}/";
	}
    $header->set_var( 'prof_url', $prof_url );
    //@@@@@ 2006/05/13 mystral_kk added -->

    $msg ="";
    if( !empty( $_USER['username'] ))
    {
        $msg = $LANG01[67];
        $msg .= ' ' . $_USER['username'].$LANG_JPN[1];
    }
    //@@@@@ 20050805,20060207 update youkoso xxx san   <-----

    $curtime =  COM_getUserDateTimeFormat();

    $header->set_var( 'welcome_msg', $msg );
    $header->set_var( 'datetime', $curtime[0] );
    $header->set_var( 'site_logo', $_CONF['layout_url']
                                   . '/images/logo.' . $_IMAGE_TYPE );
    $header->set_var( 'css_url', $_CONF['layout_url'] . '/style.css' );
    $header->set_var( 'theme', $_CONF['theme'] );

    if( empty( $LANG_CHARSET ))
    {
        $charset = $_CONF['default_charset'];

        if( empty( $charset ))
        {
            $charset = 'iso-8859-1';
        }
    }
    else
    {
        $charset = $LANG_CHARSET;
    }

    $header->set_var( 'charset', $charset );
    if( empty( $LANG_DIRECTION ))
    {
        // default to left-to-right
        $header->set_var( 'direction', 'ltr' );
    }
    else
    {
        $header->set_var( 'direction', $LANG_DIRECTION );
    }

    // Now add variables for buttons like e.g. those used by the Yahoo theme
    $header->set_var( 'button_home', $LANG_BUTTONS[1] );
    $header->set_var( 'button_contact', $LANG_BUTTONS[2] );
    $header->set_var( 'button_contribute', $LANG_BUTTONS[3] );
    $header->set_var( 'button_calendar', $LANG_BUTTONS[6] );
    $header->set_var( 'button_sitestats', $LANG_BUTTONS[7] );
    $header->set_var( 'button_personalize', $LANG_BUTTONS[8] );
    $header->set_var( 'button_search', $LANG_BUTTONS[9] );
    $header->set_var( 'button_advsearch', $LANG_BUTTONS[10] );
    $header->set_var( 'button_directory', $LANG_BUTTONS[11] );

    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();

    if( $_COM_VERBOSE )
    {
        COM_errorLog( 'num plugin menu items in header = ' . count( $plugin_menu ), 1 );
    }

    // Now add nested template for menu items
    COM_renderMenu( $header, $plugin_menu );

    if( count( $plugin_menu ) == 0 )
    {
        $header->parse( 'plg_menu_elements', 'menuitem_none', true );
    }
    else
    {
        for( $i = 1; $i <= count( $plugin_menu ); $i++ )
        {
            $header->set_var( 'menuitem_url', current( $plugin_menu ));
            $header->set_var( 'menuitem_text', key( $plugin_menu ));

            if( $i == count( $plugin_menu ))
            {
                $header->parse( 'plg_menu_elements', 'menuitem_last', true );
            }
            else
            {
                $header->parse( 'plg_menu_elements', 'menuitem', true );
            }

            next( $plugin_menu );
        }
    }

//    if( $_CONF['left_blocks_in_footer'] == 1 )
//    {
//        $header->set_var( 'geeklog_blocks', '' );
//        $header->set_var( 'left_blocks', '' );
//    }
//    else
//    {
        $lblocks = '';

        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if( is_array( $what ))
        {
            $function = $what[0];
            if( function_exists( $function ))
            {
                $lblocks = $function( $what[1], 'left' );
            }
        }
        else if( $what <> 'none' )
        {
            // Now show any blocks -- need to get the topic if not on home page
            $lblocks = COM_showBlocks( 'left', $topic );
        }

        if( empty( $lblocks ))
        {
            $header->set_var( 'geeklog_blocks', '' );
            $header->set_var( 'left_blocks', '' );
        }
        else
        {
            $header->set_var( 'geeklog_blocks', $lblocks );
            $header->parse( 'left_blocks', 'leftblocks', true );
        }
//    }

    // Call any plugin that may want to include extra Meta tags
    // or Javascript functions
    $header->set_var( 'plg_headercode', $headercode . PLG_getHeaderCode() );

    // Call to plugins to set template variables in the header
    PLG_templateSetVars( 'header', $header );

    // The following lines allow users to embed PHP in their templates.  This
    // is almost a contradition to the reasons for using templates but this may
    // prove useful at times ...
    // Don't use PHP in templates if you can live without it!

    $tmp = $header->parse( 'index_header', 'header' );

    ob_start();
    eval( '?>' . $tmp );
    $retval = ob_get_contents();
    ob_end_clean();

    return $retval;
}


/**
* Returns the site footer
*
* This loads the proper templates, does variable substitution and returns the
* HTML for the site footer.
*
* @param   boolean     $rightblock     Whether or not to show blocks on right hand side default is no
* @param   array       $custom         An array defining custom function to be used to format Rightblocks
* @see function COM_siteHeader
* @return   string  Formated HTML containing site footer and optionally right blocks
*
*/
function BlackCat_siteFooter( $rightblock = -1, $custom = '' )
{
    global $_CONF, $_TABLES, $LANG01, $LANG_BUTTONS, $_PAGE_TIMER, $topic;

    // >>> 2006/12/27 BlackCat for staticpages noblocks
    global $g_what;
    $what = $g_what;
    // <<< 2006/12/27 BlackCat for staticpages noblocks

    // Set template directory
    $footer = new Template( $_CONF['path_layout'] );

    // Set template file
    $footer->set_file( array(
            'footer'      => 'footer.thtml',
            'rightblocks' => 'rightblocks.thtml',
            'leftblocks'  => 'leftblocks.thtml'
            ));

    // Do variable assignments
    DB_change( $_TABLES['vars'], 'value', 'value + 1', 'name', 'totalhits', '', true );

    // Now add variables for buttons like e.g. those used by the Yahoo theme
    $footer->set_var( 'button_home', $LANG_BUTTONS[1] );
    $footer->set_var( 'button_contact', $LANG_BUTTONS[2] );
    $footer->set_var( 'button_contribute', $LANG_BUTTONS[3] );
    $footer->set_var( 'button_calendar', $LANG_BUTTONS[6] );
    $footer->set_var( 'button_sitestats', $LANG_BUTTONS[7] );
    $footer->set_var( 'button_personalize', $LANG_BUTTONS[8] );
    $footer->set_var( 'button_search', $LANG_BUTTONS[9] );
    $footer->set_var( 'button_advsearch', $LANG_BUTTONS[10] );
    $footer->set_var( 'button_directory', $LANG_BUTTONS[11] );

    $footer->set_var( 'site_url', $_CONF['site_url']);
    $footer->set_var( 'layout_url',$_CONF['layout_url']);
    $footer->set_var( 'site_mail', "mailto:{$_CONF['site_mail']}" );
    $footer->set_var( 'site_name', $_CONF['site_name'] );
    $footer->set_var( 'site_slogan', $_CONF['site_slogan'] );
    $rdf = substr_replace( $_CONF['rdf_file'], $_CONF['site_url'], 0,
                           strlen( $_CONF['path_html'] ) - 1 );
    $footer->set_var( 'rdf_file', $rdf );
    $footer->set_var( 'rss_url', $rdf );

    $year = date( 'Y' );
    $copyrightyear = $year;
    if( !empty( $_CONF['copyrightyear'] ))
    {
        $copyrightyear = $_CONF['copyrightyear'];
    }
    $footer->set_var( 'copyright_notice', ' ' . $LANG01[93] . ' © '
            . $copyrightyear . ' ' . $_CONF['site_name'] . '
 ' . $LANG01[94] ); $footer->set_var( 'copyright_msg', $LANG01[93] . ' © ' . $copyrightyear . ' ' . $_CONF['site_name'] ); $footer->set_var( 'current_year', $year ); $footer->set_var( 'lang_copyright', $LANG01[93] ); $footer->set_var( 'trademark_msg', $LANG01[94] ); $footer->set_var( 'powered_by', $LANG01[95] ); $footer->set_var( 'geeklog_url', 'http://www.geeklog.net/' ); $footer->set_var( 'geeklog_version', VERSION ); /* Check if an array has been passed that includes the name of a plugin * function or custom function. * This can be used to take control over what blocks are then displayed */ if( is_array( $custom )) { $function = $custom['0']; if( function_exists( $function )) { $rblocks = $function( $custom['1'], 'right' ); } } elseif( $rightblock ) { $rblocks = COM_showBlocks( 'right', $topic ); } if( $rightblock && !empty( $rblocks )) { $footer->set_var( 'geeklog_blocks', $rblocks ); $footer->parse( 'right_blocks', 'rightblocks', true ); } else { $footer->set_var( 'geeklog_blocks', '' ); $footer->set_var( 'right_blocks', '' ); } // if( $_CONF['left_blocks_in_footer'] == 1 ) // { $lblocks = ''; /* Check if an array has been passed that includes the name of a plugin * function or custom function * This can be used to take control over what blocks are then displayed */ if( is_array( $what )) { $function = $what[0]; if( function_exists( $function )) { $lblocks = $function( $what[1], 'left' ); } } else if ( $what <> 'none' ) { $lblocks = COM_showBlocks( 'left', $topic ); } if( empty( $lblocks )) { $footer->set_var( 'geeklog_blocks', '' ); $footer->set_var( 'left_blocks', '' ); } else { $footer->set_var( 'geeklog_blocks', $lblocks ); $footer->parse( 'left_blocks', 'leftblocks', true ); } // } // Global centerspan variable set in index.php if( isset( $GLOBALS['centerspan'] )) { $footer->set_var( 'centerblockfooter-span', '' ); } $exectime = $_PAGE_TIMER->stopTimer(); $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92]; $footer->set_var( 'execution_time', $exectime ); $footer->set_var( 'execution_textandtime', $exectext ); // Call to plugins to set template variables in the footer PLG_templateSetVars( 'footer', $footer ); // Actually parse the template and make variable substitutions $footer->parse( 'index_footer', 'footer' ); // Return resulting HTML return $footer->finish( $footer->get_var( 'index_footer' )); } ?>

トラックバック

このエントリのトラックバックURL:
https://www.blackcat.xyz/trackback.php/070110_geeklog_leftbrocks

以下のコメントは、その投稿者が所有するものでサイト管理者はコメントに関する責任を負いません。