User:Chughakshay16/sample
Appearance
class LayoutManager
{
static $displayList;
public static function add($component)
{
}
public static function remove($component)
{
}
}
abstract class UIComponentClass
{
// attribute properties
var $globalAttributes = array('class'=>''
,'id'=>''
,'dir'=>''
,'lang'=>''
,'tabindex'=>''
,'title'=>''
,'xml:lang'=>''
,'style'=>'');
var $parent;
var $styler;
var $root;
var $displayIndex;
var $HTMLText='';
public function getAttributeHTML()
{
$attributeHTML = '';
foreach($this->globalAttributes as $key=>$value)
{
$attributeHTML.= $value==false?"":"$key = '$value' ";
}
return $attributeHTML;
}
public function setParent($parent)
{
$this->parent= $parent;
}
public function getParent()
{
return $this->parent;
}
public function setRoot()
{
$this->root=$root;
}
public function getRoot()
{
return $this->root;
}
public function getStyler()
{
return $this->styler;
}
public function setStyler($styler)
{
$this->styler = $styler;
}
public function getDisplayIndex()
{
return $this->displayIndex;
}
public function setDisplayIndex($displayIndex)
{
$this->displayIndex=$displayIndex;
}
public function render()
{
global $wgOut;
$wgOut->addHTML($this->draw());
}
abstract public function draw();
}
class DivContainer extends UIComponentClass
{
var $childList = array();
public function __construct()
{
$this->styler = CSSFactory::factory(CSSFactory::DIV);
}
public function addChild($child)
{
$this->childList[]=$child;
$child->setParent($this);
}
public function addChildAt($index,$child)
{
$this->childList[$index]=$child;
}
public function contains($child)
{
return in_array($child,$this->childList);
}
public function getChildByName($childName)
{
foreach($this->childList as $key=>$value)
{
if($key==$childName)
return $value;
}
}
public function getChildIndex($child)
{
foreach($this->childList as $key=>$value)
{
if($value===$child)
return $key;
}
}
public function removeChild($child)
{
}
public function swapChildren($childOld,$childNew)
{
}
public function removeChildAt($index)
{
}
public function removeChildren($children)
{
}
public function draw()
{
foreach($this->childList as $key=>$child)
{
$this->HTMLText.=$child->draw();
}
$this->wrapUp();
return $this->HTMLText;
}
private function wrapUp()
{
$this->HTMLText.='<div'.$this->getAttributeHTML().'>'.$this->HTMLText.'</div>';
}
}
class VectorPanel extends DivContainer
{
public function __construct()
{
$this->addChild(new LogoBox());
$this->addChild(new NavigationBox());
$this->addChild(new NavigationBox());
}
}
class LogoBox extends DIVContainer
{
public function __construct()
{
$this->addChild(new AnchorElement());
}
}
class NavigationBox extends DivContainer
{
public function __construct()
{
$this->addChild(new Heading('',HeadingTypes::H5));
$div = new DivContainer();
$list = new ListElement(4);
$div->addChild($list);
$this->addChild($div);
}
}
class Heading extends UIComponentClass
{
var $headingText='';
var $headingType=HeadingTypes::H1;
public function __construct($headingText='',$headingType =HeadingTypes::H1)
{
$this->headingText = $headingText;
$this->headingType = $headingType;
}
public function draw()
{
$this->HTMLText = "<$this->headingType></$this->headingType>";
return $this->HTMLText;
}
public function bind()
{
}
}
class HeadingTypes
{
const H1 = 'h1';
const H2 = 'h2';
const H3 = 'h3';
const H4 = 'h4';
const H5 = 'h5';
const H6 = 'h6';
}
class AnchorElement extends UIComponentClass
{
var $anchorAttributes = array(
'href'=>'',
'rel'=>'',
'hreflang'=>'',
'target'=>'',
'type'=>'',
'media'=>'');
public function draw()
{
$this->HTMLText.= "<a ".$this->getAttributeHTML()."></a>";
return $this->HTMLText;
}
public function getAttributeHTML()
{
$attributeHtml = parent::getAttributeHTML();
foreach($this->anchorAttributes as $key=>$value)
{
$attributeHtml.= $value==false?"":"$key = '$value' ";
}
return $attributeHtml;
}
}
class ListElement extends UIComponentClass
{
var $listItems = array();
public function __construct($size)
{
for($i=0;$i<$size;$i++)
{
$this->listItems[]=new ListItemElement();
}
}
public function draw()
{
foreach($this->listItems as $item)
{
$this->HTMLText.= $item->draw();
}
$this->HTMLText = "<ul".$this->getAttributeHTML().">".$this->HTMLText."</ul>";
return $this->HTMLText;
}
}
class ListItemElement extends UIComponentClass
{
var $childItems = array();
public function __construct()
{
$this->childItems[]=new AnchorElement();
}
public function draw()
{
foreach($this->childItems as $value)
{
$this->HTMLText.= $value->draw();
}
$this->HTMLText ="<li".$this->getAttributeHTML().">".$this->HTMLText."</li>";
return $this->HTMLText;
}
}
</code><br/>
And this is how we create this object<br/>
<code>
class ConfigureConferencePage extends SpecialPage
{
function __construct(){
parent::__construct('ConfigurationPage','',false,false,'default',false);
}
function execute($par){
$panel = new VectorPanel();
$panel->render();
}
}