diff -r 299a90e28abc -r 87e08a6e4fec install/includes/ui.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/install/includes/ui.php Wed Jan 16 13:55:49 2008 -0500
@@ -0,0 +1,243 @@
+ section
+ * @var array Will be implode()'ed
+ */
+
+ var $additional_headers = array();
+
+ /**
+ * Constructor.
+ * @param string The name displayed in the
tag
+ * @param bool If true, the simplified header format is displayed.
+ */
+
+ function __construct($app_name, $simple_header)
+ {
+ $this->stages = array(
+ 'main' => array(),
+ 'hide' => array()
+ );
+ $this->app_name = $app_name;
+ $this->simple = ( $simple_header ) ? true : false;
+ }
+
+ /**
+ * Adds more text to the HTML header.
+ * @param string
+ */
+
+ function add_header($html)
+ {
+ $this->additional_headers[] = $html;
+ }
+
+ /**
+ * Adds a stage to the installer.
+ * @param string Title of the stage, should be already put through $lang->get()
+ * @param bool If true, the stage is shown among possible stages at the top of the window. If false, acts as a hidden stage
+ * @return string Unique identifier for stage, used later on set_visible_stage()
+ */
+
+ function add_stage($stage, $visible = true)
+ {
+ $key = ( $visible ) ? 'main' : 'hide';
+ $guid = md5(microtime() . mt_rand());
+ $this->stages[$key][$guid] = $stage;
+ if ( empty($this->current_stage) )
+ $this->current_stage = $guid;
+ return $guid;
+ }
+
+ /**
+ * Resets the active stage of installation. This is for the UI only; it doesn't actually change how the backend works.
+ * @param string GUID of stage, returned from add_stage()
+ * @return bool true on success, false if stage GUID not found
+ */
+
+ function set_visible_stage($guid)
+ {
+ foreach ( $this->stages['main'] as $key => $stage_name )
+ {
+ if ( $key == $guid )
+ {
+ $this->current_stage = $guid;
+ return true;
+ }
+ }
+ foreach ( $this->stages['hide'] as $key => $stage_name )
+ {
+ if ( $key == $guid )
+ {
+ $this->current_stage = $guid;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Outputs the HTML headers and start of the , including stage indicator
+ */
+
+ function show_header()
+ {
+ // Determine the name of the current stage
+ $stage_name = false;
+
+ if ( isset($this->stages['main'][$this->current_stage]) )
+ $stage_name = $this->stages['main'][$this->current_stage];
+ else if ( isset($this->stages['hide'][$this->current_stage]) )
+ $stage_name = $this->stages['hide'][$this->current_stage];
+ else
+ // Can't determine name of stage
+ return false;
+
+ $this->app_name = htmlspecialchars($this->app_name);
+ $stage_name = htmlspecialchars($stage_name);
+
+ global $lang;
+ if ( is_object($lang) && isset($GLOBALS['lang_uri']) )
+ {
+ $lang_uri = sprintf($GLOBALS['lang_uri'], $lang->lang_code);
+ $this->add_header('');
+ }
+
+ $additional_headers = implode("\n ", $this->additional_headers);
+ $title = addslashes(str_replace(' ', '_', $stage_name));
+ $js_dynamic = '';
+
+ echo <<
+
+
+ {$stage_name} • {$this->app_name}
+
+
+
+ $js_dynamic
+
+ $additional_headers
+
+
+
+
+EOF;
+ if ( !$this->simple )
+ {
+ $step = ( !empty($this->step) ) ? '
' . htmlspecialchars($this->step) . '
' : '';
+ echo <<
+
+EOF;
+ }
+ $stages_class = ( $this->simple ) ? 'stages' : 'stages stages-fixed';
+ echo <<
+
+
+EOF;
+ foreach ( $this->stages['main'] as $guid => $stage )
+ {
+ $class = ( $guid == $this->current_stage ) ? 'stage stage-active' : 'stage';
+ $stage = htmlspecialchars($stage);
+ echo " - $stage
\n ";
+ }
+ echo "
\n \n \n";
+ echo " \n ";
+ echo "
\n ";
+ }
+
+ /**
+ * Displays the page footer.
+ */
+
+ function show_footer()
+ {
+ echo <<
+ Enano and its various components, related documentation, and artwork are copyright © 2006-2008 Dan Fuhry.
+ This program is Free Software; see the file "GPL" included with this package for details.
+
+
+
+
+
+
+EOF;
+ }
+
+}
+
+?>