<?php
/**
 * @package Flatnux_theme_default_HC
 * @author Alessandro Vernassa <speleoalex@gmail.com>
 * @copyright Copyright (c) 2011
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
 *
 * if you want to use the template "index.tp.html" then delete this file else
 * rename this file in structure.php
 *
 */
defined("_FNEXEC") or die("Restricted access");
global $_FN;
$config=FN_LoadConfig("themes/{$_FN['theme']}/config.php");
if (!empty($config['top_menu_parent']) && $config['top_menu_parent'] == "__submenu__")
    $config['top_menu_parent'] = $_FN['mod'];
if (!empty($config['vertical_menu_parent']) && $config['vertical_menu_parent'] == "__submenu__")
{
    $config['vertical_menu_parent'] = empty($_FN['sectionvalues']['parent'])?$_FN['mod']:$_FN['sectionvalues']['parent'];
}
if (!empty($config['footer_menu_parent']) && $config['footer_menu_parent'] == "__submenu__")
    $config['footer_menu_parent'] = $_FN['mod'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"  xml:lang="<?php echo $_FN['lang'] ;?>">
<head><?php if (!empty($config['enable_theme_scripts'])) { ?><script type="text/javascript" src="<?php echo "themes/{$_FN['theme']}" ?>/jquery.js" ></script>
		<script type="text/javascript" src="<?php echo "themes/{$_FN['theme']}" ?>/script.js" ></script>
		<?php } ?><link rel="stylesheet" href="themes/<?php echo $_FN['theme'] ;?>/style.css" type="text/css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" href="themes/<?php echo $_FN['theme'] ;?>/style.ie6.css" type="text/css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" href="themes/<?php echo $_FN['theme'] ;?>/style.ie7.css" type="text/css" media="screen" /><![endif]-->
	<?php echo FN_HtmlHeader(false); ?>
</head>
<body>
<div id="art-page-background-glare-wrapper">
    <div id="art-page-background-glare"></div>
</div>
<div id="art-main">
    <div class="cleared reset-box"></div>
    <div class="art-box art-sheet">
        <div class="art-box-body art-sheet-body">
<div class="art-bar art-nav">
<div class="art-nav-outer">
	<ul class="art-hmenu"><?php theme_create_top_menu($config['top_menu_parent']); ?>
		</ul>

</div>
</div>
<div class="cleared reset-box"></div>
<div class="art-header">
                <div class="art-headerobject"></div>
                        <div class="art-logo">
                                                 <h1 class="art-logo-name"><a href="<?php echo $_FN['siteurl'] ;?>"><?php echo $_FN['site_title'] ;?></a></h1>
                                                                         <h2 class="art-logo-text"><?php echo $_FN['site_subtitle'] ;?></h2>
                                                </div>
                
            </div>
            <div class="cleared reset-box"></div>
            <div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-sidebar1">
<?php
if (!empty($config['show_vertical_menu']))
{
?><div class="art-box art-vmenublock">
    <div class="art-box-body art-vmenublock-body">
                <div class="art-box art-vmenublockcontent">
                    <div class="art-box-body art-vmenublockcontent-body">
                
<ul class="art-vmenu"><?php theme_create_vertical_menu($config['vertical_menu_parent']); ?>
</ul>
                
                                		<div class="cleared"></div>
                    </div>
                </div>
		<div class="cleared"></div>
    </div>
</div><?php } ?>

<?php theme_create_blocks_left() ?>


                          <div class="cleared"></div>
                        </div>
                        <div class="art-layout-cell art-content"><?php theme_create_blocks_top() ?>

<div class="art-box art-post">
    <div class="art-box-body art-post-body">
<div class="art-post-inner art-article">
                                <?php
	  if ($config['show_page_title'] == '1' && ( $_FN['mod'] != $_FN['home_section'] || $config['hide_title_in_main_page'] == '0' ) ){
	  ?><h2 class="art-postheader"><?php if ($config['show_navbar'] && $_FN['sectionvalues']['parent'])
	{
		echo FN_HtmlNavbar();
	}
	else
	{
		echo $_FN['sectionvalues']['title'];
	}?></h2><?php } ?>
                                                                
                <div class="art-postcontent"><?php theme_create_section() ?></div>
                <div class="cleared"></div>
                                
                </div>

		<div class="cleared"></div>
    </div>
</div>

                          <div class="cleared"></div>
                        <?php theme_create_blocks_bottom() ?></div>
                        <div class="art-layout-cell art-sidebar2"><?php theme_create_blocks_right() ?></div>
                    </div>
                </div>
            </div>
            <div class="cleared"></div>
            <div class="art-footer">
                <div class="art-footer-body">
                    <a href="<?php echo empty($_FN['rss_link'])?'#': $_FN['rss_link'] ;?>" class="art-rss-tag-icon" title="RSS"></a>
                            <div class="art-footer-text">
                                <p><?php theme_create_hmenu($config['footer_menu_parent']);  ?></p><p>Copyright © 2011. All Rights Reserved.</p>
                                                            </div>
                    <div class="cleared"></div>
                </div>
            </div>
    		<div class="cleared"></div>
        </div>
    </div>
    <div class="cleared"></div>
    <p class="art-page-footer"><?php echo  FN_HtmlCredits() ;?></p>
    <div class="cleared"></div>
</div>

</body>
</html>

<?php
/**
 * 
 */
function theme_create_section()
{
	echo FN_HtmlSection();
}
/**
 * 
 */
function theme_create_hmenu($parent)
{
    global $_FN;
	echo FN_HtmlMenu("&nbsp;|&nbsp;",$parent);
}
/**
 * 
 */
function theme_create_top_menu($parent)
{
	echo theme_FN_HtmlMenuTreeUL_Top($parent);
}
/**
 * 
 */
function theme_create_vertical_menu($parent)
{
	echo theme_HtmlMenuTreeUL_Vertical($parent);
}
/**
 *
 * @global array $_FN 
 */
function theme_create_blocks_left()
{
	global $_FN;
	$ret="";
	$blocks=FN_GetBlocks("left");
	foreach ($blocks as $block)
	{
		$html=FN_HtmlBlock($block['id']);
		if ($html != "")
		{
			$ret .= theme_HtmlCreateBlockLeft($block['title'],$html);
		}
	}
	echo $ret;
}
/**
 *
 * @global array $_FN 
 */
function theme_create_blocks_right()
{
	global $_FN;
	$ret="";
	$blocks=FN_GetBlocks("right");
	foreach ($blocks as $block)
	{
		$html=FN_HtmlBlock($block['id']);
		if ($html != "")
		{
			$ret .= theme_HtmlCreateBlockRight($block['title'],$html);
		}
	}
	echo $ret;
}


/**
 *
 * @global array $_FN 
 */
function theme_create_blocks_top()
{
	global $_FN;
	$ret="";
	$blocks=FN_GetBlocks("top");
	foreach ($blocks as $block)
	{
		$html=FN_HtmlBlock($block['id']);
		if ($html != "")
		{
			$ret .= theme_HtmlCreateBlockTop($block['title'],$html);
		}
	}
	echo $ret;
}

/**
 *
 * @global array $_FN 
 */
function theme_create_blocks_bottom()
{
	global $_FN;
	$ret="";
	$blocks=FN_GetBlocks("bottom");
	foreach ($blocks as $block)
	{
		$html=FN_HtmlBlock($block['id']);
		if ($html != "")
		{
			$ret .= theme_HtmlCreateBlockBottom($block['title'],$html);
		}
	}
	echo $ret;
}

/**
 *
 * @param string $title
 * @param string $block
 * @return string 
 */
function theme_HtmlCreateBlockRight($title,$text)
{
	$html= "<!-- blockitem --> <div class=\"art-box art-block\">
    <div class=\"art-box-body art-block-body\">
                ";
	if ($title!="")
	{
		$html.="<div class=\"art-bar art-blockheader\">
                    <h3 class=\"t\">$title</h3>
                </div>";
	}
	$html.= "
                <div class=\"art-box art-blockcontent\">
                    <div class=\"art-box-body art-blockcontent-body\">$text</div>
                </div>
		<div class=\"cleared\"></div>
    </div>
</div><!-- endblockitem -->";
	return $html;
}
/**
 *
 * @param string $title
 * @param string $block
 * @return string 
 */
function theme_HtmlCreateBlockLeft($title,$text)
{
	$html= "<!-- blockitem --> <div class=\"art-box art-block\">
    <div class=\"art-box-body art-block-body\">
                ";
	if ($title!="")
	{
		$html.="<div class=\"art-bar art-blockheader\">
                    <h3 class=\"t\">$title</h3>
                </div>";
	}
	$html.= "
                <div class=\"art-box art-blockcontent\">
                    <div class=\"art-box-body art-blockcontent-body\">$text</div>
                </div>
		<div class=\"cleared\"></div>
    </div>
</div><!-- endblockitem -->";
	return $html;
}
/**
 *
 * @param string $title
 * @param string $block
 * @return string 
 */
function theme_HtmlCreateBlockTop($title,$text)
{
	$html="<!-- blockitem --> <div class=\"art-box art-block\">
    <div class=\"art-box-body art-block-body\">
                <div class=\"art-bar art-blockheader\">
                    <h3 class=\"t\">$title</h3>
                </div>
                <div class=\"art-box art-blockcontent\">
                    <div class=\"art-box-body art-blockcontent-body\">$text</div>
                </div>
		<div class=\"cleared\"></div>
    </div>
</div><!-- endblockitem -->";
	return $html;
}
/**
 *
 * @param string $title
 * @param string $block
 * @return string 
 */
function theme_HtmlCreateBlockBottom($title,$text)
{
	$html="<!-- blockitem --> <div class=\"art-box art-block\">
    <div class=\"art-box-body art-block-body\">
                <div class=\"art-bar art-blockheader\">
                    <h3 class=\"t\">$title</h3>
                </div>
                <div class=\"art-box art-blockcontent\">
                    <div class=\"art-box-body art-blockcontent-body\">$text</div>
                </div>
		<div class=\"cleared\"></div>
    </div>
</div><!-- endblockitem -->";
	return $html;
}

/**
 *
 * @global array $_FN
 * @staticvar int $lev
 * @staticvar string $html
 * @param string $parent
 * @return string
 */
function theme_FN_HtmlMenuTreeUL_Top($parent="",$issubmenu=false)
{
	global $_FN;
	if (file_exists("themes/{$_FN['theme']}/config.php"))
	{
		$config=FN_LoadConfig("themes/{$_FN['theme']}/config.php");
	}
	$recursive=isset($config['make_top_menu_recursive']) ? $config['make_top_menu_recursive'] : false;
	$html="";
	$ret=array();
	$current=$_FN['mod'];
	$sections=FN_GetSections($parent);
	if (empty($sections) || count($sections) == 0)
		return "";
	foreach ($sections as $section)
	{
		$class="";
		if ($current == $section['id'] || theme_SectionIsInside($section))
		{
			$class="class=\"active\"";
		}
		$accesskey=FN_GetAccessKey($section['title'],"index.php?mod={$section['id']}");
		if ($accesskey != "")
			$accesskey=" accesskey=\"$accesskey\"";
		$title=(empty($section['description'])) ? "title=\"{$section['title']}\"" : "title=\"{$section['description']}\"";

		if ($recursive && theme_SectionHaveChilds($section['id']))
		{
			if ($parent == "")
				$html .= "\n<li><a $class $title $accesskey href=\"" . fn_rewritelink("index.php?mod={$section['id']}") . "\"><span class=\"l\"></span><span class=\"r\"></span><span class=\"t\">{$section['title']}</span></a>";
			else
				$html .= "\n<li><a $class $title $accesskey href=\"" . fn_rewritelink("index.php?mod={$section['id']}") . "\">{$section['title']}</a>
";

			$html .= "\n<ul>";
			$html .= theme_FN_HtmlMenuTreeUL_Top($section['id'],true);
			$html .= "</ul>";
			$html .= "</li>";
		}
		else
		{
			if ($parent == "")
				$html .= "\n<li><a $class $title $accesskey href=\"" . fn_rewritelink("index.php?mod={$section['id']}") . "\"><span class=\"l\"></span><span class=\"r\"></span><span class=\"t\">{$section['title']}</span></a></li>";
			else
				$html .= "\n<li><a $class $title $accesskey href=\"" . fn_rewritelink("index.php?mod={$section['id']}") . "\">{$section['title']}</a></li>";
		}
	}
	return $html;
}
/**
 *
 * @global array $_FN
 * @staticvar int $lev
 * @staticvar string $html
 * @param string $parent
 * @return string
 */
function theme_HtmlMenuTreeUL_Vertical($parent="",$issubmenu=false)
{
	global $_FN;
	$recursive=true;
	$recursive_only_active=false;
	if (file_exists("themes/{$_FN['theme']}/config.php"))
	{
		$config=FN_LoadConfig("themes/{$_FN['theme']}/config.php");
		$recursive=isset($config['make_vertical_menu_recursive']) ? $config['make_vertical_menu_recursive'] : false;
		if ($recursive > 1)
			$recursive_only_active=true;
	}
	$html="";
	$ret=array();
	$current=$_FN['mod'];
	$sections=FN_GetSections($parent);
	if (empty($sections) || count($sections) == 0)
		return "";
	foreach ($sections as $section)
	{
		$make_recursive=$recursive;
		$accesskey=FN_GetAccessKey($section['title'],"index.php?mod={$section['id']}");
		if ($accesskey != "")
			$accesskey=" accesskey=\"$accesskey\"";
		$title=(empty($section['description'])) ? "title=\"{$section['title']}\"" : "title=\"{$section['description']}\"";
		$class="";
		if ($current == $section['id'] || (!$issubmenu && theme_SectionIsInside($section)))
		{
			$class="class=\"active\"";
		}
		if ($recursive_only_active && $current != $section['id'] && !theme_SectionIsInside($section))
		{
			$make_recursive=false;
		}

		if ($issubmenu)
			$al="<a $title $accesskey href=\"" . fn_rewritelink("index.php?mod={$section['id']}") . "\" $class >{$section['title']}</a>";
		else
			$al="<a $class $title $accesskey href=\"" . fn_rewritelink("index.php?mod={$section['id']}") . "\"><span class=\"l\"></span><span class=\"r\"></span><span class=\"t\">{$section['title']}</span></a>";


		if (($make_recursive && theme_SectionHaveChilds($section['id'])))
		{
			$html .= "<li>$al";
			$html .= "\n<ul class=\"active\">\n";

			$html .= theme_HtmlMenuTreeUL_Vertical($section['id'],true);
			$html .= "\n</ul>";
			$html .= "</li>";
		}
		else
		{
			$html .= "<li>$al</li>";
		}
	}
	return $html;
}
/**
 *
 * @global array $_FN
 * @param array $section_parent
 * @return bool 
 */
function theme_SectionIsInside($section_parent)
{
	global $_FN;
	$tmpsection=$_FN['sectionvalues'];
	while (isset($tmpsection['parent']) && $tmpsection['parent'] != false)
	{
		if (isset($tmpsection['parent']) && $tmpsection['parent'] == $section_parent['id'])
		{
			return true;
		}
		$tmpsection=FN_GetSectionValues($tmpsection['parent']);
	}
	return false;
}
/**
 *
 * @param string $parent
 * @return bool 
 */
function theme_SectionHaveChilds($parent)
{
	$sections=FN_GetSections($parent);
	if (empty($sections) || count($sections) == 0)
		return false;
	return true;
}


	
/**
 *
 * @global array $_FN
 * @staticvar int $i
 * @param array $item
 * @param object $newsobject
 */
function FNNEWS_PrintNews_summary($item, $newsobject)
{
	$_MODIFY = "";
	$_IMAGENEWS = "";
	$_IMAGEARGUMENT = "";
	$_COMMENTS = "";
	$span_NUMCOMMENTS = "";
	$_TAGS = "";
	if ( !empty($item['txt_TAGS']))
	{
		$_TAGS = "{$item['txt_TAGS']}";
	}
    
	if ( !empty($item['link_COMMENTS']))
	{
		$_COMMENTS = " | {$item['txt_NUMCOMMENTS']}";
		$span_NUMCOMMENTS = "<span class=\"art-postcommentsicon\">{$item['txt_NUMCOMMENTS']}</span>";
	}
	
	if ( $item['img_news_thumb'] != "" )
	{
		$_IMAGENEWS = "<img class=\"preview-cms-logo\" alt=\"\" style=\"border:0px;\" src=\"{$item['img_news_thumb']}\" />";
	}
	if ( $item['img_argument'] != "" )
	{
		$_IMAGEARGUMENT = "<img  class=\"preview-cms-logo\" alt=\"\" style=\"border:0px;\" src=\"{$item['img_argument']}\" />";
	}
	
		
	if ($item['link_MODIFY'])
		$_MODIFY = "<a href=\"{$item['link_MODIFY']}\" title=\"{$item['txt_MODIFY']}\" ><span class=\"art-postediticon\"> </span></a>";
	
	$htmlout="<div class=\"art-box art-post\">
    <div class=\"art-box-body art-post-body\">
<div class=\"art-post-inner art-article\">
                                <h2 class=\"art-postheader\">{$item['title']}</h2>
                                                                <div class=\"art-postheadericons art-metadata-icons\">
                    <span class=\"art-postdateicon\">{$item['txt_DATE']} ({$item['txt_VIEWS']})</span> | <span class=\"art-postauthoricon\">".FN_Translate("written by")." :{$item['news_USER']}</span> | <a href=\"{$item['link_PDF']}\"><span class=\"art-postpdficon\"> </span></a> | <a accesskey=\"{$item['accesskey_PRINT']}\" href=\"{$item['link_PRINT']}\" title=\"{$item['txt_PRINT']} {$item['news_TITLE']}\" ><span class=\"art-postprinticon\"> </span></a> | <a href=\"{$item['link_SENDEMAIL']}\"><span class=\"art-postemailicon\"> </span></a> | $_MODIFY
                </div>
                <div class=\"art-postcontent\">{$_IMAGENEWS}{$_IMAGEARGUMENT}{$item['news_SUMMARY']}{$item['facebook_button_i_like']}  <p>
		<span class=\"art-button-wrapper\">
			<span class=\"art-button-l\"> </span>
			<span class=\"art-button-r\"> </span>
			<a class=\"readon art-button\" accesskey=\"{$item['accesskey_READ']}\"  href=\"{$item['link_READ']}\">{$item['txt_READ']}</a>
		</span>
  </p></div>
                <div class=\"cleared\"></div>
                                <div class=\"art-postfootericons art-metadata-icons\">
                    <span class=\"art-postcategoryicon\">".FN_Translate("category").": {$item['news_CATEGORY']} $_COMMENTS $_TAGS </span>
                </div>
                </div>

		<div class=\"cleared\"></div>
    </div>
</div>";
	echo $htmlout;
}

?>