require_once("../shared/config.inc.php");
function table_exists($database, $tableName) //zistenie, ci tabulka v databaze existuje
{
$tables = array();
$tablesResult = mysql_query("SHOW TABLES FROM $database;");
while ($row = mysql_fetch_row($tablesResult)) $tables[] = $row[0];
if (!$result) {
}
return(in_array($tableName, $tables));
}
function gettree_table($menu_id=NULL, $lang=NULL){ //vypis struktury pre stranku
$level++;
$queryString = "select menu.*, module.name as Expr1 from " . TABLE_PREFIX . "menu as menu left join " . TABLE_PREFIX . "module as module using (module_id) where 1 and child_of " . ((!is_numeric($menu_id))? ' is null': ' = \'' . $menu_id . '\'') . " order by sorter asc;";
$Result = mysql_query($queryString);
if($Result){
while($Row = mysql_fetch_assoc($Result)){
if($Row['child_of'] != 0)
{
if ($Row[$lang.'_name_seo'] != '') {
print '
'.ROOTDIR.'/'.$lang.'/'.$Row[$lang.'_name_seo'].'/
';
print ($Row['_date'] == '0000-00-00 00:00:00') ? date('Y-m-d') : date('Y-m-d', strtotime($Row['_date']));
print '
daily
';
}
}
gettree_table($Row['menu_id'], $lang);
}
}
else{
print(mysql_error());
}
mysql_free_result($Result);
$level--;
}
function gettree_table_shop($menu_id=NULL, $lang=NULL){ //vypis struktury pre eshop
$level++;
$queryString = "select menu.*, module.name as Expr1 from " . TABLE_PREFIX . "module_menu as menu left join " . TABLE_PREFIX . "module_module as module using (module_id) where 1 and child_of " . ((!is_numeric($menu_id))? ' is null': ' = \'' . $menu_id . '\'') . " and menu.menu_id NOT IN (3,5,4) order by sorter asc;";
$Result = mysql_query($queryString);
if($Result){
while($Row = mysql_fetch_assoc($Result)){
if($Row['child_of'] != 0)
{
if ($Row[$lang.'_name_seo'] != '') {
print '
'.ROOTDIR.'/'.$lang.'/'.$Row[$lang.'_name_seo'].'/
';
print ($Row['_date'] == '0000-00-00 00:00:00') ? date('Y-m-d') : date('Y-m-d', strtotime($Row['_date']));
print '
daily
';
}
}
gettree_table_shop($Row['menu_id'], $lang);
}
}
else{
print(mysql_error());
}
mysql_free_result($Result);
$level--;
}
header("Content-Type: application/xml; charset=UTF-8");
print '
';
if (!table_exists(DB_DATABASE, TABLE_PREFIX.'module_menu')) { //zistime, ci ide o eshop alebo nie
//ide o klasicku stranku nie o eshop
foreach ($cLanguage->getLanguageCodes() as $lang_code) {
gettree_table(NULL, $lang_code);
/************ VYBER CLANKOV ***********/
$query_menu = mysql_query("SELECT ".$lang_code."_name_seo FROM ".TABLE_PREFIX."menu WHERE module_id=4" );
while ($row_menu = mysql_fetch_array ($query_menu)) {
$sql = "select a.*,
_date as _date,
a.".$lang_code."_name_seo as aname_seo,
ac.".$lang_code."_name as acname
from " . TABLE_PREFIX . "article as a join " . TABLE_PREFIX . "article_category as ac using (article_category_id) left join " . TABLE_PREFIX . "user as u using (user_id) where 1 and publish = 1 and a.".$lang_code."_name_seo!='' AND ac.".$lang_code."_name_seo = '".$row_menu[$lang_code.'_name_seo']."' order by sorter asc, a._date desc";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
print '
'.ROOTDIR.'/' . $lang_code . '/' . $row_menu[$lang_code.'_name_seo'] . '/detail/' . $row['aname_seo'] . '/'. $row['article_id'].'
';
print ($row['_date'] == '0000-00-00 00:00:00') ? date('Y-m-d') : date('Y-m-d', strtotime($row['_date']));
print '
daily
';
}
}
/*********** KONIEC VYBERU CLANKOV ************/
}
}
else {
// ide o eshop
foreach ($cLanguage->getLanguageCodes() as $lang_code) {
gettree_table_shop(NULL, $lang_code);
/************ VYBER KATEGORII ***********/
$query_menu = mysql_query("SELECT ".$lang_code."_name_seo FROM ".TABLE_PREFIX."module_menu WHERE module_id=15" );
$row_menu = mysql_fetch_array ($query_menu);
$module_menu_item = $row_menu[$lang_code.'_name_seo'];
print $module_menu_item;
$sql = "select *
from " . TABLE_PREFIX . "menu WHERE menu_id !=1 order by sorter asc, _date desc";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
print '
'.ROOTDIR.'/' . $lang_code . '/' . $module_menu_item .'/'. $row[$lang_code.'_name_seo'] .'/'. $row['menu_id'].'
';
print ($row['_date'] == '0000-00-00 00:00:00') ? date('Y-m-d') : date('Y-m-d', strtotime($row['_date']));
print '
daily
';
}
/*********** KONIEC VYBERU KATEGORII ************/
/************ VYBER PRODUKTOV ***********/
$query_menu = mysql_query("SELECT ".$lang_code."_name_seo FROM ".TABLE_PREFIX."module_menu WHERE module_id=16" );
$row_menu = mysql_fetch_array ($query_menu);
$module_menu_item = $row_menu[$lang_code.'_name_seo'];
print $module_menu_item;
$sql = "select ".$lang_code."_name_seo as name_seo, product_id, date from " . TABLE_PREFIX . "product order by date desc";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
print '
'.ROOTDIR.'/' . $lang_code . '/' . $module_menu_item .'/'. $row['name_seo'] .'/'. $row['product_id'].'
';
print ($row['date'] == '0000-00-00') ? date('Y-m-d') : date('Y-m-d', strtotime($row['date']));
print '
daily
';
}
/*********** KONIEC VYBERU PRODUKTOV ************/
/************ VYBER CLANKOV ***********/
$query_menu = mysql_query("SELECT ".$lang_code."_name_seo FROM ".TABLE_PREFIX."module_menu WHERE module_id=7" );
while ($row_menu = mysql_fetch_array ($query_menu)) {
$sql = "select a.*,
_date as _date,
a.".$lang_code."_name_seo as aname_seo,
ac.name as acname
from " . TABLE_PREFIX . "article as a join " . TABLE_PREFIX . "article_category as ac using (article_category_id) left join " . TABLE_PREFIX . "user as u using (user_id) where 1 and publish = 1 and a.".$lang_code."_name_seo!='' AND ac.name_seo = '".$row_menu[$lang_code.'_name_seo']."' order by sorter asc, a._date desc";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
while ($row = mysql_fetch_array($query)) {
print '
'.ROOTDIR.'/' . $lang_code . '/' . $row_menu[$lang_code.'_name_seo'] . '/clanok/' . $row['aname_seo'] . '/'. $row['article_id'].'
';
print ($row['_date'] == '0000-00-00 00:00:00') ? date('Y-m-d') : date('Y-m-d', strtotime($row['_date']));
print '
daily
';
}
}
}
/*********** KONIEC VYBERU CLANKOV ************/
}
}
print '';
?>