* @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. * */ /** * This script generates an index of some template vars and their use within the templates. * It writes down all language variables used by various templates. */ // // Security message: // // This script is potentially dangerous. // Remove or comment the next line (die(".... ) to enable this script. // Do NOT FORGET to either remove this script or disable it after you have used it. // die("Please read the first lines of this script for instructions on how to enable it"); $directory = '../styles/subSilver/template/'; $ext = 'html'; $store_dir = '../store/'; $phpfiles_directories = array('../', '../includes/', '../includes/acm/', '../includes/auth/', '../includes/mcp/', '../includes/ucp/'); // Template Files beginning with this names are merged together $merge = array('gcp', 'login', 'mcp', 'memberlist', 'posting', 'ucp'); if (!is_writable($store_dir)) { die("Directory $store_dir is not writable!"); } $contents = implode('', file('../adm/subSilver.css', filesize('../adm/subSilver.css'))); $fp = fopen($store_dir . 'subSilver.css', 'w'); fwrite($fp, $contents); fclose($fp); $html_skeleton = ' {FILENAME}
phpBB Logo File {FILENAME}      

'; $html_skeleton .= '
Back to Contents

'; $html_skeleton .= '
Language Variables :: Includes :: Conditionals
Remaining Vars :: phpBB File Usage :: References'; $html_skeleton .= '

Language Variables

{LANGUAGE_VARIABLES}'; $html_skeleton .= '

Included Files

{INCLUDES}'; $html_skeleton .= '

Used Conditionals

{CONDITIONALS}'; $html_skeleton .= '

Remaining Vars used

{REMAINING_VARS}'; $html_skeleton .= '

This Template File is used by the following phpBB Files

{USED_BY}'; $html_skeleton .= '

References: {SEE_FILES}'; //$html_skeleton .= "\n\n"; $html_skeleton .= '


'; // Open Language File include('../language/en/lang_main.php'); include('../language/en/lang_admin.php'); $files_to_parse = $php_files = array(); $dhandler = opendir($directory); if (!$dhandler) { die("Unable to open $directory"); } $num = 0; while ($file = readdir($dhandler)) { if (is_file($directory . $file) && preg_match('#\.' . $ext . '$#i', $file)) { $files_to_parse[$num]['filename'] = $directory . $file; $files_to_parse[$num]['single_filename'] = $file; $files_to_parse[$num]['destfile'] = str_replace(".{$ext}", '', $file) . '_' . $num . '.html'; $file_to_destfile[$file] = $files_to_parse[$num]['destfile']; $num++; } } closedir($dhandler); $num = 0; foreach ($phpfiles_directories as $directory) { $dhandler = opendir($directory); if (!$dhandler) { die("Unable to open $directory"); } while ($file = readdir($dhandler)) { if (is_file($directory . $file) && preg_match('#\.php$#i', $file)) { $php_files[$num]['filename'] = $directory . $file; $php_files[$num]['single_filename'] = $file; $num++; } } closedir($dhandler); } $php_files_includes = $lang_references = array(); //$php_files_includes['viewtopic_attach_body.html'][0] = filename echo '
Parsing PHP Files'; // Parse PHP Files and get our filenames foreach ($php_files as $file_num => $data) { echo '.'; flush(); $contents = implode('', file($data['filename'], filesize($data['filename']))); $html_files = array(); preg_match_all('#([a-zA-Z0-9\-_]*?)\.' . $ext . '#s', $contents, $html_files); $html_files = array_unique($html_files[1]); foreach ($html_files as $html_file) { $html_file = trim($html_file); if ($html_file != '') { $php_files_includes[$html_file . '.' . $ext][] = $data['filename']; } } } echo '
Parsing HTML Files'; foreach ($files_to_parse as $file_num => $data) { echo '.'; flush(); $contents = implode('', file($data['filename'], filesize($data['filename']))); // Language Variables -> [0]:tpl [1]:lang $lang_vars = array(); preg_match_all('#{L_([a-z0-9\-_]*?)\}#is', $contents, $lang_vars); $contents = preg_replace('#{L_([a-z0-9\-_]*?)\}#is', '', $contents); $lang_vars[0] = array_unique($lang_vars[0]); $lang_vars[1] = array_unique($lang_vars[1]); // Includes $includes = array(); preg_match_all('##s', $contents, $includes); $contents = preg_replace('##', '', $contents); $includes = $includes[1]; $includes = array_unique($includes); // IF Conditions $switches = array(); preg_match_all('##', $contents, $switches); $contents = preg_replace('##s', '', $contents); $switches[0] = array_unique($switches[1]); // No resorting please $switches[1] = $switches[2]; unset($switches[2]); // Remaining Vars $remaining_vars = array(); preg_match_all('#{([a-z0-9\-_\.]*?)\}#is', $contents, $remaining_vars); $contents = preg_replace('#{([a-z0-9\-_]*?)\}#is', '', $contents); $remaining_vars = array_unique($remaining_vars[1]); sort($remaining_vars, SORT_STRING); // Now build the filename specific site $fp = fopen($store_dir . $data['destfile'], 'w'); $html_data = $html_skeleton; $html_data = str_replace('{FILENAME}', $data['single_filename'], $html_data); // Write up the Language Variables if (count($lang_vars[0])) { $lang_data = ''; } else { $lang_data = 'NONE
' . "\n"; } $html_data = str_replace('{LANGUAGE_VARIABLES}', $lang_data, $html_data); // Write up the Includes echo '.'; flush(); if (count($includes)) { $includes_data = ''; } else { $includes_data = 'NONE
' . "\n"; $see_files = 'NONE'; } $html_data = str_replace('{INCLUDES}', $includes_data, $html_data); $html_data = str_replace('{SEE_FILES}', $see_files, $html_data); // Write up Conditionals echo '.'; flush(); if (count($switches[0])) { $conditionals = ''; } else { $conditionals = 'NONE
' . "\n"; } $html_data = str_replace('{CONDITIONALS}', $conditionals, $html_data); // Write up Remaining Vars echo '.'; flush(); if (count($remaining_vars)) { $remaining = ''; } else { $remaining = 'NONE
' . "\n"; } $html_data = str_replace('{REMAINING_VARS}', $remaining, $html_data); if (isset($php_files_includes[$data['single_filename']]) && count($php_files_includes[$data['single_filename']])) { $usedby = ''; } else { $usedby = 'NONE
' . "\n"; } $html_data = str_replace('{USED_BY}', $usedby, $html_data); fwrite($fp, $html_data); fclose($fp); } echo '
Store Files'; $fp = fopen($store_dir . 'index.html', 'w'); $html_data = ' Contents
phpBB Logo Available Template Files      


