FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
parseMiniMenu.php
1 
2 <?php
3 
4 /***********************************************************
5  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License
9  version 2 as published by the Free Software Foundation.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  ***********************************************************/
20 
38 //require_once ('../commonTestFuncs.php');
39 
41 {
42  public $page;
43 
44  function __construct($page)
45  {
46  if (empty ($page))
47  {
48  return (array ());
49  }
50  $this->page = $page;
51  }
52  function parseMiniMenu()
53  {
54  /* take the front part of the string off, this should leave only menus */
55  $matches = preg_match("/.*?id='menu1html-..*?<small>(.*)/", $this->page, $menuList);
56  /*
57  * parse the menus. The first menu in the list is ignored if it
58  * doesn't have a link associated with it.
59  */
60  $matches = preg_match_all("/<a href='((.*?).*?)'.*?>(.*?)</", $menuList[1], $parsed, PREG_PATTERN_ORDER);
61  //print "PMINIDB: parsed is:"; print_r($parsed) . "\n";
62  //print "PMINIDB: matches is:$matches\n";
63  /*
64  * if we have a match, the create return array, else return empty
65  * array.
66  */
67  if ($matches > 0)
68  {
69  $numMenus = count($parsed[1]);
70  $menus = array ();
71  for ($i = 0; $i <= $numMenus -1; $i++)
72  {
73  $menus[$parsed[3][$i]] = $parsed[1][$i];
74  }
75  //print "PMINIDB: menus after construct:\n"; print_r($menus) . "\n";
76  return ($menus);
77  } else
78  {
79  return (array ());
80  }
81  }
82 }
83 ?>