浏览代码

New feature: online help on search inputs (date format and operators)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1341 a333f486-631f-4898-b8df-5754b55c2be0
romainq 14 年之前
父节点
当前提交
221d66461e

+ 10 - 0
application/cmdbabstract.class.inc.php

@@ -1265,6 +1265,16 @@ EOF
 				}				
 			}
 			unset($aExtraParams[$sFilterCode]);
+			
+			// Finally, add a tooltip if one is defined for this attribute definition
+			$sTip = $oAttDef->GetHelpOnSmartSearch();
+			if (strlen($sTip) > 0)
+			{
+				$sTip = addslashes($sTip);
+				$sTip = str_replace(array("\n", "\r"), " ", $sTip);
+				// :input does represent in form visible input (INPUT, SELECT, TEXTAREA)
+				$oPage->add_ready_script("$('form#fs_$sSearchFormId :input[name={$sFilterCode}]').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
+			}
 			$index++;
 			$sHtml .= '</span> ';
 		}

+ 10 - 0
application/portalwebpage.class.inc.php

@@ -77,6 +77,7 @@ class PortalWebPage extends NiceWebPage
 		$this->add_linked_script("../js/utils.js");
 		$this->add_linked_script("../js/forms-json-utils.js");
 		$this->add_linked_script("../js/swfobject.js");
+		$this->add_linked_script("../js/jquery.qtip-1.0.min.js");
 		$this->add_ready_script(
 <<<EOF
 try
@@ -454,6 +455,15 @@ EOF
 			}				
 			unset($aExtraParams[$sFieldName]);
 			$this->add('</span> ');
+
+			$sTip = $oAttDef->GetHelpOnSmartSearch();
+			if (strlen($sTip) > 0)
+			{
+				$sTip = addslashes($sTip);
+				$sTip = str_replace(array("\n", "\r"), " ", $sTip);
+				// :input does represent in form visible input (INPUT, SELECT, TEXTAREA)
+				$this->add_ready_script("$(':input[name={$sPrefix}$sFieldName]').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
+			}
 		}
 	}
 	

+ 15 - 0
core/attributedef.class.inc.php

@@ -186,6 +186,21 @@ abstract class AttributeDefinition
 	}
 	public function GetDescription() {return Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode.'+', '');} 
 	public function GetHelpOnEdition() {return Dict::S('Class:'.$this->m_sHostClass.'/Attribute:'.$this->m_sCode.'?', '');} 
+
+	public function GetHelpOnSmartSearch()
+	{
+		$aParents = array_merge(array(get_class($this) => get_class($this)), class_parents($this));
+		foreach ($aParents as $sClass)
+		{
+			$sHelp = Dict::S("Core:$sClass?SmartSearch", '-missing-');
+			if ($sHelp != '-missing-')
+			{
+				return $sHelp;
+			}
+		} 
+		return '';
+	} 
+
 	public function GetDescription_Obsolete()
 	{
 		// Written for compatibility with a data model written prior to version 0.9.1

+ 16 - 0
dictionaries/dictionary.itop.core.php

@@ -86,9 +86,25 @@ Dict::Add('EN US', 'English', 'English', array(
 
 	'Core:AttributeDateTime' => 'Date/time',
 	'Core:AttributeDateTime+' => 'Date and time (year-month-day hh:mm:ss)',
+	'Core:AttributeDateTime?SmartSearch' => '
+<p>
+	Date format:<br/>
+	<b>yyyy-mm-dd hh:mm:ss</b><br/>
+	Example: 2011-07-19 18:40:00
+</p>
+<p>
+Operators:<br/>
+	<b>&gt;</b><em>date</em><br/>
+	<b>&lt;</b><em>date</em><br/>
+	<b>[</b><em>date</em>,<em>date</em><b>]</b>
+</p>
+<p>
+If the time is omitted, it defaults to 00:00:00
+</p>',
 
 	'Core:AttributeDate' => 'Date',
 	'Core:AttributeDate+' => 'Date (year-month-day)',
+	'Core:AttributeDate?SmartSearch' => '',
 
 	'Core:AttributeDeadline' => 'Deadline',
 	'Core:AttributeDeadline+' => 'Date, displayed relatively to the current time',

+ 17 - 1
dictionaries/fr.dictionary.itop.core.php

@@ -18,7 +18,7 @@
  * @author	Erwan Taloc <erwan.taloc@combodo.com>
  * @author	Romain Quetiez <romain.quetiez@combodo.com>
  * @author	Denis Flaven <denis.flaven@combodo.com>
- * @licence	http://www.opensource.org/licenses/gpl-3.0.html LGPL
+ * @licence	http://www.opensource.org/licenses/gpl-3.0.html LGPL
  */
 
 Dict::Add('FR FR', 'French', 'Français', array(
@@ -436,8 +436,24 @@ Dict::Add('FR FR', 'French', 'Français', array(
 	'Core:AttributeTemplateHTML+' => 'HTML contenant des espaces réservés pour des données iTop',
 	'Core:AttributeDateTime' => 'Date/heure',
 	'Core:AttributeDateTime+' => 'Date et heure (année-mois-jour hh:mm:ss)',
+	'Core:AttributeDateTime?SmartSearch' => '
+<p>
+	Format de date :<br/>
+	<b>aaaa-mm-jj hh:mm:ss</b><br/>
+	Exemple : 2011-07-19 18:40:00
+</p>
+<p>
+Opérateurs :<br/>
+	<b>&gt;</b><em>date</em><br/>
+	<b>&lt;</b><em>date</em><br/>
+	<b>[</b><em>date</em>,<em>date</em><b>]</b>
+</p>
+<p>
+Si l\'heure n\'est pas spécifiée, cela revient à 00:00:00 (minuit)
+</p>',
 	'Core:AttributeDate' => 'Date',
 	'Core:AttributeDate+' => 'Date (année-mois-jour)',
+	'Core:AttributeDate?SmartSearch' => '',
 	'Core:AttributeDeadline' => 'Délai',
 	'Core:AttributeDeadline+' => 'Date/heure exprimée relativement à l\'heure courante',
 	'Core:AttributeExternalKey' => 'Clé externe',