}
    if ($p_slug != '' && !preg_match('/^[a-zA-Z0-9_-]*$/', $p_slug)) {
        $success = false;
        array_push($errors, "Invalid slug!");
    }
    if ($p_slug == '') {
        $success = false;
        array_push($errors, "The slug field is required !");
    }
    if ($success) {
        $update = array('name' => $p_name, 'slug' => $p_slug);
        if ($category['parent'] > 0 && $p_parent > 0) {
            $update['parent'] = $p_parent;
        }
        Category::update($g_id, $update);
        $category = Category::get_one($g_id);
    }
}
$categories = Category::get_all(array('parent' => 0));
include "page-header.php";
?>

<div id="wrapper">

	<?php 
include "page-left.php";
?>

	<div id="content">
			
		<form name="form_category_edit" id="form_category_edit" method="post" enctype='application/x-www-form-urlencoded' accept-charset="UTF-8" class="form">