ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
generate-includes.php File Reference

Generates an include stub for users who do not want to use the autoloader. More...

Go to the source code of this file.

Functions

 get_dependency_lookup ($file)
 Returns a lookup array of dependencies for a file. More...
 
 dep_sort ($files)
 Sorts files based on dependencies. More...
 

Variables

 $FS = new FSTools()
 
 $exclude_dirs
 
 $exclude_files
 
 $raw_files = $FS->globr('.', '*.php')
 
 $files = array()
 
 foreach ( $raw_files as $file)
 
 $version = trim(file_get_contents('../VERSION'))
 
 $php
 

Detailed Description

Generates an include stub for users who do not want to use the autoloader.

When new files are added to HTML Purifier's main codebase, this file should be called.

Definition in file generate-includes.php.

Function Documentation

◆ dep_sort()

dep_sort (   $files)

Sorts files based on dependencies.

This function is lazy and will not group files with dependencies together; it will merely ensure that a file is never included before its dependencies are.

Parameters
$filesFiles array to sort.
Returns
Sorted array ($files is not modified by reference!)

Definition at line 112 of file generate-includes.php.

References $file, $files, $ret, array, and get_dependency_lookup().

113 {
114  $ret = array();
115  $cache = array();
116  foreach ($files as $file) {
117  if (isset($cache[$file])) continue;
118  $deps = get_dependency_lookup($file);
119  foreach (array_keys($deps) as $dep) {
120  if (!isset($cache[$dep])) {
121  $ret[] = $dep;
122  $cache[$dep] = true;
123  }
124  }
125  $cache[$file] = true;
126  $ret[] = $file;
127  }
128  return $ret;
129 }
130 
132 
133 // Build the actual include stub:
134 
135 $version = trim(file_get_contents('../VERSION'));
136 
137 // stub
138 $php = "<?php
139 
158 ";
159 
160 foreach ($files as $file) {
161  $php .= "require '$file';" . PHP_EOL;
162 }
163 
164 echo "Writing HTMLPurifier.includes.php... ";
165 file_put_contents('HTMLPurifier.includes.php', $php);
166 echo "done!\n";
167 
168 $php = "<?php
169 
180 \$__dir = dirname(__FILE__);
181 
182 ";
183 
184 foreach ($files as $file) {
185  $php .= "require_once \$__dir . '/$file';" . PHP_EOL;
186 }
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
Create styles array
The data for the language used.
dep_sort($files)
Sorts files based on dependencies.
$ret
Definition: parser.php:6
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
get_dependency_lookup($file)
Returns a lookup array of dependencies for a file.
+ Here is the call graph for this function:

◆ get_dependency_lookup()

get_dependency_lookup (   $file)

Returns a lookup array of dependencies for a file.

Note
This function expects that format $name extends $parent on one line
Parameters
string$fileFile to check dependencies of.
Returns
array Lookup array of files the file is dependent on, sorted accordingly.

Definition at line 69 of file generate-includes.php.

References $fh, $file, array, and HTMLPurifier_Bootstrap\getPath().

Referenced by dep_sort().

70 {
71  static $cache = array();
72  if (isset($cache[$file])) return $cache[$file];
73  if (!file_exists($file)) {
74  echo "File doesn't exist: $file\n";
75  return array();
76  }
77  $fh = fopen($file, 'r');
78  $deps = array();
79  while (!feof($fh)) {
80  $line = fgets($fh);
81  if (strncmp('class', $line, 5) === 0) {
82  // The implementation here is fragile and will break if we attempt
83  // to use interfaces. Beware!
84  $arr = explode(' extends ', trim($line, ' {'."\n\r"), 2);
85  if (count($arr) < 2) break;
86  $parent = $arr[1];
87  $dep_file = HTMLPurifier_Bootstrap::getPath($parent);
88  if (!$dep_file) break;
89  $deps[$dep_file] = true;
90  break;
91  }
92  }
93  fclose($fh);
94  foreach (array_keys($deps) as $file) {
95  // Extra dependencies must come *before* base dependencies
96  $deps = get_dependency_lookup($file) + $deps;
97  }
98  $cache[$file] = $deps;
99  return $deps;
100 }
static getPath($class)
Returns the path for a specific class.
Definition: Bootstrap.php:58
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
get_dependency_lookup($file)
Returns a lookup array of dependencies for a file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ $exclude_dirs