This Style Document is 100% auto-generated... no human interaction included. :D

phpBB 2.2 Template


    '; sort($files_to_parse); foreach ($files_to_parse as $file_num => $data) { echo '.'; flush(); $var = $data['single_filename']; $html_data .= '
  1. ' . $var . '

  2. ' . "\n"; } $html_data .= '
  3. Appendix A: Language Variable Index

  4. '; $html_data .= '



'; fwrite($fp, $html_data); fclose($fp); // Not only write down all language files, place them into a specific array, named by the template file // All Language vars assigned to more than one template will be placed into a common file $entry = array(); $common_fp = fopen($store_dir . 'lang_common.php', 'w'); fwrite($common_fp, " Appendix A :: Language Variable Index
phpBB Logo Language Variable Index      


Back to Contents


'; echo '
Write Language Files'; asort($lang_references); ksort($lang_references); $_index = ''; $old_char = ''; foreach ($lang_references as $lang_var => $filenames) { $var = preg_replace('#^L_(.*?)#', '\1', $lang_var); $char = $var{0}; if ($old_char != $char) { $old_char = $char; $_index .= ($_index != '') ? ' :: ' : ''; $_index .= '' . $char . ''; } } $html_data .= $_index . '


'; $old_char = ''; foreach ($lang_references as $lang_var => $filenames) { echo '.'; flush(); $var = preg_replace('#^L_(.*?)#', '\1', $lang_var); $char = $var{0}; if ($old_char != $char) { $old_char = $char; $html_data .= '


Letter ' . $char . '



'; } $html_data .= '' . $lang_var . '
    '; if (sizeof($filenames) != 1) { fwrite($common_fp, (($entry['common']) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'"); $entry['common'] = true; } else if (sizeof($filenames) == 1) { // Merge logical - hardcoded $fname = (preg_match('#^(' . implode('|', $merge) . ')#', $filenames[0], $match)) ? $match[0] . '.php' : str_replace($ext, 'php', $filenames[0]); if (!$lang_fp[$fname]) { $lang_fp[$fname] = fopen($store_dir . 'lang_' . $fname, 'w'); fwrite($lang_fp[$fname], " '" . $lang[$var] . "'"); $entry[$fname] = true; } foreach ($filenames as $f_name) { $var = trim($f_name); $html_data .= '
  • ' . $var . '

  • ' . "\n"; } $html_data .= '


'; } fwrite($common_fp, ")\n);\n?>"); fclose($common_fp); foreach ($lang_fp as $filepointer) { fwrite($filepointer, ")\n);\n?>"); fclose($filepointer); } $html_data .= '


'; fwrite($fp, $html_data); fclose($fp); echo '
Finished!'; flush();