FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
parseLicGrpFileLinks.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 //require_once ('../commonTestFuncs.php');
37 
39 {
40  public $page;
41  private $test;
42 
43  function __construct($page)
44  {
45  if (empty ($page)) { return; }
46  $this->page = $page;
47  }
55  function parseLicenseGrpTbl()
56  {
57  /*
58  * The pattern below matches the license group file links NOT the table!
59  */
60  $matches = preg_match_all(
61  "|.*?id='LicItem.*?href='(.*?)'>(.*?)<.*?href=\"(.*?)\">(.*?)<|",
62  $this->page, $tableEntries, PREG_PATTERN_ORDER);
63  print "tableEntries are:\n"; print_r($tableEntries) . "\n";
64  //return($this->_createRtnLicTbl($tableEntries, $matches));
65  }
66 
67  function _createRtnLicTbl($toCombine, $matches)
68  {
69  /*
70  * if we have a match, the create return array, else return empty
71  * array.
72  */
73  if ($matches > 0)
74  {
75  $numTblEntries = count($toCombine[1]);
76  $rtnList = array ();
77  for ($i = 0; $i <= $numTblEntries-1; $i++)
78  {
79  $links = array (); // initialize/reset
80  $pushed = array_push($links ,$toCombine[1][$i], $toCombine[4][$i]);
81  if($pushed == 0) { print "parseLicenseTbl: Internal Error! Nothing Inserted!\n"; }
82  $rtnList[$toCombine[5][$i]] = $links;
83  }
84  return ($rtnList);
85  }
86  else
87  {
88  return (array ());
89  }
90  }
91 }
92 ?>