$exclude_dirs
Initial value:
'HTMLPurifier/Language/',
'HTMLPurifier/ConfigSchema/',
'HTMLPurifier/Filter/',
'HTMLPurifier/Printer/',
)
Create styles array
The data for the language used.

Definition at line 20 of file generate-includes.php.

◆ $exclude_files

$exclude_files
Initial value:
'HTMLPurifier/Lexer/PEARSax3.php',
'HTMLPurifier/Lexer/PH5P.php',
'HTMLPurifier/Printer.php',
)
Create styles array
The data for the language used.

Definition at line 29 of file generate-includes.php.

◆ $files

$files = array()

Definition at line 39 of file generate-includes.php.

Referenced by dep_sort().

◆ $FS

$FS = new FSTools()

Definition at line 18 of file generate-includes.php.

◆ $php

$php
Initial value:
= "<?php
"

Definition at line 138 of file generate-includes.php.

◆ $raw_files

$raw_files = $FS->globr('.', '*.php')

Definition at line 37 of file generate-includes.php.

◆ $version

$version = trim(file_get_contents('../VERSION'))

Definition at line 135 of file generate-includes.php.

Referenced by GuzzleHttp\Psr7\Request\__construct(), ilFileVersionTableGUI\__construct(), GuzzleHttp\Psr7\ServerRequest\__construct(), getID3_cached_mysqli\__construct(), getID3_cached_mysql\__construct(), GuzzleHttp\Psr7\Response\__construct(), ilvCard\__construct(), getID3_cached_sqlite3\__construct(), PHPExcel_Reader_Excel5\_readBof(), PHPExcel_Reader_Excel5\_readColor(), PHPExcel_Writer_Excel5_BIFFwriter\_storeBof(), ilLTIToolProvider\authenticate(), IMSGlobal\LTI\ToolProvider\ToolProvider\authenticate(), sspmod_oauth_OAuthStore\authorize(), ilSetup\checkPHPVersion(), Monolog\Handler\HipChatHandlerTest\createHandler(), getid3_dts\dialogNormalization(), TCPDF_STATIC\get_mqr(), OAuthServer\get_version(), ilDataSet\getJsonRepresentation(), getid3_lyrics3\getLyrics3Data(), ilObjRemoteFileListGUI\getProperties(), ilObjFileListGUI\getProperties(), ilMDLifecycle\getVersion(), ilPlugin\getVersion(), TCPDF\ImageEps(), ilLDAPSettingsGUI\initForm(), ilUtil\isConvertVersionAtLeast(), ilDBMySQL\isMysql4_0OrHigher(), ilDBMySQL\isMysql4_1(), ilDBMySQL\isMysql4_1OrHigher(), ilDBMySQL\isMysql5_6OrHigher(), HTMLPurifier_DefinitionCache\isOld(), MDB2_Driver_Common\loadModule(), getid3_mp3\MPEGaudioFrameLength(), sspmod_oauth_OAuthStore\new_request_token(), GuzzleHttp\Psr7\parse_request(), ilPluginAdmin\parsePluginPhp(), ilUtil\processConvertVersion(), ilDBUpdate\readCustomUpdatesFileVersion(), ilDBUpdate\readFileVersion(), ilDBUpdate\readHotfixFileVersion(), ilLTIToolProvider\result(), IMSGlobal\LTI\ToolProvider\ToolProvider\result(), assFileUpload\savePreviewData(), SAML2\SOAPClient\send(), TCPDF_STATIC\set_mqr(), ilDBMySQL\setMaxAllowedPacket(), TCPDF\setPDFVersion(), ilTextAreaInputGUI\setRTESupport(), SimpleSAML\Store\SQL\setTableVersion(), ilTextAreaInputGUI\setUseRte(), ilvCard\setVersion(), ilWorkflowEngineDefinitionsGUI\showUploadForm(), IMSGlobal\LTI\ToolProvider\ToolConsumer\signParameters(), GuzzleHttp\Psr7\withProtocolVersion(), Slim\Http\Message\withProtocolVersion(), and getid3_mp3\XingVBRidOffset().

◆ foreach

foreach($files as $file)

Definition at line 40 of file generate-includes.php.