Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

create_variable_overview.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 15.78 KiB


001  <?php
002  // -------------------------------------------------------------
003  //
004  // $Id$
005  //
006  // FILENAME  : create_variable_overview.php
007  // STARTED   : Fri Aug 15 2003
008  // COPYRIGHT : � 2003 phpBB Group
009  // WWW       : http://www.phpbb.com/
010  // LICENCE   : GPL vs2.0 [ see /docs/COPYING ] 
011  // 
012  // -------------------------------------------------------------
013   
014  /*
015      This script generates an index of some template vars and their use within the templates.
016      It writes down all language variables used by various templates.
017  */
018   
019  //
020  // Security message:
021  //
022  // This script is potentially dangerous.
023  // Remove or comment the next line (die(".... ) to enable this script.
024  // Do NOT FORGET to either remove this script or disable it after you have used it.
025  //
026  die("Please read the first lines of this script for instructions on how to enable it");
027   
028  $directory = '../styles/subSilver/template/';
029  $ext = 'html';
030  $store_dir = '../store/';
031   
032  $phpfiles_directories = array('../', '../includes/', '../includes/acm/', '../includes/auth/', '../includes/mcp/', '../includes/ucp/');
033  // Template Files beginning with this names are merged together
034  $merge = array('gcp', 'login', 'mcp', 'memberlist', 'posting', 'ucp');
035   
036  if (!is_writable($store_dir))
037  {
038      die("Directory $store_dir is not writable!");
039  }
040   
041  $contents = implode('', file('../adm/subSilver.css', filesize('../adm/subSilver.css')));
042  $fp = fopen($store_dir . 'subSilver.css', 'w');
043  fwrite($fp, $contents);
044  fclose($fp);
045   
046  $html_skeleton = '
047  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
048  <html>
049  <head>
050  <link rel="stylesheet" href="subSilver.css" type="text/css">
051  <style type="text/css">
052  <!--
053  th        { background-image: url(\'cellpic3.gif\') }
054  td.cat    { background-image: url(\'cellpic1.gif\') }
055  //-->
056  </style>
057  <title>{FILENAME}</title>
058  </head>
059  <body>
060   
061  <table width="100%" cellspacing="0" cellpadding="0" border="0">
062      <tr>
063          <td><img src="header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td>
064          <td width="100%" background="header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">File {FILENAME}</span> &nbsp; &nbsp; &nbsp;</td>
065      </tr>
066  </table>
067   
068  <table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
069      <tr>
070          <td><br clear="all" />
071   
072  ';
073  $html_skeleton .= '<br><a href="./index.html" class="gen">Back to Contents</a><br><br>';
074  $html_skeleton .= '<br><a href="#lang" class="gen">Language Variables</a> :: <a href="#includes" class="gen">Includes</a> :: <a href="#cond" class="gen">Conditionals</a><br><a href="#remain" class="gen">Remaining Vars</a> :: <a href="#usedby" class="gen">phpBB File Usage</a> :: <a href="#ref" class="gen">References</a>';
075  $html_skeleton .= '<br><br><a name="lang"></a><b>Language Variables</b><br><br>{LANGUAGE_VARIABLES}';
076  $html_skeleton .= '<br><br><a name="includes"></a><b>Included Files</b><br><br>{INCLUDES}';
077  $html_skeleton .= '<br><br><a name="cond"></a><b>Used Conditionals</b><br><br>{CONDITIONALS}';
078  $html_skeleton .= '<br><br><a name="remain"></a><b>Remaining Vars used</b><br><br>{REMAINING_VARS}';
079  $html_skeleton .= '<br><br><a name="usedby"></a><b>This Template File is used by the following phpBB Files</b><br><br>{USED_BY}';
080  $html_skeleton .= '<br><br><a name="ref"></a><b>References: </b>{SEE_FILES}';
081   
082  //$html_skeleton .= "</body>\n</html>\n";
083   
084  $html_skeleton .= '
085  <br><br>
086  <div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
087   
088          <br clear="all" /></td>
089      </tr>
090  </table>
091   
092  </body>
093  </html>
094  ';
095   
096  // Open Language File
097  include('../language/en/lang_main.php');
098  include('../language/en/lang_admin.php');
099   
100  $files_to_parse = $php_files = array();
101   
102  $dhandler = opendir($directory);
103  if (!$dhandler)
104  {
105      die("Unable to open $directory");
106  }
107   
108  $num = 0;
109  while ($file = readdir($dhandler))
110  {
111      if (is_file($directory . $file) && preg_match('#\.' . $ext . '$#i', $file))
112      {
113          $files_to_parse[$num]['filename'] = $directory . $file;
114          $files_to_parse[$num]['single_filename'] = $file;
115          $files_to_parse[$num]['destfile'] = str_replace(".{$ext}", '', $file) . '_' . $num . '.html';
116          $file_to_destfile[$file] = $files_to_parse[$num]['destfile'];
117          $num++;
118      }
119  }
120  closedir($dhandler);
121   
122  $num = 0;
123  foreach ($phpfiles_directories as $directory)
124  {
125      $dhandler = opendir($directory);
126      if (!$dhandler)
127      {
128          die("Unable to open $directory");
129      }
130   
131      while ($file = readdir($dhandler))
132      {
133          if (is_file($directory . $file) && preg_match('#\.php$#i', $file))
134          {
135              $php_files[$num]['filename'] = $directory . $file;
136              $php_files[$num]['single_filename'] = $file;
137              $num++;
138          }
139      }
140      closedir($dhandler);
141  }
142   
143  $php_files_includes = $lang_references = array();
144   
145  //$php_files_includes['viewtopic_attach_body.html'][0] = filename
146   
147  echo '<br>Parsing PHP Files';
148   
149  // Parse PHP Files and get our filenames
150  foreach ($php_files as $file_num => $data)
151  {
152      echo '.';
153      flush();
154      $contents = implode('', file($data['filename'], filesize($data['filename'])));
155   
156      $html_files = array();
157      preg_match_all('#([a-zA-Z0-9\-_]*?)\.' . $ext . '#s', $contents, $html_files);
158      $html_files = array_unique($html_files[1]);
159   
160      foreach ($html_files as $html_file)
161      {
162          $html_file = trim($html_file);
163          if ($html_file != '')
164          {
165              $php_files_includes[$html_file . '.' . $ext][] = $data['filename'];
166          }
167      }
168  }
169   
170  echo '<br>Parsing HTML Files';
171  foreach ($files_to_parse as $file_num => $data)
172  {
173      echo '.';
174      flush();
175      $contents = implode('', file($data['filename'], filesize($data['filename'])));
176   
177      // Language Variables -> [0]:tpl [1]:lang
178      $lang_vars = array();
179      preg_match_all('#{L_([a-z0-9\-_]*?)\}#is', $contents, $lang_vars);
180      $contents = preg_replace('#{L_([a-z0-9\-_]*?)\}#is', '', $contents);
181      $lang_vars[0] = array_unique($lang_vars[0]);
182      $lang_vars[1] = array_unique($lang_vars[1]);
183   
184      // Includes
185      $includes = array();
186      preg_match_all('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#s', $contents, $includes);
187      $contents = preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', '', $contents);
188      $includes = $includes[1];
189      $includes = array_unique($includes);
190   
191      // IF Conditions
192      $switches = array();
193      preg_match_all('#<!-- [IF]|[ELSEIF] ([a-zA-Z0-9\-_\.]+?) (.*?)?[ ]?-->#', $contents, $switches);
194      $contents = preg_replace('#<!-- [IF]|[ELSEIF] ([a-zA-Z0-9\-_]) (.*?)?[ ]?-->#s', '', $contents);
195      $switches[0] = array_unique($switches[1]); // No resorting please
196      $switches[1] = $switches[2];
197      unset($switches[2]);
198   
199      // Remaining Vars
200      $remaining_vars = array();
201      preg_match_all('#{([a-z0-9\-_\.]*?)\}#is', $contents, $remaining_vars);
202      $contents = preg_replace('#{([a-z0-9\-_]*?)\}#is', '', $contents);
203      $remaining_vars = array_unique($remaining_vars[1]);
204      sort($remaining_vars, SORT_STRING);
205   
206      // Now build the filename specific site
207      $fp = fopen($store_dir . $data['destfile'], 'w');
208      $html_data = $html_skeleton;
209   
210      $html_data = str_replace('{FILENAME}', $data['single_filename'], $html_data);
211   
212      // Write up the Language Variables
213      if (count($lang_vars[0]))
214      {
215          $lang_data = '<ul>';
216          for ($num = 0; $num <= count($lang_vars[0]); $num++)
217          {
218              $var = $lang_vars[0][$num];
219              if ($var != '')
220              {
221                  $_var = str_replace(array('{', '}'), array('', ''), $var);
222                  $lang_references[$_var][] = $data['single_filename'];
223                  $lang_data .= '<li>' . $var . '<br>' . "\n" . ((isset($lang[$_var])) ? htmlspecialchars(str_replace("\\'", "'", $lang[$_var])) : '<span style="color:red">No Language Variable available</span>') . '<br></li><br>' . "\n";
224              }
225          }
226          $lang_data .= '</ul>';
227      }
228      else
229      {
230          $lang_data = '<b>NONE</b><br>' . "\n";
231      }
232   
233      $html_data = str_replace('{LANGUAGE_VARIABLES}', $lang_data, $html_data);
234   
235      // Write up the Includes
236      echo '.';
237      flush();
238      if (count($includes))
239      {
240          $includes_data = '<ul>';
241          $see_files = '';
242          for ($num = 0; $num <= count($includes); $num++)
243          {
244              $var = $includes[$num];
245              if ($var != '')
246              {
247                  $includes_data .= '<li><a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a></li><br>' . "\n";
248                  $see_files .= ($see_files != '') ? ' :: ' : '';
249                  $see_files .= '<a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a>';
250              }
251          }
252          $includes_data .= '</ul>';
253      }
254      else
255      {
256          $includes_data = '<b>NONE</b><br>' . "\n";
257          $see_files = '<b>NONE</b>';
258      }
259   
260      $html_data = str_replace('{INCLUDES}', $includes_data, $html_data);
261      $html_data = str_replace('{SEE_FILES}', $see_files, $html_data);
262   
263      // Write up Conditionals
264      echo '.';
265      flush();
266      if (count($switches[0]))
267      {
268          $conditionals = '<ul>';
269          for ($num = 0; $num <= count($switches[0]); $num++)
270          {
271              $var = trim($switches[0][$num]);
272              if ($var != '')
273              {
274                  if ($var == 'not')
275                  {
276                      $conditionals .= '<li>' . trim($switches[1][$num]) . '<br><b>Negation</b><br>' . "\n";
277                      $block_var = explode('.', trim($switches[1][$num]));
278                      unset($block_var[0]);
279                  }
280                  else
281                  {
282                      $conditionals .= '<li>' . $var . ((trim($switches[1][$num]) != '') ? '<br>' . "\n" . '<i>Compared with</i> -&gt; <b>' . trim($switches[1][$num]) . '</b>' : '') . '<br>' . "\n";
283                      $block_var = explode('.', $var);
284                      unset($block_var[count($block_var)-1]);
285                  }
286   
287                  if (count($block_var))
288                  {
289                      for ($_num = count($block_var)-1; $_num >= 0; $_num--)
290                      {
291                          $conditionals .= ($_num == count($block_var)-1) ? '<i>Element of Block</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n" : '<i>...which is an element of</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n";
292                      }
293                  }
294                  $conditionals .= '<br></li>' . "\n";
295              }
296          }
297          $conditionals .= '</ul>';
298      }
299      else
300      {
301          $conditionals = '<b>NONE</b><br>' . "\n";
302      }
303   
304      $html_data = str_replace('{CONDITIONALS}', $conditionals, $html_data);
305   
306      // Write up Remaining Vars
307      echo '.';
308      flush();
309      if (count($remaining_vars))
310      {
311          $remaining = '<ul>';
312          for ($num = 0; $num <= count($remaining_vars); $num++)
313          {
314              $var = trim($remaining_vars[$num]);
315              if ($var != '')
316              {
317                  $remaining .= '<li>' . $var . '<br>' . "\n";
318                  $block_var = explode('.', $var);
319                  unset($block_var[count($block_var)-1]);
320   
321                  if (count($block_var))
322                  {
323                      for ($_num = count($block_var)-1; $_num >= 0; $_num--)
324                      {
325                          $remaining .= ($_num == count($block_var)-1) ? '<i>Element of Block</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n" : '<i>...which is an element of</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n";
326                      }
327                  }
328                  $remaining .= '<br></li>' . "\n";
329              }
330          }
331          $remaining .= '</ul>';
332      }
333      else
334      {
335          $remaining = '<b>NONE</b><br>' . "\n";
336      }
337   
338      $html_data = str_replace('{REMAINING_VARS}', $remaining, $html_data);
339   
340      if (isset($php_files_includes[$data['single_filename']]) && count($php_files_includes[$data['single_filename']]))
341      {
342          $usedby = '<ul>';
343          foreach ($php_files_includes[$data['single_filename']] as $php_filename)
344          {
345              $usedby .= '<li>' . str_replace('../', '', $php_filename) . '</li>';
346          }
347          $usedby .= '</ul>';
348      }
349      else
350      {
351          $usedby = '<b>NONE</b><br>' . "\n";
352      }
353   
354      $html_data = str_replace('{USED_BY}', $usedby, $html_data);
355   
356      fwrite($fp, $html_data);
357      fclose($fp);
358  }
359   
360  echo '<br>Store Files';
361   
362  $fp = fopen($store_dir . 'index.html', 'w');
363   
364  $html_data = '
365  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
366  <html>
367  <head>
368  <link rel="stylesheet" href="subSilver.css" type="text/css">
369  <style type="text/css">
370  <!--
371  th        { background-image: url(\'cellpic3.gif\') }
372  td.cat    { background-image: url(\'cellpic1.gif\') }
373  //-->
374  </style>
375  <title>Contents</title>
376  </head>
377  <body>
378   
379  <table width="100%" cellspacing="0" cellpadding="0" border="0">
380      <tr>
381          <td><img src="header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td>
382          <td width="100%" background="header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">Available Template Files</span> &nbsp; &nbsp; &nbsp;</td>
383      </tr>
384  </table>
385   
386  <table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
387      <tr>
388          <td><br clear="all" />
389  <br>This Style Document is 100% auto-generated... no human interaction included. :D<br>
390  <h2>phpBB 2.2 Template</h2>
391  <br>
392  <ol>
393  ';
394   
395  sort($files_to_parse);
396  foreach ($files_to_parse as $file_num => $data)
397  {
398      echo '.';
399      flush();
400      $var = $data['single_filename'];
401      $html_data .= '<li><a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a></li><br>' . "\n";
402  }
403   
404  $html_data .= '<br><li><a href="./lang_index.html" class="gen">Appendix A: Language Variable Index</a></li><br>';
405   
406  $html_data .= '
407  </ol><br><br>
408  <div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
409   
410          <br clear="all" /></td>
411      </tr>
412  </table>
413   
414  </body>
415  </html>
416  ';
417   
418  fwrite($fp, $html_data);
419  fclose($fp);
420   
421  // Not only write down all language files, place them into a specific array, named by the template file
422  // All Language vars assigned to more than one template will be placed into a common file
423  $entry = array();
424  $common_fp = fopen($store_dir . 'lang_common.php', 'w');
425  fwrite($common_fp, "<?php\n\n \$lang = array(\n");
426   
427  $fp = fopen($store_dir . 'lang_index.html', 'w');
428   
429  $html_data = '
430  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
431  <html>
432  <head>
433  <link rel="stylesheet" href="subSilver.css" type="text/css">
434  <style type="text/css">
435  <!--
436  th        { background-image: url(\'cellpic3.gif\') }
437  td.cat    { background-image: url(\'cellpic1.gif\') }
438  //-->
439  </style>
440  <title>Appendix A :: Language Variable Index</title>
441  </head>
442  <body>
443   
444  <table width="100%" cellspacing="0" cellpadding="0" border="0">
445      <tr>
446          <td><img src="header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td>
447          <td width="100%" background="header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">Language Variable Index</span> &nbsp; &nbsp; &nbsp;</td>
448      </tr>
449  </table>
450   
451  <table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
452      <tr>
453          <td><br clear="all" />
454  <br><a href="./index.html" class="gen">Back to Contents</a><br><br>
455  <br>
456  ';
457   
458  echo '<br>Write Language Files';
459   
460  asort($lang_references);
461  ksort($lang_references);
462  $_index = '';
463  $old_char = '';
464  foreach ($lang_references as $lang_var => $filenames)
465  {
466      $var = preg_replace('#^L_(.*?)#', '\1', $lang_var);
467      $char = $var{0};
468      if ($old_char != $char)
469      {
470          $old_char = $char;
471          $_index .= ($_index != '') ? ' :: ' : '';
472          $_index .= '<a href="#' . $char . '" class="gen"><b>' . $char . '</b></a>';
473      }
474  }
475   
476  $html_data .= $_index . '<br><br><br>';
477  $old_char = '';
478  foreach ($lang_references as $lang_var => $filenames)
479  {
480      echo '.';
481      flush();
482      $var = preg_replace('#^L_(.*?)#', '\1', $lang_var);
483      $char = $var{0};
484      if ($old_char != $char)
485      {
486          $old_char = $char;
487          $html_data .= '<br><hr><br><a name="' . $char . '"></a><h2>Letter ' . $char . '</h2><br><br>';
488      }
489   
490      $html_data .= '<b>' . $lang_var . '</b><ul>';
491   
492      if (sizeof($filenames) != 1)
493      {
494          fwrite($common_fp, (($entry['common']) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'");
495          $entry['common'] = true;
496      }
497      else if (sizeof($filenames) == 1)
498      {
499          // Merge logical - hardcoded
500          $fname = (preg_match('#^(' . implode('|', $merge) . ')#', $filenames[0], $match)) ? $match[0] . '.php' : str_replace($ext, 'php', $filenames[0]);
501          
502          if (!$lang_fp[$fname])
503          {
504              $lang_fp[$fname] = fopen($store_dir . 'lang_' . $fname, 'w');
505              fwrite($lang_fp[$fname], "<?php\n\n\$lang = array(\n");
506              $entry[$fname] = false;
507          }
508          fwrite($lang_fp[$fname], (($entry[$fname]) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'");
509          $entry[$fname] = true;
510      }
511      
512      foreach ($filenames as $f_name)
513      {
514          $var = trim($f_name);
515          $html_data .= '<li><a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a></li><br>' . "\n";
516      }
517      $html_data .= '</ul><br><br>';
518  }
519   
520  fwrite($common_fp, ")\n);\n?>");
521  fclose($common_fp);
522   
523  foreach ($lang_fp as $filepointer)
524  {
525      fwrite($filepointer, ")\n);\n?>");
526      fclose($filepointer);
527  }
528   
529  $html_data .= '
530  <br><br>
531  <div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
532   
533          <br clear="all" /></td>
534      </tr>
535  </table>
536   
537  </body>
538  </html>
539  ';
540   
541  fwrite($fp, $html_data);
542  fclose($fp);
543   
544  echo '<br>Finished!';
545  flush();
546   
547  ?>