Blame Scripts/Php/Newbb2Phpbb/classes/html.php

878a2b
878a2b
/***
878a2b
 * HTML - Used to htmlblock html code.
878a2b
 */
878a2b
878a2b
class HTML
878a2b
{
878a2b
878a2b
   /***
878a2b
    * Format html htmlblock
878a2b
    */
878a2b
    function format_htmlblock( $htmlblock = array() )
878a2b
    {
878a2b
        $html_formatted = '';
878a2b
878a2b
        // Define amount of tabs
878a2b
        $tabs = array(0 => '',
878a2b
                      1 => "\t",
878a2b
                      2 => "\t\t",
878a2b
                      3 => "\t\t\t",
878a2b
                      4 => "\t\t\t\t",
878a2b
                      5 => "\t\t\t\t\t");
878a2b
878a2b
        // Define indententaion level by tags
878a2b
        $levels = array('/<\/?html/'                                                     => 0,
878a2b
                        '/<\/?(body|head)( .+|>)/'                                       => 1,
878a2b
                        '/<\/?(title)( .+|>)/'                                           => 2,
878a2b
                        '/<\/?(br|hr) \/>/'                                              => 2,
878a2b
                        '/<\/?(p|pre|table|dl|ul|ol|div|h[1-9]|form|link)( .+|>)/'       => 3,
878a2b
                        '/<\/?(li|dt|dd|span|select|option|tr)( .+|>)/'                  => 4,
878a2b
                        '/<\/?(th|td)( .+|>)/'                                           => 5);
878a2b
878a2b
        // Set line level, line by line
878a2b
        foreach ( $htmlblock as $line )
878a2b
        {
878a2b
            foreach ( $levels as $tag => $level )
878a2b
            {
878a2b
                if ( preg_match( $tag, $line ) )
878a2b
                {
878a2b
                    $html_formatted .= $tabs[$level] . $line . "\n";
878a2b
                }
878a2b
            
878a2b
            }
878a2b
        }
878a2b
878a2b
        return $html_formatted;
878a2b
    }
878a2b
878a2b
   /***
878a2b
    * Format messages
878a2b
    *
878a2b
    * $message  : the message text itself.
878a2b
    * $color    : grey|green|orange|blue|violet|red
878a2b
    *             if no color is specified grey color is assumed as default
878a2b
    */
878a2b
    function format_message( $message = 'Empty', $color = '' )
878a2b
    {
878a2b
        // Validate color to be used
878a2b
        $valid_colors = array('grey', 'green', 'orange', 'violet', 'blue', 'red');
878a2b
        if ( ! in_array( $color, $valid_colors ) )
878a2b
        {
878a2b
            $color = ''; 
878a2b
        }
878a2b
878a2b
        // Build message html
878a2b
        $html = '
' . strtoupper($message) . '
';
878a2b
878a2b
        return $html;
878a2b
    }
878a2b
878a2b
   /***
878a2b
    * Where is my position in the migration ?
878a2b
    * ----------------------------------------------------
878a2b
    * It is somehow a breadcrumb of where you are in the migration process.
878a2b
    */
878a2b
    function get_stepPosition()
878a2b
    {
878a2b
        // Define migration process stepts
878a2b
        $steps = array(0 => 'Configuration',
878a2b
                       1 => 'Verification',
878a2b
                       2 => 'Migration', 
878a2b
                       3 => 'Reset Passwords');
878a2b
878a2b
        $position = isset( $_POST['step'] )?$_POST['step']:0;
878a2b
   
878a2b
        $htmlblock = array('
    ');
878a2b
878a2b
        foreach ( $steps as $key => $value )
878a2b
        {
878a2b
            if ( $position == $key)
878a2b
            {
878a2b
                array_push($htmlblock,'
  • '. $value.'
  • ');
    878a2b
                }
    878a2b
                else
    878a2b
                {
    878a2b
                    array_push($htmlblock,'
  • '. $value.'
  • ');
    878a2b
                }
    878a2b
            }
    878a2b
            
    878a2b
            array_push( $htmlblock, '');
    878a2b
    878a2b
            return $htmlblock;
    878a2b
        }
    878a2b
    878a2b
       /***
    878a2b
        * Navibar
    878a2b
        */
    878a2b
        function get_navibar()
    878a2b
        {
    878a2b
            global $db;
    878a2b
    878a2b
            $htmlblock = array('
      ');
    878a2b
    878a2b
            if ( isset($_GET['p']) && $_GET['p'] == 'help' )
    878a2b
            {
    878a2b
                array_push($htmlblock, '
  • Main
  • ');
    878a2b
                array_push($htmlblock, '
  • Help
  • ');
    878a2b
            }
    878a2b
            else
    878a2b
            {
    878a2b
                array_push($htmlblock, '
  • Main
  • ');
    878a2b
                array_push($htmlblock, '
  • Help
  • ');
    878a2b
            }
    878a2b
    878a2b
            array_push( $htmlblock, '');
    878a2b
    878a2b
            return $htmlblock;
    878a2b
        }
    878a2b
    }
    878a2b
    878a2b
    $html = new HTML;
    878a2b
    ?>