Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
Profiles.php
Go to the documentation of this file.
1 <?php
2 // A delegate class for the Profiles table.
3 // This may contain parsing functions, serializing functions, and formatting functions
4 // It may also contain permissions functions.
5 // It may also contain
7 /*
8  //Examples of functions
9 
10  // Signatures
11  // ==========
12  //
13  // Field Functions
14  // ----------------
15  // function field_name__parse($value);
16  // function field_name__pushValue($value, &$quickform_element);
17  // function field_name__pullValue(&$quickform_element);
18  // function field_name__serialize($value);
19  // function field_name__toString($value);
20  // function field_name__permissions($user, &$record);
21  // function field_name__link($values=null);
22  //
23  // Table Functions
24  // ----------------
25  // function permissions($user, &$record);
26  // function init(&$table);
27  // function beforeSave(&$record);
28  // function afterSave(&$record);
29  // function beforeUpdate(&$record);
30  // function afterUpdate(&$record);
31  // function beforeDelete(&$record);
32  // function afterDelete(&$record);
33 
34 
35  // A Parsing function that doesn't do anything. This is called anytime the
36  // value of the `created` field's value is set. It should handle any type
37  // of input that may be received especially input as would be received from
38  // the database directly. It must also be able to handle input in the native
39  // format. Ie: if $value is given in the correct format to be stored, it should
40  // be passed through with no change.
41  //
42  // assertTrue( created__parse( created__parse($value) ) == created__parse($value) )
43  // ie: This function is transitive.
44  function created__parse($value){
45  return $value;
46  }
47 
48  // Prepares the value of a quickform_element to be inserted into the table.
49  // The output of this function should be acceptable as input for created__parse($value)
50  function created__prepare($quickform_element){
51 
52  return $quickform_element->getValue();
53 
54  }
55 
56  // A function that takes a value in the specific format that is stored in the table
57  // and formats it in such a way that it can be stored in the database.
58  //
59  // assertTrue( created__serialize($value) == created__serialize( created__parse( created__serialize($value) ) )
60  // ie: The output of this function should be acceptable to create__parse and vice versa
61  function created__serialize($value){
62  return $value;
63  }
64 
65  // A function that takes a value as stored in the table and formats it as a string.
66  // The output should be consistent as it is also used to compare fields for equality.
67  function created__toString($value){
68  return $value;
69  }
70 
71  // Returns a permissions array indicating whether this user has view or update permissions
72  // Presumeably this function
73  function created__permissions($user, &$record){
74  return array(
75  'View' => true,
76  'Update' => false);
77 
78  }
79  */
80 
81 
82  function fname__link(&$record){
83  if ( !is_a($record, "Dataface_Record") ){
84  trigger_error("in tables_Profiles::fname__link() expecting 'Dataface_Record' as first argument but received '".get_class($record)."'.\n<br>".Dataface_Error::printStackTrace(), E_USER_ERROR);
85  }
86 
87  return array(
88  "-action"=>"browse",
89  "-table"=>"Profiles",
90  "fname"=>$record->strval('fname'),
91  "lname"=>$record->strval('lname'),
92  "description"=>"My name is \$fname");
93  }
94 
95  function lname__link(&$record){
96  if ( !is_a($record, "Dataface_Record") ){
97  trigger_error("in tables_Profiles::lname__link() expecting 'Dataface_Record' as first argument but received '".get_class($record)."'.\n<br>".Dataface_Error::printStackTrace(), E_USER_ERROR);
98  }
99 
100 
101  return "http://www.google.ca?fname=".$record->strval('fname')."&lname=".$record->strval('lname');
102  }
103 
104  function description__link(&$record){
105 
106  return "http://www.google.ca?fname=\$fname&lname=\$lname";
107  }
108 }
109 
110 
111 ?>