ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
HFile Class Reference
+ Inheritance diagram for HFile:
+ Collaboration diagram for HFile:

Public Member Functions

 __construct ()
 
 parse_file ($file)
 
 to_perl ($stub, $tofile=1)
 
 to_php ($stub, $tofile=1)
 
 _get_categories ()
 
 _dump_linkscripts ()
 
 _dump_perl_linkscripts ()
 
 _dump_perl_defaultscripts ()
 
 _dump_colours ()
 
 _dump_var ($variable, $name)
 
 _dump_array ($array, $name)
 
 _dump_perl_array ($array, $name)
 
 _dump_hash ($hash, $name)
 
 _dump_perl_hash ($hash, $name)
 

Detailed Description

Definition at line 21 of file HFile.php.

Constructor & Destructor Documentation

◆ __construct()

HFile::__construct ( )

Definition at line 24 of file HFile.php.

References array.

25  {
26  # Language name.
27  $this->lang_name = "";
28  # Language configuration hashtable.
29  $this->indent_depth = 8;
30 
31  $this->config = array();
32  $color = 0;
33  $parsing = "";
34  $this->validkeys = array();
35 
36  $this->indent = array();
37  $this->unindent = array();
38  $this->blockcommenton = array();
39  $this->blockcommentoff = array();
40  $this->linecommenton = array();
41  $this->preprocessors = array();
42 
43  # Zoning
44  $this->zones = array();
45 
46  # Hashtable of keywords - maps from keyword to colour.
47  $this->keywords = array();
48 
49  # Used for conversion from keyword -> regexp.
50  $this->keypats = array();
51 
52  # Which colours to use for each 'level'.
53  $this->colours = array("blue", "purple", "gray", "brown", "blue", "purple", "gray", "brown");
54  $this->quotecolour = "blue";
55  $this->blockcommentcolour = "green";
56  $this->linecommentcolour = "green";
57  $this->stringchars = array();
58  $this->delimiters = array();
59  $this->escchar = "\\";
60 
61  # Caches for the harvesters.
62  $this->comcache = "";
63  $this->stringcache = "";
64 
65  # Toggles
66  $this->perl = 0;
67  $this->notrim = 0;
68  $this->nocase = 0;
69  }
Create styles array
The data for the language used.

Member Function Documentation

◆ _dump_array()

HFile::_dump_array (   $array,
  $name 
)

Definition at line 232 of file HFile.php.

Referenced by _dump_colours(), and to_php().

233  {
234  $first = 1;
235  print $name." = array(";
236  foreach($array as $a)
237  {
238  if (!$first) print ", "; else $first = 0;
239  print "\"".addslashes($a)."\"";
240  }
241  print ");\n";
242  }
+ Here is the caller graph for this function:

◆ _dump_colours()

HFile::_dump_colours ( )

Definition at line 217 of file HFile.php.

References _dump_array(), and array.

Referenced by to_php().

218  {
219  $usedcols = array();
220  foreach($this->used_categories as $c)
221  {
222  array_push($usedcols, $this->colours[$c-1]);
223  }
224  $this->_dump_array($usedcols, "\$this->colours ");
225  }
_dump_array($array, $name)
Definition: HFile.php:232
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dump_hash()

HFile::_dump_hash (   $hash,
  $name 
)

Definition at line 256 of file HFile.php.

Referenced by _dump_linkscripts(), and to_php().

257  {
258  $first = 1;
259  print $name." = array(";
260  foreach(array_keys($hash) as $k)
261  {
262  if (!$first) print ", "; else $first = 0;
263  print "\n \"".addslashes($k)."\"";
264  print " => \"".addslashes($hash[$k])."\"";
265  }
266  print ");\n";
267  }
+ Here is the caller graph for this function:

◆ _dump_linkscripts()

HFile::_dump_linkscripts ( )

Definition at line 177 of file HFile.php.

References _dump_hash(), and array.

Referenced by to_php().

