TeamSpeak 3 PHP Framework  1.1.16
Copyright © Planet TeamSpeak. All rights reserved.
 All Classes Namespaces Files Functions Variables Pages
TeamSpeak3_Viewer_Html Class Reference

Renders nodes used in HTML-based TeamSpeak 3 viewers. More...

+ Inheritance diagram for TeamSpeak3_Viewer_Html:

Public Member Functions

 __construct ($iconpath="images/viewer/", $flagpath=null, $ftclient=null, $pattern=null)
 The TeamSpeak3_Viewer_Html constructor.
 
 fetchObject (TeamSpeak3_Node_Abstract $node, array $siblings=array())
 Returns the code needed to display a node in a TeamSpeak 3 viewer.
 

Protected Member Functions

 getContainerIdent ()
 Returns a unique identifier for the current node which can be used as a HTML id property.
 
 getContainerClass ()
 Returns a dynamic string for the current container element which can be used as a HTML class property.
 
 getContainerSummary ()
 Returns the ID of the current node which will be used as a summary element for the container element.
 
 getRowClass ()
 Returns a dynamic string for the current row element which can be used as a HTML class property.
 
 getPrefixClass ()
 Returns a string for the current prefix element which can be used as a HTML class property.
 
 getPrefix ()
 Returns the HTML img tags to display the prefix of the current node.
 
 getCorpusClass ()
 Returns a string for the current corpus element which can be used as a HTML class property.
 
 getCorpusTitle ()
 Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Abstract object.
 
 getCorpusIcon ()
 Returns a HTML img tag which can be used to display the status icon for a TeamSpeak_Node_Abstract object.
 
 getCorpusName ()
 Returns a string for the current corpus element which contains the display name for the current TeamSpeak_Node_Abstract object.
 
 getSuffixClass ()
 Returns a string for the current suffix element which can be used as a HTML class property.
 
 getSuffixIcon ()
 Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Abstract object.
 
 getSuffixIconServer ()
 Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Server object.
 
 getSuffixIconChannel ()
 Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Channel object.
 
 getSuffixIconClient ()
 Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Client object.
 
 getSuffixFlag ()
 Returns a HTML img tag which can be used to display the country flag for a TeamSpeak_Node_Client object.
 
 getImage ($name, $text="", $class=null, $iconpath=TRUE, $flagpath=FALSE)
 Returns the code to display a custom HTML img tag.
 

Protected Attributes

 $pattern = "<table id='%0' class='%1' summary='%2'><tr class='%3'><td class='%4'>%5</td><td class='%6' title='%7'>%8 %9</td><td class='%10'>%11%12</td></tr></table>\n"
 
 $currObj = null
 
 $currSib = null
 
 $currNum = 0
 
 $iconpath = null
 
 $flagpath = null
 
 $ftclient = null
 
 $cachedIcons = array(100, 200, 300, 400, 500, 600)
 
 $remoteIcons = array()
 

Detailed Description

Renders nodes used in HTML-based TeamSpeak 3 viewers.

Definition at line 32 of file Html.php.

Constructor & Destructor Documentation

TeamSpeak3_Viewer_Html::__construct (   $iconpath = "images/viewer/",
  $flagpath = null,
  $ftclient = null,
  $pattern = null 
)

The TeamSpeak3_Viewer_Html constructor.

Parameters
string$iconpath
string$flagpath
string$ftclient
string$pattern
Returns
void

Definition at line 107 of file Html.php.

{
$this->iconpath = $iconpath;
$this->flagpath = $flagpath;
$this->ftclient = $ftclient;
if($pattern)
{
$this->pattern = $pattern;
}
}

Member Function Documentation

TeamSpeak3_Viewer_Html::fetchObject ( TeamSpeak3_Node_Abstract  $node,
array  $siblings = array() 
)

Returns the code needed to display a node in a TeamSpeak 3 viewer.

Parameters
TeamSpeak3_Node_Abstract$node
array$siblings
Returns
string

Definition at line 126 of file Html.php.

