Location: PHPKode > projects > Katyshop > katyshop_ro_0.3.2.1/web/admin/category.php
<?php
/**
 * Product: Katyshop
 * @version 0.3.2.1
 * @author Catalin Hulea - hide@address.com
 * @copyright Copyright (C) 2007 Catalin Hulea
 * @license GNU General Public License version 3
 * 			You can find a copy of GNU GPL v3 at this path: /docs/LICENSE
 * @link https://sourceforge.net/projects/katyshop
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
require_once(dirname(dirname(__FILE__)) . "/init.php");
require_once(WEB_DIR . "/includes/req_admin.php");
$db = Application::getDb();
$category = Application::getCurrentCategory();
?>
<html>
<head>
<title><?php echo APP_NAME; ?></title>
<?php require_once(WEB_DIR . "/includes/html_head.php"); ?>
</head>

<body>
<div id="container">
<?php require_once(WEB_DIR . "/includes/header.php"); ?>
<div id="middle">
<div id="left_vertical_line">
<?php require_once(WEB_DIR . "/admin/includes/left.php"); ?>
<div id="content">
<h1>Administrare categorii</h1>
<?php require_once(WEB_DIR . "/includes/print_messages.php"); ?>
<?php require_once(WEB_DIR . "/admin/includes/breadcrumb.php"); ?>

<form action="admin/formparser/category.php?action=delete" method="post" id="frm_delete_category">
<input type="hidden" name="id_category" value="0">
</form>

<form action="admin/formparser/category.php?action=change_position" method="post" id="frm_change_category_position">
<input type="hidden" name="id_category" value="0">
<input type="hidden" name="direction" value="up">
</form>

<form action="admin/formparser/category.php?action=change_active_state" method="post" id="frm_change_category_active_state">
<input type="hidden" name="id_category" value="0">
<input type="hidden" name="active" value="1">
</form>

<form action="admin/formparser/product.php?action=delete" method="post" id="frm_delete_product">
<input type="hidden" name="id_product" value="0">
</form>

<form action="admin/formparser/product.php?action=change_position" method="post" id="frm_change_product_position">
<input type="hidden" name="id_product" value="0">
<input type="hidden" name="direction" value="up">
</form>

<form action="admin/formparser/product.php?action=change_active_state" method="post" id="frm_change_product_active_state">
<input type="hidden" name="id_product" value="0">
<input type="hidden" name="active" value="1">
</form>
<?php
if($category->id == 0)
{
	$category->title = "Root";
	$category->description = "Categoria principala pentru produsele din siteul dumneavoastra";
}
?>
<dl>
<dt class="title"><b><?php echo Escape::html($category->title); ?></b></dt>
<dd>
<table cellpadding="0" cellspacing="0" style="margin: 0px; width: 98%; ">
<tr>
<td>
	<p class="content">
	<?php
	if(!empty($category->picture) && is_file(WEB_DIR . "/img/categories/{$category->picture}"))
	{
		?>
		<img src="img/categories/<?php echo Escape::htmlValue($category->picture); ?>"><br>
		<?php
	}
	echo nl2br(Escape::html($category->description));
	?>
	</p>

	<ul class="actions">
	<li class="up"><a href="admin/category.php?id_category=<?php echo intval(@$category->id_parent); ?>">Categoria parinte</a></li>
	<li class="add_category"><a href="admin/category.php?action=edit&id_category=0&id_parent=<?php echo intval(@$category->id); ?>">Adaugati o noua categorie</a></li>
	<li class="add_product"><a href="admin/product.php?action=edit&id_product=0&id_category=<?php echo intval(@$category->id); ?>">Adaugati un nou produs</a></li>
	<?php
	if(intval($category->id) > 0)
	{
		?>
		<li class="edit"><a href="admin/category.php?action=edit&id_category=<?php echo intval(@$category->id); ?>">Editare categorie <?php echo Escape::html($category->title); ?></a></li>
		<li class="move"><a href="admin/category.php?action=change_parent&id_category=<?php echo intval(@$category->id); ?>">Mutati categoria</a></li>
		<li class="delete"><a href="javascript:deleteCategory('<?php echo intval($category->id); ?>'); " style="color: red; ">Stergeti categoria <?php echo Escape::html($category->title); ?></a></li>
		<?php
		if($category->active == 1)
		{
			?>
			<li><img src="img/icons/bullet_green.gif"> Categoria este activa</a></li>
			<li><a href="category.php?id_category=<?php echo Escape::htmlValue($category->id); ?>">Vizualizati categoria pe siteul public</a></li>
			<?php
		}
		else
		{
			?>
			<li><img src="img/icons/bullet_red.gif"> Categoria nu este activa</a></li>
			<?php
		}
	}
	?>
	</ul>

	<br clear="all">
	&nbsp;
</td>
</tr>
</table>
</dd>
</dl>

<?php
if(@$_GET["action"] == "edit")
{
	if(isset($_GET["id_category"]))
	{
		$c = $db->tbCategory->getRecordById(@$_GET["id_category"]);
	}
	else
	{
		$c = SessionHandler::get("editCategory");
		if(!is_a($c, "Category"))
			$c = new Category();
	}
	if(!empty($_GET["id_parent"]))
		$c->id_parent = intval($_GET["id_parent"]);

	if($c->pos == 0)
	{
		$temp = $db->tbCategory->getMaxPos($c->id_parent);
		$c->pos = $temp + 1;
	}
	?>
	<dl>
	<dt></dt>
	<dd>
		<h2><?php echo (intval($c->id) > 0) ? "Editati categoria " . Escape::html($c->title) : "Adaugati o noua categorie"; ?></h2>
		<form action="admin/formparser/category.php?action=save" method="post" enctype="multipart/form-data">
		<input type="hidden" name="MAX_FILE_SIZE" value="8000000">
		<input type="hidden" name="id" value="<?php echo Escape::htmlValue($c->id); ?>">
		<table>
		<tr>
		<td>Titlu</td><td><input type="text" name="title" value="<?php echo Escape::htmlValue($c->title); ?>"></td>
		</tr>
		<tr>
		<td>Categoria parinte</td>
		<td>
			<?php
			$temp = $db->tbCategory->getRecordById($c->id_parent);
			?>
			<input type="hidden" name="id_parent" value="<?php echo Escape::htmlValue($c->id_parent); ?>">
			<a href="admin/category.php?id_category=<?php echo intval($temp->id); ?>"><?php echo ($temp->id > 0) ? Escape::html($temp->title) : Escape::html(APP_NAME); ?></a>
			<?php
			if($c->id > 0)
			{
				?>
				<br>
				<a href="admin/category.php?action=change_parent&id_category=<?php echo intval($c->id); ?>">click aici pentru a schimba categoria parinte</a>
				<?php
			}
			?>
		</td>
		</tr>
		<tr>
		<td>Pozitia</td><td><input type="text" name="pos" value="<?php echo Escape::htmlValue($c->pos); ?>"></td>
		</tr>
		<tr>
		<td>Descriere</td><td><textarea name="description" cols="30" rows="5"><?php echo Escape::html($c->description); ?></textarea></td>
		</tr>
		<tr>
		<td>Imagine</td>
		<td>
			<?php
			if(!empty($c->picture))
			{
				?>
				<a href="img/categories/<?php echo Escape::htmlValue($c->picture); ?>" target="_blank"><?php echo Escape::html($c->picture); ?></a>
				<br>
				<?php
			}
			?>
			<a href="javascript:changeCategoryPicture(); " id="the_picture_link">click aici pentru a schimba imaginea</a>
			<br>
			<input type="file" name="picture" disabled style="display: none; " id="the_picture">
		</td>
		</tr>
		<tr>
		<td>Active</td>
		<td>
			<input type="radio" name="active" value="0" id="category_active_0" <?php echo $c->active == 1 ? "" : "checked"; ?>><label for="category_active_0"> Da</label>
			<input type="radio" name="active" value="1" id="category_active_1" <?php echo $c->active == 1 ? "checked" : ""; ?>><label for="category_active_1"> Nu</label>
		</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>
			<input type="submit" value="Salvati" class="button">
			<input type="button" value="Cancel" class="button" onclick="redirect('admin/category.php?id_category=<?php echo (intval($c->id) > 0) ? intval($c->id) : intval($c->id_parent); ?>'); ">
		</td>
		</tr>
		</table>
		</form>
	</dd>
	<?php
}
elseif (@$_GET["action"] == "change_parent")
{
	require_once(WEB_DIR . "/admin/includes/select_parent_category.php");
}
else
{
	if(empty($_GET["order_by"]["subcategs"]))
		$_GET["order_by"]["subcategs"] = "pos";
	if(empty($_GET["order_direction"]["subcategs"]))
		$_GET["order_direction"]["subcategs"] = "asc";
	// subcategories list
	$list = $db->tbCategory->getChildCategories($category->id, @$_GET["order_by"]["subcategs"], @$_GET["order_direction"]["subcategs"]);
	if(count($list) > 0)
	{
		?>
		<a name="subcategs"></a>
		<dl>
		<dt></dt>
		<dd>
		<h3>Subcategoriile din <?php echo Escape::html($category->title); ?></h3>
		<table width="470">
		<tr>
		<td width="35">
			<?php
			displayOrderBy($category->id, "pos", "asc", "admin/category.php", "subcategs");
			displayOrderBy($category->id, "pos", "desc", "admin/category.php", "subcategs");
			?>
		</td>
		<td></td>
		<td width="300">
			<?php
			displayOrderBy($category->id, "title", "asc", "admin/category.php", "subcategs");
			displayOrderBy($category->id, "title", "desc", "admin/category.php", "subcategs");
			?>
		</td>
		<td width="40">
			<?php
			displayOrderBy($category->id, "active", "asc", "admin/category.php", "subcategs");
			displayOrderBy($category->id, "active", "desc", "admin/category.php", "subcategs");
			?>
		</td>
		<td width="60">
			<?php
			displayOrderBy($category->id, "date_created", "asc", "admin/category.php", "subcategs");
			displayOrderBy($category->id, "date_created", "desc", "admin/category.php", "subcategs");
			?>
		</td>
		</tr>
		<?php
		for($i = 0; $i < count($list); $i++)
		{
			$c = $list[$i];
			?>
			<tr valign="top">
			<td>
				<table cellpadding="0" cellspacing="0" style="margin: 0px;">
				<tr>
				<td style="font-size: 20pt; "><?php echo Escape::html($c->pos); ?></td>
				<td>
					<a href="javascript:category_moveUp('<?php echo intval($c->id); ?>'); " title="move up" style="display: block; "><img src="img/icons/bullet_arrow_up_blue.gif" alt="move up"></a>
					<a href="javascript:category_moveDown('<?php echo intval($c->id); ?>'); " title="move down"><img src="img/icons/bullet_arrow_down_blue.gif" alt="move down"></a>
				</td>
				</tr>
				</table>
			</td>
			<td align="center">
			<?php
			if(!empty($c->picture) && is_file(WEB_DIR . "/img/categories/{$c->picture}"))
			{
				?>
				<a href="admin/category.php?id_category=<?php echo intval($c->id); ?>">
				<img src="img/categories/<?php echo Escape::htmlValue($c->picture); ?>">
				</a>
				<?php
			}
			?>
			</td>
			<td>
			<a href="admin/category.php?id_category=<?php echo intval($c->id); ?>"><?php echo Escape::html($c->title); ?></a>
			<br>
			<?php echo nl2br(Escape::html(Tools::limitString($c->description, 100))); ?>
			</td>
			<td>
			<?php
			if(intval($c->active) == 1)
			{
				?>
				<a href="javascript:deactivateCategory('<?php echo intval($c->id); ?>'); " title="dezactivati"><img src="img/icons/bullet_red_blur.gif" alt="dezactivati"></a>
				<img src="img/icons/bullet_green.gif" alt="categoria este activa pe siteul public">
				<?php
			}
			else
			{
				?>
				<img src="img/icons/bullet_red.gif" alt="categoria nu este activa pe siteul public">
				<a href="javascript:activateCategory('<?php echo intval($c->id); ?>'); " title="activati"><img src="img/icons/bullet_green_blur.gif" alt="activati"></a>
				<?php
			}
			?>
			</td>
			<td style="font-size: 8pt;">
				<table cellpadding="0" cellspacing="0" style="margin: 0px;">
				<tr>
				<td><a href="admin/category.php?action=edit&id_category=<?php echo intval($c->id); ?>" title="editati"><img src="img/icons/edit.gif" alt="editati"></a></td>
				<td><a href="admin/category.php?action=change_parent&id_category=<?php echo intval($c->id); ?>" title="mutati"><img src="img/icons/move.gif" alt="mutati"></a></td>
				<td><a href="javascript:deleteCategory('<?php echo intval($c->id); ?>'); " title="stergeti"><img src="img/icons/delete.png" alt="stergeti"></a></td>
				</tr>
				</table>
			<?php echo Escape::html($c->date_created); ?>
			</td>
			</tr>
			<?php
		}
		?>
		</table>
		</dd>
		</dl>
		<?php
	}
	require_once(WEB_DIR . "/admin/includes/products_list.php");
}
?>

</div>
<?php require_once(WEB_DIR . "/includes/right.php"); ?>
<?php require_once(WEB_DIR . "/includes/footer.php"); ?>
</div>
</div>
</div>
</body>
</html>
Return current item: Katyshop