Index projects by their path in the project list object to make them easier to find
--- a/include/git/ProjectListArray.class.php
+++ b/include/git/ProjectListArray.class.php
@@ -72,7 +72,7 @@
if (isset($projData['pushurl']) && is_string($projData['pushurl'])) {
$projObj->SetPushUrl($projData['pushurl']);
}
- $this->projects[] = $projObj;
+ $this->projects[$projData['project']] = $projObj;
} catch (Exception $e) {
}
}
--- a/include/git/ProjectListArrayLegacy.class.php
+++ b/include/git/ProjectListArrayLegacy.class.php
@@ -62,7 +62,7 @@
$projObj = new GitPHP_Project($ppath);
if ($cat != GITPHP_NO_CATEGORY)
$projObj->SetCategory($cat);
- $this->projects[] = $projObj;
+ $this->projects[$ppath] = $projObj;
} catch (Exception $e) {
}
}
--- a/include/git/ProjectListBase.class.php
+++ b/include/git/ProjectListBase.class.php
@@ -87,11 +87,8 @@
if (empty($project))
return null;
- foreach ($this->projects as $projObj) {
- if ($projObj->GetProject() == $project) {
- return $projObj;
- }
- }
+ if (isset($this->projects[$project]))
+ return $this->projects[$project];
return null;
}
@@ -179,17 +176,17 @@
{
switch ($sortBy) {
case GITPHP_SORT_DESCRIPTION:
- usort($this->projects, array('GitPHP_Project', 'CompareDescription'));
+ uasort($this->projects, array('GitPHP_Project', 'CompareDescription'));
break;
case GITPHP_SORT_OWNER:
- usort($this->projects, array('GitPHP_Project', 'CompareOwner'));
+ uasort($this->projects, array('GitPHP_Project', 'CompareOwner'));
break;
case GITPHP_SORT_AGE:
- usort($this->projects, array('GitPHP_Project', 'CompareAge'));
+ uasort($this->projects, array('GitPHP_Project', 'CompareAge'));
break;
case GITPHP_SORT_PROJECT:
default:
- usort($this->projects, array('GitPHP_Project', 'CompareProject'));
+ uasort($this->projects, array('GitPHP_Project', 'CompareProject'));
break;
}
}
--- a/include/git/ProjectListDirectory.class.php
+++ b/include/git/ProjectListDirectory.class.php
@@ -87,7 +87,7 @@
$proj = new GitPHP_Project($projectPath);
$proj->SetCategory(trim(substr($dir, strlen($this->projectDir)), '/'));
if ((!GitPHP_Config::GetInstance()->GetValue('exportedonly', false)) || $proj->GetDaemonEnabled()) {
- $this->projects[] = $proj;
+ $this->projects[$projectPath] = $proj;
}
} catch (Exception $e) {
}
--- a/include/git/ProjectListFile.class.php
+++ b/include/git/ProjectListFile.class.php
@@ -70,7 +70,7 @@
$projObj->SetOwner($projOwner);
}
}
- $this->projects[] = $projObj;
+ $this->projects[$regs[1]] = $projObj;
} catch (Exception $e) {
}
}