Changeset 878
- Timestamp:
- 11/03/08 22:06:07 (4 years ago)
- Location:
- trunk/app
- Files:
-
- 1 deleted
- 1 edited
-
models/wiki.php (modified) (1 diff)
-
tmp/cache/views/empty (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/models/wiki.php
r874 r878 131 131 $lines = explode("\n", $content); 132 132 //die(debug($lines)); 133 foreach ($lines as $line): // line by line 134 $line = trim($line); // clean line 135 $key = substr($line, 0, 1); // first character to check if is ol (#) or ul (*) 136 //die(debug($key)); 137 if ($key && array_key_exists($key, $markup) && $processMarkup === true): // if $processMarkup is true and, if so, it continues processing 138 if (!$markup[$key]['processing']): // is not set 139 $markup[$key]['processing'] = true; // true by default 140 $line = $markup[$key]['open'] . '<li> ' . substr($line, 1) . ' </li>'; // ?? 141 else: 142 $line = '<li> ' . substr($line, 1) . ' </li>'; 143 endif; 144 else: 145 if ($markup['*']['processing']): // ul 146 $markup['*']['processing'] = false; 147 $line = ' ' . $markup['*']['close'] . ' ' . $line; 148 endif; 149 150 if ($markup['#']['processing']): // ol 151 $markup['#']['processing'] = false; 152 $line = ' ' . $markup['#']['close'] . ' ' . $line; 153 endif; 154 $line .= ' <br /> '; // break anyway 155 endif; 156 157 $words = explode(' ', $line); // now words in line 158 foreach ($words as $word): 159 $word = trim($word); // clean 160 $key = substr($word, 0, 3); 161 if ($key && array_key_exists($key, $markup)): 162 if ($key == '&&&'): //<pre> 163 if ($markup[$key]['processing']): // true 164 $markup[$key]['processing'] = false; 165 $processMarkup = true; 166 $word = $markup[$key]['close'] . substr($word,3); 167 else: 168 $markup[$key]['processing'] = true; 169 $processMarkup = false; 170 $word = $markup[$key]['open'] . substr($word,3); 171 endif; 172 elseif ($processMarkup): 173 if ($markup[$key]['processing']): 174 $markup[$key]['processing'] = false; 175 $word = $markup[$key]['close'] . substr($word,3); 176 else: 177 if ($key != '---' && $key != 'htt'): 178 $markup[$key]['processing'] = true; 179 endif; 180 if ($key == 'htt'): 181 if (substr($word, 0,7) == 'http://'): 182 $word = "<a href='" . $word . "'>".$word."</a>"; 183 else: 184 if ($key == '[[['): 185 $markup["]]]"]['processing'] = substr($word,3); 186 endif; 187 $word = $markup[$key]['open'] . substr($word,3); 188 endif; 189 endif; 190 endif; 191 else: 192 if ($processMarkup): 193 if ($markup[']]]']['processing'] && substr($word, -3, 3) != ']]]'): 194 $markup[']]]']['processing'] .= ' ' . $word; 195 $word = ''; 196 endif; 197 endif; 198 endif; 199 200 $key = (string) substr($word, -3, 3); // final three characters 201 if ($key && array_key_exists($key, $markup)): 202 if ($key == '&&&'): 203 if ($markup[$key]['processing']): 204 $markup[$key]['processing'] = false; 205 $processMarkup = true; 206 $word = substr($word,0,-3) . $markup[$key]['close']; 207 else: 208 $markup[$key]['processing'] = true; 209 $processMarkup = false; 210 $word = substr($word,0,-3) . $markup[$key]['open']; 211 endif; 212 elseif ($processMarkup): 213 if ($markup[$key]['processing'] && $key != ']]]'): 214 $markup[$key]['processing'] = false; 215 $word = substr($word,0,-3) . $markup[$key]['close']; 216 else: 217 if ($key != '---' && $key != ']]]'): 218 $markup[$key]['processing'] = true; 219 elseif ($key != 'htt'): 220 if ($key == '[[['): 221 $markup[$key]['processing'] = true; 222 $markup[']]]']['processing'] = substr($word,0,-3); 223 $word = substr($word,0,-3); 224 elseif ($key == ']]]'): 225 if ($markup[$key]['processing']): // true 226 if (!$markup['[[[']['processing']): 227 $markup[$key]['processing'] .= ' ' . substr($word,0,-3); 228 else: 229 $markup[$key]['processing'] = substr($markup[$key]['processing'],0,-3); 230 endif; 133 foreach ($lines as $line) 134 { 135 $line = trim($line); 136 $key = substr($line, 0, 1); 137 if ($key && array_key_exists($key, $markup) && $processMarkup) 138 { 139 if (!$markup[$key]['processing']) 140 { 141 $markup[$key]['processing'] = true; 142 $line = $markup[$key]['open'] . '<li> ' . substr($line, 1) . ' </li>'; 143 } else { 144 $line = '<li> ' . substr($line, 1) . ' </li>'; 145 } 146 } else { 147 if ($markup['*']['processing']) { 148 $markup['*']['processing'] = false; 149 $line = ' ' . $markup['*']['close'] . ' ' . $line; 150 } 151 if ($markup['#']['processing']) { 152 $markup['#']['processing'] = false; 153 $line = ' ' . $markup['#']['close'] . ' ' . $line; 154 } 155 $line .= " <br /> "; 156 } 157 $words = explode(" ", $line); 158 foreach ($words as $word) { 159 $word = trim($word); 160 $key = substr($word, 0, 3); 161 if ($key && array_key_exists($key, $markup)) { 162 if ($key == '&&&') { 163 if ($markup[$key]['processing']) { 164 $markup[$key]['processing'] = false; 165 $processMarkup = true; 166 $word = $markup[$key]['close'] . substr($word,3); 167 } else { 168 $markup[$key]['processing'] = true; 169 $processMarkup = false; 170 $word = $markup[$key]['open'] . substr($word,3); 171 } 172 } else if ($processMarkup) { 173 if ($markup[$key]['processing']) { 174 $markup[$key]['processing'] = false; 175 $word = $markup[$key]['close'] . substr($word,3); 176 } else { 177 if ($key != '---' && $key != 'htt') { 178 $markup[$key]['processing'] = true; 179 } 180 if ($key == 'htt') { 181 if (substr($word, 0,7) == "http://") { 182 $word = "<a href='" . $word . "'>".$word."</a>"; 183 } 184 } else { 185 if ($key == '[[[') { 186 $markup["]]]"]['processing'] = substr($word,3); 187 } 188 $word = $markup[$key]['open'] . substr($word,3); 189 } 190 } 191 } 192 } else { 193 if ($processMarkup) { 194 if ($markup["]]]"]['processing'] && substr($word, -3, 3) != "]]]") { 195 $markup["]]]"]['processing'] .= ' ' . $word; 196 $word = ''; 197 } 198 } 199 } 231 200 232 if (strpos($markup[$key]['processing'], '|')): 233 list($alink, $atitle) = explode('|', $markup[$key]['processing']); 234 else: 235 $alink = $markup[$key]['processing']; 236 $atitle = false; 237 endif; 238 239 if (strpos($alink, "://")): 240 $word = "<a href='" . $alink . "'>"; 241 else: 242 $word = "<a href='/wikis/view/" . preg_replace("/[^a-z]/", "", strtolower($alink)) ."'>"; 243 endif; 244 245 if ($atitle): 246 $word .= $atitle; 247 else: 248 $word .= $alink; 249 endif; 250 $word .= "</a>"; 251 $markup[$key]['processing'] = false; 252 $markup['[[[']['processing'] = false; 253 endif; 254 endif; 255 else: 256 $word = substr($word,0,-3) . $markup[$key]['open']; 257 endif; 258 endif; 259 endif; 260 endif; 261 else: 262 if ($processMarkup): 263 if ($processMarkup && $markup[']]]']['processing']): 264 $word = ''; 265 endif; 266 $markup['[[[']['processing'] = false; 267 endif; 268 endif; 269 $content .= $word . ' '; 201 $key = substr($word, -3, 3); 202 if ($key && array_key_exists($key, $markup)) { 203 if ($key == '&&&') { 204 if ($markup[$key]['processing']) { 205 $markup[$key]['processing'] = false; 206 $processMarkup = true; 207 $word = substr($word,0,-3) . $markup[$key]['close']; 208 } else { 209 $markup[$key]['processing'] = true; 210 $processMarkup = false; 211 $word = substr($word,0,-3) . $markup[$key]['open']; 212 } 213 } else if ($processMarkup) { 214 if ($markup[$key]['processing'] && $key != ']]]') { 215 $markup[$key]['processing'] = false; 216 $word = substr($word,0,-3) . $markup[$key]['close']; 217 } else { 218 if ($key != '---' && $key != ']]]') { 219 $markup[$key]['processing'] = true; 220 } else if ($key != 'htt') { 221 if ($key == '[[[') { 222 $markup[$key]['processing'] = true; 223 $markup[']]]']['processing'] = substr($word,0,-3); 224 $word = substr($word,0,-3); 225 } else if ($key == ']]]') { 226 if ($markup[$key]['processing']) { 227 if (!$markup["[[["]['processing']) { 228 $markup[$key]['processing'] .= ' ' . substr($word,0,-3); 229 } else { 230 $markup[$key]['processing'] = substr($markup[$key]['processing'],0,-3); 231 } 232 if (strpos($markup[$key]['processing'], "|")) { 233 list($alink, $atitle) = explode('|', $markup[$key]['processing']); 234 } else { 235 $alink = $markup[$key]['processing']; 236 $atitle = false; 237 } 238 if (strpos($alink, "://")) { 239 $word = "<a href='" . $alink . "'>"; 240 } else { 241 $word = "<a href='/entries/view/" . preg_replace("/[^a-z]/", "", strtolower($alink)) ."'>"; 242 } 243 if ($atitle) { 244 $word .= $atitle; 245 } else { 246 $word .= $alink; 247 } 248 $word .= "</a>"; 249 $markup[$key]['processing'] = false; 250 $markup['[[[']['processing'] = false; 251 } 252 } else { 253 $word = substr($word,0,-3) . $markup[$key]['open']; 254 } 255 } 256 } 257 } 258 } else { 259 if ($processMarkup) { 260 if ($processMarkup && $markup[']]]']['processing']) { 261 $word = ''; 262 } 263 $markup["[[["]['processing'] = false; 264 } 265 } 270 266 $wiki['Wiki']['content'] = $content; 271 endforeach; 272 endforeach; 267 } 268 } 269 273 270 return $wiki; 274 271 }
Note: See TracChangeset
for help on using the changeset viewer.
