Catalogue-Editor for PHPRetro
Hello!
I have made a catalogue editor for my PHP-Retro, and I thought I could share it with you!
Installation is easy.
1. Make a file in the housekeeping-folder named catalogue.php.
2. Insert this code into the file:
PHP Code:
<?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # Catalogue-script made by RetroDonald
|| # Script Copyright (C) 2009-2010 RetroDonald. All Rights Reserved.
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/
$page['dir'] = '\housekeeping';
$page['housekeeping'] = true;
$page['rank'] = 5;
require_once('../includes/core.php');
require_once('./includes/hksession.php');
$lang->addLocale("housekeeping.news");
$page['name'] = $lang->loc['pagename.news'];
$page['category'] = "tools";
require_once('./templates/housekeeping_header.php');
?>
<div class="page_title">
<img src="<?php echo PATH; ?>/housekeeping/images/icons/<?php echo $icon; ?>" class="pticon">
<span class="page_name_shadow">Catalogue</span>
<span class="page_name">Catalogue</span>
</div>
<div class="page_main">
<table border="0" cellpadding="0" cellspacing="0" height="100%">
<tbody>
<tr height="100%" />
<td class="page_main_left">
<div class="left_date"><?php echo date('l F j, Y | g:iA'); ?></div>
<div class="hr"></div>
<div class="text">
<?php echo $description; ?>
</div>
</td>
<td class="page_main_right">
<div class="center">
<?php
if(!$_GET[edit] && !$_GET[fjern] && !$_GET[mobler] && !$_GET[mobeledit] && !$_GET[mobellag] && !$_GET[lag]){
echo("Here, you can edit the catalogue! Choose a catagory to edit. You can edit the furnis inside too....<br><a href='?lag=lag'>Add Catagory</a><br><a href='?mobellag=lag'>Add Furni</a><br>");
$rar = mysql_query("SELECT * FROM catalogue_pages ORDER BY indexid"); ?>
<table height="100%"><tbody>
<tr class="header">
<th width="50">IndexID</th>
<th width="300">IndexNAME</th>
<th width="50">Number of furniture</th>
<th width="50">Minimum rank</th>
<th width="50"></th>
</tr><?php
while($m = mysql_fetch_array($rar)){
$t = mysql_query("SELECT * FROM catalogue_items WHERE catalogue_id_page='$m[indexid]'");
$num = mysql_num_rows($t);
echo("<tr><td width='50'>$m[indexid]</td>
<td width='300'>$m[displayname]</td>
<td width='50'>$num</td>
<td width='50'>$m[minrank]</td>
<td width='50' class='action'><a href='?edit=$m[indexid]'><img src='images/icons/edit.png'></a><a href='?fjern=$b[indexid]'><img src='images/icons/remove.png'></a></td></tr>");
}
echo("</tbody></table>");
}
if($_GET[edit]){
if($_POST[submit]){
mysql_query("UPDATE catalogue_pages SET indexname='$_POST[indexname]', displayname='$_POST[displayname]', style_layout='$_POST[style_layout]', img_header='$_POST[img_header]', img_side='$_POST[img_side]', label_description='$_POST[label_description]', label_misc='$_POST[label_misc]', label_moredetails='$_POST[label_moredetails]' WHERE indexid='$_GET[edit]'");
echo("The catagory was updated!");
}else{
$rar = mysql_query("SELECT * FROM catalogue_pages WHERE indexid='$_GET[edit]'");
$t = mysql_fetch_array($rar);
echo("<form method='post'><table><tr><td width='50%'>Indexname: </td><td width='50%'><input value='$t[indexname]' type='text' name='indexname'></td></tr>
<tr><td width='50%'>Displayname: </td><td width='50%'><input value='$t[displayname]' type='text' name='displayname'></td></tr>
<tr><td width='50%'>Style_Layout: </td><td width='50%'><input value='$t[style_layout]' type='text' name='style_layout'></td></tr>
<tr><td width='50%'>Img_Header: </td><td width='50%'><input value='$t[img_header]' type='text' name='img_header'></td></tr>
<tr><td width='50%'>Img_Side: </td><td width='50%'><input value='$t[img_side]' type='text' name='img_side'></td></tr>
<tr><td width='50%'>Label_Description: </td><td width='50%'><textarea style='width: 200px; height: 100px;' name='label_description'>$t[label_description]</textarea></td></tr>
<tr><td width='50%'>Label_Misc: </td><td width='50%'><textarea style='width: 200px; height: 100px;' name='label_misc'>$t[label_misc]</textarea></td></tr>
<tr><td width='50%'>Label_Moredetails: </td><td width='50%'><textarea style='width: 200px; height: 100px;' name='label_moredetails'>$t[label_moredetails]</textarea></td></tr>
<tr><td width='50%'>Furnitures: </td><td width='50%'><a href='?mobler=$_GET[edit]'>Show Furniture</a></td></tr>
<br><input type='submit' name='submit' value='Update'>
</table></form>
");
}
}
if($_GET[mobler]){
echo("Here is the furnis in the catagory! Click one of them to edit it.<br>");
$rar = mysql_query("SELECT * FROM catalogue_items WHERE catalogue_id_page='$_GET[mobler]'");
while($m = mysql_fetch_array($rar)){
echo("<a href='?mobeledit=$m[tid]'>$m[catalogue_name]</a><br>");
}
}
if($_GET[mobeledit]){
$rar = mysql_query("SELECT * FROM catalogue_items WHERE tid='$_GET[mobeledit]'");
$t = mysql_fetch_array($rar);
if($_POST[submit]){
mysql_query("UPDATE catalogue_items SET catalogue_name='$_POST[catalogue_name]', name_cct='$_POST[name_cct]', recycleable='$_POST[recycleable]', catalogue_description='$_POST[catalogue_description]', catalogue_cost='$_POST[catalogue_cost]', catalogue_id_page='$_POST[catalogue_id_page]', door='$_POST[door]', tradeable='$_POST[tradeable]' WHERE tid='$_GET[mobeledit]'");
echo("The furni was updated!<br><br>");
} echo("
<table height='100%'><tbody><form method='post'>
</tr><td width='50%'>Name</td>
<td width='50%'><input type='text' name='catalogue_name' value='$t[catalogue_name]'></td></tr>
</tr><td width='50%'>Description</td>
<td width='50%'><input type='text' name='catalogue_description' value='$t[catalogue_description]'></td></tr>
</tr><td width='50%'>Price</td>
<td width='50%'><input type='text' name='catalogue_cost' value='$t[catalogue_cost]'></td></tr>
</tr><td width='50%'>Page</td>
<td width='50%'><select name='catalogue_id_page'><option>$t[catalogue_id_page]</option>");
$rar = mysql_query("SELECT * FROM catalogue_pages ORDER BY indexid");
while($l = mysql_fetch_array($rar)){
echo("<option value='$l[indexid]'>$l[displayname]</option>");
}
echo("</select></td></tr>
</tr><td width='50%'>Door</td>
<td width='50%'><select name='door'><option>$t[door]</option><option value='0'>No</option><option value='1'>Yes</option></select></td></tr>
</tr><td width='50%'>Tradeable</td>
<td width='50%'><select name='tradeable'><option>$t[tradeable]</option><option value='1'>Yes</option><option value='0'>No</option></select></td></tr>
</tr><td width='50%'>Recycleable</td>
<td width='50%'><select name='recycleable'><option>$t[recycleable]</option><option value='1'>Yes</option><option value='0'>No</option></select></td></tr>
</tr><td width='50%'>CCT-Name</td>
<td width='50%'><input type='text' name='name_cct' value='$t[name_cct]'></td></tr>
</tbody></table><br><input type='submit' name='submit' value='Update'><>
</form>
");
}
if($_GET[mobellag]){
if($_POST[submit]){
mysql_query("INSERT INTO catalogue_items (catalogue_name, name_cct, recycleable, catalogue_description, catalogue_cost, catalogue_id_page, door, tradeable) VALUES ('$_POST[catalogue_name]', '$_POST[name_cct]', '$_POST[recycleable]', '$_POST[catalogue_description]', '$_POST[catalogue_cost]', '$_POST[catalogue_id_page]', '$_POST[door]', '$_POST[tradeable]')");
echo("The furni was made!<br><br>");
} echo("
<table height='100%'><tbody><form method='post'>
</tr><td width='50%'>Name</td>
<td width='50%'><input type='text' name='catalogue_name'></td></tr>
</tr><td width='50%'>Description</td>
<td width='50%'><input type='text' name='catalogue_description'></td></tr>
</tr><td width='50%'>Price</td>
<td width='50%'><input type='text' name='catalogue_cost'></td></tr>
</tr><td width='50%'>Catagory</td>
<td width='50%'><select name='catalogue_id_page'>");
$rar = mysql_query("SELECT * FROM catalogue_pages ORDER BY indexid");
while($l = mysql_fetch_array($rar)){
echo("<option value='$l[indexid]'>$l[displayname]</option>");
}
echo("</select></td></tr>
</tr><td width='50%'>Door</td>
<td width='50%'><select name='door'><option value='0'>No</option><option value='1'>Yes</option></select></td></tr>
</tr><td width='50%'>Tradeable</td>
<td width='50%'><select name='tradeable'><option value='1'>Yes</option><option value='0'>No</option></select></td></tr>
</tr><td width='50%'>Recycleable</td>
<td width='50%'><select name='recycleable'><option value='1'>Yes</option><option value='0'>No</option></select></td></tr>
</tr><td width='50%'>CCT-Name</td>
<td width='50%'><input type='text' name='name_cct'></td></tr>
</tbody></table><br><input type='submit' name='submit' value='Add Furni'><>
</form>
");
}
if($_GET[lag]){
if($_POST[submit]){
$rar = mysql_query("SELECT * FROM catalogue_pages ORDER BY indexid DESC LIMIT 1");
$r = mysql_fetch_array($rar);
$id = $r[indexid] + 1;
mysql_query("INSERT INTO catalogue_pages (indexid, indexname, displayname, style_layout, img_header, img_side, label_description, label_misc, label_moredetails) VALUES ('$id', '$_POST[indexname]', '$_POST[displayname]', '$_POST[style_layout]', '$_POST[img_header]', '$_POST[img_side]', '$_POST[label_description]', '$_POST[label_misc]', '$_POST[label_moredetails]')");
echo("The catalogue-page was made.");
}else{
echo("<form method='post'><table><tr><td width='50%'>Indexname: </td><td width='50%'><input value='$t[indexname]' type='text' name='indexname'></td></tr>
<tr><td width='50%'>Displayname: </td><td width='50%'><input value='$t[displayname]' type='text' name='displayname'></td></tr>
<tr><td width='50%'>Style_Layout: </td><td width='50%'><input value='$t[style_layout]' type='text' name='style_layout'></td></tr>
<tr><td width='50%'>Img_Header: </td><td width='50%'><input value='$t[img_header]' type='text' name='img_header'></td></tr>
<tr><td width='50%'>Img_Side: </td><td width='50%'><input value='$t[img_side]' type='text' name='img_side'></td></tr>
<tr><td width='50%'>Label_Description: </td><td width='50%'><textarea style='width: 200px; height: 100px;' name='label_description'>$t[label_description]</textarea></td></tr>
<tr><td width='50%'>Label_Misc: </td><td width='50%'><textarea style='width: 200px; height: 100px;' name='label_misc'>$t[label_misc]</textarea></td></tr>
<tr><td width='50%'>Label_Moredetails: </td><td width='50%'><textarea style='width: 200px; height: 100px;' name='label_moredetails'>$t[label_moredetails]</textarea></td></tr>
</table><br><input type='submit' name='submit' value='Add Catagory'></form>
");
}
} ?>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<?php require_once('./templates/housekeeping_footer.php');
?>
3. Open up templates/housekeeping-header.php
4. Replace the code with this:
PHP Code:
<?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/
$version = version();
$lang->addLocale("housekeeping.header");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>PHPRetro Housekeeping: <?php echo $page['name']; ?></title>
<link rel="shortcut icon" href="<?php echo PATH; ?>/housekeeping/favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="stylesheet" href="<?php echo PATH; ?>/housekeeping/images/styles/style.css" type="text/css">
<link rel="stylesheet" href="<?php echo PATH; ?>/housekeeping/images/styles/boxes.css" type="text/css">
<?php if($page['scrollbar'] == true){ ?>
<script type="text/javascript" src="<?php echo PATH; ?>/housekeeping/images/js/jsScroller.js"></script>
<script type="text/javascript" src="<?php echo PATH; ?>/housekeeping/images/js/jsScrollbar.js"></script>
<script type="text/javascript">
var scroller = null;
var scrollbar = null;
</script>
<?php } ?>
<?php if($page['second_scrollbar'] == true){ ?>
<script type="text/javascript" src="<?php echo PATH; ?>/housekeeping/images/js/jsScroller2.js"></script>
<script type="text/javascript" src="<?php echo PATH; ?>/housekeeping/images/js/jsScrollbar2.js"></script>
<script type="text/javascript">
var scroller2 = null;
var scrollbar2 = null;
</script>
<?php } ?>
<script type="text/javascript">
window.onload = function(){
<?php if($page['scrollbar'] == true){ ?>
scroller = new jsScroller(document.getElementById("listview"), 244, 96);
scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container"), scroller, false);
<?php } ?>
<?php if($page['second_scrollbar'] == true){ ?>
scroller2 = new jsScroller2(document.getElementById("listview2"), 244, 96);
scrollbar2 = new jsScrollbar2 (document.getElementById("Scrollbar2-Container"), scroller2, false);
<?php } ?>
};
</script>
<meta name="build" content="PHPRetro <?php echo $version['version']." ".$version['stable']; ?>" />
</head>
<body>
<div class="panel">
<div class="header_left"> <br /> <br /> <br /><a href="http://www.phpretro.com/"><img src="<?php echo PATH; ?>/housekeeping/images/header_logo.png" alt="PHPRetro"></a></div>
<div class="header_right"><img src="<?php echo PATH; ?>/housekeeping/images/header_tm1.gif"></div>
<div class="panel_title">
<span class="text">PHPRetro <?php echo $version['major'].".".$version['minor']; ?> <?php echo $lang->loc['housekeeping']; ?></span>
<div class="close_button"><a href="<?php echo PATH; ?>/housekeeping/logout"><img src="<?php echo PATH; ?>/housekeeping/images/button_close.gif" alt="<?php echo $lang->loc['logout']; ?>"></a></div>
</div>
<?php if($page['category'] != "login"){ ?>
<div class="panel_header">
<ul <?php if($page['category'] == "dashboard"){ ?>class="selected" <?php } ?>id="item">
<li class="top"><div style="text-align:center"><a href="#"><?php echo $lang->loc['dashboard']; ?></a></div></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/dashboard"><?php echo $lang->loc['home']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/updates"><?php echo $lang->loc['updates']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/logs"><?php echo $lang->loc['logs']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/about"><?php echo $lang->loc['about']; ?></a></li>
</ul>
<div class="border"></div>
<ul <?php if($page['category'] == "settings"){ ?>class="selected" <?php } ?>id="item">
<li class="top"><div style="text-align:center"><a href="#"><?php echo $lang->loc['settings']; ?></a></div></li>
<?php $sql = $db->query("SELECT id,name FROM ".PREFIX."settings_pages ORDER BY `order` ASC");
while($row = $db->fetch_row($sql)){ echo "<li class=\"item\"><a href=\"".PATH."/housekeeping/settings/".$row[0]."\">".$row[1]."</a></li>\n"; }
?>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/cache"><?php echo $lang->loc['cache']; ?></a></li>
</ul>
<div class="border"></div>
<ul <?php if($page['category'] == "tools"){ ?>class="selected" <?php } ?>id="item">
<li class="top"><div style="text-align:center"><a href="#"><?php echo $lang->loc['tools']; ?></a></div></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/banners"><?php echo $lang->loc['banners']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/campaigns"><?php echo $lang->loc['campaigns']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/catalogue"><?php echo $lang->loc['catalogue']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/collectables"><?php echo $lang->loc['collectables']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/faq"><?php echo $lang->loc['faq']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/news"><?php echo $lang->loc['news']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/newsletter"><?php echo $lang->loc['newsletter']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/recommended"><?php echo $lang->loc['recommended']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/vouchers"><?php echo $lang->loc['vouchers']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/catalogue">Catalogue</a></li>
</ul>
<div class="border"></div>
<ul <?php if($page['category'] == "users"){ ?>class="selected" <?php } ?>id="item">
<li class="top"><div style="text-align:center"><a href="#"><?php echo $lang->loc['users']; ?></a></div></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/users"><?php echo $lang->loc['users']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/bans"><?php echo $lang->loc['bans']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/alerts"><?php echo $lang->loc['alerts']; ?></a></li>
<li class="item"><a href="<?php echo PATH; ?>/housekeeping/help"><?php echo $lang->loc['help']; ?></a></li>
</ul>
<div class="border"></div>
</div>
<div class="clear"></div>
<?php } ?>
<div class="topborder"></div>
Then you are done!
You will find the editor under Tools in the menu!
Hope it's useful!
WHOOPS!
This does NOT support languages, you will have to translate the entire file if you want that!
REALLY REALL REALLY SORRY!
Now it should edit only one page...
The same crap happened to me, so I feel sorry for you
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Do you have any screenshots? Looks nice!
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Quote:
Originally Posted by
bokeoke12
Do you have any screenshots? Looks nice!
It is amost just plain text, and the rest would be like the rest of the PHPRetro housekeeping...
So thats why I didnt add any screenshots :P
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Nice One, Mind Making It Admin Only?
Re: [ADD-ON] Catalogue-Editor for PHPRetro
looks nice [2]! i will test it
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Can you make an "Massa Stuff" Addon :/
Re: [ADD-ON] Catalogue-Editor for PHPRetro
lol, if you edit a page is every page in de catalogue the same.
Re: [ADD-ON] Catalogue-Editor for PHPRetro
this is already in phpretro anyway my ''mypage'' stuff has like 2 stickerz and one backround option so i dont use this i doont know how to add stuff anyway good for people who have a crappy phpretro stuff but i had already had this catalogue thing.
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Quote:
Originally Posted by
Just
Nice One, Mind Making It Admin Only?
It's quite obvious, change;
PHP Code:
$page['rank'] = 5;
To:
PHP Code:
$page['rank'] = YOUR_RANK_HERE;
And it's the same for every page (if you want to change the ranks)
On topic:
Is this for the hotel catalog (client) ?
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Quote:
Originally Posted by
Scresho
Can you make an "Massa Stuff" Addon :/
>.< please xD
Re: [ADD-ON] Catalogue-Editor for PHPRetro
thank you for un-useful stuff, it destroyed my catalogue.. >.< now every page is the same stuff.
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Quote:
Originally Posted by
tidesj
thank you for un-useful stuff, it destroyed my catalogue.. >.< now every page is the same stuff.
SORRY!
I AM REALLY SORRY!
It is fixed now
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Quote:
Originally Posted by
tidesj
thank you for un-useful stuff, it destroyed my catalogue.. >.< now every page is the same stuff.
Thats why you always take db backups:thumbup1:
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Do it work on holocms to?
Re: [ADD-ON] Catalogue-Editor for PHPRetro
Quote:
Originally Posted by
Spyron
Do it work on holocms to?
No.
---
It'd be great to see a screenshot just to see what it contains.