178  {
179  print "
180 # Each category can specify a PHP function that takes in the function name, and returns a string
181 # to put in its place. This can be used to generate links, images, etc.\n\n";
182 
183  $linkhash = array();
184 
185  foreach($this->used_categories as $c)
186  {
187  $linkhash{$c} = "donothing";
188  }
189 
190  $this->_dump_hash($linkhash, "\$this->linkscripts ");
191  print "}\n";
192  print "\n# DoNothing link function\n\n";
193  print "function donothing(\$keywordin)\n{\n return \$keywordin;\n}\n";
194  }
_dump_hash($hash, $name)
Definition: HFile.php:256
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dump_perl_array()

HFile::_dump_perl_array (   $array,
  $name 
)

Definition at line 244 of file HFile.php.

Referenced by to_perl().

245  {
246  $first = 1;
247  print $name." = [";
248  foreach($array as $a)
249  {
250  if (!$first) print ", "; else $first = 0;
251  print "\"".addslashes($a)."\"";
252  }
253  print "];\n";
254  }
+ Here is the caller graph for this function:

◆ _dump_perl_defaultscripts()

HFile::_dump_perl_defaultscripts ( )

Definition at line 211 of file HFile.php.

Referenced by to_perl().

212  {
213  print "\n# DoNothing link function\n\n";
214  print "sub donothing\n{\nmy ( \$self ) = @_;\nreturn;\n}\n";
215  }
+ Here is the caller graph for this function:

◆ _dump_perl_hash()

HFile::_dump_perl_hash (   $hash,
  $name 
)

Definition at line 269 of file HFile.php.

Referenced by _dump_perl_linkscripts(), and to_perl().

270  {
271  $first = 1;
272  print $name." = {";
273  foreach(array_keys($hash) as $k)
274  {
275  if (!$first) print ", "; else $first = 0;
276  print "\n \"".addslashes($k)."\"";
277  print " => \"".addslashes($hash[$k])."\"";
278  }
279  print "};\n";
280  }
+ Here is the caller graph for this function:

◆ _dump_perl_linkscripts()

HFile::_dump_perl_linkscripts ( )

Definition at line 196 of file HFile.php.

References _dump_perl_hash(), and array.

Referenced by to_perl().

197  {
198  print "
199 # Each category can specify a Perl function that takes in the function name, and returns a string
200 # to put in its place. This can be used to generate links, images, etc.\n\n";
201 
202  $linkhash = array();
203  foreach($this->used_categories as $c)
204  {
205  $linkhash{$c} = "donothing";
206  }
207 
208  $this->_dump_perl_hash($linkhash, "\$self->{linkscripts} ");
209  }
Create styles array
The data for the language used.
_dump_perl_hash($hash, $name)
Definition: HFile.php:269
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dump_var()

HFile::_dump_var (   $variable,
  $name 
)

Definition at line 227 of file HFile.php.

Referenced by to_perl(), and to_php().

228  {
229  print $name." = \"".addslashes($variable)."\";\n";
230  }
+ Here is the caller graph for this function:

◆ _get_categories()

HFile::_get_categories ( )

Definition at line 165 of file HFile.php.

References array.

Referenced by to_perl(), and to_php().

