1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
<?php
/**
***********************************************************************************************
* @copyright 2004-2016 The Admidio Team
* @see http://www.admidio.org/
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 only
***********************************************************************************************
*/
/**
* @class HtmlFormInstallation
* @brief Create the html script for an installation / update form
*
* This class will create the complete html for a installation / update page.
* First you set the modus (update or installation) and then you can optional
* add custom text to the page. The main configuration part will be the
* form. You can use the complete methods of the Form class.
* @par Examples
* @code // create a simple installation form with a free text, a text field and a submit button
* $form = new HtmlFormInstallation('installation-form', 'next_html_page.php');
* $form->setText('This is an example.');
* $form->addSubmitButton('next_page', $gL10n->get('SYS_NEXT'), array('icon' => 'layout/forward.png', 'type' => 'button'));
* $form->show();
* @endcode
*/
class HtmlFormInstallation extends HtmlForm
{
private $descriptionTitle; ///< A title for the description of the form. This will be displayed as h2
private $descriptionText; ///< A text that will be shown after the headline before the form will be set
private $headline; ///< Headline of the form
private $title; ///< Title of the html page
/**
* Constructor creates the form element
* @param string $id Id of the form
* @param string $action Optional action attribute of the form
*/
public function __construct($id, $action)
{
parent::__construct($id, $action);
$this->descriptionText = '';
$this->descriptionTitle = '';
}
/**
* If the method is called then a text with an optional title will be displayed after
* the headline before the form will be displayed.
* @param string $description The (html) text that should be shown.
* @param string $title The headline of the description. If set than this will be displayed
* before the description as h2
*/
public function setFormDescription($description, $title = '')
{
$this->descriptionText = $description;
$this->descriptionTitle = $title;
}
/**
* Set the form in the installation modus. Therefore headline and title will be changed.
* This is the default modus and will be set automatically if not modus is set in the calling code.
*/
public function setInstallationModus()
{
global $gL10n;
$this->title = $gL10n->get('INS_INSTALLATION');
$this->headline = $gL10n->get('INS_INSTALLATION_VERSION', ADMIDIO_VERSION_TEXT);
}
/**
* Set the form in the update modus. Therefore headline and title will be changed.
*/
public function setUpdateModus()
{
global $gL10n;
$this->title = $gL10n->get('INS_UPDATE');
$this->headline = $gL10n->get('INS_UPDATE_VERSION', ADMIDIO_VERSION_TEXT);
}
/**
* This method will create the whole html installation/update code. It will show the headline,
* text and the configured form. If no modus is set the installation modus will be set here.
* @param bool $directOutput This is only used for compatibility to show method of parent class HtmlForm
* @return string Return the html code of the form.
*/
public function show($directOutput = true)
{
global $gL10n;
// if no modus set then set installation modus
if ($this->title === '')
{
$this->setInstallationModus();
}
header('Content-type: text/html; charset=utf-8');
$html = '
<!DOCTYPE html>
<html>
<head>
<!-- (c) 2004 - 2016 The Admidio Team - http://www.admidio.org -->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="Admidio Team" />
<meta name="robots" content="noindex" />
<title>Admidio - ' . $this->title . '</title>
<link rel="shortcut icon" type="image/x-icon" href="layout/favicon.png" />
<link rel="stylesheet" type="text/css" href="../libs/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="layout/admidio.css" />
<script type="text/javascript" src="../libs/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../libs/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../system/js/common_functions.js"></script>
</head>
<body>
<div class="admidio-container" id="adm_content">
<img id="admidio-logo" src="layout/logo.png" alt="Logo" />
<h1>' . $this->headline . '</h1>';
// if set then show description
if ($this->descriptionText !== '')
{
if ($this->descriptionTitle !== '')
{
$html .= '<h3>' . $this->descriptionTitle . '</h3>';
}
$html .= '<p>' . $this->descriptionText . '</p>';
}
// now show the configured form
$html .= parent::show(false);
$html .= '</div>
</body>
</html>';
return $html;
}
}