UI - WizardClass and PageObjects

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rupo
Forum Commoner
Posts: 25
Joined: Thu Jul 05, 2007 11:22 am

UI - WizardClass and PageObjects

Post by Rupo »

Hi,

at the moment I'm working hard on a wizardClass, which should task easy creating wizard. Accordingly, a pageobject should arrange the pages width methods: iscurrent | show | is valid

Code: Select all

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)
        {
        }

    }
And now a new newswizard, as a kind of wizardBase

Code: Select all

<?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);
        }
At the moment there are no pageobjects, and I've no idea who to build them and set the interaction ...
Tahnks for some brainstorming

Greetz
Rupo
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm having a tough time figuring out the meat of your post. What's the point of the thread?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I think he wants to know how to build and interact with pageobjects.
Rupo
Forum Commoner
Posts: 25
Joined: Thu Jul 05, 2007 11:22 am

Post by Rupo »

Well,

creating a wizardBaseClass, which allows to create several wizards. Which means creating UI-guided steps, to do some jobs, for instance to add new news to a wiki system (4-steps: selTitle|selCat|selPattern|saveText)

Therefore its the job to create pageobjects of each step. But I've at the moment no idea how to build them and which informations these Objects should contain and finally how to place an interaction.

so long
Rupo
Rupo
Forum Commoner
Posts: 25
Joined: Thu Jul 05, 2007 11:22 am

Post by Rupo »

astions wrote:I think he wants to know how to build and interact with pageobjects.
that' wright ... some hints?
Post Reply