<?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
*/

/**
* Автоматически генерирует административное меню на основе данных
*  предоставляемых установленными модулями
* 
* @var: array $options
* @return: str
*/

function user_menu($options){
global $MAIN_DB;
  $sql = "SELECT * FROM ".$MAIN_DB-> prefix("system_menu")." ORDER BY m_id ASC";
  $res = $MAIN_DB -> query($sql);
  $rows = array();
  while( $row = $MAIN_DB -> fetch_array($res) ){
    $rows[]=$row;
  }

  
	$t = new PHPTAL( false );
	$t -> setSource(TMPL_USER_MENU);
	$t -> rows = $rows;
	return $t -> execute();
}

define('TMPL_USER_MENU',
' 
<tal:block tal:condition="rows" tal:repeat="r rows">
  
 <table width="80%" border="0" cellspacing="6" cellpadding="0">
      <tr> 
          <td width="10" align="right"><img src="/inc/squr.gif" width="8" height="8" align="baseline" vspace="2" hspace="2"></td>
          <td><a class="menu" href="${r/m_src}" >${r/m_name}</a></td>
        </tr>
        <tr> 
          <td colspan="2" align="center"><img src="/inc/rd-t.gif" width="217" height="3"></td>
        </tr>
        </table>
 
</tal:block>  
  
  ');
?>