References TeamSpeak3_Helper_String\factory(), getContainerClass(), getContainerIdent(), getContainerSummary(), getCorpusClass(), getCorpusIcon(), getCorpusName(), getCorpusTitle(), getPrefix(), getPrefixClass(), getRowClass(), getSuffixClass(), getSuffixFlag(), and getSuffixIcon().

{
$this->currObj = $node;
$this->currSib = $siblings;
$args = array(
$this->getRowClass(),
$this->getPrefixClass(),
$this->getPrefix(),
$this->getCorpusClass(),
$this->getCorpusTitle(),
$this->getCorpusIcon(),
$this->getCorpusName(),
$this->getSuffixClass(),
$this->getSuffixIcon(),
$this->getSuffixFlag(),
);
return TeamSpeak3_Helper_String::factory($this->pattern)->arg($args);
}
TeamSpeak3_Viewer_Html::getContainerIdent ( )
protected

Returns a unique identifier for the current node which can be used as a HTML id property.

Returns
string

Definition at line 156 of file Html.php.

Referenced by fetchObject().

{
return $this->currObj->getUniqueId();
}
TeamSpeak3_Viewer_Html::getContainerClass ( )
protected

Returns a dynamic string for the current container element which can be used as a HTML class property.

Returns
string

Definition at line 167 of file Html.php.

Referenced by fetchObject().

{
return "ts3_viewer " . $this->currObj->getClass(null);
}
TeamSpeak3_Viewer_Html::getContainerSummary ( )
protected

Returns the ID of the current node which will be used as a summary element for the container element.

Returns
integer

Definition at line 178 of file Html.php.

Referenced by fetchObject().

{
return $this->currObj->getId();
}
TeamSpeak3_Viewer_Html::getRowClass ( )
protected

Returns a dynamic string for the current row element which can be used as a HTML class property.

Returns
string

Definition at line 189 of file Html.php.

Referenced by fetchObject().

{
return ++$this->currNum%2 ? "row1" : "row2";
}
TeamSpeak3_Viewer_Html::getPrefixClass ( )
protected

Returns a string for the current prefix element which can be used as a HTML class property.

Returns
string

Definition at line 200 of file Html.php.

Referenced by fetchObject().

{
return "prefix " . $this->currObj->getClass(null);
}
TeamSpeak3_Viewer_Html::getPrefix ( )
protected

Returns the HTML img tags to display the prefix of the current node.

Returns
string

Definition at line 210 of file Html.php.

References getImage().

Referenced by fetchObject().

{
$prefix = "";
if(count($this->currSib))
{
$last = array_pop($this->currSib);
foreach($this->currSib as $sibling)
{
$prefix .= ($sibling) ? $this->getImage("tree_line.gif") : $this->getImage("tree_blank.png");
}
$prefix .= ($last) ? $this->getImage("tree_end.gif") : $this->getImage("tree_mid.gif");
}
return $prefix;
}
TeamSpeak3_Viewer_Html::getCorpusClass ( )
protected

Returns a string for the current corpus element which can be used as a HTML class property.

If the current node is a channel spacer the class string will contain additional class names to allow further customization of the content via CSS.

Returns
string

Definition at line 236 of file Html.php.

References TeamSpeak3_Node_Channel\isSpacer(), TeamSpeak3\SPACER_ALIGN_CENTER, TeamSpeak3\SPACER_ALIGN_LEFT, TeamSpeak3\SPACER_ALIGN_RIGHT, TeamSpeak3\SPACER_DASHDOTDOTLINE, TeamSpeak3\SPACER_DASHDOTLINE, TeamSpeak3\SPACER_DASHLINE, TeamSpeak3\SPACER_DOTLINE, and TeamSpeak3\SPACER_SOLIDLINE.

Referenced by fetchObject().

{
$extras = "";
if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer())
{
switch($this->currObj->spacerGetType())
{
$extras .= " solidline";
break;
$extras .= " dashline";
break;
$extras .= " dashdotline";
break;
$extras .= " dashdotdotline";
break;
$extras .= " dotline";
break;
}
switch($this->currObj->spacerGetAlign())
{
$extras .= " center";
break;
$extras .= " right";
break;
$extras .= " left";
break;
}
}
return "corpus " . $this->currObj->getClass(null) . $extras;
}
TeamSpeak3_Viewer_Html::getCorpusTitle ( )
protected

Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Abstract object.

