summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-28 14:37:06 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-28 14:37:06 -0400
commit51a39822c8a8c0efe86d4d8939ed06a752f5e927 (patch)
treeb6ed719283096f41a101f2e5f72cbca8207706a4
parentConverted frontend wizard form element classes to not be specific to the fron... (diff)
downloadingenue-51a39822c8a8c0efe86d4d8939ed06a752f5e927.tar.gz
ingenue-51a39822c8a8c0efe86d4d8939ed06a752f5e927.tar.bz2
ingenue-51a39822c8a8c0efe86d4d8939ed06a752f5e927.zip
Made package selector, pkglist more efficient by filtering out package metadata that we don't use from the array
-rw-r--r--frontend/modules/gentoo/step4.php2
-rwxr-xr-xpkglist.php2
-rw-r--r--shared/classes/gentoo_package.php17
-rw-r--r--shared/classes/gentoo_profile.php5
4 files changed, 14 insertions, 12 deletions
diff --git a/frontend/modules/gentoo/step4.php b/frontend/modules/gentoo/step4.php
index 11d0c1e..b0051f8 100644
--- a/frontend/modules/gentoo/step4.php
+++ b/frontend/modules/gentoo/step4.php
@@ -1,6 +1,6 @@
<?php
$profile=new sql_gentoo_profile($this->get_opt('profile'));
-$pkgs=$profile->get_packages(true);
+$pkgs=$profile->get_packages(true, array('desc', 'masked'));
$meta=array(
array('id' => 'plist', 'autosize'=> true),
array('delim' => '', 'tag' => 'div', 'label' => '%n', 'collapsed' => true),
diff --git a/pkglist.php b/pkglist.php
index a0c577c..65cbfa9 100755
--- a/pkglist.php
+++ b/pkglist.php
@@ -8,7 +8,7 @@ $r=$pdo->query('SELECT * FROM `gentoo_profiles`'.(isset($argv[1])?' WHERE `name`
while ($p=$r->fetch(PDO::FETCH_ASSOC)) {
$p=new sql_gentoo_profile($p);
echo ($p->name?$p->name:$p->pkgdir)."\n";
- $packages=$p->get_packages();
+ $packages=$p->get_packages(false, array('desc', 'masked'));
foreach ($packages as $bcat => $lcats) {
foreach ($lcats as $lcat => $pkgs) {
foreach ($pkgs as $name => $vers) {
diff --git a/shared/classes/gentoo_package.php b/shared/classes/gentoo_package.php
index 41fec01..e13878e 100644
--- a/shared/classes/gentoo_package.php
+++ b/shared/classes/gentoo_package.php
@@ -46,25 +46,26 @@ class sql_gentoo_package extends sql_row_obj {
)
);
- function &to_array($skip_masked=false) {
+ function &to_array($skip_masked=false, $trim=null) {
$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);
+ if (!$skip_masked && $name == 'keywords')
+ $r['masked']=$this->is_masked($val);
+ if (!isset($trim) || in_array($name, $trim))
+ $r[$name]=$val;
}
return $r;
}
- function is_masked(&$array=null) {
- if ($array === null) {
+ function is_masked($keywords=null) {
+ if ($keywords === null) {
$array=$this->to_array(true);
+ $keywords=$array['keywords'];
}
$heads=$this->get_profile()->get_headers();
- return !count(array_intersect(explode(' ', $array['keywords']), explode(' ', $heads['accept_keywords'])));
+ return !count(array_intersect(explode(' ', $keywords), explode(' ', $heads['accept_keywords'])));
}
public static function from_atom($atom, &$profile=null) {
global $S;
diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php
index 51cc5a4..7184aad 100644
--- a/shared/classes/gentoo_profile.php
+++ b/shared/classes/gentoo_profile.php
@@ -195,13 +195,14 @@ class sql_gentoo_profile extends sql_row_obj {
}
return true;
}
- public function &get_packages($omit_masked=false) {
+ public function &get_packages($omit_masked=false, $trim=null) {
global $S;
+ $skip_masked=!in_array('masked', $trim);
$r=$S['pdo']->query('SELECT * FROM `gentoo_packages` WHERE `profile`='.$this->id);
$p=array();
while ($pkg=$r->fetch(PDO::FETCH_ASSOC)) {
$pkg=new sql_gentoo_package($pkg);
- $array=$pkg->to_array();
+ $array=$pkg->to_array($skip_masked, $trim);
if (!($omit_masked && $array['masked']))
$p[$pkg->bcat][$pkg->lcat][$pkg->name][$pkg->version]=$array;
}