<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$bagaccess_array['all']=0;
$bagaccess_array['logs']=0;
$bagaccess_array['deleted']=0;
$bagaccess_array['access']=0;
$bagaccess_array['']=0;
$bagaccess_array['articles']=1;
$language=get('language');
$header=get('header');
$menu=get('menu');
$article=get('article');
$first_menu='';
$external_link_array=array();
$content_menu_array=array();
$content_array=search('articles Menu Title');
reset($content_array);
foreach($content_array as $content_line)
{
if($language=='')
$language=read($content_line,'Language');
if($language==read($content_line,'Language'))
{
$last_menu_order=$content_menu_array[read($content_line,'Menu header').' ----split---- '.read($content_line,'Menu item')];
if($last_menu_order=='' or read($content_line,'Menu order')<$last_menu_order)
$content_menu_array[read($content_line,'Menu header').' ----split---- '.read($content_line,'Menu item')]=read($content_line,'Menu order');
if(read($content_line,'Menu link'))
$external_link_array[read($content_line,'Menu header')][read($content_line,'Menu item')]=read($content_line,'Menu link');
}
$content_language_array[read($content_line,'Language')]=1;
}
//sorting menu
asort($content_menu_array);
$tmp_content_menu_array=array();
reset($content_menu_array);
foreach($content_menu_array as $key => $val)
{
$tmp_pos=strpos($key,' ----split---- ');
$tmp_content_menu_array[substr($key,0,$tmp_pos)][substr($key,$tmp_pos+15)]=$val;
if($menu=='')
$menu=substr($key,$tmp_pos+15);
if($header=='')
$header=substr($key,0,$tmp_pos);
}
$content_menu_array=$tmp_content_menu_array;
if($article)
$content_array=search('sysId='.$article.' MyBag=articles');
elseif($language=='')
$content_array=search('articles [Menu header='.$header.'] -Language [Menu item='.$menu.'] '.$article);
else
$content_array=search('articles [Menu header='.$header.'] [Language='.$language.'] [Menu item='.$menu.'] '.$article);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="SHORTCUT ICON" href="favicon.ico" />
<title><?php echo cfg_skin_name; ?></title>
</head>
<body style="margin:3px;">
<h1><?php echo cfg_skin_name; ?></h1>
<?php
$first_lang=1;
reset($content_language_array);
foreach($content_language_array as $tmp_language => $tmp)
{
if(!$first_lang)
echo ' | ';
echo '<a href="index.php?odb_language='.urlencode($tmp_language).'">';
echo $tmp_language;
echo '</a>';
$first_lang=0;
}
?>
<?php
echo '<ul>';
reset($content_menu_array);
foreach($content_menu_array as $content_menu_header => $content_menu_item_array)
{
echo '<li>';
//echo '<b>';
echo($content_menu_header);
//echo '</b>';
echo '<ul>';
reset($content_menu_item_array);
foreach($content_menu_item_array as $content_menu_name => $tmp)
{
if($content_menu_name)
{
echo '<li>';
$tmp_link='odb_language='.urlencode($language).'&odb_header='.urlencode($content_menu_header).'&odb_menu='.urlencode($content_menu_name);
$tmp_link=str_replace("'","",$tmp_link);
$link_content='';
$link_content.='<'.'?php'.CRLF;
$link_content.='$tmp_str=\''.$tmp_link.'\';'.CRLF;
$link_content.='parse_str($tmp_str,$inner_get_array);'.CRLF;
$link_content.='include(\'./index.php\');'.CRLF;
$link_content.='?'.'>'.CRLF;
if(!isset($external_link_array[$content_menu_header][$content_menu_name]))
if(!file_exists(cfg_base_path.'/'.linkname($content_menu_header).'-'.linkname($content_menu_name).'.php') or $link_content!=file_get_contents(cfg_base_path.'/'.linkname($content_menu_header).'-'.linkname($content_menu_name).'.php'))
{
$fp=fopen(cfg_base_path.'/'.linkname($content_menu_header).'-'.linkname($content_menu_name).'.php','wb');
fwrite($fp,$link_content);
fclose($fp);
}
if(isset($external_link_array[$content_menu_header][$content_menu_name]))
{
echo '<a href="'.$external_link_array[$content_menu_header][$content_menu_name].'">';
echo($content_menu_name);
echo '</a>';
}
else
{
echo '<a href="'.linkname($content_menu_header).'-'.linkname($content_menu_name).'.php">';
echo($content_menu_name);
echo '</a>';
}
echo '</li>';
}
}
echo '</ul>';
echo '</li>';
}
echo '</ul>';
?>
<hr />
<?php
echo($header);
echo ' » ';
echo $menu;
if($article)
{
//echo ' » ';
//echo $article;
}
reset($content_array);
foreach($content_array as $content_line)
{
echo '<div>';
if(strlen(read($content_line,'Image title')))
{
$show_value=read($content_line,'Image title');
$show_name='odb_Image_'.read($content_line,'sysId');
echo('<a href="odb_index.php?odb_sys=download&odb_preview=1000&odb_field='.$show_name.'">');
echo '<img title="'.$show_value.'" src="odb_index.php?odb_sys=download&odb_preview=50&odb_field='.$show_name.'" alt="'.$show_value.'" /></a><br />';
echo '<small>'.$show_value.'</small>';
}
elseif(strlen(read($content_line,'Image')))
{
$show_value=substr(read($content_line,'Image'),0,-5);
$show_name='odb_Image_'.read($content_line,'sysId');
echo('<a href="odb_index.php?odb_sys=download&odb_preview=1000&odb_field='.$show_name.'">');
echo '<img style="float:right; margin:5px; border:#ccc 1px solid;" title="'.$show_value.'" src="odb_index.php?odb_sys=download&odb_preview=250&odb_field='.$show_name.'" alt="'.$show_value.'" /></a>';
}
//echo '<img style="float:right; margin:5px; border:#ccc 1px solid;" src="./images/'.read($content_line,'Image').'" />';
echo '<h2>';
echo read($content_line,'Title');
echo '</h2>';
//echo '<p>';
//echo '<small>';
//$tmp_date=read($content_line,'sysModDate');
//echo substr($tmp_date,6,2).'.'.substr($tmp_date,4,2).'.'.substr($tmp_date,0,4);
//echo ' '.read($content_line,'sysModBy');
//echo '</small>';
//echo '</p>';
echo '<p>';
echo str_replace('CRLF','<br />',read($content_line,'Start text'));
echo '</p>';
if(count($content_array)==1)
{
echo '<br /><p>';
echo str_replace('CRLF','<br />',read($content_line,'Main text'));
echo '</p>';
}
elseif(strlen(read($content_line,'Main text')))
{
echo '<p>';
echo '<a href="index.php?odb_article='.read($content_line,'sysId').'">';
myecho('More...');
echo '</a>';
echo '</p><br />';
}
echo '</div>';
}
?>
<hr />
<a href="index.php?odb_showcms=no">login</a>
</body>
</html>