summaryrefslogtreecommitdiff
blob: 580312f69f013934b621a72aa36403765f1c81ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
class sql_gentoo_package extends sql_row_obj {
	protected $table='gentoo_packages', $primary_key=array('id'), $columns=array(
		'id' => array (
			'type' => 'INT',
			'length' => 10,
			'unsigned' => true,
			'not_null' => true,
			'auto_increment' => true
		),
		'profile' => array (
			'type' => 'TINYINT',
			'length' => 3,
			'unsigned' => true,
			'not_null' => true,
			'default' => 0,
			'refers_to' => 'gentoo_profiles.id'
		),
		'bcat' => array (
			'type' => 'VARCHAR',
			'length' => 255,
			'not_null' => true,
			'default' => ''
		),
		'lcat' => array (
			'type' => 'VARCHAR',
			'length' => 255,
			'not_null' => true,
			'default' => ''
		),
		'name' => array (
			'type' => 'VARCHAR',
			'length' => 255,
			'not_null' => true,
			'default' => ''
		),
		'version' => array (
			'type' => 'VARCHAR',
			'length' => 255,
			'not_null' => true,
			'default' => ''
		),
		'data' => array (
			'type' => 'TEXT',
			'not_null' => true
		)

	);
	function &to_array($skip_masked=false) {
		$r=array();
		foreach (explode("\n", $this->data) as $line) {
			if (!strlen($line)) continue;
			list($name, $val)=explode(': ', $line, 2);
			$name=strtolower($name);
			$r[$name]=$val;
		}
		if (!$skip_masked) {
			$r['masked']=$this->is_masked($r);
		}
		return $r;
	}
	function is_masked(&$array=null) {
		if ($array === null) {
			$array=$this->to_array(true);
		}
		$heads=$this->get_profile()->get_headers();
		$accept=explode(' ', $heads['accept_keywords']);
		foreach ($accept as $akwd) {
			foreach (explode(' ', $array['keywords']) as $kwd) {
				if ($akwd == $kwd) {
					return false;
				}
			}
		}
		return true;
	}
}
?>