Framework  3.9
boolean_type_renderer.inc
Go to the documentation of this file.
1 <?php
5 /**************************************************************
6 
7  Copyright (c) 2007-2010 Sonjara, Inc
8 
9  Permission is hereby granted, free of charge, to any person
10  obtaining a copy of this software and associated documentation
11  files (the "Software"), to deal in the Software without
12  restriction, including without limitation the rights to use,
13  copy, modify, merge, publish, distribute, sublicense, and/or sell
14  copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following
16  conditions:
17 
18  The above copyright notice and this permission notice shall be
19  included in all copies or substantial portions of the Software.
20 
21  Except as contained in this notice, the name(s) of the above
22  copyright holders shall not be used in advertising or otherwise
23  to promote the sale, use or other dealings in this Software
24  without prior written authorization.
25 
26  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
28  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
30  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
31  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33  OTHER DEALINGS IN THE SOFTWARE.
34 
35 *****************************************************************/
36 
37 
38 require_once realpath(dirname(__FILE__)."/abstract_type_renderer.inc");
39 
41 {
43  {
44  }
45 
46  /*
47  * If no template, then return True/False. If there is a template
48  * but missing a value for true or false, then return True/False.
49  *
50  * Template should be provided in the format:
51  * {my_field_name:StringForTrue/StringForFalse}
52  * e.g.,
53  * {active:Yes/No} returns Yes if active and No if not
54  */
55  static function format($value, $template = "")
56  {
57  trace("BooleanTypeRenderer template is $template and value is $value", 5);
58 
59  $text = null;
60 
61  if($template)
62  {
63  list($true, $false) = explode("/", $template);
64  if($true !== '' && $false !== '')
65  $text = ($value) ? $true : $false;
66  }
67 
68  if($text === null)
69  $text = ($value) ? "True" : "False";
70 
71  return $text;
72  }
73 }
74 
static format($value, $template="")
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010