Fork me on GitHub

Theme Select Core Block  Bottom

  • Hi,

    I have begin a Theme Select Block.

    It works at 90% as you can see at top right of

    http://imagicweb.com

    I have a problem with retrieving the current URL, as the "thelang.php" block does

    I have tried to use the "thelang.php" way of calling the currentURL, but it has not worked for me.

    Can someone help me to finish this block?

    THANKS!

    copy, save as themes.php and put in includes/blocks
    go to the blocks admin panel, new block - > Core/Select Theme
    enjoy, and... report bugs! (or help)

    Code

    <?
    // File: $Id: themes.php,v 0.1 2004/02/17 22:26:15 jeanloui Exp $ $Name:  $
    // ----------------------------------------------------------------------
    // POST-NUKE Content Management System
    // Copyright (C) 2001 by the Post-Nuke Development Team.
    // http://www.postnuke.com/
    // ----------------------------------------------------------------------
    // Based on:
    // PHP-NUKE Web Portal System - http://phpnuke.org/
    // Thatware - http://thatware.org/
    // ----------------------------------------------------------------------
    // LICENSE
    //
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License (GPL)
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // To read the license please visit http://www.gnu.org/copyleft/gpl.html
    // ----------------------------------------------------------------------
    // Original Author of file: Xavier Blanquer at imagicweb.com
    // Purpose of file: simple theme select menublock
    // ----------------------------------------------------------------------

    $blocks_modules['themes'] = array(
        'func_display' => 'blocks_themes_block',
        'text_type' => 'Themes',
       
        // this will be the name of the new block : Core/Select Theme
        'text_type_long' => 'Select Theme',
        'allow_multiple' => false,
        'form_content' => false,
        'form_refresh' => false,
       
        // I supose THIS BLOCK can support xhtml..., I uncomment
        'support_xhtml' => true,
        'show_preview' => true
    );

    // Security
    pnSecAddSchema('Themesblock::', 'Block title::');

    function blocks_themes_block($row) {

        if (!pnSecAuthAction(0, 'Themesblock::', "$row[title]::", ACCESS_OVERVIEW)) {
            return;
        }
       
        // we don't need here the db connection ?
        // list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        $currentlang = pnUserGetLang();
        
        // block actions
        
        // get the theme of the user
        $current_theme = pnUserGetTheme();
        
        // clean the previous current URL
        $currentURL = "";

        
        // get the current URL --------- HELP NEEDED HERE ---------------
        $currentURL = $_SERVER['REQUEST_URI'];
        
        
    //  CURRENTURL by thelang.php -----------

    //  $currentURL = $_SERVER['REQUEST_URI'];
    //  if ($currentURL === "") { $currentURL = "index.php"; }
    //  $pattern = '/\?newlang=.../';
    //  $currentURL = preg_replace ($pattern, '', $currentURL);
    //  $pattern = '/\&newlang=.../';
    //  $currentURL = pnVarPrepForDisplay(preg_replace ($pattern, '', $currentURL));
    //  $append = "&amp;";
    //
    //  if (strpos($currentURL, '?') === false) { $append = "?"; }
       
       
        $my_content = "\n\n<form name=\"change_theme\" method=\"post\" action=\"index.php\">\n\n";
        $my_content .= "<select name =\"selected_theme\" onChange=\"top.location.href=this.options[this.selectedIndex].value\" class=\"pn-text\">\n\n";

        $handle = opendir('themes');
        while (false !== ($file = readdir($handle))) {
       
            if ($file == $current_theme) {
            $selected = " selected /";}
            else
            {
            $selected = "";
            }
           
            // avoid listing of unappropiate files in the themes directory
           
            if ($file != "." && $file != ".." && $file != "index.html" && $file != ".DS_Store") {
            $my_content .= "<option value=index.php?theme=" . $file ."&".$currentURL. $selected . ">" . $file . "</option>\n\n";
        }
        }
       
        // don't forget to close the dir
        closedir($handle);
       

        $my_content .= "\n</select>\n";
        $my_content .= "</form>\n\n";

        // common on all the blocks:
       
        if (empty($row['title'])) {
        $row['title'] = _THEMESELECT;
           
        // where must this be defined? in language/global.php ?
        }
       
        $row['content'] = $my_content;
        return themesideblock($row);
    }
    ?>
  • 0 users

This list is based on users active over the last 60 minutes.