FOSSology  4.4.0
Open Source License Compliance by Open Source Software
parseLicGrpFileLinks.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
25 //require_once ('../commonTestFuncs.php');
26 
28 {
29  public $page;
30  private $test;
31 
32  function __construct($page)
33  {
34  if (empty ($page)) { return; }
35  $this->page = $page;
36  }
44  function parseLicenseGrpTbl()
45  {
46  /*
47  * The pattern below matches the license group file links NOT the table!
48  */
49  $matches = preg_match_all(
50  "|.*?id='LicItem.*?href='(.*?)'>(.*?)<.*?href=\"(.*?)\">(.*?)<|",
51  $this->page, $tableEntries, PREG_PATTERN_ORDER);
52  print "tableEntries are:\n"; print_r($tableEntries) . "\n";
53  //return($this->_createRtnLicTbl($tableEntries, $matches));
54  }
55 
56  function _createRtnLicTbl($toCombine, $matches)
57  {
58  /*
59  * if we have a match, the create return array, else return empty
60  * array.
61  */
62  if ($matches > 0)
63  {
64  $numTblEntries = count($toCombine[1]);
65  $rtnList = array ();
66  for ($i = 0; $i <= $numTblEntries-1; $i++)
67  {
68  $links = array (); // initialize/reset
69  $pushed = array_push($links ,$toCombine[1][$i], $toCombine[4][$i]);
70  if($pushed == 0) { print "parseLicenseTbl: Internal Error! Nothing Inserted!\n"; }
71  $rtnList[$toCombine[5][$i]] = $links;
72  }
73  return ($rtnList);
74  }
75  else
76  {
77  return (array ());
78  }
79  }
80 }