Framework  3.9
TextTypeRenderer Class Reference
+ Inheritance diagram for TextTypeRenderer:
+ Collaboration diagram for TextTypeRenderer:

Public Member Functions

 TextTypeRenderer ()
 
- Public Member Functions inherited from AbstractTypeRenderer
 AbstractTypeRenderer ()
 

Static Public Member Functions

static format ($value, $template="")
 
- Static Public Member Functions inherited from AbstractTypeRenderer
static translationDateTemplate ($template, $includeTime=true)
 

Detailed Description

Definition at line 40 of file text_type_renderer.inc.

Member Function Documentation

◆ format()

static TextTypeRenderer::format (   $value,
  $template = "" 
)
static

Reimplemented from AbstractTypeRenderer.

Definition at line 46 of file text_type_renderer.inc.

47  {
48  if (!$template) return $value;
49 
50 
51  if ($template[0] == '/')
52  {
53  $clauses = array();
54  if (preg_match("/(\\/.*?\\/)(.*?)\\//", $template, $clauses))
55  {
56  return preg_replace($clauses[1], $clauses[2], $value);
57  }
58  }
59 
60  if ($template[0] == '|')
61  {
62  $clauses = array();
63  if (preg_match("/(|.*?|)(.*?)|/", $template, $clauses))
64  {
65  return preg_replace($clauses[1], $clauses[2], $value);
66  }
67  }
68 
69  switch($template)
70  {
71  case "codify":
72  return codify($value);
73 
74  case "prettify":
75  return prettify($value);
76 
77  case "upper":
78  return strtoupper($value);
79 
80  case "lower":
81  return strtolower($value);
82 
83  case "ucfirst":
84  return ucfirst($value);
85 
86  case "lcfirst":
87  return lcfirst($value);
88 
89  case "ucwords":
90  return ucwords(strtolower($value));
91 
92  case "stripHTML":
93  return stripHTML($value);
94 
95  case "jsSafe":
96  return jsSafe($value);
97 
98  case "html":
99  return formatAsHTML($value);
100 
101  case "htmlSafe":
102  return htmlsafe($value);
103 
104  case "HTML":
105  return formatAsHtml($value);
106 
107  case "xml":
108  return xmlEntities($value);
109 
110  case "xmlSafe":
111  return xmlEntities(stripHTML($value));
112 
113  case "firstSentence":
114  return firstSentence($value);
115 
116  default:
117 
118  if (is_numeric($template))
119  {
120  return ellipsis(stripHTML($value), $template, true);
121  }
122  }
123 
124  return $value;
125  }
codify($name)
Takes a text string and converts it into a code-compliant format, suitable for use as a variable name...
Definition: functions.inc:1399
xmlEntities($string)
Function to provide html to XML entity renaming.
Definition: functions.inc:1903
stripHTML($text)
Definition: functions.inc:847
firstSentence($text)
Returns the first sentence of the supplied text.
Definition: functions.inc:839
jsSafe($str, $escapeEntities=false)
Utility function to escape a string correctly for use in a Javascript client-side call.
Definition: functions.inc:434
formatAsHTML($text)
Takes a string and formats it for display as HTML, removing any HTML tags it contains,...
Definition: functions.inc:1456
ellipsis($txt, $max, $wholeWord=false)
Truncate the supplied text at the given maximum length.
Definition: functions.inc:779
prettify($name)
Takes a variable or field name and converts it into a human-readable version (assuming that the origi...
Definition: functions.inc:1413
htmlsafe($str)
Definition: functions.inc:451

◆ TextTypeRenderer()

TextTypeRenderer::TextTypeRenderer ( )

Definition at line 42 of file text_type_renderer.inc.

43  {
44  }

The documentation for this class was generated from the following file: