Bladeren bron

N°1006.2 Templates: $this->raw(attcode)$ can be used to display an date(time) attribute in the SQL format like before.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4914 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 7 jaren geleden
bovenliggende
commit
298188ade6
1 gewijzigde bestanden met toevoegingen van 30 en 2 verwijderingen
  1. 30 2
      core/attributedef.class.inc.php

+ 30 - 2
core/attributedef.class.inc.php

@@ -702,7 +702,7 @@ abstract class AttributeDefinition
 				break;
 				
 				default:
-				throw new Exception("Unknown verb '$sVerb' for attribute ".$this->GetCode().' in class '.get_class($oHostObj));
+				throw new Exception("Unknown verb '$sVerb' for attribute ".$this->GetCode().' in class '.get_class($oHostObject));
 			}
 		}
 		return null;
@@ -3966,9 +3966,37 @@ class AttributeDateTime extends AttributeDBField
     /**
      * @inheritdoc
      */
+    public function EnumTemplateVerbs()
+    {
+        return array(
+            '' => 'Formatted representation',
+            'raw' => 'Not formatted representation',
+        );
+    }
+
+    /**
+     * @inheritdoc
+     */
     public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true)
     {
-        return static::GetFormat()->format($value);
+        switch ($sVerb)
+        {
+            case '':
+            case 'text':
+                return static::GetFormat()->format($value);
+                break;
+            case 'html':
+                // Note: Not passing formatted value as the method will format it.
+                return $this->GetAsHTML($value);
+                break;
+            case 'raw':
+                return $value;
+                break;
+            default:
+                return parent::GetForTemplate($value, $sVerb, $oHostObject, $bLocalize);
+                break;
+        }
+        return null;
     }
 
 	static public function ListExpectedParams()