private function treeToJsonArray(MurmurTree $tree, $connecturlTemplate, $path)
 {
     /**
      * @var MurmurChannel
      */
     $chan = $tree->getRootChannel();
     if ($connecturlTemplate != null && $chan->getParentChannelId() != -1) {
         $path .= '/' . urlencode($chan->getName());
     }
     // subchannels data array
     $prior = array();
     $subChannels = $tree->getSubChannels();
     if (!empty($subChannels)) {
         usort($subChannels, 'self::channelCompare');
         foreach ($subChannels as $subChannel) {
             $prior[] = $this->treeToJsonArray($subChannel, $connecturlTemplate, $path);
         }
     }
     // This channels data array
     $array = array();
     $array['id'] = $chan->getId();
     $array['parent'] = $chan->getParentChannelId();
     $array['temporary'] = $chan->isTemporary();
     $array['position'] = $chan->getPosition();
     $array['name'] = $chan->getName();
     $array['description'] = $chan->getDescription();
     if ($connecturlTemplate != null) {
         // Remove template placeholder. The URL is complete here.
         $array['x_connecturl'] = sprintf($connecturlTemplate, $path);
     }
     $array['channels'] = $prior;
     $array['links'] = $chan->getLinkedChannelIds();
     $array['users'] = $this->usersToJsonArray($tree->getUsers(), $chan->getId());
     return $array;
 }
 private function treeToJsonArray(MurmurTree $tree)
 {
     $array = array();
     $prior = array();
     $subChannels = $tree->getSubChannels();
     if (!empty($subChannels)) {
         foreach ($subChannels as $subChannel) {
             $prior[] = $this->treeToJsonArray($subChannel);
         }
     }
     /**
      * @var MurmurChannel
      */
     $chan = $tree->getRootChannel();
     $array['id'] = $chan->getId();
     $array['parent'] = $chan->getParentChannelId();
     $array['temporary'] = $chan->isTemporary();
     $array['position'] = $chan->getPosition();
     $array['name'] = $chan->getName();
     $array['description'] = $chan->getDescription();
     $array['channels'] = $prior;
     $array['links'] = $chan->getLinkedChannelIds();
     $array['users'] = $this->usersToJsonArray($tree->getUsers(), $chan->getId());
     return $array;
 }
Exemple #3
0
 /**
  * @return MurmurTree
  * @throws Murmur_ServerBootedException
  */
 public function getTree()
 {
     return MurmurTree::fromIceObject($this->iceObj->getTree(), $this);
 }
Exemple #4
0
            function treePrint(MurmurTree $tree, $first = true)
            {
                $subs = $tree->getSubChannels();
                if ($first) {
                    echo '<div id="jq_editable_server_conf_defaultchannel_form">';
                    //TODO i18n
                    echo '<p>Select the channel unregistered and new users are to join when joining the server.</p>';
                }
                ?>
									<ul>
										<li class="form_clickable_submit jslink" id="channel_<?php 
                echo $tree->getRootChannel()->getId();
                ?>
"><?php 
                echo $tree->getRootChannel()->getName();
                ?>
</li>
										<?php 
                if (!empty($subs)) {
                    foreach ($subs as $subTree) {
                        treePrint($subTree, false);
                    }
                }
                ?>
									</ul>
								<?php 
                if ($first) {
                    echo '</div>';
                }
            }