FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
parseLicenseTblDirs.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
36 {
37  public $page;
38  private $test;
39 
40  function __construct($page)
41  {
42  if (empty ($page)) { return; }
43  $this->page = $page;
44  }
53  {
54 
55  // old bsam table$pat ='|.*?id="Lic-.+" align="left"><a href=\'(.*?)\'><b>(.*?)<\/b>|';
56  $pat = "|.*id='[0-9]+'.*align='left'.*href='(.*?)'>(.*?)<\/a>|";
57  $matches = preg_match_all($pat, $this->page, $tableEntries, PREG_PATTERN_ORDER);
58  //print "PLTDIR: Matches is:$matches\ntableEntries are:\n"; print_r($tableEntries) . "\n";
59  return($this->_createDirList($tableEntries, $matches));
60  }
61 
62  function _createDirList($toCombine, $matches)
63  {
64  /*
65  * if we have a match, the create return array, else return empty
66  * array.
67  */
68  if ($matches > 0)
69  {
70  $numTblEntries = count($toCombine[1]);
71  $rtnList = array ();
72  for ($i = 0; $i <= $numTblEntries-1; $i++)
73  {
74  $clean = strip_tags($toCombine[2][$i]);
75  $rtnList[$clean] = $toCombine[1][$i];
76  }
77  return ($rtnList);
78  }
79  else
80  {
81  return (array ());
82  }
83  }
84 }
85 ?>