3 * FusionForge document manager
5 * Copyright 2005, Fabio Bertagnin
6 * Copyright 2009-2010, Franck Villaume - Capgemini
7 * http://fusionforge.org
9 * This file is part of FusionForge.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published
13 * by the Free Software Foundation; either version 2 of the License,
14 * or (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with FusionForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
37 function Parsedata($ppath="")
39 $this->p_path = $ppath;
40 $p = get_parser_list ($ppath);
44 function get_parse_data ($data, $title, $description, $filetype)
49 if (array_key_exists($filetype, $this->parsers))
51 // parse data if good parser exists
52 $parser = $this->p_path.$this->parsers[$filetype];
53 $filename = tempnam("/tmp/","tmp");
54 $fp = fopen ($filename, "w");
58 $cmd = "php -f $parser $filename";
59 $rep = shell_exec ($cmd);
60 if ( file_exists ($filename ) ) {
65 // always parse titre and description
66 $data2 = utf8_decode("$title $description");
67 // temporary file for treatement
68 $filename = tempnam("/tmp", "tmp");
69 $fp = fopen ($filename, "w");
72 $cmd = $this->p_path.$this->parsers["text/plain"];
73 $cmd = "php -f $cmd $filename";
74 $rep1 = shell_exec ($cmd);
75 // dont need to unlink the filename because parser_text already remove it
76 return preg_replace("/\n/", " ", "$rep $rep1");
80 function print_debug ($text)
87 function get_parser_list ($parser_path)
89 $file = $parser_path."parser_list.txt";
91 $fp = fopen ($file, "r");
94 $buff = fread($fp, 2048);
95 $a1 = explode ("\n", $buff);
98 if (trim($a) != "" && substr($a, 0,1) != "#")
100 $a2 = explode ("|", $a);
101 $rep[$a2[0]] = $a2[1];
110 // c-file-style: "bsd"