Selaa lähdekoodia

- New conditional block 'itopcheck' in the templates

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@531 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 vuotta sitten
vanhempi
commit
07c689ded8
2 muutettua tiedostoa jossa 21 lisäystä ja 3 poistoa
  1. 15 1
      application/template.class.inc.php
  2. 6 2
      business/templates/welcome_menu.html

+ 15 - 1
application/template.class.inc.php

@@ -35,7 +35,7 @@ class DisplayTemplate
 	
 	public function __construct($sTemplate)
 	{
-		$this->m_aTags = array('itopblock', 'itoptabs', 'itoptab', 'itoptoggle', 'itopstring');
+		$this->m_aTags = array('itopblock', 'itopcheck', 'itoptabs', 'itoptab', 'itoptoggle', 'itopstring');
 		$this->m_sTemplate = $sTemplate;
 	}
 	
@@ -168,6 +168,20 @@ class DisplayTemplate
 				$oPage->SetCurrentTabContainer('');
 			break;
 			
+			case 'itopcheck':
+				$sClassName = $aAttributes['class'];
+				if (MetaModel::IsValidClass($sClassName))
+				{
+					$oTemplate = new DisplayTemplate($sContent);
+					$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
+				}
+				else
+				{
+					// Leave a trace for those who'd like to understand why nothing is displayed
+					$oPage->add("<!-- class $sClassName does not exist, skipping some part of the template -->\n");
+				}
+			break;
+			
 			case 'itoptab':
 				$oPage->SetCurrentTab(Dict::S(str_replace('_', ' ', $aAttributes['name'])));
 				$oTemplate = new DisplayTemplate($sContent);

+ 6 - 2
business/templates/welcome_menu.html

@@ -38,12 +38,16 @@ display: list-item;
 </tr>
 <tr>
 <td class="dashboard2">
+<itopcheck class="ServiceCall">
 <p style="text-align:left; font-family:Verdana, Arial, sans-serif; font-size:16px;"><itopstring>UI:WelcomeMenu:MyCalls</itopstring></p>
-<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT bizServiceCall AS i WHERE i.caller_id = :current_contact_id</itopblock>
+<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT ServiceCall AS i WHERE i.caller_id = :current_contact_id</itopblock>
+</itopcheck>
 </td>
 <td class="dashboard2">
+<itopcheck class="IncidentTicket">
 <p style="text-align:left; font-family:Verdana, Arial, sans-serif; font-size:16px;"><itopstring>UI:WelcomeMenu:MyIncidents</itopstring></p>
-<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT bizIncidentTicket AS i WHERE i.caller_id = :current_contact_id</itopblock>
+<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT IncidentTicket AS i WHERE i.caller_id = :current_contact_id</itopblock>
+</itopcheck>
 </td>
 
 </tr>