Rieccomi dopo tanto tempo!

Sto creando una specie di miniCMS da poter utilizzare nel mio sito e vorrei chiedervi: come posso far funzionare questo script che ho provato a fare per generare il percorso della pagina attuale?

La tabella MySql è così strutturata

category_id | parent_id | category_name

ed ecco il codice che uso attualmente (verrà richiamato da onArticleDisplay()):

Codice PHP:
public function categoryPath($element,$data=array()){
$elem_data=$this->getCategory($element);
if(
$elem_data['parent_id']!==0){
array_push($data,array(
'index.php?com='.$this->plug_name.'&parent_id='.$elem_data['category_id'],
$elem_data['category_name'])
);
$this->categoryPath($elem_data['parent_id'],$data);
}
return
$data;
}
Come notate fa parte di una classe, getCategoy([id categoria]) ritorna i dati della riga avente quell'id categoria sotto forma di array.

ecco qui cosa esce:
http://matt93.altervista.org/php5/?c...s&article_id=1

ed ecco l'intero codice della pagina:
Codice PHP:
<?
// Component callback
class Articles{
var
$plug_name='Articles';

public function
onMCMSContent(){
global
$mcms,$mcmsplugins;
if(!
$mcms->request('article_id')){
$mcmsplugins->callEvent('ArticlesCategoryDisplay');
$mcmsplugins->callEvent('ArticlesListDisplay');
}else{
$article_id=$mcms->request('article_id');
if(!
$mcms->checkType($article_id,'numeric')){
$mcms->error404();
}else{
$mcmsplugins->callEvent('ArticlesDisplay');
}
}
}

public function
onArticlesDisplay(){
global
$mcms,$mcmsdb,$mcmstemplate,$mcmsarticles,$mcmsplugins;
$article_data=$mcmsarticles->getArticle($mcms->request('article_id'));
if(
$article_data['category_id']==0){
$parent_data=array('category_name'=>'Tutti gli articoli','category_id'=>0,'parent_id'=>0);
}else{
$parent_data=$mcmsarticles->getCategory($article_data['category_id']);
}

$mcmstemplate->page_path[]=$mcmsarticles->categoryPath($parent_data['category_id']);

$mcmstemplate->page_path[]=array('index.php?com='.$this->plug_name.'&article_id='.$mcms->request('article_id'), $article_data['article_title']);

echo
'<h3>'.$article_data['article_title'].'</h3>';
$mcmsplugins->callEvent('ArticlesDisplayTop');
echo
$article_data['article_content'];
$mcmsplugins->callEvent('ArticlesDisplayBottom');
}

public function
onArticlesCategoryDisplay(){
global
$mcms,$mcmsdb,$mcmstemplate,$mcmsarticles;

if(!
$mcms->request('parent_id')){
$parent_id=0;
$parent_data=array('category_name'=>'Tutti gli articoli','category_id'=>0,'parent_id'=>0);
}else{
$parent_id=$mcms->request('parent_id');
$parent_data=$mcmsarticles->getCategory($parent_id);
}

$this->tplArticlesCategoryDisplay($parent_data);

$mcmstemplate->page_path[]=array('index.php?com='.$this->plug_name.'&parent_id='.$parent_data['category_id'], $parent_data['category_name']);

foreach(
$mcmsarticles->getCategories($parent_id) as $row){
$this->tplArticlesCategoryDisplayRow($row);
}
}

public function
onArticlesListDisplay(){
global
$mcms,$mcmsarticles;
if(!
$mcms->request('parent_id')){
$parent_id=0;
}else{
$parent_id=$mcms->request('parent_id');
}
$this->tplArticlesListDisplay();
$articles=$mcmsarticles->getArticles($parent_id);
if(
count($articles)>0){
foreach(
$articles as $row){
$this->tplArticlesListDisplayRow($row);
}
}else{
?><i>Nessun Articolo</i><?
}
}

public function
tplArticlesListDisplay(){
// Template sopra la lista degli articoli
?>
<h2>Articoli</h2>
<?
}

public function
tplArticlesListDisplayRow($row){
// Template per la lista degli articoli
?>
<p><a href="?com=<?= $this->plug_name ?>&article_id=<?= $row['article_id'] ?>"><?= $row['article_title'] ?></a></p>
<?
}

public function
tplArticlesCategoryDisplay($parent_data){
// Template sopra alla lista delle categorie
?>
<h2>Categorie<?
if($parent_data['parent_id']!==0){
echo
': '.$parent_data['category_name'];
}
?></h2>
<p>Qui puoi vedere tutte le categorie disponibili.<?
if($parent_data['parent_id']!==0){
?> <a href="?com=<?= $this->plug_name ?>&parent_id=<?= $parent_data['parent_id'] ?>">Torna alla categoria superiore.</a><? } ?></p>
<?
}

public function
tplArticlesCategoryDisplayRow($row){
// Template per la lista delle categorie
?>
<p><a href="?com=<?= $this->plug_name ?>&parent_id=<?= $row['category_id'] ?>"><?= $row['category_name'] ?></a> <?= $row['category_description'] ?></p>
<?
}

public function
init(){
// Genera l'istanza
global $mcmsarticles;
$mcmsarticles=new MCMSArticles;
}
}

// System class Callback
class MCMSArticles{
public function
getArticle($article_id){
global
$mcmsdb;
$q=$mcmsdb->sql_query("SELECT * FROM `".$mcmsdb->pf."articles` WHERE `article_id`='".$article_id."' LIMIT 1;");
$ret=array();
while(
$row=$mcmsdb->sql_fetchrow($q)){
$ret=$row;
}
return
$ret;
}

public function
getCategory($category_id){
global
$mcmsdb;
$q=$mcmsdb->sql_query("SELECT * FROM `".$mcmsdb->pf."articles_cats` WHERE `category_id`='".$category_id."' LIMIT 1;");
$ret=array();
while(
$row=$mcmsdb->sql_fetchrow($q)){
$ret=$row;
}
return
$ret;
}

public function
getArticles($category_id){
global
$mcmsdb;
$q=$mcmsdb->sql_query("SELECT * FROM `".$mcmsdb->pf."articles` WHERE `category_id`='".$category_id."'");
$ret=array();
while(
$row=$mcmsdb->sql_fetchrow($q)){
$ret[]=$row;
}
return
$ret;
}

public function
getCategories($parent_id){
global
$mcmsdb;
$q=$mcmsdb->sql_query("SELECT * FROM `".$mcmsdb->pf."articles_cats` WHERE `parent_id`='".$parent_id."'");
$ret=array();
while(
$row=$mcmsdb->sql_fetchrow($q)){
$ret[]=$row;
}
return
$ret;
}

public function
categoryPath($element,$data=array()){
$elem_data=$this->getCategory($element);
if(
$elem_data['parent_id']!==0){
array_push($data,array(
'index.php?com='.$this->plug_name.'&parent_id='.$elem_data['category_id'],
$elem_data['category_name'])
);
$this->categoryPath($elem_data['parent_id'],$data);
}
return
$data;
}
}
?>