function display() { $root = new ExtNode('root', 'root', true); $sb = new StudioBrowser(); $sb->loadModules(); foreach ($sb->modules as $name => $studioMod) { $root->add_node($this->buildStudioNode($studioMod)); } $json = getJSONobj(); echo $json->encode($root); }
/** * Builds children nodes for folders for TreeView * @return $folderNode TreeView node */ function buildTreeNodeFolders($a, $nodePath, $folderStates, $subscriptions) { $label = $a['name']; global $mod_strings; if ($a['name'] == 'My Drafts') { $label = $mod_strings['LBL_LIST_TITLE_MY_DRAFTS']; } if ($a['name'] == 'Sent Emails') { $label = $mod_strings['LBL_LIST_TITLE_MY_SENT']; } $unseen = $this->getCountNewItems($a['id'], array('field' => 'status', 'value' => 'unread'), $a); $folderNode = new ExtNode($a['id'], $label); $folderNode->dynamicloadfunction = ''; $folderNode->expanded = false; $nodePath .= "::{$a['id']}"; if (array_key_exists($nodePath, $folderStates)) { if ($folderStates[$nodePath] == 'open') { $folderNode->expanded = true; } } $folderNode->dynamic_load = true; $folderNode->set_property('click', "SUGAR.email2.listView.populateListFrameSugarFolder(YAHOO.namespace('frameFolders').selectednode, '{$a['id']}', 'false');"); $folderNode->set_property('ieId', 'folder'); $folderNode->set_property('mbox', $a['id']); $folderNode->set_property('is_group', $a['is_group'] == 1 ? 'true' : 'false'); $folderNode->set_property('is_dynamic', $a['is_dynamic'] == 1 ? 'true' : 'false'); $folderNode->set_property('unseen', $unseen); $folderNode->set_property('folder_type', $a['folder_type']); if (in_array($a['id'], $subscriptions) && $a['has_child'] == 1) { $qGetChildren = $this->core . $this->coreWhere . "AND parent_folder = '{$a['id']}' " . $this->coreOrderBy; $rGetChildren = $this->db->query($qGetChildren); while ($aGetChildren = $this->db->fetchByAssoc($rGetChildren)) { $folderNode->add_node($this->buildTreeNodeFolders($aGetChildren, $nodePath, $folderStates, $subscriptions)); } } return $folderNode; }
/** * Builds up a TreeView Node object * @param mixed * @param mixed * @param string * @param string ID of InboundEmail instance * @param string nodePath Serialized path from root node to current node * @param bool isGroup * @param bool forceRefresh * @return mixed */ function buildTreeNode($key, $label, $mbox, $ieId, $nodePath, $isGroup, $ie) { global $sugar_config; // get unread counts $exMbox = explode("::", $nodePath); $unseen = 0; $GLOBALS['log']->debug("{$key} --- {$nodePath}::{$label}"); if (count($exMbox) >= 2) { $mailbox = ""; for ($i = 2; $i < count($exMbox); $i++) { if ($mailbox != "") { $mailbox .= "."; } $mailbox .= "{$exMbox[$i]}"; } $mailbox = substr($key, strpos($key, '.')); $unseen = $this->getUnreadCount($ie, $mailbox); if ($unseen > 0) { //$label = " <span id='span{$ie->id}{$ie->mailbox}' style='font-weight:bold'>{$label} (<span id='span{$ie->id}{$ie->mailbox}nums'>{$unseen}</span>)</span>"; } } $nodePath = $nodePath . "::" . $label; $node = new ExtNode($nodePath, $label); $node->dynamicloadfunction = ''; $node->expanded = false; $node->set_property('labelStyle', "remoteFolder"); if (array_key_exists($nodePath, $this->folderStates)) { if ($this->folderStates[$nodePath] == 'open') { $node->expanded = true; } } $group = $isGroup ? 'true' : 'false'; $node->dynamic_load = true; //$node->set_property('href', " SUGAR.email2.listView.populateListFrame(YAHOO.namespace('frameFolders').selectednode, '{$ieId}', 'false');"); $node->set_property('isGroup', $group); $node->set_property('isDynamic', 'false'); $node->set_property('ieId', $ieId); $node->set_property('mbox', $key); $node->set_property('unseen', $unseen); $node->set_property('cls', 'ieFolder'); if (is_array($mbox)) { foreach ($mbox as $k => $v) { $node->add_node($this->buildTreeNode("{$key}.{$k}", $k, $v, $ieId, $nodePath, $isGroup, $ie)); } } return $node; }