Fakoli Framework
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 format ($value, $template="")
 
static translationDateTemplate ($template, $includeTime=true)
 

Detailed Description

Definition at line 37 of file text_type_renderer.inc.

Member Function Documentation

◆ format()

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

Definition at line 43 of file text_type_renderer.inc.

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

◆ TextTypeRenderer()

TextTypeRenderer::TextTypeRenderer ( )

Definition at line 39 of file text_type_renderer.inc.

40  {
41  }

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