diff --git a/appbrowse.php b/appbrowse.php index 9731976..01a3c71 100644 --- a/appbrowse.php +++ b/appbrowse.php @@ -26,9 +26,9 @@ function admin_menu() } // list sub categories -$cat = new Category($aClean['iCatId']?$aClean['iCatId']:"0"); -$catFullPath = make_cat_path($cat->getCategoryPath()); -$subs = $cat->aSubcatsIds; +$oCat = new Category($aClean['iCatId']?$aClean['iCatId']:"0"); +$sCatFullPath = Category::make_cat_path($oCat->getCategoryPath()); +$subs = $oCat->aSubcatsIds; //display admin box if($_SESSION['current']->hasPriv("admin") && $aClean['iCatId'] != 0) @@ -40,7 +40,7 @@ apidb_header("Browse Applications"); if($subs) { echo html_frame_start("",'98%','',2); - echo "
Category: ". $catFullPath ."
\n";
+ echo "
Category: ". $sCatFullPath ."
\n";
echo html_frame_end();
echo html_frame_start("","98%","",0);
@@ -80,11 +80,11 @@ if($subs)
// list applications in this category
-$apps = $cat->aApplicationsIds;
+$apps = $oCat->aApplicationsIds;
if($apps)
{
echo html_frame_start("",'98%','',2);
- echo "
Category: ". $catFullPath ."
\n";
+ echo "
Category: ". $sCatFullPath ."
\n";
echo html_frame_end();
echo html_frame_start("","98%","",0);
diff --git a/appview.php b/appview.php
index 089504a..f333d10 100644
--- a/appview.php
+++ b/appview.php
@@ -13,7 +13,7 @@
*
* TODO:
* - replace sSub with iAction and replace "delete", "unqueue", etc. with integer constants DELETE, UNQUEUE, etc.
- * - move and rename display_catpath and display_bundle in their respective modules
+ * - move and rename display_bundle into its respective modules
* - replace require_once with require after checking that it won't break anything
*/
@@ -38,20 +38,6 @@ $aClean['iTestingId'] = makeSafe($_REQUEST['iTestingId']);
$oApp = new Application($aClean['iAppId']);
$oVersion = new Version($aClean['iVersionId']);
-/**
- * display the full path of the Category we are looking at
- */
-function display_catpath($catId, $appId, $versionId = '')
-{
- $cat = new Category($catId);
-
- $catFullPath = make_cat_path($cat->getCategoryPath(), $appId, $versionId);
- echo html_frame_start("",'98%','',2);
- echo "
Category: ". $catFullPath ."
\n";
- echo html_frame_end();
-}
-
-
/**
* Displays the SUB apps that belong to this application.
*/
diff --git a/include/application.php b/include/application.php
index f38ac1d..f745f0c 100644
--- a/include/application.php
+++ b/include/application.php
@@ -506,7 +506,8 @@ class Application {
apidb_header("Viewing App - ".$this->sName);
// cat display
- display_catpath($this->iCatId, $this->iAppId);
+ $oCategory = new Category($this->iCatId);
+ $oCategory->display($this->iAppId);
// set Vendor
$oVendor = new Vendor($this->iVendorId);
diff --git a/include/category.php b/include/category.php
index b9bc3e9..58be7f0 100644
--- a/include/category.php
+++ b/include/category.php
@@ -163,6 +163,8 @@ class Category {
{
$aPath = array();
$iCatId = $this->iCatId;
+
+ /* loop, working up through categories until we have no parent */
while($iCatId != 0)
{
$hResult = query_parameters("SELECT catName, catId, catParent FROM appCategory WHERE catId = '?'",
@@ -207,46 +209,53 @@ class Category {
return $totalApps;
}
-}
-
-/*
- * Application functions that are not part of the class
- */
-
-/**
- * create the Category: line at the top of appdb pages$
- */
-function make_cat_path($path, $appId = '', $versionId = '')
-{
- $str = "";
- $catCount = 0;
- while(list($iCatIdx, list($iCatId, $name)) = each($path))
+ /**
+ * create the Category: line at the top of appdb pages$
+ */
+ function make_cat_path($path, $appId = '', $versionId = '')
{
- if($name == "ROOT")
- $catname = "Main";
- else
- $catname = $name;
-
- if ($catCount > 0) $str .= " > ";
- $str .= html_ahref($catname,"appbrowse.php?catId=$iCatId");
- $catCount++;
- }
-
- if(!empty($appId))
- {
- $oApp = new Application($appId);
- if(!empty($versionId))
+ $str = "";
+ $catCount = 0;
+ while(list($iCatIdx, list($iCatId, $name)) = each($path))
{
- $oVersion = new Version($versionId);
- $str .= " > ".html_ahref($oApp->sName,"appview.php?iAppId=$appId");
- $str .= " > ".$oVersion->sName;
- } else
- {
- $str .= " > ".$oApp->sName;
+ if($name == "ROOT")
+ $catname = "Main";
+ else
+ $catname = $name;
+
+ if ($catCount > 0) $str .= " > ";
+ $str .= html_ahref($catname,"appbrowse.php?catId=$iCatId");
+ $catCount++;
}
+
+ if(!empty($appId))
+ {
+ $oApp = new Application($appId);
+ if(!empty($versionId))
+ {
+ $oVersion = new Version($versionId);
+ $str .= " > ".html_ahref($oApp->sName,"appview.php?iAppId=$appId");
+ $str .= " > ".$oVersion->sName;
+ } else
+ {
+ $str .= " > ".$oApp->sName;
+ }
+ }
+
+ return $str;
}
- return $str;
+ /**
+ * display the full path of the Category we are looking at
+ */
+ function display($appId, $versionId = '')
+ {
+ $sCatFullPath = Category::make_cat_path($this->getCategoryPath(), $appId, $versionId);
+ echo html_frame_start("",'98%','',2);
+ echo "
Category: ". $sCatFullPath ."
\n";
+ echo html_frame_end();
+ }
}
+
?>
diff --git a/include/version.php b/include/version.php
index 2063f8a..d39b465 100644
--- a/include/version.php
+++ b/include/version.php
@@ -624,7 +624,8 @@ class Version {
apidb_header("Viewing App- ".$oApp->sName." Version - ".$this->sName);
// cat
- display_catpath($oApp->iCatId, $oApp->iAppId, $this->iVersionId);
+ $oCategory = new Category($oApp->iCatId);
+ $oCategory->display($oApp->iAppId, $this->iVersionId);
// set URL
$appLinkURL = ($oApp->sWebpage) ? "sWebpage."\">".substr(stripslashes($oApp->sWebpage),0,30)."": " ";