Exemple #1
0
 function getAllCats($subcats)
 {
     $return = array();
     foreach ($subcats as $key => $value) {
         if (is_array($value)) {
             $return = array_merge($return, getAllCats($value));
         } else {
             if (!is_numeric($key)) {
                 $return[] = $key;
             }
         }
     }
     return $return;
 }
if (isset($_GET["update"])) {
    if (isset($_SESSION['logged_in_user_id'])) {
        updateCatData($_GET["cat_id"], $_GET["age"], $_GET["home_status"], $_GET["description"]);
    }
}
//kõik objektide kujul massiivis
$cat_array = getAllCats();
$keyword = "";
if (isset($_GET["keyword"])) {
    $keyword = $_GET["keyword"];
    //otsime
    $cat_array = getAllCats($keyword);
} else {
    //näitame kõiki tulemusi
    //kõik objektide kujul massiivis
    $cat_array = getAllCats();
}
//$access_level = 2;
?>


    
    <div class="container-fluid">
        <div class="row"  id="body">
            <div class="col-sm-offset-1 col-sm-6">
				<h1>Kasside tabel</h1>
				<form action="otsivad.php" method="get">
					<input name="keyword" type="search" value="<?php 
echo $keyword;
?>
" >
                }
            }
        }
        return $list2;
    }
}
global $module_name, $lang_module, $module_data, $nv_Request;
$xtpl = new XTemplate("block_search.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/modules/" . $module_file);
$xtpl->assign('LANG', $lang_module);
$key = filter_text_input('q', 'post', '', 1, NV_MAX_SEARCH_LENGTH);
$cat = $nv_Request->get_int('cat', 'post');
$xtpl->assign('keyvalue', $key);
$xtpl->assign('FORMACTION', NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=newsearch');
$query = "SELECT id, title, alias, parentid FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE parentid=0 ORDER BY weight";
$result = $db->sql_query($query);
$nv_list_cats = getAllCats(0);
foreach ($nv_list_cats as $cat_i) {
    if ($cat == $cat_i['id']) {
        $cat_i['selected'] = "selected=\"selected\"";
    }
    $xtpl->assign('loop', $cat_i);
    $xtpl->parse('main.loop');
}
//while ( $row = $db->sql_fetchrow( $result ) )
//{
//    $row['select'] = ( $row['id'] == $cat ) ? 'selected=selected' : '';
//    $xtpl->assign( 'loop', $row );
//    /*	$subdata = getsubcat ( $row ['id'], $cat, '--' );
//	if (! empty ( $subdata )) {
//		$xtpl->assign ( 'subcat', $subdata );
//		unset ( $subdata );