Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/admin/configurator.php
<?php

# ------------------------------------------------------------------------------
#
# This is a file of functions for the TVEz configurator  
#
# ------------------------------------------------------------------------------
#
# Copyright (C) 2003 Christian Eheim and Alex Pachikov
#                                                                               
# This file is part of TVEz (tvez.sourceforge.net).
#                                                                               
# TVEz 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.
#                                                                               
# TVEz 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 TVEz; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#                                                                               
# ------------------------------------------------------------------------------
#
# Created on 02/12/2003 by Alex Pachikov
#
# LAST MODIFIED:
# $Date: 2004/01/11 23:20:47 $
# $Revision: 1.1.1.1 $
# $Author: eheim $
#
# ------------------------------------------------------------------------------

function config_table($heading) {
  global $config_text_php, $config_text_perl;
print "
</table>
<br>
<h2>$heading</h2>
<table width=100% cellpadding=8 cellspacing=0 border=1 align=center>";
# write the variables
$config_text_perl .= "\n".'# '.$heading."\n";
$config_text_php .= "\n".'# '.$heading."\n";
}

# this creates a configurable check box
function config_check($name,$varname,$formname,$desc) {

  global $config_text_php, $config_text_perl, $HTTP_POST_VARS;
  print '
   <tr> <td align=right valign=top class=configname>
   '.$name.' 
    </td> <td align=left valign=top class=configvalue> 
	 ';

	// The box was checked during submit
	if (isset($HTTP_POST_VARS["$formname"])) {
      $value = 1;
	}
	// The form was submitted but the box was not checked
    elseif (isset($HTTP_POST_VARS["save"])) {
      $value = 0;
	// We are just reading the config
    } else {
      $value = $varname;
    }

	$value = preg_replace("/\\\\'/", "'", $value);

	if ($value)
      print "<input type=checkbox name=$formname checked class=configform>";
	else
      print "<input type=checkbox name=$formname class=configform>";

  print '
    </td> <td align=left valign=top class=configdesc> 
     '.$desc.' ($'.$formname.') &nbsp; 
    </td> </tr>
  ';

  # write the variables
  $config_text_perl .= '$'.$formname." = ".$value.";\n";
  $config_text_php .= '$'.$formname." = ".$value.";\n";
}


# this creates a configurable text input 
function config_input($name,$varname,$formname,$desc) {

  global $config_text_php, $config_text_perl, $HTTP_POST_VARS;
  print '
   <tr> <td align=right valign=top class=configname>
   '.$name.' 
    </td> <td align=left valign=top class=configvalue> 
     <input type=text size=25 value="';

    if ($HTTP_POST_VARS["$formname"]) {
      $value = $HTTP_POST_VARS["$formname"];
    } else {
      $value = $varname;
    }
	$value = preg_replace("/\\\\'/", "'", $value);
    print $value;

  print '" name="'.$formname.'" class=configform>
    </td> <td align=left valign=top class=configdesc> 
     '.$desc.' ($'.$formname.') &nbsp; 
    </td> </tr>
  ';

  # write the variables
  $config_text_perl .= '$'.$formname." = \"".$value."\";\n";
  $config_text_php .= '$'.$formname." = \"".$value."\";\n";
}

# this creates a text area that will read in one line at a time. 
function config_textarea($name,$varname,$formname,$desc) {

  global $config_text_php, $config_text_perl, $HTTP_POST_VARS;
  print '
   <tr> <td align=right valign=top class=configname>
   '.$name.' 
    </td> <td align=left valign=top class=configvalue> 
     <textarea class=configform rows=5 cols=25 name="'.$formname.'">';

    if ($HTTP_POST_VARS[$formname]) {
      $value = $HTTP_POST_VARS[$formname];
    } else {
      $value = "";
       if(count($varname) > 0) {
        foreach($varname as $vn) {
          $value .= "$vn\r\n";
        }
      }
    }
	$value = preg_replace("/\\\\'/", "'", $value);
      print $value;

  print '</textarea></td> <td align=left valign=top class=configdesc> 
     '.$desc.' ($'.$formname.')  &nbsp; 
    </td> </tr>
  ';

  # make the perl array
  $config_text_perl .= '@'.$formname." = (";
  $exval = array_unique(explode("\r\n", $value));
  if (end($exval) == "") array_pop($exval);
  foreach ($exval as $val) {
     $config_text_perl .= '"'.$val.'"';
     if ($val != end($exval)) $config_text_perl .= ",";
  }
  $config_text_perl .= ");\n";

  # make the php array
  $config_text_php .= '$'.$formname." = Array(";
  $exval = array_unique(explode("\r\n", $value));
  if (end($exval) == "") array_pop($exval);
  foreach ($exval as $val) {
     $config_text_php .= '"'.$val.'"';
     if ($val != end($exval)) $config_text_php .= ",";
  }
  $config_text_php .= ");\n";
}

?>
Return current item: TVEz - Media Library