# this is a common header shared in details2 layout by many pages
# we use the $theme_type to determine what content is expressed
#echo 'TT:'.$this->{'Instance/theme_type'};
##################
##################
##################
# default $this->{'Instance/theme_type'} NOT SET
if ((!isset($this->{'Instance/theme_type'})) || ($this->{'Instance/theme_type'} == '')) {
# default case
echo '
'.$this->{'Instance/PageTitle'}.'';
echo "\n".'';
echo "\n".'';
} elseif ($this->{'Instance/theme_type'} == 'SEARCH') {
##################
##################
##################
# this is from the old results2-layout
// get list of sources for description
# set if not set
if (!isset($descSources))
$descSources = '';
if(isset($this->{'Instance/RecipeResults'}['sources']) && is_array($this->{'Instance/RecipeResults'}['sources']) )
foreach($this->{'Instance/RecipeResults'}['sources'] as $Key=>$Value){
//split $key at '*' to get sourceid
$arr=explode('*',$Key);
//$source_id = $arr[0];
//$source_name = $arr[1];
$descSources .= $arr[1].', ';
}
# get the ingredient list of the recipies returned
$il = '';
#ingredientList
if(isset($this->{'Instance/RecipeResults'}['RecipesArray']) && is_array($this->{'Instance/RecipeResults'}['RecipesArray']) )
foreach($this->{'Instance/RecipeResults'}['RecipesArray'] as $Key=>$Value){
# add the IngredientList value but only if set
if (isset($Value->ingredientList) && !empty($Value->ingredientList))
if ($il == '') {
$il = $Value->ingredientList;
} else {
$il = $il.','.$Value->ingredientList;
}
} # end foreach recipe
# explode and unique/sort the ingredient list
# need to lowercase BEFORE the sort
$il_array = explode(',',strtolower($il));
$il_array = array_unique($il_array);
sort($il_array);
$il = implode(',',$il_array);
$il = strtolower($il);
#echo $il;
# and benjamin wants a version for the description with extra spaces
$ild = implode(', ',$il_array);
$ild = strtolower($ild);
function replace_multiple_spaces($string)
{
// tabs, new lines and carriages are also replaced
$string = ereg_replace("[ \t\n\r]+", " ", $string);
return $string;
}
//Determine if the results are filtered by source and create title string accordingly.
$from = '';
if((!isset($_GET['as_cmp'])) || ($_GET['as_cmp'] == '')) {
$from = '';
} else {
$source_name = 'undefined';
if(isset($this->{'Instance/RecipeResults'}['sources']) && is_array($this->{'Instance/RecipeResults'}['sources']) )
foreach($this->{'Instance/RecipeResults'}['sources'] as $Key=>$Value){
//split $key at '*' to get sourceid
$arr=explode('*',$Key);
$source_id = $arr[0];
$source_name = $arr[1];
}
$from = 'from '.ucwords($source_name);
}
//$source =((isset($_GET['as_cmp'])) && ($_GET['as_cmp'] <> '')) ? 'from '.$from : '';
$q = ((isset($_GET['q'])) && ($_GET['q'] <> '')) ? $_GET['q'] : '';
$i = ((isset($_GET['i'])) && ($_GET['i'] <> '')) ? ' with '.$_GET['i'] : '';
$title = $q.' Recipes '.$i.' | RecipeBridge Recipe Search';
# if $q is empty and we have $i use $i inplace of $q but drop any 'with'
if ($q == '') {
$i = str_replace('with','',$i);
$title = $i.' Recipes | RecipeBridge Recipe Search';
}
/*
if ($i != '') {
$title = $q.' Recipes with '.$i.' | RecipeBridge Recipe Search';
}
*/
$title = replace_multiple_spaces($title);
$title = ucfirst(trim($title)); //Capitalize the first letter
//67 Recipes For $q with $i
$description = substr($title.' from '.substr_replace($descSources ,"",-1),0,130);
$description = substr($description,0,strrpos($description,','));
$description = $description;
//Capitalize the first letter
$description = ucwords($q).' Recipes containing ingredients ';
$sd = ucwords($q).' Recipes';
if ($q == '') {
$i = str_replace('with','',$i);
$description = ucwords($i).' Recipes containing ingredients ';
$sd = ucwords($i).' Recipes';
}
$description = trim($description);
$description = $description.' '.$ild;
$description = substr($description,0,160);
$i = ucwords(trim(str_replace('with','',$i)));
$kw = $q;
if ($i != '') { $kw = $kw.','.$i; }
#$kw = $q.','.$i;
if ($q == '') {
$kw = $i;
}
$kw = ucwords(trim($kw)); //Capitalize the first letter
$kw = $sd.', '.$kw.','.$il;
$kw = substr($kw,0,200);
$pageTitle = ucwords(strtolower($title));
echo ''.$pageTitle.'';
echo "\n".'';
echo "\n".'';
} # end SEARCH
?>