102 lines
3.2 KiB
Plaintext
102 lines
3.2 KiB
Plaintext
<?php
|
|
/*
|
|
* Gallery - a web based photo album viewer and editor
|
|
* Copyright (C) 2000-2007 Bharat Mediratta
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License 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.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
/**
|
|
* Progress bar status
|
|
* @package Install
|
|
*/
|
|
class StatusTemplate {
|
|
/**
|
|
* Render the header (from <html> to the statusblock or the navbar)
|
|
*/
|
|
function renderHeader($renderStatusBlock=false) {
|
|
global $steps;
|
|
global $currentStep;
|
|
|
|
$templateData = array();
|
|
$templateData['MainPage']['showHeader'] = 1;
|
|
if ($renderStatusBlock) {
|
|
$templateData['MainPage']['showStatusBlock'] = 1;
|
|
}
|
|
include(dirname(__FILE__) . '/templates/MainPage.html');
|
|
}
|
|
|
|
/**
|
|
* Render a single status message
|
|
* @param string $title the status title
|
|
* @param string $description the status description
|
|
* @param float $percentComplete ranging from 0 to 1
|
|
* @return object GalleryStatus a status code
|
|
*/
|
|
function renderStatusMessage($title, $description, $percentComplete) {
|
|
$templateData = array();
|
|
$templateData['MainPage']['showStatus'] = 1;
|
|
$templateData['MainPage']['status'] = array(
|
|
'title' => $title,
|
|
'description' => $description,
|
|
'percentComplete' => GalleryUtilities::roundToString($percentComplete, 2));
|
|
include(dirname(__FILE__) . '/templates/MainPage.html');
|
|
flush();
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Render the body and footer (everything below the status message)
|
|
* @param array $templateData
|
|
*/
|
|
function renderBodyAndFooter($templateData) {
|
|
global $steps;
|
|
global $currentStep;
|
|
global $stepNumber;
|
|
|
|
$stepsComplete = max($stepNumber - ($currentStep->isComplete() ? 0 : 1), 0);
|
|
$templateData['percentComplete'] =
|
|
(int)((100 * ($stepsComplete / (sizeof($steps)-1))) / 5) * 5;
|
|
|
|
$templateData['MainPage']['showBodyAndFooter'] = 1;
|
|
include(dirname(__FILE__) . '/templates/MainPage.html');
|
|
}
|
|
|
|
/**
|
|
* Hide the status block
|
|
*/
|
|
function hideStatusBlock() {
|
|
$templateData = array();
|
|
$templateData['MainPage']['hideStatusBlock'] = 1;
|
|
include(dirname(__FILE__) . '/templates/MainPage.html');
|
|
}
|
|
|
|
/**
|
|
* Render the whole page, except for the status block and messages. This is the way
|
|
* that we render most pages that don't have interactive status messages.
|
|
* @param array $templateData
|
|
*/
|
|
function renderHeaderBodyAndFooter($templateData) {
|
|
/*
|
|
* This is a little inefficient because we're loading MainPage twice. But we're not
|
|
* required to be really efficient here, and this is a nice way to compose it.
|
|
*/
|
|
$this->renderHeader();
|
|
$this->renderBodyAndFooter($templateData);
|
|
}
|
|
}
|
|
?>
|