FOSSology  4.4.0
Open Source License Compliance by Open Source Software
parseLicenseTblDirs.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 {
26  public $page;
27  private $test;
28 
29  function __construct($page)
30  {
31  if (empty ($page)) { return; }
32  $this->page = $page;
33  }
42  {
43 
44  // old bsam table$pat ='|.*?id="Lic-.+" align="left"><a href=\'(.*?)\'><b>(.*?)<\/b>|';
45  $pat = "|.*id='[0-9]+'.*align='left'.*href='(.*?)'>(.*?)<\/a>|";
46  $matches = preg_match_all($pat, $this->page, $tableEntries, PREG_PATTERN_ORDER);
47  //print "PLTDIR: Matches is:$matches\ntableEntries are:\n"; print_r($tableEntries) . "\n";
48  return($this->_createDirList($tableEntries, $matches));
49  }
50 
51  function _createDirList($toCombine, $matches)
52  {
53  /*
54  * if we have a match, the create return array, else return empty
55  * array.
56  */
57  if ($matches > 0)
58  {
59  $numTblEntries = count($toCombine[1]);
60  $rtnList = array ();
61  for ($i = 0; $i <= $numTblEntries-1; $i++)
62  {
63  $clean = strip_tags($toCombine[2][$i]);
64  $rtnList[$clean] = $toCombine[1][$i];
65  }
66  return ($rtnList);
67  }
68  else
69  {
70  return (array ());
71  }
72  }
73 }