166  {
167  $usedcats = array();
168 
169  foreach(array_keys($this->keywords) as $k)
170  {
171  $cat = $this->keywords[$k];
172  if (!in_array($cat, $usedcats)) array_push($usedcats, $cat);
173  }
174  return $usedcats;
175  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parse_file()

HFile::parse_file (   $file)

Definition at line 71 of file HFile.php.

72  {
73  print "This method should not be called from here, but from an extending configuration class.<br>";
74  }

◆ to_perl()

HFile::to_perl (   $stub,
  $tofile = 1 
)

Definition at line 76 of file HFile.php.

References _dump_perl_array(), _dump_perl_defaultscripts(), _dump_perl_hash(), _dump_perl_linkscripts(), _dump_var(), and _get_categories().

77  {
78  $this->used_categories = $this->_get_categories();
79  print "
80 package HFile::$stub;
81 
82 ###############################
83 #
84 # Beautifier Perl HFile
85 # Language: $stub
86 #
87 ###############################
88 
89 use Beautifier::HFile;
90 @ISA = qw(HFile);
91 sub new
92 {
93  my( \$class ) = @_;
94  my \$self = {};
95  bless \$self, \$class;
96 
97  # Flags:
98 ";
99  $this->_dump_var($this->nocase, " \$self->{nocase} ");
100  $this->_dump_var($this->notrim, " \$self->{notrim} ");
101  $this->_dump_var($this->perl, " \$self->{perl} ");
102  $this->_dump_perl_array($this->indent, " \$self->{indent} ");
103  $this->_dump_perl_array($this->unindent, " \$self->{unindent} ");
104  $this->_dump_perl_array($this->stringchars, " \$self->{stringchars} ");
105  $this->_dump_perl_array($this->delimiters, " \$self->{delimiters} ");
106  $this->_dump_var($this->escchar, " \$self->{escchar} ");
107  $this->_dump_perl_array($this->linecommenton, " \$self->{linecommenton} ");
108  $this->_dump_perl_array($this->blockcommenton, " \$self->{blockcommenton} ");
109  $this->_dump_perl_array($this->blockcommentoff, " \$self->{blockcommentoff}");
110  $this->_dump_perl_hash($this->keywords, " \$self->{keywords} ");
111  $this->_dump_perl_linkscripts();
112 print "
113  return \$self;
114 }
115 
116 ";
117 
118  $this->_dump_perl_defaultscripts();
119 print "1;\n";
120  }
_dump_var($variable, $name)
Definition: HFile.php:227
_dump_perl_defaultscripts()
Definition: HFile.php:211
_get_categories()
Definition: HFile.php:165
_dump_perl_linkscripts()
Definition: HFile.php:196
_dump_perl_array($array, $name)
Definition: HFile.php:244
_dump_perl_hash($hash, $name)
Definition: HFile.php:269
+ Here is the call graph for this function:

◆ to_php()

HFile::to_php (   $stub,
  $tofile = 1 
)

Definition at line 122 of file HFile.php.

References _dump_array(), _dump_colours(), _dump_hash(), _dump_linkscripts(), _dump_var(), and _get_categories().

123  {
124 
125 
126  $this->used_categories = $this->_get_categories();
127 
128  if ($tofile) print "<?php\n"; else print "&lt;?\n";
129  print "require_once('psh.php');\n";
130  print "class psh_$stub extends psh\n{\n";
131  print "function psh_$stub(){\n";
132  print "\$this->psh();\n";
133  print "######################################\n";
134  print "# Beautifier Highlighting Configuration File \n";
135  print "# $this->lang_name\n";
136  print "######################################\n";
137  print "# Flags\n\n";
138  $this->_dump_var($this->nocase, "\$this->nocase ");
139  $this->_dump_var($this->notrim, "\$this->notrim ");
140  $this->_dump_var($this->perl, "\$this->perl ");
141  print "\n# Colours\n\n";
142  $this->_dump_colours();
143  $this->_dump_var("blue", "\$this->quotecolour ");
144  $this->_dump_var("green", "\$this->blockcommentcolour");
145  $this->_dump_var("green", "\$this->linecommentcolour ");
146  print "\n# Indent Strings\n\n";
147  $this->_dump_array($this->indent, "\$this->indent ");
148  $this->_dump_array($this->unindent, "\$this->unindent ");
149  print "\n# String characters and delimiters\n\n";
150  $this->_dump_array($this->stringchars, "\$this->stringchars ");
151  $this->_dump_array($this->delimiters, "\$this->delimiters ");
152  $this->_dump_var ($this->escchar, "\$this->escchar ");
153  print "\n# Comment settings\n\n";
154  $this->_dump_array($this->linecommenton, "\$this->linecommenton ");
155  $this->_dump_var ($this->blockcommenton, "\$this->blockcommenton ");
156  $this->_dump_var ($this->blockcommentoff, "\$this->blockcommentoff ");
157  print "\n# Keywords (keyword mapping to colour number)\n\n";
158  $this->_dump_hash ($this->keywords, "\$this->keywords ");
159  print "\n# Special extensions\n";
160  $this->_dump_linkscripts();
161  print "}\n";
162  if ($tofile) print "\n?>"; else print "\n?&gt;";
163  }
_dump_array($array, $name)
Definition: HFile.php:232
_dump_var($variable, $name)
Definition: HFile.php:227
_dump_hash($hash, $name)
Definition: HFile.php:256
_get_categories()
Definition: HFile.php:165
_dump_colours()
Definition: HFile.php:217
_dump_linkscripts()
Definition: HFile.php:177
+ Here is the call graph for this function:

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