Documentation TYPO3 par Ameos

text_plain__external.inc.php

00001 <?php
00002 /* $Id: text_plain__external.inc.php,v 2.1 2003/11/26 22:52:24 rabus Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 function PMA_EscapeShellArg($string, $prepend = '\'') {
00006     return $prepend . ereg_replace("'", "'\\''", $string) . $prepend;
00007 }
00008 
00009 function PMA_transformation_text_plain__external_nowrap($options = array()) {
00010     if (!isset($options[3]) || $options[3] == '') {
00011         $nowrap = true;
00012     } elseif ($options[3] == '1' || $options[3] == 1) {
00013         $nowrap = true;
00014     } else {
00015         $nowrap = false;
00016     }
00017 
00018     return $nowrap;
00019 }
00020 
00021 function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
00022     // possibly use a global transform and feed it with special options:
00023     // include('./libraries/transformations/global.inc.php');
00024 
00025     // further operations on $buffer using the $options[] array.
00026 
00027     $allowed_programs = array();
00028     $allowed_programs[0] = '/usr/local/bin/tidy';
00029     $allowed_programs[1] = '/usr/local/bin/validate';
00030 
00031     if (!isset($options[0]) ||  $options[0] == '') {
00032         $program = $allowed_programs[0];
00033     } else {
00034         $program = $allowed_programs[$options[0]];
00035     }
00036 
00037     if (!isset($options[1]) || $options[1] == '') {
00038         $poptions = '-f /dev/null -i -wrap -q';
00039     } else {
00040         $poptions = $options[1];
00041     }
00042 
00043     if (!isset($options[2]) || $options[2] == '') {
00044         $options[2] = 1;
00045     }
00046 
00047     if (!isset($options[3]) || $options[3] == '') {
00048         $options[3] = 1;
00049     }
00050 
00051     $cmdline = 'echo ' . PMA_EscapeShellArg($buffer) . ' | ' . $program . ' ' . PMA_EscapeShellArg($poptions, '');
00052     $newstring = `$cmdline`;
00053 
00054     if ($options[2] == 1 || $options[2] == '2') {
00055         $retstring = htmlspecialchars($newstring);
00056     } else {
00057         $retstring = $newstring;
00058     }
00059 
00060     return $retstring;
00061 }
00062 
00063 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6