[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
1 <?php 2 3 // list and search help for recipes 4 5 6 if( ! ( strpos($content["all"],'{RECIPES:')===false ) ) { 7 8 9 // define neccessary functions only when RT is in use 10 11 function doRecipes($matches) { 12 13 global $_getVar; 14 15 // split into array by "," 16 $recipe = convertStringToArray($matches[1]); 17 // get additional values for each option 18 foreach($recipe as $key => $value) { 19 $recipe[$key] = explode('|', $value); 20 $optindex = $recipe[$key][0]; 21 $option[ $optindex ] = array(); 22 unset($recipe[$key][0]); 23 if(count($recipe[$key])) { 24 $c = 0; 25 foreach($recipe[$key] as $optval) { 26 $option[ $optindex ][$c] = $optval; 27 $c++; 28 } 29 } 30 } 31 32 $recipe = ''; 33 $set_it = false; 34 35 if(isset($option['LOCALE']) && !empty($option['LOCALE'][0])) { 36 $_oldLocale = setlocale(LC_ALL, NULL); 37 setlocale(LC_ALL, $option['LOCALE'][0]); 38 } 39 40 if(empty($_getVar['recipesearch'])) { // && isset($option['LISTCAT']) 41 42 //$recipe .= listRecipeCategories($option); 43 $recipe .= showRecipeSeach(); 44 45 } else { 46 47 $recipe .= listRecipes(); 48 } 49 50 if(isset($_oldLocale)) { 51 setlocale(LC_ALL, $_oldLocale); 52 } 53 54 return $recipe; 55 56 } 57 58 function showRecipeSeach() { 59 60 global $_getVar; 61 62 $search = file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/recipe/search/search.html'); 63 64 return ($search ? $search : ''); 65 66 } 67 68 69 function listRecipeCategories($option) { 70 71 global $_getVar; 72 73 $cat = _dbQuery('SELECT acontent_text FROM '.DB_PREPEND.'phpwcms_articlecontent WHERE acontent_type=26 AND acontent_trash=0'); 74 $cat_all = ''; 75 if($cat) { 76 foreach($cat as $temp) { 77 if($temp['acontent_text']) { 78 if($cat_all) $cat_all .= ', '; 79 $cat_all .= $temp['acontent_text']; 80 } 81 } 82 $cat_all = convertStringToArray($cat_all); 83 sort($cat_all, SORT_LOCALE_STRING); 84 } else { 85 $cat_all = array(); 86 } 87 88 $cat = ''; 89 90 unset($_getVar['recipecat']); 91 $base_link = 'index.php' . returnGlobalGET_QueryString('htmlentities'); 92 foreach($cat_all as $temp) { 93 94 $cat .= ' <li><a href="'.$base_link.'&recipecat='.rawurlencode($temp).'" '; 95 $temp = html_specialchars($temp); 96 $cat .= 'title="'.$temp.'">'.$temp.'</a></li>' . LF; 97 98 } 99 100 if($cat) { 101 102 $cat = LF . '<ul>' . LF . $cat . '</ul>' . LF; 103 104 } 105 106 if(isset($option['LISTCAT'][0])) $cat = $option['LISTCAT'][0] . $cat; 107 if(isset($option['LISTCAT'][1])) $cat .= $option['LISTCAT'][1]; 108 109 return $cat; 110 111 } 112 113 114 function listRecipes($alt=NULL) { 115 116 global $_getVar; 117 $order_by = array(); 118 119 /* 120 $recipecat = trim($recipecat); 121 122 if($recipecat == '') { 123 return listRecipeCategories( array( 'LISTCAT'=> array() ) ); 124 } 125 */ 126 127 $sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent "; 128 $sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON "; 129 $sql .= DB_PREPEND . "phpwcms_article.article_id = " . DB_PREPEND . "phpwcms_articlecontent.acontent_aid "; 130 $sql .= "WHERE acontent_type=26 AND acontent_visible = 1 "; 131 $sql .= "AND acontent_trash = 0 AND "; 132 133 if(!empty($_getVar['recipecat'])) { 134 $sql .= "acontent_text LIKE '%".aporeplace($_getVar['recipecat'])."%' AND "; 135 } 136 137 if(!empty($_getVar['recipecal']) && intval($_getVar['recipecal'])) { 138 139 $_getVar['recipecal'] = intval($_getVar['recipecal']); 140 141 switch($_getVar['recipecal']) { 142 //bis 400 kcal 143 case 1: $sql .= "( SUBSTRING(acontent_alink, 3) / 4.1868) <= 400 AND "; 144 $order_by[] = 'acontent_alink'; 145 break; 146 147 //400 bis 600 kcal 148 case 2: $sql .= "( SUBSTRING(acontent_alink, 3) / 4.1868) > 400 AND "; 149 $sql .= "( SUBSTRING(acontent_alink, 3) / 4.1868) <= 600 AND "; 150 $order_by[] = 'acontent_alink'; 151 break; 152 153 //über 600 kcal 154 case 3: $sql .= "( SUBSTRING(acontent_alink, 3) / 4.1868) > 600 AND "; 155 $order_by[] = 'acontent_alink'; 156 break; 157 158 } 159 160 } 161 162 if(!empty($_getVar['recipetime']) && intval($_getVar['recipetime'])) { 163 164 $_getVar['recipetime'] = intval($_getVar['recipetime']); 165 166 switch($_getVar['recipetime']) { 167 //bis 20 Min. 168 case 1: $sql .= "( SUBSTRING(acontent_media, 3) * 1) <= 20 AND "; 169 $order_by[] = 'acontent_media'; 170 break; 171 172 //20 bis 40 Min. 173 case 2: $sql .= "( SUBSTRING(acontent_media, 3) * 1) > 20 AND "; 174 $sql .= "( SUBSTRING(acontent_media, 3) * 1) <= 40 AND "; 175 $order_by[] = 'acontent_media'; 176 break; 177 178 //über 40 Min. 179 case 3: $sql .= "( SUBSTRING(acontent_media, 3) * 1) > 40 AND "; 180 $order_by[] = 'acontent_media'; 181 break; 182 183 } 184 185 } 186 187 if(!empty($_getVar['recipetext'])) { 188 189 $text = optimizeForSearch(rawurldecode($_getVar['recipetext'])); 190 $text = str_replace(array('UPDATE', 'INSERT', 'SELECT', 'FROM', 'DROP', 'CREATE', "'"), '', $text); 191 $text = convertStringToArray($text, ' '); 192 $t = array(); 193 $sql .= '( '; 194 foreach($text as $value) { 195 196 $t[] = '( CONCAT(acontent_newsletter, '.DB_PREPEND."phpwcms_article.article_title, acontent_title) LIKE '%".aporeplace($value)."%' )"; 197 198 } 199 $sql .= implode(' AND ', $t).' ) AND '; 200 201 } 202 203 $order_by[] = 'article_title'; 204 205 $sql .= DB_PREPEND . "phpwcms_article.article_deleted=0 AND "; 206 $sql .= DB_PREPEND . "phpwcms_article.article_begin < NOW() AND "; 207 $sql .= DB_PREPEND . "phpwcms_article.article_end > NOW() "; 208 $sql .= 'ORDER BY '.implode(', ', $order_by); 209 210 $result = _dbQuery($sql); 211 $result_listing = ''; 212 213 if(is_array($result) && count($result)) { 214 215 $articles = array(); 216 217 foreach($result as $value) { 218 219 $value['article_image'] = unserialize($value['article_image']); 220 $articles[ $value['article_id'] ] = $value; 221 222 } 223 $result_listing = list_articles_summary($articles); 224 225 } 226 227 return $result_listing; 228 229 } 230 231 232 233 $content["all"] = preg_replace_callback('/\{RECIPES:(.*?)\}/s', 'doRecipes', $content["all"]); 234 } 235 236 237 238 239 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |