<?php

/*$leap = new EfiHome();
$arrTabs =$leap->loadedDomains4Role[Account::getMyRole()];
$arrDomain = $leap->domains;
*/
//pr(Registor::getRoles());
//global $template;
//pr($template);
//pr($template->adminMenu);
//pr($template->domainMenu);
$arrR = Registor::getAllAdminMenuByRoles(Account::getMyRoles());
//pr($arrR);
/*
 * list of icons
 * fa fa-dashboard
 * fa fa-files-o
 * fa fa-th
 * fa fa-pie-chart
 * fa fa-laptop
 * fa fa-edit
 * fa fa-table
 * fa fa-calendar
 * fa fa-envelope
 * fa fa-envelope
 * fa fa-share
 * fa fa-book
 * fa fa-bar-chart-o
 * fa-wrench
 */
$arrDomainName2Icon = array("Appear" => "fa fa-eye", "Appearance" => "fa fa-tint", "Capsule" => "fa fa-bullhorn", "Content" => "fa fa-bookmark", "Developer" => "fa fa-tasks", "Email" => "fa fa-envelope-o", "Finance" => "fa fa-money", "Komisi" => "fa fa-dollar", "PageCategories" => "fa fa-university", "PaketManagement" => "fa fa-dribbble", "Payment" => "fa fa-diamond", "PushNot" => "fa fa-share", "Setting" => "fa fa-edit", "UserAndRoles" => "fa fa-users");
    function search()
    {
        $q = addslashes($_GET['q']);
        ?>
        <div class="row">
            <div class="col-md-12">
        <h1>Search Results for "<?php 
        echo $q;
        ?>
"</h1>
        <?php 
        $allowed = Registor::getAllAdminMenuByRoles(Account::getMyRoles());
        //        pr($allowed);
        $allows = array();
        foreach ($allowed as $alls) {
            foreach ($alls as $key => $c) {
                $allows[] = $key;
            }
        }
        //        echo $q;
        //        pr(Registor::getAllAdminMenuFromSession());
        $allAdmin = Registor::getAllAdminMenuSearch();
        //        pr($allAdmin);
        foreach ($allAdmin as $all) {
            foreach ($all as $key => $value) {
                $save[$key] = $value;
            }
        }
        $stored = $save;
        foreach ($stored as $key => $store) {
            if (stripos($store, $q) !== false) {
                //                echo "Key: " . $key . "<br />Found: " . $q . "<br />";
                $keys[] = $key;
            }
        }
        $regs = Registor::getAllAdminMenu();
        //        pr($regs);
        $cnt = 0;
        foreach ($regs as $domain => $arre) {
            foreach ($arre as $key => $re) {
                if (in_array($key, $keys)) {
                    if (in_array($key, $allows)) {
                        $cnt++;
                        ?>
                        <div class="menuicon" style="background: white; padding: 10px; margin: 10px; margin-left: 0px;">
                            <h3 style="margin: 0; padding: 0; margin-bottom: 10px;">
                                <a href="javascript:openLw('<?php 
                        echo $key;
                        ?>
','<?php 
                        echo _SPPATH . $re;
                        ?>
','fade');activkanMenuKiri('<?php 
                        echo $key;
                        ?>
');"><?php 
                        echo Lang::t($key);
                        ?>
</a>
                            </h3>

                            <p>
                                <?php 
                        echo $save[$key];
                        ?>
                            </p>
                        </div>
                    <?php 
                    }
                }
            }
        }
        if ($cnt < 1) {
            ?>
            <h3>
                <?php 
            echo Lang::t('Cannot Find Any Matching Features');
            ?>
            </h3>
            <?php 
        }
        //        pr(Registor::getAllAdminMenuSearch());
        ?>
</div>
        </div><?php 
    }