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