FOSSology  4.4.0
Open Source License Compliance by Open Source Software
parseMiniMenu.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 
31  function __construct($page)
32  {
33  if (empty ($page))
34  {
35  return (array ());
36  }
37  $this->page = $page;
38  }
39  function parseMiniMenu()
40  {
41  /* take the front part of the string off, this should leave only menus */
42  $matches = preg_match("/.*?id='menu1html-..*?<small>(.*)/", $this->page, $menuList);
43  /*
44  * parse the menus. The first menu in the list is ignored if it
45  * doesn't have a link associated with it.
46  */
47  $matches = preg_match_all("/<a href='((.*?).*?)'.*?>(.*?)</", $menuList[1], $parsed, PREG_PATTERN_ORDER);
48  //print "PMINIDB: parsed is:"; print_r($parsed) . "\n";
49  //print "PMINIDB: matches is:$matches\n";
50  /*
51  * if we have a match, the create return array, else return empty
52  * array.
53  */
54  if ($matches > 0)
55  {
56  $numMenus = count($parsed[1]);
57  $menus = array ();
58  for ($i = 0; $i <= $numMenus -1; $i++)
59  {
60  $menus[$parsed[3][$i]] = $parsed[1][$i];
61  }
62  //print "PMINIDB: menus after construct:\n"; print_r($menus) . "\n";
63  return ($menus);
64  } else
65  {
66  return (array ());
67  }
68  }
69 }