Просмотр исходного кода

Added the ability to Find then Remove a tab inside a page

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1861 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 лет назад
Родитель
Сommit
9a8f1cd5a5
1 измененных файлов с 41 добавлено и 0 удалено
  1. 41 0
      application/itopwebpage.class.inc.php

+ 41 - 0
application/itopwebpage.class.inc.php

@@ -867,6 +867,47 @@ EOF
 		return $this->m_sCurrentTab;
 	}
 	
+	public function RemoveTab($sTabLabel, $sTabContainer = null)
+	{
+		if ($sTabContainer == null)
+		{
+			$sTabContainer = $this->m_sCurrentTabContainer;
+		}
+		if (isset($this->m_aTabs[$sTabContainer][$sTabLabel]))
+		{
+			// Delete the content of the tab
+			unset($this->m_aTabs[$sTabContainer][$sTabLabel]);
+			
+			// If we just removed the active tab, let's reset the active tab
+			if (($this->m_sCurrentTabContainer == $sTabContainer) &&  ($this->m_sCurrentTab == $sTabLabel))
+			{
+				$this->m_sCurrentTab = '';
+			}
+		}
+	}
+
+	/**
+	 * Finds the tab whose title matches a given pattern
+	 * @return mixed The name of the tab as a string or false if not found
+	 */
+	public function FindTab($sPattern, $sTabContainer = null)
+	{
+		$return = false;
+		if ($sTabContainer == null)
+		{
+			$sTabContainer = $this->m_sCurrentTabContainer;
+		}
+		foreach($this->m_aTabs[$sTabContainer] as $sTabLabel => $void)
+		{
+			if (preg_match($sPattern, $sTabLabel))
+			{
+				$result = $sTabLabel;
+				break;
+			}
+		}
+		return $result;
+	}
+	
 	/**
 	 * Make the given tab the active one, as if it were clicked
 	 * DOES NOT WORK: apparently in the *old* version of jquery