Ver código fonte

New extension API: iPageUIExtension to alter the display of *each* iTopWebPage.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2507 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 anos atrás
pai
commit
191bc48c4c

+ 36 - 0
application/applicationextension.inc.php

@@ -191,3 +191,39 @@ class SeparatorPopupMenuItem extends ApplicationPopupMenuItem
 		return array ('label' => '<hr class="menu-separator">', 'url' => '');
 	}
 }
+
+/**
+ * Implement this interface to add content to any iTopWebPage
+ * There are 3 places where content can be added:
+ * - The north pane: (normaly empty/hidden) at the top of the page, spanning the whole
+ *   width of the page
+ * - The south pane: (normaly empty/hidden) at the bottom of the page, spanning the whole
+ *   width of the page
+ * - The admin banner (two tones gray background) at the left of the global search.
+ *   Limited space, use it for short messages
+ * Each of the methods of this interface is supposed to return the HTML to be inserted at
+ * the specified place and can use the passed iTopWebPage object to add javascript or CSS definitions
+ *
+ */
+interface iPageUIExtension
+{
+	/**
+	 * Add content to the North pane
+	 * @param WebPage $oPage The page to insert stuff into.
+	 * @return string The HTML content to add into the page
+	 */
+	public function GetNorthPaneHtml(iTopWebPage $oPage);
+	/**
+	 * Add content to the South pane
+	 * @param WebPage $oPage The page to insert stuff into.
+	 * @return string The HTML content to add into the page
+	 */
+	public function GetSouthPaneHtml(iTopWebPage $oPage);
+	/**
+	 * Add content to the "admin banner"
+	 * @param WebPage $oPage The page to insert stuff into.
+	 * @return string The HTML content to add into the page
+	 */
+	public function GetBannerHtml(iTopWebPage $oPage);
+}
+

+ 29 - 2
application/itopwebpage.class.inc.php

@@ -708,11 +708,37 @@ EOF
 				}
 				$sApplicationBanner .= '<div id="admin-banner"><span style="padding:5px;">'.Dict::Format('UI:ApplicationEnvironment', $sEnvLabel).$sBackButton.'<span></div>';
 			}
-
+			
+			foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance)
+			{
+				$sApplicationBanner .= $oExtensionInstance->GetBannerHtml($this);
+			}
+			
+			$sNorthPane = '';
+			foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance)
+			{
+				$sNorthPane .= $oExtensionInstance->GetNorthPaneHtml($this);
+			}
+			if (!empty($sNorthPane))
+			{
+				$sNorthPane = '<div id="bottom-pane" class="ui-layout-south">'.$sNorthPane.'</div>';
+			}
+			
+			$sSouthPane = '';
+			foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance)
+			{
+				$sSouthPane .= $oExtensionInstance->GetSouthPaneHtml($this);
+			}
+			if (!empty($sSouthPane))
+			{
+				$sSouthPane = '<div id="bottom-pane" class="ui-layout-south">'.$sSouthPane.'</div>';
+			}
+			
 			$sIconUrl = Utils::GetConfig()->Get('app_icon_url');
 			$sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help');
 			//$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
 
+			$sHtml .= $sNorthPane;
 			$sHtml .= '<div id="left-pane" class="ui-layout-west">';
 			$sHtml .= '<!-- Beginning of the left pane -->';
 			$sHtml .= ' <div class="ui-layout-north">';
@@ -752,7 +778,8 @@ EOF
 			$sHtml .= ' <!-- End of page content -->';
 			$sHtml .= ' </div>';
 			$sHtml .= '</div>';
-				
+			$sHtml .= $sSouthPane;
+			
 			// Add the captured output
 			if (trim($s_captured_output) != "")
 			{

+ 1 - 1
core/metamodel.class.php

@@ -1328,7 +1328,7 @@ abstract class MetaModel
 
 		// Build the list of available extensions
 		//
-		$aInterfaces = array('iApplicationUIExtension', 'iApplicationObjectExtension', 'iQueryModifier', 'iOnClassInitialization', 'iPopupMenuExtension');
+		$aInterfaces = array('iApplicationUIExtension', 'iApplicationObjectExtension', 'iQueryModifier', 'iOnClassInitialization', 'iPopupMenuExtension', 'iPageUIExtension');
 		foreach($aInterfaces as $sInterface)
 		{
 			self::$m_aExtensionClasses[$sInterface] = array();