[Openfirst-cvscommit] modules export.php,NONE,1.1 index.php,NONE,1.1 info.php,NONE,1.1 openfirst.inf
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2005-05-15 05:30:59
|
Update of /cvsroot/openfirst/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29831 Added Files: export.php index.php info.php openfirst.info.php Log Message: Some module utilities (mostly dealing with info files) --- NEW FILE: export.php --- <?php /* * openFIRST.awards - index.php * * Copyright (C) 2003, * openFIRST Project * Original Author: David Di Biase <dav...@ea...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include_once("../config/globals.php"); function GetVarValue($var) { ob_Start(); var_export($var); $Value = ob_Get_Contents(); ob_End_Clean(); return $Value; } $incl = ofirst_dbquery('SELECT * FROM ofirst_config'); include_once($header); ?><fieldset> <legend>Code</legend> <dl> <?php foreach($Modules as $key => $data) { $version = $data['ver']; $includes = $data['inc']; $admin = $data['admin']; $nav = $data['nav']; if (strlen($version) <= 0) $version = 'CVS'; $code = GetVarValue($key); $name = GetVarValue(ucwords($key)); $version = GetVarValue($version); $includes = GetVarValue($includes); $admin = GetVarValue($admin); $nav = GetVarValue($nav); $PHPCode = '<'."?php global \$Modules; \$Modules[$code]['name'] = $name; \$Modules[$code]['ver'] = $version; \$Modules[$code]['inc'] = $includes; \$Modules[$code]['admin'] = $admin; \$Modules[$code]['nav'] = $nav; if (!isset(\$Modules['awards']['active']) { \$Modules['awards']['active'] = false; } if (!isset(\$Modules['awards']['show']) { \$Modules['awards']['show'] = false; } ?".'>'; if (isset($_REQUEST['save'])) { $save_len = file_put_contents("$fbasepath/$key/openfirst.info.php", $PHPCode); } ?><dt style="font-weight:bold;"><h2><?php echo htmlentities($key); ?></h2><?php if (isset($_REQUEST['save'])) { echo htmlentities("$save_len / ".strlen($PHPCode)); } ?></dt><dd> <textarea readonly="readonly" rows="18" cols="75"><?php if (false) { highlight_string($PHPCode); } else { echo htmlentities($PHPCode); } ?></textarea></dd><?php } ?> </dl></fieldset> <?php include_once($footer); ?> --- NEW FILE: openfirst.info.php --- <?php global $Modules; $Modules['modules']['name'] = 'Modules'; $Modules['modules']['ver'] = 'CVS'; $Modules['modules']['inc'] = array ( 0 => '', ); $Modules['modules']['admin'] = NULL; $Modules['modules']['nav'] = '<a href="$basepath/modules/export.php">Export module info</a> | <a href="$basepath/modules/info.php">Generate info file</a>'; if (!isset($Modules['awards']['active']) { $Modules['awards']['active'] = false; } if (!isset($Modules['awards']['show']) { $Modules['awards']['show'] = false; } ?> --- NEW FILE: info.php --- <?php /* * openFIRST.awards - index.php * * Copyright (C) 2003, * openFIRST Project * Original Author: David Di Biase <dav...@ea...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include_once("../config/globals.php"); $posted = false; if (isset($_POST['code'])) { $posted = true; $code = $_POST['code']; $name = $_POST['name']; $version = $_POST['version']; if (!isset($_POST['includes'])) $_POST['includes'] = array(); $includes = $_POST['includes']; $admin = $_POST['admin']; $nav = $_POST['nav']; } else { $posted = false; $code = ''; $name = ''; $version = ''; $includes = array(); $admin = ''; $nav = ''; } function GetVarValue($var) { ob_Start(); var_export($var); $Value = ob_Get_Contents(); ob_End_Clean(); return $Value; } $fields = array( 'name' => array( 'label' => 'Name', 'type' => 'text', 'value' => $name ), 'code' => array( 'label' => 'ID', 'type' => 'text', 'value' => $code ), 'version' => array( 'label' => 'Version', 'type' => 'text', 'value' => $version ), 'admin' => array( 'label' => 'Admin bar', 'type' => 'textarea', 'value' => $admin ), 'nav' => array( 'label' => 'Nav bar', 'type' => 'textarea', 'value' => $nav ), 'includes' => array( 'label' => 'Includes', 'type' => 'itemlist', 'value' => $includes ) ); include_once($header); ?><html> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data"> <fieldset style="left:auto; right:auto; padding:.5em; width:auto; margin: 1em; display:inline;"> <legend>Info</legend> <div><table style="border: none 0px;"> <colgroup> <col id="labels" style="text-align:right;" /> <col id="values" /> </colgroup> <?php foreach($fields as $key=>$item) { echo '<tr><td><label for="'.htmlentities($key).'">'.htmlentities($item['label']).':</td><td>'; switch ($item['type']) { case 'textarea': echo '<textarea rows="5" cols="50" id="'.htmlentities($key).'" name="'.htmlentities($key).'">'.htmlentities($item['value']).'</textarea>'; break; case 'itemlist': echo ' <div class="filelist" style="width: 100%;"> <script language="javascript"> var '.htmlentities($key).'Count = 0; function '.htmlentities($key).'Add() { document.getElementById("'.htmlentities($key).'").options['.htmlentities($key).'Count] = new Option(document.getElementById("'.htmlentities($key).'").value, document.getElementById("'.htmlentities($key).'name").value); '.htmlentities($key).'Count++; document.getElementById("'.htmlentities($key).'name").value = ""; } </script> <input type="text" id="'.htmlentities($key).'name" name="'.htmlentities($key).'name" value="" style="width: 75%;" /><input type="button" value="Add" onclick="'.htmlentities($key).'Add()" style="width: 25%;" /><br /> <select size="6" name="'.htmlentities($key).'" id="'.htmlentities($key).'" style="width: 100%; display:block">'; foreach($item['value'] as $value) { echo '<option value="'.htmlentities($value).'">'.htmlentities($value).'</option>'; } echo '</select> </div> '; break; default: echo '<input type="'.htmlentities($item['type']).'" id="'.htmlentities($key).'" name="'.htmlentities($key).'" value="'.htmlentities($item['value']).'" />'; } echo '</td></tr>'; } ?> <tr> <td>‌</td> <td><input type="submit" value="Submit" /></td> </tr> </table></div> </fieldset> </form> <?php if ($posted) { $code = GetVarValue($code); $name = GetVarValue($name); $version = GetVarValue($version); $includes = GetVarValue($includes); $admin = GetVarValue($admin); $nav = GetVarValue($nav); $PHPCode = '<'."?php global \$Modules; \$Modules[$code]['name'] = $name; \$Modules[$code]['ver'] = $version; \$Modules[$code]['inc'] = $includes; \$Modules[$code]['admin'] = $admin; \$Modules[$code]['nav'] = $nav; if (!isset(\$Modules['awards']['active']) { \$Modules['awards']['active'] = false; } if (!isset(\$Modules['awards']['show']) { \$Modules['awards']['show'] = false; } ?".'>'; ?><fieldset> <legend>Code</legend> <dl><dt style="font-weight:bold;">openfirst.info.php</dt><dd> <!--pre style="padding: 1em;border: 1px dashed #2f6fab;color: Black;background-color: #f9f9f9;line-height: 1.1em;"--> <textarea readonly="readonly" rows="18" cols="75"><?php if (false) { highlight_string($PHPCode); } else { echo htmlentities($PHPCode); } ?></textarea></dd></dl></fieldset><?php } include_once($footer); ?> --- NEW FILE: index.php --- <?php /* * openFIRST.awards - index.php * * Copyright (C) 2003, * openFIRST Project * Original Author: David Di Biase <dav...@ea...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include_once("../config/globals.php"); header("location: $basepath/modules/info.php"); ?> |