public function __construct(Tracker_Hierarchy_HierarchicalTracker $tracker, array $possible_children, TreeNode $hierarchy) { $this->tracker = $tracker; $this->tracker_name = $tracker->getUnhierarchizedTracker()->getName(); $this->possible_children = array_values($possible_children); $this->hierarchy = $hierarchy; $visitor = new TreeNode_InjectPaddingInTreeNodeVisitor(); $this->hierarchy->accept($visitor); }
public function __construct(Tracker_Hierarchy_HierarchicalTracker $tracker, array $possible_children, TreeNode $hierarchy, array $trackers_not_in_hierarchy) { $this->tracker = $tracker; $this->tracker_name = $tracker->getUnhierarchizedTracker()->getName(); $this->possible_children = array_values($possible_children); $this->hierarchy = $hierarchy; $this->trackers_not_in_hierarchy = $trackers_not_in_hierarchy; $this->has_trackers_not_in_hierarchy = count($trackers_not_in_hierarchy) > 0; $this->cannot_be_used_in_hierarchy = in_array($tracker->getUnhierarchizedTracker(), $this->trackers_not_in_hierarchy); $visitor = new TreeNode_InjectPaddingInTreeNodeVisitor(); $this->hierarchy->accept($visitor); usort($this->trackers_not_in_hierarchy, array($this, 'sortTrackerAlphabetically')); }
function ItInjectsPadding() { $root = new TreeNode(); $node1 = new TreeNode(); $node2 = new TreeNode(); $root->addChild($node1); $node1->addChild($node2); $visitor = new TreeNode_InjectPaddingInTreeNodeVisitor(); $root->accept($visitor); $data = $node2->getData(); $this->assertPattern('%div class="tree-blank" >[^<]*</div><div class="tree-last"%', $data['tree-padding']); }
/** * When visit a given tree node with an InjectSpanPadding visitor */ protected function when_VisitTreeNodeWith_InjectSpanPadding(TreeNode &$givenTreeNode) { $visitor = new TreeNode_InjectSpanPaddingInTreeNodeVisitor(true); $givenTreeNode->accept($visitor); return $givenTreeNode; }
function outerTabs($params) { global $Language, $sys_use_trove, $sys_use_snippet; $selected_top_tab = ''; if (isset($params['selected_top_tab'])) { $selected_top_tab = $params['selected_top_tab']; } $menuTree = new TreeNode(); $sthSelected = false; $menuTree->addChild(new TreeNode(array('link' => '/', 'title' => $Language->getText('menu', 'home')))); // We need to keep a reference on this node in order to set the // selected value in the data. See bottom of this function. $homeNode =& $menuTree->getChild(0); if (user_isloggedin()) { $selected = isset($params['selected_top_tab']) && $params['selected_top_tab'] == '/my/' || strstr(getStringFromServer('REQUEST_URI'), '/my/') || strstr(getStringFromServer('REQUEST_URI'), '/account/'); $sthSelected = $sthSelected || $selected; $mynode = new TreeNode(array('link' => '/my/', 'title' => $Language->getText('menu', 'my_personal_page'), 'selected' => $selected)); if ($selected) { $selected = isset($params['selected_top_tab']) && $params['selected_top_tab'] == '/my/' || (bool) strstr(getStringFromServer('REQUEST_URI'), '/my/'); $mynode->addChild(new TreeNode(array('link' => '/my/', 'title' => $Language->getText('my_index', 'my_dashboard'), 'selected' => $selected))); $selected = (bool) strstr(getStringFromServer('REQUEST_URI'), '/account/'); $mynode->addChild(new TreeNode(array('link' => '/account/', 'title' => $Language->getText('my_index', 'account_maintenance'), 'selected' => $selected))); } $menuTree->addChild($mynode); } else { $selected = (bool) strstr(getStringFromServer('REQUEST_URI'), '/my/'); $sthSelected = $sthSelected || $selected; $menuTree->addChild(new TreeNode(array('link' => '/my/', 'title' => $Language->getText('menu', 'my_personal_page'), 'selected' => $selected))); } if ($GLOBALS['sys_use_trove'] != 0 || isset($params['group']) && $params['group']) { $selected = false; if (isset($params['group']) && $params['group']) { // get group info using the common result set $pm = ProjectManager::instance(); $project = $pm->getProject($params['group']); if ($project && is_object($project)) { if ($project->isError()) { die('is error'); } else { $sthSelected = true; $projTree = $this->project_tabs($params['toptab'], $params['group']); $projTree->setData(array('link' => '/softwaremap/', 'title' => $Language->getText('menu', 'projectree'), 'selected' => true)); //'link'=>'/projects/'.$project->getUnixName().'/' //,'title'=>$project->getPublicName() //,'selected' => true)); $menuTree->addChild($projTree); } } } else { $selected = (bool) strstr(getStringFromServer('REQUEST_URI'), 'softwaremap'); $sthSelected = $sthSelected || $selected; $menuTree->addChild(new TreeNode(array('link' => '/softwaremap/', 'title' => $Language->getText('menu', 'projectree'), 'selected' => $selected))); } } if ($GLOBALS['sys_use_snippet'] != 0) { $selected = (bool) strstr(getStringFromServer('REQUEST_URI'), '/snippet/'); $sthSelected = $sthSelected || $selected; $menuTree->addChild(new TreeNode(array('link' => '/snippet/', 'title' => $Language->getText('menu', 'code_snippet'), 'selected' => $selected))); } if (user_ismember(1, 'A')) { $selected = strpos(getStringFromServer('REQUEST_URI'), '/admin/') === 0 || $selected_top_tab === 'admin'; $sthSelected = $sthSelected || $selected; $menuTree->addChild(new TreeNode(array('link' => '/admin/', 'title' => $Language->getText('menu', 'admin'), 'selected' => $selected))); } $selected = (bool) (strstr(getStringFromServer('REQUEST_URI'), '/site/') || $selected_top_tab === 'site'); $sthSelected = $sthSelected || $selected; $menuTree->addChild(new TreeNode(array('link' => '/site/', 'title' => $Language->getText('include_layout', 'Help'), 'selected' => $selected))); $additional_tabs = array(); include $GLOBALS['Language']->getContent('layout/extra_tabs', null, null, '.php'); foreach ($additional_tabs as $t) { $sthSelected = $sthSelected || $t['selected']; $menuTree->addChild(new TreeNode($t)); } // Set selected value for 'home' link (this is the selected tab // if no other was previously selected) $homeNodeData =& $homeNode->getData(); $homeNodeData['selected'] = !$sthSelected; $buildMenuVisitor = new BuildMenuVisitor(); $menuTree->accept($buildMenuVisitor); echo $buildMenuVisitor->getHtml(); }
function getTestListAsTreeNode() { $breadcrumb = $this->getTestList(); array_shift($breadcrumb); $root = new TreeNode(); $parent = $root; foreach ($breadcrumb as $b) { $node = new TreeNode(array('title' => $b)); $parent->addChild($node); $parent = $node; } $root->accept(new TreeNode_InjectPaddingInTreeNodeVisitor()); return $root; }