Changeset 1090 for trunk/include/section_init.inc.php
- Timestamp:
- Mar 21, 2006, 2:27:21 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/section_init.inc.php
-
Property
svn:eol-style
set to
native
r1086 r1090 41 41 */ 42 42 43 // "index.php?/category/12-foo/start-24&action=fill_caddie" must return : 43 // "index.php?/category/12-foo/start-24&action=fill_caddie" or 44 // "index.php/category/12-foo/start-24&action=fill_caddie" 45 // must return : 44 46 // 45 47 // array( … … 52 54 $page['section'] = 'categories'; 53 55 54 foreach (array_keys($_GET) as $keynum => $key) 55 { 56 if (0 == $keynum) 57 { 58 // deleting first "/" if displayed 59 $tokens = explode( 60 '/', 61 preg_replace('#^/#', '', $key) 62 ); 63 64 // $tokens = array( 65 // 0 => category, 66 // 1 => 12-foo, 67 // 2 => start-24 68 // ); 69 70 $next_token = 0; 71 72 if (basename($_SERVER['PHP_SELF']) == 'picture.php') 56 if ( isset($_SERVER["PATH_INFO"]) ) 57 { 58 $rewritten = $_SERVER["PATH_INFO"]; 59 $rewritten = str_replace('//', '/', $rewritten); 60 $path_count = count( explode('/', $rewritten) ); 61 $page['root_path'] = PHPWG_ROOT_PATH.str_repeat('../', $path_count-1); 62 } 63 else 64 { 65 $rewritten = ''; 66 foreach (array_keys($_GET) as $keynum => $key) 67 { 68 $rewritten = $key; 69 break; 70 } 71 $page['root_path'] = PHPWG_ROOT_PATH; 72 } 73 //phpinfo(); 74 // deleting first "/" if displayed 75 $tokens = explode( 76 '/', 77 preg_replace('#^/#', '', $rewritten) 78 ); 79 // $tokens = array( 80 // 0 => category, 81 // 1 => 12-foo, 82 // 2 => start-24 83 // ); 84 85 $next_token = 0; 86 if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php') 87 { 88 89 // the first token must be the numeric identifier of the picture 90 preg_match('/(\d+)/', $tokens[$next_token], $matches); 91 if (!isset($matches[1])) 92 { 93 die('Fatal: picture identifier is missing'); 94 } 95 $page['image_id'] = $matches[1]; 96 97 $next_token++; 98 } 99 100 if (0 === strpos($tokens[$next_token], 'cat')) 101 { 102 $page['section'] = 'categories'; 103 $next_token++; 104 105 if (isset($tokens[$next_token]) 106 and preg_match('/^(\d+)/', $tokens[$next_token], $matches)) 107 { 108 $page['category'] = $matches[1]; 109 $next_token++; 110 } 111 } 112 else if (0 === strpos($tokens[$next_token], 'tag')) 113 { 114 $page['section'] = 'tags'; 115 $page['tags'] = array(); 116 117 $next_token++; 118 119 for ($i = $next_token; ; $i++) 120 { 121 if (!isset($tokens[$i])) 73 122 { 74 // the first token must be the numeric identifier of the picture 75 preg_match('/(\d+)/', $tokens[$next_token], $matches); 76 if (!isset($matches[1])) 123 break; 124 } 125 126 preg_match('/^(\d+)/', $tokens[$i], $matches); 127 if (!isset($matches[1])) 128 { 129 if (0 == count($page['tags'])) 77 130 { 78 die('Fatal: picture identifier is missing');131 die('Fatal: at least one tag required'); 79 132 } 80 $page['image_id'] = $matches[1]; 81 82 $next_token++; 83 } 84 85 if (0 === strpos($tokens[$next_token], 'cat')) 86 { 87 $page['section'] = 'categories'; 88 $next_token++; 89 90 if (isset($tokens[$next_token]) 91 and preg_match('/^(\d+)/', $tokens[$next_token], $matches)) 92 { 93 $page['category'] = $matches[1]; 94 $next_token++; 95 } 96 } 97 else if (0 === strpos($tokens[$next_token], 'tag')) 98 { 99 $page['section'] = 'tags'; 100 $page['tags'] = array(); 101 102 $next_token++; 103 104 for ($i = $next_token; ; $i++) 105 { 106 if (!isset($tokens[$i])) 107 { 108 break; 109 } 110 111 preg_match('/^(\d+)/', $tokens[$i], $matches); 112 if (!isset($matches[1])) 113 { 114 if (0 == count($page['tags'])) 115 { 116 die('Fatal: at least one tag required'); 117 } 118 else 119 { 120 break; 121 } 122 } 123 array_push($page['tags'], $matches[1]); 124 } 125 126 $next_token = $i; 127 } 128 else if (0 === strpos($tokens[$next_token], 'fav')) 129 { 130 $page['section'] = 'favorites'; 131 $next_token++; 132 } 133 else if ('most_visited' == $tokens[$next_token]) 134 { 135 $page['section'] = 'most_visited'; 136 $next_token++; 137 } 138 else if ('best_rated' == $tokens[$next_token]) 139 { 140 $page['section'] = 'best_rated'; 141 $next_token++; 142 } 143 else if ('recent_pics' == $tokens[$next_token]) 144 { 145 $page['section'] = 'recent_pics'; 146 $next_token++; 147 } 148 else if ('recent_cats' == $tokens[$next_token]) 149 { 150 $page['section'] = 'recent_cats'; 151 $next_token++; 152 } 153 else if ('search' == $tokens[$next_token]) 154 { 155 $page['section'] = 'search'; 156 $next_token++; 157 158 preg_match('/(\d+)/', $tokens[$next_token], $matches); 159 if (!isset($matches[1])) 160 { 161 die('Fatal: search identifier is missing'); 162 } 163 $page['search'] = $matches[1]; 164 $next_token++; 165 } 166 else if ('list' == $tokens[$next_token]) 167 { 168 $page['section'] = 'list'; 169 $next_token++; 170 171 $page['list'] = array(); 172 if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token])) 173 { 174 die('wrong format on list GET parameter'); 175 } 176 foreach (explode(',', $tokens[$next_token]) as $image_id) 177 { 178 array_push($page['list'], $image_id); 179 } 180 $next_token++; 181 } 182 else 183 { 184 $page['section'] = 'categories'; 185 $next_token++; 186 } 187 188 for ($i = $next_token; ; $i++) 189 { 190 if (!isset($tokens[$i])) 133 else 191 134 { 192 135 break; 193 136 } 194 195 if (preg_match('/^start-(\d+)/', $tokens[$i], $matches)) 137 } 138 array_push($page['tags'], $matches[1]); 139 } 140 141 $next_token = $i; 142 } 143 else if (0 === strpos($tokens[$next_token], 'fav')) 144 { 145 $page['section'] = 'favorites'; 146 $next_token++; 147 } 148 else if ('most_visited' == $tokens[$next_token]) 149 { 150 $page['section'] = 'most_visited'; 151 $next_token++; 152 } 153 else if ('best_rated' == $tokens[$next_token]) 154 { 155 $page['section'] = 'best_rated'; 156 $next_token++; 157 } 158 else if ('recent_pics' == $tokens[$next_token]) 159 { 160 $page['section'] = 'recent_pics'; 161 $next_token++; 162 } 163 else if ('recent_cats' == $tokens[$next_token]) 164 { 165 $page['section'] = 'recent_cats'; 166 $next_token++; 167 } 168 else if ('search' == $tokens[$next_token]) 169 { 170 $page['section'] = 'search'; 171 $next_token++; 172 173 preg_match('/(\d+)/', $tokens[$next_token], $matches); 174 if (!isset($matches[1])) 175 { 176 die('Fatal: search identifier is missing'); 177 } 178 $page['search'] = $matches[1]; 179 $next_token++; 180 } 181 else if ('list' == $tokens[$next_token]) 182 { 183 $page['section'] = 'list'; 184 $next_token++; 185 186 $page['list'] = array(); 187 if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token])) 188 { 189 die('wrong format on list GET parameter'); 190 } 191 foreach (explode(',', $tokens[$next_token]) as $image_id) 192 { 193 array_push($page['list'], $image_id); 194 } 195 $next_token++; 196 } 197 else 198 { 199 $page['section'] = 'categories'; 200 $next_token++; 201 } 202 203 for ($i = $next_token; ; $i++) 204 { 205 if (!isset($tokens[$i])) 206 { 207 break; 208 } 209 210 if (preg_match('/^start-(\d+)/', $tokens[$i], $matches)) 211 { 212 $page['start'] = $matches[1]; 213 } 214 215 if (preg_match('/^posted|created/', $tokens[$i] )) 216 { 217 $chronology_tokens = explode('-', $tokens[$i] ); 218 $page['chronology_field'] = $chronology_tokens[0]; 219 array_shift($chronology_tokens); 220 $page['chronology_style'] = $chronology_tokens[0]; 221 array_shift($chronology_tokens); 222 if ( count($chronology_tokens)>0 ) 223 { 224 if ('list'==$chronology_tokens[0] or 225 'calendar'==$chronology_tokens[0]) 196 226 { 197 $page['start'] = $matches[1]; 227 $page['chronology_view'] = $chronology_tokens[0]; 228 array_shift($chronology_tokens); 198 229 } 199 200 if (preg_match('/^posted|created/', $tokens[$i] )) 201 { 202 $chronology_tokens = explode('-', $tokens[$i] ); 203 $page['chronology']['field'] = $chronology_tokens[0]; 204 array_shift($chronology_tokens); 205 $page['chronology']['style'] = $chronology_tokens[0]; 206 array_shift($chronology_tokens); 207 if ( count($chronology_tokens)>0 ) 208 { 209 if ('list'==$chronology_tokens[0] or 210 'calendar'==$chronology_tokens[0]) 211 { 212 $page['chronology']['view'] = $chronology_tokens[0]; 213 array_shift($chronology_tokens); 214 } 215 $page['chronology_date'] = $chronology_tokens; 216 } 217 } 230 $page['chronology_date'] = $chronology_tokens; 218 231 } 219 232 } 220 233 } 234 221 235 222 236 // $page['nb_image_page'] is the number of picture to display on this page … … 470 484 // +-----------------------------------------------------------------------+ 471 485 472 if (isset($page['chronology ']))486 if (isset($page['chronology_field'])) 473 487 { 474 488 include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' ); … … 476 490 } 477 491 478 // echo '<pre>'; print_r($page); echo '</pre>';479 480 481 492 ?> -
Property
svn:eol-style
set to
Note: See TracChangeset
for help on using the changeset viewer.