Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

Script for correctly displaying all [Spacers]

This discussion is related to the TSServer addon.

Hey,
I really do Like this Plugin, but for me the [spacers] are shown in a really ugly way, so i wrote a kinda replacement.

So first of all upload this file: https://upload.wikimedia.org/wikipedia/commons/8/8c/Transparent.png to your images folder ( TSServer/design/images/transparent.png)

After that open TSServer/views/statusmodule.php and replace the function:
private function renderChannels($parentId, $show = false)
` private function renderChannels($parentId, $show = false)
{
$out = "";
foreach ($this->_channelDatas as $channel)
{
if($channel["pid"] == $parentId)
{
$icon = "16x16_channel_green.png";
if( $channel["channel_maxclients"] > -1 && ($channel["total_clients"] >= $channel["channel_maxclients"])) $icon = "16x16_channel_red.png";
else if( $channel["channel_maxfamilyclients"] > -1 && ($channel["total_clients_family"] >= $channel["channel_maxfamilyclients"])) $icon = "16x16_channel_red.png";
else if($channel["channel_flag_password"] == 1) $icon = "16x16_channel_yellow.png";

            $flags = array();
            if($channel["channel_flag_default"] == 1) $flags[] = '16x16_default.png';
            if($channel["channel_needed_talk_power"] > 0) $flags[] = '16x16_moderated.png';
            if($channel["channel_flag_password"] == 1) $flags[] = '16x16_register.png';

            $link = "javascript:tsstatusconnect('" . $this->_host . "','" . $this->_serverDatas["virtualserver_port"] . "','" . htmlentities($channel["channel_name"]) . "')";

            $showCurrent = $show || count($this->_limitedChannels) == 0 || in_array($channel["cid"], $this->_limitedChannels);

            if($showCurrent) $out .= '
            <div class="tsstatusItem">
                <div class="tsstatusLabel">
                    <a href="' . $link . '">
                        <img src="' . $this->imagePath . $icon . '" />' . $channel["channel_name"] . '
                    </a>
                </div>
                <div class="tsstatusFlags">
                    ' . $this->renderFlags($flags) . '
                </div>
                ' . (count($this->_userDatas) > 0 ? $this->renderUsers($channel["cid"]) : '');

            $out .= $this->renderChannels($channel["cid"], $showCurrent);

            if($showCurrent) $out .= '</div>';
        }
    }
    return $out;
}
`

With this:

`private function SpacerEscape($name, $icon){

    $suchmuster_special = '/[\[].*[\]]./';
    $suchmuster = '/[\[].*[\]]/';
    preg_match($suchmuster, $name, $treffer);
    preg_match($suchmuster_special, $name, $treffer_special);
    $rep = "";
    if(sizeof($treffer) > 0)
    {
        if(sizeof($treffer_special) > 0){
            $rep = str_replace($treffer[0], "", $treffer_special[0]);
            if(strcmp($name, $treffer_special[0]) == 0)
            {
                for ($i=0; $i < 8 ; $i++) { 
                    $rep.=$rep;
                }
            }

        }
        else{

            $rep = "          ";
        }
        $name = str_replace($treffer[0], $rep, $name);
        $icon = "transparent.png";
    }

    return '<img src="' . $this->imagePath . $icon . '" />' . $name; 
}
private function renderChannels($parentId, $show = false)
{
    $out = "";
    foreach ($this->_channelDatas as $channel)
    {
        if($channel["pid"] == $parentId)
        {
            $icon = "16x16_channel_green.png";
            if( $channel["channel_maxclients"] > -1 && ($channel["total_clients"] >= $channel["channel_maxclients"])) $icon = "16x16_channel_red.png";
            else if( $channel["channel_maxfamilyclients"] > -1 && ($channel["total_clients_family"] >= $channel["channel_maxfamilyclients"])) $icon = "16x16_channel_red.png";
            else if($channel["channel_flag_password"] == 1) $icon = "16x16_channel_yellow.png";

            $flags = array();
            if($channel["channel_flag_default"] == 1) $flags[] = '16x16_default.png';
            if($channel["channel_needed_talk_power"] > 0) $flags[] = '16x16_moderated.png';
            if($channel["channel_flag_password"] == 1) $flags[] = '16x16_register.png';

            $link = "javascript:tsstatusconnect('" . $this->_host . "','" . $this->_serverDatas["virtualserver_port"] . "','" . htmlentities($channel["channel_name"]) . "')";

            $showCurrent = $show || count($this->_limitedChannels) == 0 || in_array($channel["cid"], $this->_limitedChannels);

            if($showCurrent) $out .= '
            <div class="tsstatusItem">
                <div class="tsstatusLabel">
                    <a href="' . $link . '">
                        '. $this->SpacerEscape($channel["channel_name"], $icon) .'
                    </a>
                </div>
                <div class="tsstatusFlags">
                    ' . $this->renderFlags($flags) . '
                </div>
                ' . (count($this->_userDatas) > 0 ? $this->renderUsers($channel["cid"]) : '');

            $out .= $this->renderChannels($channel["cid"], $showCurrent);

            if($showCurrent) $out .= '</div>';
        }
    }
    return $out;
}`
R_J

Comments

Sign In or Register to comment.