<?php
if(!strlen($pathtoroot))
{
  $path=dirname(realpath(__FILE__));
  if(strlen($path))
  {
    /* determine the OS type for path parsing */
    $pos = strpos($path,":");
    if ($pos === false)
    {
      $gOS_TYPE="unix";
      $pathchar = "/";
    }
    else
    {
      $gOS_TYPE="win";
      $pathchar="\\";
    }
    $p = $path.$pathchar;
    /*Start looking for the root flag file */
    while(!strlen($pathtoroot) && strlen($p))
    {
      $sub = substr($p,strlen($pathchar)*-1);
      if($sub==$pathchar)
      {
        $filename = $p."root.flg";
      }
      else
        $filename = $p.$pathchar."root.flg";
      if(file_exists($filename))
      {
        $pathtoroot = $p;
      }
      else
      {
        $parent = realpath($p.$pathchar."..".$pathchar);
	if($parent!=$p)
	{
	  $p = $parent;
	}
	else
	  $p = "";
      }
    }
    if(!strlen($pathtoroot))
      $pathtoroot = ".".$pathchar;
  }
  else
  {
    $pathtoroot = ".".$pathchar;
  }
}

$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;

require_once($pathtoroot."kernel/startup.php");

$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");


$admin = $objConfig->Get("AdminDirectory");
//echo "Admin: $admin <br>\n";
if(!strlen($admin))
    $admin = "admin";

$localURL=$rootURL."kernel/";
$adminURL=$rootURL.$admin;
$imagesURL = $adminURL."/images";

$cssURL = $adminURL."/include";
$jsURL = $adminURL."/include/subitems";
//admin only util

$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
//require_once ($pathtoroot."kernel/admin/include/navmenu.php");
//require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
$section = $_GET["section"];

$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];

$incs = array();

$m = GetModuleArray();
foreach($m as $key=>$value)
{
    $inc = $pathtoroot.$value."admin/include/summary/".$sectionname.".php";
    //echo "<pre>". $inc ."</pre><BR>"; 
    if(file_exists($inc))
        $incs[] = $inc;
}

$envar = BuildEnv();
$charset = GetRegionalOption('Charset');
print <<<END
<html>
<head>
  <title>In-portal</title>
  <meta http-equiv="content-type" content="text/html;charset=$charset">
  <meta http-equiv="Pragma" content="no-cache">
  <script language="JavaScript">
    imagesPath='$imagesURL'+'/';
    clear_checkboxes=0;
  </script> 

END;

require_once($pathtoroot.$admin."/include/mainscript.php");

print <<<END
  <link rel="stylesheet" type="text/css" href="$cssURL/style.css">
  <link rel="stylesheet" type="text/css" href="$cssURL/subitems.css">
  <script src="$jsURL/listitems.js"></script>
  <script src="$jsURL/imgbuttons.js"></script>
  <script src="$jsURL/navboxes.js"></script>

END;
	int_SectionHeader();
    
?>      
<table cellspacing="0" cellpadding="0" width="100%" border="0">
  <tr>
    <td valign="top">
<?php
	$parent = $objSections->GetSection($section);
	$sub = $objSections->GetSection( $parent->Get("child") );
	$has_modules = is_object($sub);
?>
           <table cellspacing="0" cellpadding="2" border="0" width="100%" CLASS="<?php echo $has_modules ? 'tableborder_full' : ''; ?>">
<?php  
	if($has_modules)
	{
		while(is_object($sub))
		{
			echo '<tr isListItem="true" '.int_table_color_ret().'>'."\n";
			echo '	<td class="subitem_icon">';
			echo '		<img align="left" src="'.$sub->IconURL(2).'" border="0">';
			echo '	</td>';
			echo '	<td class="subitem_description"><a href="'.$sub->URL().'" class="dLink">';
			$lang_tag = 'la_Description_'.$sub->Get('key');
			echo admin_language( $sub->Get('name') ).'</a>';
			echo prompt_language($lang_tag); //$sub->Get("description");
			echo '	</td>'."\n";
			echo '</tr>'."\n";
			$sub = $objSections->GetSection( $sub->Get('right') );
		}
	}
	else
	{
		echo '<tr><td>&nbsp;</td></tr>';
	}
?>
          </TABLE>
        </TD>
<?php
if(count($incs)>0)
{
?>
  <td width="1"><img src="<?php echo $imagesURL; ?>/spacer.gif" width="4" height="1"></td>        
  <td width="269" valign="top" class="boxContainer">
<?php
	// including each module summaries here  
    for($i=0;$i<count($incs);$i++)
        include($incs[$i]);
  
?>
  </TD>
<?php
}
?>
  </TR>
</TABLE>
<?php
if(count($incs)>0)
{
?>
<script>
      init();
</script>
<?php
}
?>
<form ID="viewmenu" NAME="viewmenu" method="post" action="user_list.php?env=<?php echo BuildEnv(); ?>" name="viewmenu">
  <input type="hidden" name="fieldname" value="">
  <input type="hidden" name="varvalue" value="">
  <input type="hidden" name="varvalue2" value="">
  <input type="hidden" name="Action" value="">
</form>
<?php int_footer(); ?>