Returns
string

Definition at line 290 of file Html.php.

References TeamSpeak3_Helper_Convert\codec(), TeamSpeak3_Helper_Convert\groupType(), TeamSpeak3_Node_Channel\isSpacer(), TeamSpeak3_Helper_Convert\seconds(), and TeamSpeak3_Helper_Convert\version().

Referenced by fetchObject().

{
if($this->currObj instanceof TeamSpeak3_Node_Server)
{
return "ID: " . $this->currObj->getId() . " | Clients: " . $this->currObj->clientCount() . "/" . $this->currObj["virtualserver_maxclients"] . " | Uptime: " . TeamSpeak3_Helper_Convert::seconds($this->currObj["virtualserver_uptime"]);
}
elseif($this->currObj instanceof TeamSpeak3_Node_Channel && !$this->currObj->isSpacer())
{
return "ID: " . $this->currObj->getId() . " | Codec: " . TeamSpeak3_Helper_Convert::codec($this->currObj["channel_codec"]) . " | Quality: " . $this->currObj["channel_codec_quality"];
}
elseif($this->currObj instanceof TeamSpeak3_Node_Client)
{
return "ID: " . $this->currObj->getId() . " | Version: " . TeamSpeak3_Helper_Convert::version($this->currObj["client_version"]) . " | Platform: " . $this->currObj["client_platform"];
}
elseif($this->currObj instanceof TeamSpeak3_Node_Servergroup || $this->currObj instanceof TeamSpeak3_Node_Channelgroup)
{
return "ID: " . $this->currObj->getId() . " | Type: " . TeamSpeak3_Helper_Convert::groupType($this->currObj["type"]) . " (" . ($this->currObj["savedb"] ? "Permanent" : "Temporary") . ")";
}
}
TeamSpeak3_Viewer_Html::getCorpusIcon ( )
protected

Returns a HTML img tag which can be used to display the status icon for a TeamSpeak_Node_Abstract object.

Returns
string

Definition at line 316 of file Html.php.

References getImage(), and TeamSpeak3_Node_Channel\isSpacer().

Referenced by fetchObject().

{
if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer()) return;
return $this->getImage($this->currObj->getIcon() . ".png");
}
TeamSpeak3_Viewer_Html::getCorpusName ( )
protected

Returns a string for the current corpus element which contains the display name for the current TeamSpeak_Node_Abstract object.

Returns
string

Definition at line 329 of file Html.php.

References TeamSpeak3\GROUP_NAMEMODE_BEFORE, TeamSpeak3\GROUP_NAMEMODE_BEHIND, TeamSpeak3_Node_Channel\isSpacer(), TeamSpeak3\SPACER_ALIGN_REPEAT, and TeamSpeak3\SPACER_CUSTOM.

Referenced by fetchObject().

{
if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer())
{
if($this->currObj->spacerGetType() != TeamSpeak3::SPACER_CUSTOM) return;
$string = $this->currObj["channel_name"]->section("]", 1, 99);
if($this->currObj->spacerGetAlign() == TeamSpeak3::SPACER_ALIGN_REPEAT)
{
$string->resize(30, $string);
}
return htmlspecialchars($string);
}
if($this->currObj instanceof TeamSpeak3_Node_Client)
{
$before = array();
$behind = array();
foreach($this->currObj->memberOf() as $group)
{
if($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEFORE)
{
$before[] = "[" . htmlspecialchars($group["name"]) . "]";
}
elseif($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEHIND)
{
$behind[] = "[" . htmlspecialchars($group["name"]) . "]";
}
}
return implode("", $before) . " " . htmlspecialchars($this->currObj) . " " . implode("", $behind);
}
return htmlspecialchars($this->currObj);
}
TeamSpeak3_Viewer_Html::getSuffixClass ( )
protected

Returns a string for the current suffix element which can be used as a HTML class property.

Returns
string

Definition at line 374 of file Html.php.

Referenced by fetchObject().

