<? $pageTitle = 'Home'; ?>
<? require 'common/header.php';
    //echo 'nightmare: '.User::cryptPassword("nightmare") . '<br />';
    //echo 'nightmare01: '.User::cryptPassword("nightmare01") . '<br />';
    //echo 'nightmare12345: '.User::cryptPassword("nightmare12345") . '<br />';

?>
<br />
<br />
<br />
<br />
<style type="text/css">
    ul ul{
        margin-lefT:30px;
    }

    ul.breadcrumb{
        list-style-type:none;

    }
    ul.breadcrumb > li {
        display:inline;

    }

    ul.breadcrumb > li a{
        padding:3px 8px;
                background-color:#e1e1e1;
    }

    ul.breadcrumb > li.active > a{
        background: #383838 ;
        color:#fff;
    }
</style>
<?php

    $table = new Table('pages');
    echo $table->drawBreadcrumb(6,
        array (
            'tables' => array (
                'pages' => array
                (
                    'foreignKey' => 'link_category_id',
                ) ,
                'categories' => array (
                    'foreignKey' => 'link_category_id',
                    'link' => 'categories/%title_ar%',
                    'foreignKey2' => 'link_master_section',
                ),
                'master_sections' => array (
                     'link' => 'master_sections/%title_en%'
                )
            )
        )
    );

    die;
    $table = new Table('products');
    echo $table->drawBreadcrumb(2,
        array (
            'tables' => array (
                'products' => array
                (
                    'foreignKey' => 'link_subgroup_id',
                    'link' => 'products/%title%',
                ) ,
                'subgroups' => array (
                    'foreignKey' => 'link_group_id',
                ),
                'groups' => array (
                    'foreignKey' => 'link_category_id'
                )
            )
        )
    );

    die;
    $menu = TableTraversal::createMenu("product_categories", array(
            'product_availability' => array(
                'display_field' => 'amount_left'
            ),
            'product_categories' => array(
                'order' => 'name ASC',
                'display_field' => 'name',
                'page_link' => 'product-categories.html'
            )
        ));
    drawMenu($menu);

    /*
    To create a sitemap, you use the above function on every table you need it displayed on the site map page. you only choose the parent tables. Like in the above example, only product_categories is selected and the script will traverse all the child tables
    */


    // $siteMap = new Sitemap(array('order'=> array('product_categories') , 'exclude' => array('rooms','room_photos') ));
    //   $siteMap->drawSiteMap();

    //    die;
    //    $menu = MenuItem::createMenu("product_categories", array(
    //                'product_availability' => 'amount_left',
    //                'product_categories' => array(
    //                    'display_field' => 'name'
    //                )
    //            ));
    //     drawMenu($menu,3);


    //    $siteMap = new Sitemap(array('order'=> array('product_categories') , 'exclude' => array('rooms','room_photos') ));
    //    $siteMap->drawSiteMap();

    //    die;
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    $table = new Table("product_categories");
    $array = array(
        'conditions' => array('id'=>1,'name LIKE','%george','age >' => 13),
        'fields' => array('id','name','COUNT(*)'),
        'order' => 'name ASC, id DESC',
    );


    $pagination = new Pagination($page,2,10);
    $result = $table->safeFind($array,$pagination);
    pr($result);
    echo $pagination->displayPagination();


?>
