diff options
Diffstat (limited to 'shared/classes/gentoo_package.php')
-rw-r--r-- | shared/classes/gentoo_package.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/shared/classes/gentoo_package.php b/shared/classes/gentoo_package.php index f16a3e1..4426565 100644 --- a/shared/classes/gentoo_package.php +++ b/shared/classes/gentoo_package.php @@ -66,5 +66,25 @@ class sql_gentoo_package extends sql_row_obj { $heads=$this->get_profile()->get_headers(); return !count(array_intersect(explode(' ', $array['keywords']), explode(' ', $heads['accept_keywords']))); } + public static function from_atom($atom, &$profile=null) { + global $S; + if (strpos($atom, '/')) { + list($bcat, $name)=explode('/', $atom); + if ($i=strpos($bcat, '-')) { + $lcat=substr($bcat, $i); + $bcat=substr($bcat, 0, strlen($bcat)-strlen($lcat)); + } + } else { + $name=$atom; + } + $c=array(); + if ($profile) $c[]='`profile`='.$profile->id; + if ($bcat) $c[]='`bcat`="'.$bcat.'"'; + if ($lcat) $c[]='`lcat`="'.$lcat.'"'; + if ($name) $c[]='`name`="'.$name.'"'; + $c=implode(' AND ', $c); + $r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE '.$c.' LIMIT 1'); + return $r->rowCount()?new sql_gentoo_package($r->fetch(PDO::FETCH_ASSOC)):null; + } } ?> |