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
32 * @return boolean true
37 function Parsedata($ppath="") {
38 $this->p_path = $ppath;
39 $p = get_parser_list ($ppath);
44 function get_parse_data($data, $title, $description, $filetype) {
48 if (array_key_exists($filetype, $this->parsers)) {
49 // parse data if good parser exists
50 $parser = $this->p_path.$this->parsers[$filetype];
51 $filename = tempnam("/tmp/","tmp");
52 $fp = fopen ($filename, "w");
55 $cmd = "php -f $parser $filename";
56 $rep = shell_exec ($cmd);
57 if ( file_exists ($filename ) ) {
61 // always parse titre and description
62 $data2 = utf8_decode("$title $description");
63 // temporary file for treatement
64 $filename = tempnam("/tmp", "tmp");
65 $fp = fopen ($filename, "w");
68 $cmd = $this->p_path.$this->parsers["text/plain"];
69 $cmd = "php -f $cmd $filename";
70 $rep1 = shell_exec ($cmd);
71 // dont need to unlink the filename because parser_text already remove it
72 return preg_replace("/\n/", " ", "$rep $rep1");
75 function print_debug($text) {
81 function get_parser_list($parser_path) {
82 $file = $parser_path."parser_list.txt";
84 $fp = fopen ($file, "r");
86 $buff = fread($fp, 2048);
87 $a1 = explode ("\n", $buff);
89 if (trim($a) != "" && substr($a, 0,1) != "#") {
90 $a2 = explode ("|", $a);
91 $rep[$a2[0]] = $a2[1];
100 // c-file-style: "bsd"