Tutorial Programming

Tutorial membuat aplikasi collapse menu


<html>
<?
echo '<font face="verdana" size="2">';
class submenu {

var $urls; 
var $desps;
var $cot;
var $id; 
//easily modify you menu symbols, can also use image tags
var $openSymbol = '(+)';
var $closedSymbol = '(--)';
var $itemBranch = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp|---';

function create($id) {
$this->cot=0; 
$this->id=$id;
}

function add($url, $desp) { 
$this->urls[$this->cot]=$url;
$this->desps[$this->cot]=$desp; 
$this->cot++;
}

function open() { 
$i=0;
while($i<$this->cot) {
if ($i==0) { 
global $PHP_SELF;
echo '<b><a href="'.$PHP_SELF.'?action=close&id=">'.$this->closedSymbol.$this->desps[0].'</a></b><br>';
}
else {
echo $this->itemBranch.'<a href="'.$this->urls[$i].'">'.$this->desps[$i].'</a><br>';
}
$i++;
}

}

function close() { 
global $PHP_SELF;
if (! $this->id){

} else {

echo '<b><a href="'.$PHP_SELF.'?action=open&id='.$this->id.'">'.$this->openSymbol.$this->desps[0].' </a></b><br>'; 

}

}

}

class menu {

var $submenus;
var $cot; 
var $id; 

function create() { 
$this->cot=0;
$this->id=2;
}

function add($submenu) { 
$this->submenus[$this->cot]=new submenu;
$this->submenus[$this->cot]=$submenu;
$this->cot++;
}

function show() { 
$i=0;
$tmp = new submenu;
while ($i<$this->cot) {
$tmp=$this->submenus[$i];
if ($tmp->id==(string)$this->id) {
$tmp->open();
}
else {
$tmp->close();
}
$i++;
}
}

function hide() { 
$tmp = new submenu;
$tmp->close();
} 
}

$sm_1=new submenu;
$sm_1->create('1');
$sm_1->add('',' Download File');
$sm_1->add('http://www.winxpinfo.com','Windows XP');
$sm_1->add('http://www.freestuffhome.net','Gratisan');
$sm_1->add('http://www.adcsoft.com','ADC Software');
$sm_1->add('http://www.lutfian.com','Lutfian Software');

$sm_2=new submenu;
$sm_2->create('2');
$sm_2->add('',' Search Engine');
$sm_2->add('http://www.google.com','Google');
$sm_2->add('http://www.yahoo.com','Yahoo');
$sm_2->add('http://www.Altavista.com','Altavista');
$sm_2->add('http://www.youtube.com','Search Indonesia');

$sm_3=new submenu;
$sm_3->create('3');
$sm_3->add('',' Tutorial Programming aryejfa.com');
$sm_3->add('www.aryejfa.com/2015/03/tutorial-php.html','Perl');
$sm_3->add('www.aryejfa.com/2015/03/portofolio.html','Registry');
$sm_3->add('www.aryejfa.com/2015/03/tutorial-sql.html','PHP');
$sm_3->add('www.aryejfa.com/2015/03/tutorial-android.html','Desain Web');

$sm_4=new submenu;
$sm_4->create('4');
$sm_4->add('',' Berita');
$sm_4->add('http://www.detik.com','Detik');
$sm_4->add('http://www.detikinet.com','Detikinet');
$sm_4->add('http://www.kompas.com','Kompas');
$sm_4->add('http://www.Astaga.com','Astaga');

$m_1=new menu;
$m_1->create();
$m_1->add($sm_1);
$m_1->add($sm_2);
$m_1->add($sm_3);
$m_1->add($sm_4);

if ($action=='') {
$m_1->show();
}


if ($action=='open') {
$m_1->id=$id;
$m_1->show();
}

if ($action=='close') {
$m_1->id=$id;
$m_1->hide();
$m_1->show();
}

echo '</font>';
?>

Silakan download aplikasi  disini

No comments:

Post a Comment

Tutorial Programming Designed by Templateism | Ary EJFA Copyright © 2015

Theme images by richcano. Powered by Blogger.