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