Seid Gegrüßt,
bin gerade dabei eine wizard-Klasse zu erstellen, mit der man relativ simple später beliebig viele wizards(als ui-Benutzerführung) erstellen kann.
Dabei sollte u.a. die Verwaltung der Seiten mittels pageObjecte realisiert werden.Ein Pageobject soll dabei erzeugt werden, das jeweils die Seite verwaltet (methoden: iscurrent | show | validate). Irgendwie komm ich damit aber nicht weiter. Anbei meine bescheidenen Ansätze:
und jetzt eine abgeleitete Klasse
Nur page Objekte hab ich da noch nicht ... Ich warte mal auf ein schlaues Brainstorming
Thanxs
Trallala
bin gerade dabei eine wizard-Klasse zu erstellen, mit der man relativ simple später beliebig viele wizards(als ui-Benutzerführung) erstellen kann.
Dabei sollte u.a. die Verwaltung der Seiten mittels pageObjecte realisiert werden.Ein Pageobject soll dabei erzeugt werden, das jeweils die Seite verwaltet (methoden: iscurrent | show | validate). Irgendwie komm ich damit aber nicht weiter. Anbei meine bescheidenen Ansätze:
PHP-Code:
abstract class wizardBase
{
protected $pages = array();
protected $currentpage;
protected $numpages;
protected $_npwValidationCandidates=array();
public function __construct()
{
if (isset($_SESSION['wizard']))
$this->wSession=$_SESSION['wizard'];
}
protected function addCurrentPage($currentpage)
{
$this->currentpage=$currentpage;
$this->showPage($this->currentpage);
}
protected function addPageArray($page)
{
foreach ($page AS $item)
$this->pages[]=$item;
$this->numpages=count($this->pages);
}
protected function addValidationCandidatesArray($array)
{
for($i=1;$i<=count($array);$i++)
$this->_npwValidationCandidates[$i]=$array[$i];
print_r($this->_npwValidationCandidates);
}
protected function gotoNextPage()
{
if (($this->currentpage < $this->numpages) && ($this->currentpage != $this->numpages))
{
$this->currentpage+=1;
$this->showPage($this->currentpage);
}
else
{
echo "niemals!";
}
}
protected function gotoPreviousPage()
{
}
/**
* cancel Wizard
* @return unset wizard-session-array
**/
protected function cancel()
{
unset($this->wSession);
header("Location: index.php/Hauptseite");
}
public function finish()
{
}
/**
* generate ToolbarButtons as a function of currentpage & numpages
*@ return buttonArray
**/
function showButtons()
{
$buttons['cancel']='enabled';
/* disable prevButton on 1st page */
if ($this->currentpage == '1')
$buttons['prev']='disabled';
/* disablenextButton on last page */
if ($this->currentpage == $this->numpages)
{
$buttons['next']='disabled';
$buttons['finish']='enabled';
}
else
{
$buttons['next']='enabled';
$buttons['finish']='disabled';
}
return $this->buttons=$buttons;
}
public function showPage($_npwCurrentPage)
{
global $wgOut;
$wgOut->setPageTitle(wfMsg('editing', $this->mTitle->mTextform));
$this->showPageIntro($_npwCurrentPage);
$this->showPageBody($_npwCurrentPage);
$this->showPageToolbarButtons($_npwCurrentPage);
}
public function errorMesage($mess)
{
}
}
PHP-Code:
<?php
class newPageWizard
extends wizardBase
{
private $_npwCurrentPage = NULL;
private $_npwPageArray = array();
public $_npwValidationCandidates=array();
public function __construct()
{
global $wgRequest, $wgTitle;
$this->mTitle=&$wgTitle;
/*initialize currentpage , pageArray */
$_npwCurrentPage='1';
if ($wgRequest->getVal('page'))
$_npwCurrentPage=$wgRequest->getVal('page');
$_npwPageArray=array
(
"setTitle",
"selectCat",
"selectPattern",
"saveNews"
);
$_npwValidationCandidates[1]=array
(
"news_title",
"news_topic"
);
$this->initialize($_npwCurrentPage, $_npwPageArray,$_npwValidationCandidates);
if ($wgRequest->getVal('news_cancel'))
parent::cancel();
if ($wgRequest->getVal('button_next'))
parent::getNextCard();
}
private function initialize($_npwCurrentPage, $_npwPageArray, $_npwValidationCandidates)
{
$this->addCurrentPage($_npwCurrentPage);
$this->addPageArray($_npwPageArray);
$this->addValidationCandidatesArray($_npwValidationCandidates);
}
Thanxs
Trallala

Kommentar