{
return "suffix " . $this->currObj->getClass(null);
}
TeamSpeak3_Viewer_Html::getSuffixIcon ( )
protected

Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Abstract object.

Returns
string

Definition at line 385 of file Html.php.

References getSuffixIconChannel(), getSuffixIconClient(), and getSuffixIconServer().

Referenced by fetchObject().

{
if($this->currObj instanceof TeamSpeak3_Node_Server)
{
return $this->getSuffixIconServer();
}
elseif($this->currObj instanceof TeamSpeak3_Node_Channel)
{
return $this->getSuffixIconChannel();
}
elseif($this->currObj instanceof TeamSpeak3_Node_Client)
{
return $this->getSuffixIconClient();
}
}
TeamSpeak3_Viewer_Html::getSuffixIconServer ( )
protected

Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Server object.

Returns
string

Definition at line 407 of file Html.php.

References TeamSpeak3\factory(), getImage(), and TeamSpeak3_Helper_Convert\imageMimeType().

Referenced by getSuffixIcon().

{
$html = "";
if($this->currObj["virtualserver_icon_id"])
{
if(!$this->currObj->iconIsLocal("virtualserver_icon_id") && $this->ftclient)
{
if(!isset($this->cacheIcon[$this->currObj["virtualserver_icon_id"]]))
{
$download = $this->currObj->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->currObj->iconGetName("virtualserver_icon_id"));
if($this->ftclient == "data:image")
{
$download = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
}
$this->cacheIcon[$this->currObj["virtualserver_icon_id"]] = $download;
}
else
{
$download = $this->cacheIcon[$this->currObj["virtualserver_icon_id"]];
}
if($this->ftclient == "data:image")
{
$html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Server Icon", null, FALSE);
}
else
{
$html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Server Icon", null, FALSE);
}
}
elseif(in_array($this->currObj["virtualserver_icon_id"], $this->cachedIcons))
{
$html .= $this->getImage("group_icon_" . $this->currObj["virtualserver_icon_id"] . ".png", "Server Icon");
}
}
return $html;
}
TeamSpeak3_Viewer_Html::getSuffixIconChannel ( )
protected

Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Channel object.

Returns
string

Definition at line 455 of file Html.php.

References TeamSpeak3\factory(), getImage(), TeamSpeak3_Helper_Convert\imageMimeType(), and TeamSpeak3_Node_Channel\isSpacer().

Referenced by getSuffixIcon().

{
if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer()) return;
$html = "";
if($this->currObj["channel_flag_default"])
{
$html .= $this->getImage("channel_flag_default.png", "Default Channel");
}
if($this->currObj["channel_flag_password"])
{
$html .= $this->getImage("channel_flag_password.png", "Password-protected");
}
if($this->currObj["channel_codec"] == 3)
{
$html .= $this->getImage("channel_flag_music.png", "Music Codec");
}
if($this->currObj["channel_needed_talk_power"])
{
$html .= $this->getImage("channel_flag_moderated.png", "Moderated");
}
if($this->currObj["channel_icon_id"])
{
if(!$this->currObj->iconIsLocal("channel_icon_id") && $this->ftclient)
{
if(!isset($this->cacheIcon[$this->currObj["channel_icon_id"]]))
{
$download = $this->currObj->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->currObj->iconGetName("channel_icon_id"));
if($this->ftclient == "data:image")
{
$download = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
}
$this->cacheIcon[$this->currObj["channel_icon_id"]] = $download;
}
else
{
$download = $this->cacheIcon[$this->currObj["channel_icon_id"]];
}
if($this->ftclient == "data:image")
{
$html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Channel Icon", null, FALSE);
}
else
{
$html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Channel Icon", null, FALSE);
}
}
elseif(in_array($this->currObj["channel_icon_id"], $this->cachedIcons))
{
$html .= $this->getImage("group_icon_" . $this->currObj["channel_icon_id"] . ".png", "Channel Icon");
}
}
return $html;
}
TeamSpeak3_Viewer_Html::getSuffixIconClient ( )
protected

Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Client object.

Returns
string

Definition at line 525 of file Html.php.

