164 lines
4.0 KiB
PHP
164 lines
4.0 KiB
PHP
<?php
|
|
|
|
/** Menu Link
|
|
*
|
|
* @version 1.9.0
|
|
* @since 2007-05-01
|
|
* @author martin lenzelbauer
|
|
*/
|
|
class MenuLink extends Page{
|
|
|
|
var $href; //url
|
|
var $target; //target window
|
|
|
|
/** C'tor
|
|
*/
|
|
//------------------------------------------------
|
|
function MenuLink($id, $parent){
|
|
//------------------------------------------------
|
|
parent::Page($id, $parent);
|
|
$this->name = "[unbenannter Link]";
|
|
$this->href = "";
|
|
$this->target = "_blank";
|
|
}
|
|
|
|
|
|
|
|
/** @see Page::install()
|
|
*/
|
|
//-----------------------------------------------
|
|
function install(){
|
|
//-----------------------------------------------
|
|
$query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_menulink (
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
href VARCHAR(200) NOT NULL,
|
|
target ENUM('_self','_blank') NOT NULL DEFAULT '_blank',
|
|
PRIMARY KEY (id)
|
|
)");
|
|
dbQuery($query);
|
|
}
|
|
|
|
|
|
/** @see CmsObject::load()
|
|
*/
|
|
//-----------------------------------------------
|
|
function load($path=array()){
|
|
//-----------------------------------------------
|
|
parent::load($path);
|
|
if(!$this->classId){
|
|
return;
|
|
}
|
|
$query = sprintf("SELECT * FROM bruckm_menulink WHERE id = %d", $this->classId);
|
|
$result = dbQuery($query);
|
|
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
|
|
$this->href = $line['href'];
|
|
$this->target = $line['target'];
|
|
}
|
|
|
|
|
|
/** @see Page::doSave()
|
|
*/
|
|
//----------------------------------------------
|
|
function doSave(){
|
|
//----------------------------------------------
|
|
$query = sprintf("UPDATE bruckm_menulink SET href = %s, target = %s WHERE id = %d",
|
|
sqlstring($this->href),
|
|
sqlstring($this->target),
|
|
sqlnum($this->classId));
|
|
dbQuery($query);
|
|
parent::doSave();
|
|
}
|
|
|
|
|
|
/** @see Page::doCreate()
|
|
*/
|
|
//----------------------------------------------
|
|
function doCreate(){
|
|
//----------------------------------------------
|
|
$query = sprintf("INSERT INTO bruckm_menulink (href) VALUES (%s)", sqlstring($this->href));
|
|
dbQuery($query);
|
|
$this->classId = mysql_insert_id();
|
|
parent::doCreate();
|
|
}
|
|
|
|
|
|
/** @see Page::doDelete()
|
|
*/
|
|
//-----------------------------------------------
|
|
function doDelete(){
|
|
//-----------------------------------------------
|
|
parent::doDelete();
|
|
$query = sprintf("DELETE FROM bruckm_menulink WHERE id = %d LIMIT 1", $this->classId);
|
|
dbQuery($query);
|
|
}
|
|
|
|
|
|
/** @see CmsObject::update()
|
|
*/
|
|
//-----------------------------------------------
|
|
function update(){
|
|
//-----------------------------------------------
|
|
parent::update();
|
|
$this->href = $_POST['href'];
|
|
$this->target = $_POST['target'];
|
|
}
|
|
|
|
|
|
/** @see CmsObject::show()
|
|
*/
|
|
//---------------------------------------------
|
|
function show(){
|
|
//---------------------------------------------
|
|
header("Location: " . $this->href);
|
|
}
|
|
|
|
/** @see CmsObject::doPrintClassContent()
|
|
*/
|
|
//-----------------------------------------------
|
|
function doPrintClassContent(){
|
|
//-----------------------------------------------
|
|
$t = new Template(CMS_TEMPLATE_DIR."menulink.html");
|
|
$t->setVar("HREF", $this->href);
|
|
if($this->target == "_blank"){
|
|
$t->setVar("TARGET_BLANK", "selected=\"selected\"");
|
|
$t->setVar("TARGET_SELF", "");
|
|
}
|
|
else{
|
|
$t->setVar("TARGET_SELF", "selected=\"selected\"");
|
|
$t->setVar("TARGET_BLANK", "");
|
|
}
|
|
return $t->toString();
|
|
}
|
|
|
|
|
|
/** @see Page::doPublish()
|
|
*/
|
|
//----------------------------------------------
|
|
function doPublish(){
|
|
//----------------------------------------------
|
|
return "<a href=\"".$this->href."\" target=\"".$this->target."\">".$this->name."</a>";
|
|
}
|
|
|
|
|
|
/** the same as doPublish()
|
|
*/
|
|
//------------------------------------------------
|
|
function printAsMenuItem(){
|
|
//------------------------------------------------
|
|
return "<li>" . $this->doPublish() . "</li>";
|
|
}
|
|
|
|
|
|
/** @see Element::getCssClass()
|
|
*/
|
|
//------------------------------------------------
|
|
function getCssClass(){
|
|
//------------------------------------------------
|
|
return "itemMenuLink";
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
?>
|