<?php
/**
* @author:  Bunzia Alexander <nifus@mail.ru> <http://www.weblancer.net/users/nifus/>
* @copyright: Copyright (c) 2010, Bunzia Alexander
* @version: 1.0
* @license: http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @package: HiLo CMS
*/

if ( !defined("inc_system_admin_menu") ){
  define("inc_system_admin_menu", 1);
  
  
  /**
  * Для блока admin_menu
  *
  */
  function admin_menu(){
    include_once(MAIN_SOURCE_PATH.'/modules/admin/inc/url.php');
    include_once(MAIN_SOURCE_PATH.'/modules/users/lang/'.MAIN_LANG.'/blocks.php');
    
    /*if ( $MAIN_USER -> type()=='developer'){*/
      $menu[] = array('url'=>URL_ADMIN_MAIN ,'title' => B_ADMIN_SITE);
      $menu[] = array('url'=> URL_ADMIN_CONFIG, 'title'=>B_ADMIN_CONFIG);
      $menu[] = array('url'=> URL_ADMIN_PAGES, 'title'=>B_ADMIN_MODULES);
      $menu[] = array('url'=> URL_ADMIN_BLOCKS,  'title'=>B_ADMIN_BLOCKS);
      //$menu[] = array('url'=> URL_ADMIN_TMPL,    'title'=>B_ADMIN_TMPL);
      //$menu[] = array('url'=> URL_ADMIN_COMMENTS,'title'=>B_ADMIN_COMMENTS);
      $menu[] = array('url'=> URL_ADMIN_MAIL ,'title'=>B_ADMIN_MAIL_TMPL);
      //$menu[] = array('url'=> URL_ADMIN_CATEGORY ,'title'=>B_ADMIN_CATEGORY);
      $menu[] = array('url'=> URL_ADMIN_STAT_PAGES ,'title'=>B_ADMIN_PAGES);
      //$menu[] = array('url'=> URL_ADMIN_PLUGINS ,'title'=>B_ADMIN_PLUGINS);
      //$menu[] = array('url'=> URL_ADMIN_EVENTS ,'title'=>B_ADMIN_EVENTS);
      
     // $menu[] = array('url'=> URL_ADMIN_SNIPPETS ,'title'=>B_ADMIN_SNIPPETS);
      //$menu[] = array('url'=> URL_ADMIN_LANGS ,'title'=>B_ADMIN_LANGS);
      $menu[] = array('url'=> URL_ADMIN_META ,'title'=>B_ADMIN_META);
     
    /*}else{
      $menu[] = array('url'=>URL_ADMIN_MAIN ,'title' => B_ADMIN_SITE);
      $menu[] = array('url'=> URL_ADMIN_CONFIG, 'title'=>B_ADMIN_CONFIG);
      $menu[] = array('url'=> URL_ADMIN_BLOCKS,  'title'=>B_ADMIN_BLOCKS);
      $menu[] = array('url'=> URL_ADMIN_COMMENTS,'title'=>B_ADMIN_COMMENTS);
      $menu[] = array('url'=> URL_ADMIN_MAIL ,'title'=>B_ADMIN_MAIL_TMPL);
      $menu[] = array('url'=> URL_ADMIN_CATEGORY ,'title'=>B_ADMIN_CATEGORY);
      $menu[] = array('url'=> URL_ADMIN_STAT_PAGES ,'title'=>B_ADMIN_PAGES);

    }*/
    return $menu;
  }

  /**
  * Для события admin_event_htaccess
  *
  */
  function admin_htaccess(){
    
    include_once(MAIN_SOURCE_PATH.'/modules/admin/inc/class.staticPages.php');
    $rows = staticPages::list_pages();
    $urls = array();
    foreach( $rows as $row ){
      $urls['#^'.MAIN_DIR.$row['p_url'].'$#i']= array( 'p_name'=>'admin_stat_pages_view','act'=>'view','url'=>$row['p_url'] );
    }
     $urls['#^'.MAIN_DIR.'contact$#i']= array( 'p_name'=>'admin_contacts','act'=>'index');
    return $urls;
  }

  /**
  * Для события admin_event_cache
  *
  */
  function admin_cache(){
  global $MAIN_DB;
    $sql = "SELECT * FROM ".MAIN_MODULES_TBL;
    $res = $MAIN_DB -> query($sql);
    $rows = array();
    while( $row = $MAIN_DB -> fetch_assoc($res) ){
      $rows[MAIN_MODULES_TBL][ $row['m_id']] = $row;
      //$rows[MAIN_MODULES_TBL][ $row['m_path']] = $row;
    }
   
    return $rows;
  }

}
?>