References TeamSpeak3\factory(), getImage(), and TeamSpeak3_Helper_Convert\imageMimeType().

Referenced by getSuffixIcon().

{
$html = "";
if($this->currObj["client_is_priority_speaker"])
{
$html .= $this->getImage("client_priority.png", "Priority Speaker");
}
if($this->currObj["client_is_channel_commander"])
{
$html .= $this->getImage("client_cc.png", "Channel Commander");
}
if($this->currObj["client_is_talker"])
{
$html .= $this->getImage("client_talker.png", "Talk Power granted");
}
elseif($cntp = $this->currObj->getParent()->channelGetById($this->currObj["cid"])->channel_needed_talk_power)
{
if($cntp > $this->currObj["client_talk_power"])
{
$html .= $this->getImage("client_mic_muted.png", "Insufficient Talk Power");
}
}
foreach($this->currObj->memberOf() as $group)
{
if(!$group["iconid"]) continue;
$type = ($group instanceof TeamSpeak3_Node_Servergroup) ? "Server Group" : "Channel Group";
if(!$group->iconIsLocal("iconid") && $this->ftclient)
{
if(!isset($this->cacheIcon[$group["iconid"]]))
{
$download = $group->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $group->iconGetName("iconid"));
if($this->ftclient == "data:image")
{
$download = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
}
$this->cacheIcon[$group["iconid"]] = $download;
}
else
{
$download = $this->cacheIcon[$group["iconid"]];
}
if($this->ftclient == "data:image")
{
$html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), $group . " [" . $type . "]", null, FALSE);
}
else
{
$html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), $group . " [" . $type . "]", null, FALSE);
}
}
elseif(in_array($group["iconid"], $this->cachedIcons))
{
$html .= $this->getImage("group_icon_" . $group["iconid"] . ".png", $group . " [" . $type . "]");
}
}
if($this->currObj["client_icon_id"])
{
if(!$this->currObj->iconIsLocal("client_icon_id") && $this->ftclient)
{
if(!isset($this->cacheIcon[$this->currObj["client_icon_id"]]))
{
$download = $this->currObj->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->currObj->iconGetName("client_icon_id"));
if($this->ftclient == "data:image")
{
$download = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
}
$this->cacheIcon[$this->currObj["client_icon_id"]] = $download;
}
else
{
$download = $this->cacheIcon[$this->currObj["client_icon_id"]];
}
if($this->ftclient == "data:image")
{
$html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Client Icon", null, FALSE);
}
else
{
$html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Client Icon", null, FALSE);
}
}
elseif(in_array($this->currObj["client_icon_id"], $this->cachedIcons))
{
$html .= $this->getImage("group_icon_" . $this->currObj["client_icon_id"] . ".png", "Client Icon");
}
}
return $html;
}
TeamSpeak3_Viewer_Html::getSuffixFlag ( )
protected

Returns a HTML img tag which can be used to display the country flag for a TeamSpeak_Node_Client object.

Returns
string

Definition at line 634 of file Html.php.

References getImage().

Referenced by fetchObject().

{
if(!$this->currObj instanceof TeamSpeak3_Node_Client) return;
if($this->flagpath && $this->currObj["client_country"])
{
return $this->getImage($this->currObj["client_country"]->toLower() . ".png", $this->currObj["client_country"], null, FALSE, TRUE);
}
}
TeamSpeak3_Viewer_Html::getImage (   $name,
  $text = "",
  $class = null,
  $iconpath = TRUE,
  $flagpath = FALSE 
)
protected

Returns the code to display a custom HTML img tag.

Parameters
string$name
string$text
string$class
boolean$iconpath
boolean$flagpath
Returns
string

Definition at line 654 of file Html.php.

Referenced by getCorpusIcon(), getPrefix(), getSuffixFlag(), getSuffixIconChannel(), getSuffixIconClient(), and getSuffixIconServer().

{
$src = "";
if($iconpath)
{
$src = $this->iconpath;
}
if($flagpath)
{
$src = $this->flagpath;
}
return "<img src='" . $src . $name . "' title='" . $text . "' alt='' align='top' />";
}

The documentation for this class was generated from the following file: