Source for file standard.php
Documentation is available at standard.php
* @copyright 2009-2010 NADEO
require_once( APP_FRAMEWORK_GUI_TOOLKIT_PATH.
'GuiTools.class.php' );
require_once( APP_FRAMEWORK_GUI_TOOLKIT_PATH.
'GuiDefaultStyles.class.php' );
* The GuiComponent is a generic and abstract element that only contains
* position, size and scale info.
* Sets the X position of the element
* Sets the Y position of the element
* Sets the Z position of the element
* Sets the position of the element
* Sets the width of the element
* Sets the height of the element
* Sets the size of the element
* Sets the scale factor of the element. 1=original size, 2=double size, 0.5
* Returns the X position of the element
* Returns the Y position of the element
* Returns the Z position of the element
* Returns the width of the element
* Returns the height of the element
* Returns the scale of the element
* Base class for creating GUI elements
protected $valign =
null;
protected $halign =
null;
protected $xmlTagName =
'xmltag'; // Redeclare this for each child
* Manialink element default constructor. It's common to specify the size of
* the element in the constructor.
* @param float Width of the element
* @param float Height of the element
* Sets the style of the element. See http://fish.stabb.de/styles/ of the
* manialink 'example' for more information on Manialink styles.
* Sets the sub-style of the element. See http://fish.stabb.de/styles/ of
* the manialink 'example' for more information on Manialink styles.
$this->subStyle =
$substyle;
* Sets the vertical alignment of the element.
* @param string Vertical alignment can be either "top", "center" or
* Sets the horizontal alignment of the element
* @param string Horizontal alignement can be eithe "left", "center" or
* Sets the alignment of the element
* @param string Horizontal alignement can be eithe "left", "center" or
* @param string Vertical alignment can be either "top", "center" or
function setAlign($halign =
null, $valign =
null)
* Sets the Manialink of the element. It works as a hyperlink.
* @param string Can be either a short Manialink or an URL pointing to a
$this->manialink =
$manialink;
* Sets the hyperlink of the element
* Sets the Maniazones link of the element
$this->maniazone =
$maniazone;
* Adds the player information parameters ("playerlogin", "nickname",
* "path", "lang") to the URL when you click on the link
* Sets the action of the element. For example, if you use the action "0" in
* the explorer, it closes the explorer when you click on the element.
* Sets the action key associated to the element. Only works on dedicated
$this->actionKey =
$actionKey;
* Sets the background color of the element using a 3-digit RGB hexadecimal
* value. For example, "fff" is white and "000" is black
* @param string 3-digit RGB hexadecimal value
$this->bgcolor =
$bgcolor;
* Applies an image to the element. If you don't specify the second
* parameter, it will look for the image in the path defined by the
* APP_IMAGE_DIR_URL constant
* @param string The image filename (or URL)
* @param string The URL that will be appended to the image. Use null if you
* want to specify an absolute URL as first parameter
function setImage($image, $absoluteUrl =
APP_IMAGE_DIR_URL)
$this->image =
$absoluteUrl .
$image;
* Set the image id of the element, used for internationalization
$this->imageid =
$imageid;
* Applies an image to the highlighter state of the element. The second
* parameter works just like GuiElement::setImage()
* @param string The image filename (or URL)
* @param string The URL that will be appended to the image. Use null if you
* want to specify an absolute URL as first parameter
function setImageFocus($imageFocus, $absoluteUrl =
APP_IMAGE_DIR_URL)
$this->imageFocus =
$absoluteUrl .
$imageFocus;
$this->imageFocus =
$imageFocus;
* Set the image focus id of the element, used for internationalization
* Returns the style of the element
* Returns the substyle of the element
* Returns the horizontal alignment of the element
* Returns the vertical alignment of the element
* Returns the Manialink hyperlink of the element
* Returns the Maniazones hyperlink of the element
* Returns the hyperlink of the element
* Returns the action associated to the element
* Returns the action key associated to the element
* Returns whether the elements adds player information parameter to the URL
return $this->addPlayerId;
* Returns the background color of the element
* @return string 3-digit RGB hexadecimal value
* Returns the image placed in the element
* @return string The image URL
* Returns the image placed in the element in its highlighted state
* @return string The image URL
return $this->imageFocus;
return $this->imageFocusid;
* Imports links and actions from another Manialink element
* @param GuiElement The source object
function addLink(GuiElement $object)
$this->manialink =
$object->getManialink();
$this->url =
$object->getUrl();
$this->maniazone =
$object->getManiazone();
$this->action =
$object->getAction();
$this->actionKey =
$object->getActionKey();
if($object->getAddPlayerId())
* Returns whether the object has a link or an action (either Manialink,
* Maniazones link, hyperlink or action)
return $this->manialink ||
$this->url ||
$this->action ||
$this->maniazone;
* Override this method in subclasses to perform some action before
protected function preFilter()
* Override this method in subclasses to perform some action after rendering
protected function postFilter()
* Saves the object in the Manialink object stack for further rendering.
* Thanks to the use of GuiElement::preFilter() and GuiElement::
* postFilter(), you shouldn't have to override this method
// Optional pre filtering
if($layout instanceof
AbstractLayout)
$layout->preFilter($this);
$this->posX +=
$layout->xIndex;
$this->posY +=
$layout->yIndex;
$this->posZ +=
$layout->zIndex;
$this->xml =
Manialink::$domDocument->createElement($this->xmlTagName);
end(Manialink::$parentNodes)->appendChild($this->xml);
if($this->posX ||
$this->posY ||
$this->posZ)
$this->xml->setAttribute('posn',
$this->posX.
' '.
$this->posY.
' '.
$this->posZ);
if($this->sizeX ||
$this->sizeY)
$this->xml->setAttribute('sizen', $this->sizeX.
' '.
$this->sizeY);
if($this->halign !==
null)
$this->xml->setAttribute('halign', $this->halign);
if($this->valign !==
null)
$this->xml->setAttribute('valign', $this->valign);
if($this->scale !==
null)
$this->xml->setAttribute('scale', $this->scale);
if($this->style !==
null)
$this->xml->setAttribute('style', $this->style);
if($this->subStyle !==
null)
$this->xml->setAttribute('substyle', $this->subStyle);
if($this->bgcolor !==
null)
$this->xml->setAttribute('bgcolor', $this->bgcolor);
if($this->addPlayerId !==
null &&
Manialink::$linksEnabled)
$this->xml->setAttribute('addplayerid', $this->addPlayerId);
if($this->manialink !==
null &&
Manialink::$linksEnabled)
$this->xml->setAttribute('manialink', $this->manialink);
if($this->url !==
null &&
Manialink::$linksEnabled)
$this->xml->setAttribute('url', $this->url);
if($this->maniazone !==
null &&
Manialink::$linksEnabled)
$this->xml->setAttribute('maniazone', $this->maniazone);
if($this->action !==
null)
$this->xml->setAttribute('action', $this->action);
if($this->actionKey !==
null)
$this->xml->setAttribute('actionkey', $this->actionKey);
if($this->image !==
null)
$this->xml->setAttribute('image', $this->image);
if($this->imageid !==
null)
$this->xml->setAttribute('imageid', $this->imageid);
if($this->imageFocus !==
null)
$this->xml->setAttribute('imagefocus', $this->imageFocus);
if($this->imageFocusid !==
null)
$this->xml->setAttribute('imagefocusid', $this->imageFocusid);
$layout->postFilter($this);
* A blank element, useful to place gaps between elements when using layouts
protected $xmlTagName =
null;
* Manialink <b>style</b> for the <b>Quad</b> element
protected $xmlTagName =
'quad';
protected $style =
GuiDefaultStyles::Quad_Style;
protected $subStyle =
GuiDefaultStyles::Quad_Substyle;
* Should be abstract some day, use classes like "Icons128x128_1" instead
protected $style =
GuiDefaultStyles::Icon_Style;
protected $subStyle =
GuiDefaultStyles::Icon_Substyle;
protected $style =
Quad::Bgs1;
protected $subStyle =
self::BgWindow1;
protected $style =
Quad::Bgs1InRace;
protected $style =
Quad::BgRaceScore2;
protected $subStyle =
self::BgCardServer;
* BgsChallengeMedals quad
protected $style =
Quad::BgsChallengeMedals;
protected $subStyle =
self::BgBronze;
protected $style =
Quad::BgsPlayerCard;
protected $subStyle =
self::BgActivePlayerCard;
protected $style =
Quad::Icons128x128_1;
protected $subStyle =
self::Forever;
protected $style =
Quad::Icons128x32_1;
protected $subStyle =
self::RT_Cup;
protected $style =
Quad::Icons64x64_1;
protected $subStyle =
self::GenericButton;
protected $style =
Quad::MedalsBig;
protected $subStyle =
self::MedalBronze;
* @deprecated Use Icons64x64_1 instead
class Icon64 extends Icon
protected $style =
GuiDefaultStyles::Icon64_Style;
protected $subStyle =
GuiDefaultStyles::Icon64_Substyle;
* @deprecated Use Icons128x32_1 instead
class Icon128 extends Icon
protected $style =
GuiDefaultStyles::Icon128_Style;
protected $subStyle =
GuiDefaultStyles::Icon128_Substyle;
* @deprecated Use MedalsBig instead
class IconMedal extends Icon
protected $style =
GuiDefaultStyles::IconMedal_Style;
protected $subStyle =
GuiDefaultStyles::IconMedal_Substyle;
* Manialink include tag, used to include another Manialink file inside a Manialink
* Use the setUrl() method
* Manialink::redirectManialink() is a shortcut
* Manialink <b>styles</b> for the <b>Format</b> element and its children
protected $xmlTagName =
'format';
protected $halign =
null;
protected $valign =
null;
protected $subStyle =
null;
$this->textSize =
$textsize;
* @param string 3-digit RGB hexadecimal value
$this->textColor =
$textcolor;
* @return string 3-digit RGB hexadecimal value
protected function postFilter()
if($this->textSize !==
null)
$this->xml->setAttribute('textsize', $this->textSize);
if($this->textColor !==
null)
$this->xml->setAttribute('textcolor', $this->textColor);
protected $xmlTagName =
'label';
protected $style =
GuiDefaultStyles::Label_Style;
* Sets the text Id for use with Manialink dictionaries
* Sets the maximum number of lines to display
$this->maxline =
$maxline;
* Enables wraping the text into several lines if the line is too short
* Returns the maximum number of lines to display
* Returns whether word wrapping is enabled
return $this->autonewline;
protected function postFilter()
$this->xml->setAttribute('text', $this->text);
$this->xml->setAttribute('text', TMStrings::stripLinks($this->text));
if($this->textid !==
null)
$this->xml->setAttribute('textid', $this->textid);
$this->xml->setAttribute('textid', TMStrings::stripLinks($this->textid));
if($this->autonewline !==
null)
$this->xml->setAttribute('autonewline', $this->autonewline);
if($this->maxline !==
null)
$this->xml->setAttribute('maxline', $this->maxline);
* Input field for Manialinks
protected $xmlTagName =
'entry';
protected $style =
GuiDefaultStyles::Entry_Style;
* Sets the name of the entry. Will be used as the parameter name in the URL
* when submitting the page
* Sets the default value of the entry
$this->defaultValue =
$value;
* Returns the name of the entry
* Returns the default value of the entry
return $this->defaultValue;
protected function postFilter()
$this->xml->setAttribute('name', $this->name);
if($this->defaultValue !==
null)
$this->xml->setAttribute('default', $this->defaultValue);
* File input field for Manialinks
protected $xmlTagName =
'fileentry';
* Sets the default folder
* Returns the default folder
protected function postFilter()
if($this->folder !==
null)
$this->xml->setAttribute('folder', $this->folder);
protected $subStyle =
null;
protected $style =
GuiDefaultStyles::Button_Style;
protected $xmlTagName =
'music';
protected $halign =
null;
protected $valign =
null;
* Sets the data to play. If you don't specify the second parameter, it will
* look for the image in the path defined by the APP_DATA_DIR_URL constant
* @param string The image filename (or URL)
* @param string The URL that will be appended to the image. Use null if you
* want to specify an absolute URL as first parameter
function setData($filename, $absoluteUrl =
APP_DATA_DIR_URL)
$this->data =
$absoluteUrl .
$filename;
protected function postFilter()
$this->xml->setAttribute('data', $this->data);
protected $xmlTagName =
'music';
* Autoplay the data when it's done loading
* Loop when the end of the data is reached
* Returns whether auto playing is enabled
* Returns whether looping is enabled
protected function postFilter()
$this->xml->setAttribute('play', $this->play);
if($this->looping !==
null)
$this->xml->setAttribute('looping', $this->looping);
protected $xmlTagName =
'video';