SeekByAttribute("parent",$id); while (list(,$id) = @each($list)) { $item = $collection -> GetItem($id); $template = new Template("./templates/main/menuitem.html"); $template -> SetEntityValue('REPLACE_LINK_VALUE',"./?id=$id"); $template -> SetEntityValue('REPLACE_NAME_VALUE',$item -> GetAttribute("name")); $row[] = $template -> Parse(); } return @join(",",$row); } function CreateHints() { $collection = new Collection("hints"); $list = $collection -> GetItemsList(); $count = 0; while(list(,$id) = @each($list)) { $item = $collection -> GetItem($id); $template = new Template("./hint_dataitem_tpl.js"); $template -> SetEntityValue('REPLACE_NUM_VALUE',$count++); $template -> SetEntityValue('REPLACE_HINTTITLE_VALUE',$item -> GetAttribute("title")); $template -> SetEntityValue('REPLACE_HINTCONTENT_VALUE',DropQuotes(FromFile("./templates/main/hint".$id.".html"))); $hintsHtml .= $template -> Parse(); } $template = new Template("./hint_data_tpl.js"); $template -> SetEntityValue("REPLACE_HINTS_LIST",$hintsHtml); ToFile("./hint_data.js",$template -> Parse()); reset($list); $count = 0; while(list(,$id) = @each($list)) { $template = new Template("./templates/main/sponsorsitem.html"); $template -> SetEntityValue('REPLACE_NUM_VALUE',$count++); $textHtml .= $template -> Parse(); } $template = new Template("./templates/main/sponsors_tpl.html"); $template -> SetEntityValue("REPLACE_HINTS_LIST",$textHtml); ToFile("./templates/main/_oursponsors.html",$template -> Parse()); } function CreateJS() { $template = new Template("./menu_data_tpl.js"); $template -> SetEntityValue('REPLACE_2_BLOCK',GetMenuBlock(2)); $template -> SetEntityValue('REPLACE_3_BLOCK',GetMenuBlock(3)); $template -> SetEntityValue('REPLACE_4_BLOCK',GetMenuBlock(4)); $template -> SetEntityValue('REPLACE_5_BLOCK',GetMenuBlock(5)); $template -> SetEntityValue('REPLACE_6_BLOCK',GetMenuBlock(6)); $template -> SetEntityValue('REPLACE_18_BLOCK',GetMenuBlock(18)); ToFile("./menu_data.js",$template -> Parse()); } function DrawTitle($title) { $template = new Template("./templates/lists/title.html"); $template -> SetEntityValue("REPLACE_TITLE_VALUE",$title); return $template -> Parse(); } function DrawTitleLink($title,$list,$id) { $template = new Template("./templates/lists/title_link.html"); $template -> SetEntityValue("REPLACE_TITLE_VALUE",$title); $page = $_REQUEST["id"]; $template -> SetEntityValue("REPLACE_LINK_VALUE","?desc=yes&list=$list&id=$page&page=$id"); return $template -> Parse(); } function DrawEmailBlock($title,$list,$id) { $template = new Template("./templates/lists/email.html"); $template -> SetEntityValue("REPLACE_TITLE_VALUE",$title); $page = $_REQUEST["id"]; $template -> SetEntityValue("REPLACE_LINK_VALUE","?desc=yes&list=$list&id=$page&page=$id"); return $template -> Parse(); } function DrawMoreDescBlock($list,$id) { $template = new Template("./templates/lists/more.html"); $page = $_REQUEST["id"]; $template -> SetEntityValue("REPLACE_LINK_VALUE","?desc=yes&list=$list&id=$page&page=$id"); return $template -> Parse(); } function DrawTitlePDFLink($title,$pdflink) { $template = new Template("./templates/lists/title_link.html"); $template -> SetEntityValue("REPLACE_TITLE_VALUE",$title); $template -> SetEntityValue("REPLACE_LINK_VALUE",$pdflink); return $template -> Parse(); } function DrawPDFBlock($pdflink) { $template = new Template("./templates/lists/pdf.html"); $template -> SetEntityValue("REPLACE_PDFLINK_VALUE",$pdflink); return $template -> Parse(); } function MakeTemplate($id) { $collection = new Collection("lists"); $item = $collection -> GetItem($id); $structure = $item -> GetAttribute("structure"); $collection = new Collection("structure_template"); global $config_vars; mysql_pconnect($config_vars["database_server"],$config_vars["database_username"],$config_vars["database_password"]); mysql_select_db($config_vars["database_name"]); $query = "select * from nhcpi_list_$id"; $result = mysql_query($query); while($row = @mysql_fetch_array($result)) { $template = new Template("./templates/lists/list.html"); $fields["structure"] = $structure; $fields["template"] = 1; if ($collection -> SeekByMultiple($fields)) { $fields["template"] = 6; if ($collection -> SeekByMultiple($fields)) { $template -> SetEntityValue("REPLACE_TITLE_BLOCK",DrawTitle($row["title"])); } else { $fields["template"] = 5; if ($collection -> SeekByMultiple($fields)) { $template -> SetEntityValue("REPLACE_TITLE_BLOCK",DrawTitlePDFLink($row["title"],$row["pdflink"])); } else { $template -> SetEntityValue("REPLACE_TITLE_BLOCK",DrawTitleLink($row["title"],$id,$row["id"])); } } } $fields["template"] = 2; if ($collection -> SeekByMultiple($fields)) { $fields["template"] = 7; if ($collection -> SeekByMultiple($fields)) { $template -> SetEntityValue("REPLACE_DESCRIPTION_VALUE",CutText(stripslashes(strip_tags($row["content"])),200)); $template -> SetEntityValue("REPLACE_MORE_BLOCK",DrawMoreDescBlock($id,$row["id"])); } else { $template -> SetEntityValue("REPLACE_DESCRIPTION_VALUE",stripslashes($row["content"])); $template -> SetEntityValue("REPLACE_MORE_BLOCK",''); } } $fields["template"] = 3; if ($collection -> SeekByMultiple($fields)) { $template -> SetEntityValue("REPLACE_PDFLINK_BLOCK",DrawPDFBlock($row["pdflink"])); } $fields["template"] = 8; if ($collection -> SeekByMultiple($fields)) { $template -> SetEntityValue("REPLACE_EMAIL_BLOCK",DrawEmailBlock($row["title"],$id,$row["id"])); } $textHtml .= $template -> Parse(); } return $textHtml; } function IsRR() { $item = new Item("pages",$_REQUEST["id"]); $parent = $_REQUEST["id"]; if ($parent == 8) { return true; } $section = $item -> GetAttribute("section"); if ($section == "Initiatives") { while ($parent != 3) { $item = new Item("pages",$parent); $parent = $item -> GetAttribute("parent"); if ($parent == 8) { return true; } } } return false; } if ($_REQUEST["desc"] == "yes") { $structure = "./content/view.xml"; } elseif ($_REQUEST["id"] < 2) { $structure = "./content/main.xml"; CreateJS(); CreateHints(); } elseif($_REQUEST["id"] == 17) { $structure = "./content/sitemap.xml"; } elseif($_REQUEST["id"] == 19) { $structure = "./content/publications/publications.xml"; } elseif($_REQUEST["id"] == 20) { $structure = "./content/publications/bytype.xml"; } elseif($_REQUEST["id"] == 21) { $structure = "./content/publications/bytopic.xml"; } elseif (IsRR()) { $structure = "./content/rewardingresults.xml"; } else { $structure = $_REQUEST["structure"]; } if (!$structure) { $structure = "./content/index.xml"; } session_start(); header("Cache-control: public"); $content = new PageContent($structure); $page = $content -> ParseContent($_REQUEST); while (strstr($page,'/menu.gif')) { $page = preg_replace('/\/menu.gif/','/1x1t.gif',$page,1); $start = strpos($page,'TEMPLATE:START'); $end = strpos($page,'TEMPLATE:END'); $submenu = substr($page,$start,$end - $start); $submenu = split(' ',$submenu); $type = substr($submenu[1],6,-5); $dir = substr($submenu[2],5,-4); if ($start) { $submenu = MakeTemplate($type); $page = preg_replace('/submenu="TEMPLATE:START(.*)TEMPLATE:END">/',">$submenu",$page,1); } } echo $page; ?>