Fatal error: Call to undefined method Menu::getDataEncoded() in Menu.php on line 164
Hej til alle,Efter jeg har flyttet min cms hjemmeside over på en til ny server for jeg fejl nå jeg skal ændre min menu, oprete eller optader ny link i menu.
Fatal error: Call to undefined method Menu::getDataEncoded() in htdocs/include/classes/Menu.php on line 164
Jeg vil være meget taknemmelig hvis nogen kan hjælp mig.
Den gammle server info:
phpMyAdmin - 2.11.4
MySQL klientversion: 5.0.32
Den ny sever info:
phpMyAdmin - 3.3.0
MySQL klientversion: 5.1.48
Menu.php file:
<?php
class Menu {
private $id;
protected $menu;
public $error;
function Menu($id = "") {
$this->id = $id;
if($this->id!=""){
$sql = "SELECT * FROM ".DB_PREFIX."menus WHERE id = '".intval($this->id)."'";
$this->menu = database_query($sql,DATA_ONLY,1);
}else{
$this->menu['id'] = "0";
$this->menu['menu_name'] = "";
$this->menu['menu_order'] = "";
}
}
public function getName(){
if(isset($this->menu['menu_name'])) return $this->getDataDecoded($this->menu['menu_name']);
else return "";
}
public function ResortMenus()
{
$sql = "SELECT id, menu_order FROM ".DB_PREFIX."menus";
$getall = database_query($sql,DATA_ONLY, ALL_ROWS);
foreach ($getall as $val){
$trans[$val['id']]=$val['menu_order'];
}
return $trans;
}
public function ResortPages($menu_id=0)
{
$sql = "SELECT id, page_order FROM ".DB_PREFIX."static_pages WHERE menu_id = '".intval($menu_id)."'";
$getall = database_query($sql,DATA_ONLY, ALL_ROWS);
foreach ($getall as $val){
$trans[$val['id']]=$val['page_order'];
}
return $trans;
}
public function getId(){
return $this->id;
}
public function PagesCount($menu_id=0)
{
$sql = "SELECT count(*) as CNT FROM ".DB_PREFIX."static_pages WHERE menu_id = '".intval($menu_id)."'";
$cnt_qry = database_query($sql,DATA_ONLY,1);
return $cnt_qry["CNT"];
}
public function MinPageOrder($menu_id=0)
{
$sql = "SELECT coalesce( min( page_order ) , 1 ) AS MIN
FROM ".DB_PREFIX."static_pages
WHERE menu_id = '".intval($menu_id)."'";
$cnt_qry = database_query($sql,DATA_ONLY,1);
return $cnt_qry["MIN"];
}
public function MaxPageOrder($menu_id=0)
{
$sql = "SELECT coalesce( max( page_order ) , 1 ) AS MAX
FROM ".DB_PREFIX."static_pages
WHERE menu_id = '".intval($menu_id)."'";
$cnt_qry = database_query($sql,DATA_ONLY,1);
return $cnt_qry["MAX"];
}
public function getOrder(){
if(isset($this->menu['menu_order'])) return $this->menu['menu_order'];
else return "";
}
function getAll($order = "menu_order ASC", $join_table = "") {
// Build ORDER BY CLAUSE
if($order=="")$order_clause = "";
else $order_clause = "ORDER BY $order";
// Build JOIN clause
if($join_table=="") {
$join_clause = "";
$join_select_fields = "";
}
else {
$join_clause = "LEFT OUTER JOIN ".DB_PREFIX.$join_table." ON ".DB_PREFIX.$join_table.".menu_id=".DB_PREFIX."menus.id ";
$join_select_fields = ", ".DB_PREFIX.$join_table.".* ";
}
$sql = "SELECT ".DB_PREFIX."menus.* $join_select_fields
FROM ".DB_PREFIX."menus
$join_clause
$order_clause";
$res = database_query($sql,DATA_AND_ROWS);
return $res;
}
function menuUpdate($params = Array()) {
if(isset($this->id)){
if(strtolower(_SITE_MODE) == "demo"){
$this->error = OPERATION_BLOCKED;
return false;
}
// Get input parameters
if(isset($params['name']) && $params['name']!=""){
$this->menu['menu_name'] = $params['name'];
}else{
$this->error = MENU_NAME_EMPTY;
return false;
}
if(isset($params['order']))$this->menu['menu_order'] = $params['order'];
$reorder=$this->ResortMenus();
$reorder=Resort($reorder,$this->id,$this->menu['menu_order']);
foreach($reorder as $key=>$val)
{
$sql = "UPDATE ".DB_PREFIX."menus
SET menu_order = ".$val."
WHERE id = ".$key."";
database_void_query($sql);
}
$sql = "UPDATE ".DB_PREFIX."menus
SET menu_name = '".$this->getDataEncoded($this->menu['menu_name'])."'
WHERE id = ".intval($this->id)."";
//menu_order = ".$this->menu['menu_order']."
if (database_void_query($sql)){
return true;
} else {
$this->error = TRY_LATER;
return false;
}
}else{
$this->error = MENU_MISSED;
return false;
}
}
function menuCreate($params = Array()) {
// Get input parameters
if(isset($params['name']))$this->menu['menu_name'] = $params['name'];
if(isset($params['order']))$this->menu['menu_order'] = $params['order'];
// Prevent creating of empty records in our 'menus' table
if($this->menu['menu_name']!=""){
if(strtolower(_SITE_MODE) == "demo"){
$this->error = OPERATION_BLOCKED;
return false;
}
$sql = "INSERT INTO ".DB_PREFIX."menus(menu_name, menu_order)
VALUES('".$this->getDataEncoded($this->menu['menu_name'])."', 1000000)";
$last=database_void_query($sql,false,true);
/*if(database_void_query($sql,false,true)){
$this->error = TRY_LATER;
return true;
}else{
return false;
}*/
$reorder=$this->ResortMenus();
$reorder=Resort($reorder,$last,$this->menu['menu_order']);
//print_r($reorder);exit();
foreach($reorder as $key=>$val)
{
$sql = "UPDATE ".DB_PREFIX."menus
SET menu_order = ".$val."
WHERE id = ".$key."";
database_void_query($sql);
}
return true;
}else{
$this->error = MENU_NAME_EMPTY;
return false;
}
}
function menuDelete($menu_id = "") {
if(strtolower(_SITE_MODE) == "demo"){
$this->error = OPERATION_BLOCKED;
return false;
}
$reorder=$this->ResortMenus();
$reorder=Resort($reorder,$menu_id,100000);
//print_r($reorder);exit();
foreach($reorder as $key=>$val)
{
$sql = "UPDATE ".DB_PREFIX."menus
SET menu_order = ".$val."
WHERE id = ".$key."";
database_void_query($sql);
}
$sql = "DELETE FROM ".DB_PREFIX."menus WHERE id = ".intval($menu_id)."";
if (database_void_query($sql)) return true;
return false;
}
/**
* Get all menus array
* @param $order - order clause
* @param $join_table - join tables
**/
function getAllTop($order = "page_order ASC") {
// Build ORDER BY CLAUSE
if($order=="")$order_clause = "";
else $order_clause = "ORDER BY $order";
// Get all top menus
$sql = "SELECT ".DB_PREFIX."static_pages.*
FROM ".DB_PREFIX."static_pages
WHERE ".DB_PREFIX."static_pages.page_placement = 'top'
$order_clause";
return database_query($sql,DATA_AND_ROWS);
}
function getAllBottom($order = "page_order ASC") {
// Build ORDER BY CLAUSE
if($order=="")$order_clause = "";
else $order_clause = "ORDER BY $order";
// Get all top menus
$sql = "SELECT ".DB_PREFIX."static_pages.*
FROM ".DB_PREFIX."static_pages
WHERE ".DB_PREFIX."static_pages.page_placement = 'bottom'
$order_clause";
return database_query($sql,DATA_AND_ROWS);
}
function GetAllCategories()
{
$sql = "SELECT ".DB_PREFIX."prod_categories.*
FROM ".DB_PREFIX."prod_categories ORDER BY category_order";
return database_query($sql,DATA_AND_ROWS);
}
/**
* Draw all menus as a tree (for left menu)
* @param $is_logged_in
* @param $site_preview
**/
function drawTopMenu($is_logged_in = false, $site_preview = "0") {
// If not logged in or site preview == 1 - draw menu
echo "<a class='main_link'href='index.php'>FORSIDE</a>";
if((!$is_logged_in)||($site_preview)){
$menus = self::getAllTop("page_order ASC");
for($menu_ind = 0; $menu_ind < $menus[1]; $menu_ind++) {
if($menus[0][$menu_ind]['menu_link'] == "")
continue;
// Draw current menu link
echo "".get_divider()."";
if(!GS_USEREDIRECT)
{
echo "<a class='main_menu_link'
href='index.php?page=static_pages&pid=".$menus[0][$menu_ind]['id'].(($site_preview == "1") ? "&preview=1" : "")."&name=".$menus[0][$menu_ind]['page_key']."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a>";
}
else
{
echo "<a class='main_menu_link'
href='".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a>";
}
}
}else{
echo "".get_divider()."";
}
}
function drawBottomMenu( $site_preview = "0") {
// If not logged in or site preview == 1 - draw menu
$menus = self::getAllBottom("page_order ASC");
for($menu_ind = 0; $menu_ind < $menus[1]; $menu_ind++) {
if($menus[0][$menu_ind]['menu_link'] == "")
continue;
// Draw current menu link
if(!GS_USEREDIRECT)
{
echo "<a class='main_menu_link'
href='index.php?page=static_pages&pid=".$menus[0][$menu_ind]['id'].(($site_preview == "1") ? "&preview=1" : "")."&name=".$menus[0][$menu_ind]['page_key']."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a>";
}
else
{
echo "<a class='main_menu_link'
href='
".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a>";
}
echo "".get_divider()."";
}
}
//Added By Iti 16/06/09
function drawSiteMap()
{
echo "<table width=600px >
<tr><td width='50%' valign=top align='center'>";
//Top links
echo "<table>
<tr><td><a class='main_link' href='index.php'>Home</a></td></tr>";
if((!$is_logged_in)||($site_preview)){
$menus = self::getAllTop("page_order ASC");
for($menu_ind = 0; $menu_ind < $menus[1]; $menu_ind++) {
if($menus[0][$menu_ind]['menu_link'] == "")
continue;
if(!GS_USEREDIRECT)
{
echo "<tr><td><a class='main_menu_link'
href='index.php?page=static_pages&pid=".$menus[0][$menu_ind]['id'].(($site_preview == "1") ? "&preview=1" : "")."&name=".$menus[0][$menu_ind]['page_key']."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a></td></tr>";
}
else
{
echo "<tr><td><a class='main_menu_link'
href='
".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a></td></tr>";
}
}
}
echo "</table></td>
<td width='50%' valign=top align='center'><div>";
// Display all menu titles (names) according to their order
$cur_menu = "";
$is_start = true;
for($menu_ind = 0; $menu_ind < $menus[1]; $menu_ind++) {
// Menu name has changed
if($menus[0][$menu_ind]['menu_name'] != $cur_menu) {
// Save new menu name
$cur_menu = $menus[0][$menu_ind]['menu_name'];
// End drawing current menu
if(!$is_start){
echo "</table>";
}else $is_start = false;
echo "<table border=0 cellspacing=0 cellpadding=0>
<tr><Td Align=center><b>".camelCase($menus[0][$menu_ind]['menu_name'])."<b></Td></TR>";
}
if(!GS_USEREDIRECT){
// OLD style Draw current menu link
if($menus[0][$menu_ind]['page_key']!="")
echo "<tr><td><a class='main_menu_link' href='" . HTTPS_ADDRESS . "index.php?page=static_pages&name=".$menus[0][$menu_ind]['page_key']."'>".camelCase($menus[0][$menu_ind]['menu_link'])."</a></td></tr>";
// SEO link
}
else
{
if($menus[0][$menu_ind]['page_key']!=""){
/*if($menus[0][$menu_ind]['id']!=GS_CONTACTFORM)
{*/
echo "<tr><td style='padding:0px;'><a class='main_menu_link' href='
".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a></td></tr>";
/*}
else
{
echo "<tr><td style='padding:0px;'><a class='main_menu_link' href=' ".$menus[0][$menu_ind]['id']."/".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a></td></tr>";
}*/
}
}
}
// End drawing last menu
if(!$is_start){
echo "</table>";
}
if ($ecommerce_place['show_price_list']==1 && $ecommerce_place['display_on']=='bottom') {
echo "<table border=0 cellspacing=0 cellpadding=0>
<tr><td><b>".$ecommerce_place['title']."</b></td></TR>";
echo "<tr><td><a class='main_menu_link' >Price List</a></td></tr>";
echo "<tr><td><div id='ctdiv1' style='display:inline'>";
for($cat_ind = 0; $cat_ind < $categories[1]; $cat_ind++)
{
if($categories[0][$cat_ind]['category_name'] == "")
continue;
echo " – <a class='main_menu_link'
href='" . HTTPS_ADDRESS . "index.php?page=categories&cid=".$categories[0][$cat_ind]['id']."'>".camel_case($categories[0][$cat_ind]['category_name'])."</a><br>";
}
}
echo "</table></td><tr></table></div></td>";
echo "</tr></table>";
self::drawBottomMenu($is_logged_in, $site_preview);
}
//End added by Iti 16/06/09
function drawTree($is_logged_in = false, $site_preview = "0") {
// Get all menus which have items (links to static pages)
// If not logged in or site preview == 1 - draw menu
if($is_logged_in && $site_preview != "1"){
return false;
}
$menus = self::getAll("menu_order ASC,".DB_PREFIX."menus.id,page_order ASC","static_pages");
// Display all menu titles (names) according to their order
$cur_menu = "";
$is_start = true;
for($menu_ind = 0; $menu_ind < $menus[1]; $menu_ind++) {
// Menu name has changed
if($menus[0][$menu_ind]['menu_name'] != $cur_menu) {
// Save new menu name
$cur_menu = $menus[0][$menu_ind]['menu_name'];
// End drawing current menu
if(!$is_start){
echo "</table>";
drawBlockBottom();
}else $is_start = false;
// Draw space line between menus
//if($menu_ind > "0") echo "<br>";
// Start draw new menu
drawBlockTop();
echo "<table class='moduletable' width='100%' border=0 cellspacing=0 cellpadding=0>
<tr><TH Align=center>".camelCase($menus[0][$menu_ind]['menu_name'])."</TH></TR>";
}
if(!GS_USEREDIRECT){
// OLD style Draw current menu link
if($menus[0][$menu_ind]['page_key']!="")
echo ";<span class='menu_item'><a class='main_menu_link' href='" . HTTPS_ADDRESS . "index.php?page=static_pages&name=".$menus[0][$menu_ind]['page_key']."'>".camelCase($menus[0][$menu_ind]['menu_link'])."</a></span><br>";
// SEO link
}
else
{
if($menus[0][$menu_ind]['page_key']!="")
{
/*if($menus[0][$menu_ind]['id']!=GS_CONTACTFORM)
{*/
echo "<tr><td style='padding:0px;'><span class='menu_item'><a class='main_menu_link' href=' ".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a></span></td></tr>";
/*}
else
{
echo "<tr><td style='padding:0px;'><span class='menu_item'><a class='main_menu_link' href=' ".$menus[0][$menu_ind]['id']."/".$menus[0][$menu_ind]['page_key'].".html".(($site_preview == "1") ? "?preview=1" : "")."'>".camel_case($menus[0][$menu_ind]['menu_link'])."</a></span></td></tr>";
}*/
}
}
}
// End drawing last menu
if(!$is_start){
echo "</table>";
drawBlockBottom();
}
drawBlockBottom();
//echo "<br>";
}
private function getDataDecoded($string = ""){
$string = str_replace('\\\\', "\\", $string); // double quotation mark
$string = str_replace('\"', """, $string); // double quotation mark
$string = str_replace("\'", "'", $string); // single quotation mark
$string = str_replace('"', """, $string); // double quotation mark
$string = str_replace("'", "'", $string); // single quotation mark
return $string;
}
}
?>