Changeset 2593:6741802596a0 for inc/public
- Timestamp:
- 11/27/13 16:32:38 (12 years ago)
- Branch:
- twig
- Children:
- 2612:1537212bd291, 2613:014098e27ea0
- Parents:
- 2468:d7fda5a0bd39 (diff), 2589:3d427735ca70 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- inc/public
- Files:
-
- 19 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/public/lib.urlhandlers.php
r2313 r2593 15 15 { 16 16 public $args; 17 17 18 18 public function getURLFor($type,$value='') { 19 19 $core =& $GLOBALS['core']; … … 30 30 return $url; 31 31 } 32 32 33 33 public function register($type,$url,$representation,$handler) 34 34 { … … 38 38 parent::register($t[0],$t[1],$t[2],$t[3]); 39 39 } 40 40 41 41 public static function p404() 42 42 { 43 43 throw new Exception ("Page not found",404); 44 44 } 45 45 46 46 public static function default404($args,$type,$e) 47 47 { … … 51 51 $_ctx =& $GLOBALS['_ctx']; 52 52 $core = $GLOBALS['core']; 53 53 54 54 header('Content-Type: text/html; charset=UTF-8'); 55 55 http::head(404,'Not Found'); … … 57 57 $_ctx->current_tpl = '404.html'; 58 58 $_ctx->content_type = 'text/html'; 59 59 60 60 echo $core->tpl->getData($_ctx->current_tpl); 61 61 62 62 # --BEHAVIOR-- publicAfterDocument 63 63 $core->callBehavior('publicAfterDocument',$core); 64 64 exit; 65 65 } 66 66 67 67 protected static function getPageNumber(&$args) 68 68 { … … 74 74 } 75 75 } 76 76 77 77 return false; 78 78 } 79 79 80 80 protected static function serveDocument($tpl,$content_type='text/html',$http_cache=true,$http_etag=true) 81 81 { 82 82 $_ctx =& $GLOBALS['_ctx']; 83 83 $core =& $GLOBALS['core']; 84 84 85 85 if ($_ctx->nb_entry_per_page === null) { 86 86 $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page; 87 87 } 88 88 if ($_ctx->nb_entry_first_page === null) { 89 $_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page; 90 } 91 89 92 $tpl_file = $core->tpl->getFilePath($tpl); 90 93 91 94 if (!$tpl_file) { 92 95 throw new Exception('Unable to find template '); 93 96 } 94 97 95 98 $result = new ArrayObject; 96 99 97 100 $_ctx->current_tpl = $tpl; 98 101 $_ctx->content_type = $content_type; … … 100 103 $_ctx->http_etag = $http_etag; 101 104 $core->callBehavior('urlHandlerBeforeGetData',$_ctx); 102 105 103 106 if ($_ctx->http_cache) { 104 107 $GLOBALS['mod_files'][] = $tpl_file; … … 111 114 $result['tpl'] = $_ctx->current_tpl; 112 115 $result['blogupddt'] = $core->blog->upddt; 113 116 114 117 # --BEHAVIOR-- urlHandlerServeDocument 115 118 $core->callBehavior('urlHandlerServeDocument',$result); 116 119 117 120 if ($_ctx->http_cache && $_ctx->http_etag) { 118 121 http::etag($result['content'],http::getSelfURI()); … … 120 123 echo $result['content']; 121 124 } 122 125 123 126 public function getDocument() 124 127 { 125 128 $core =& $GLOBALS['core']; 126 129 127 130 $type = $args = ''; 128 131 129 132 if ($this->mode == 'path_info') 130 133 { … … 134 137 { 135 138 $part = ''; 136 139 137 140 $qs = $this->parseQueryString(); 138 141 139 142 # Recreates some _GET and _REQUEST pairs 140 143 if (!empty($qs)) … … 147 150 $_GET = $qs; 148 151 $_REQUEST = array_merge($qs,$_REQUEST); 149 152 150 153 list($k,$v) = each($qs); 151 154 if ($v === null) { … … 156 159 } 157 160 } 158 161 159 162 $_SERVER['URL_REQUEST_PART'] = $part; 160 163 161 164 $this->getArgs($part,$type,$this->args); 162 165 163 166 # --BEHAVIOR-- urlHandlerGetArgsDocument 164 167 $core->callBehavior('urlHandlerGetArgsDocument',$this); 165 168 166 169 if (!$type) 167 170 { … … 175 178 } 176 179 } 177 180 178 181 public static function home($args) 179 182 { 180 183 $n = self::getPageNumber($args); 181 184 182 185 if ($args && !$n) 183 186 { 184 # "Then specified URL went unrecognized by all URL handlers and 187 # "Then specified URL went unrecognized by all URL handlers and 185 188 # defaults to the home page, but is not a page number. 186 189 self::p404(); … … 188 191 else 189 192 { 193 $_ctx =& $GLOBALS['_ctx']; 190 194 $core =& $GLOBALS['core']; 191 195 192 196 if ($n) { 193 197 $GLOBALS['_page_number'] = $n; 194 198 $core->url->type = $n > 1 ? 'default-page' : 'default'; 195 199 } 196 200 197 201 if (empty($_GET['q'])) { 202 if ($core->blog->settings->system->nb_post_for_home !== null) { 203 $_ctx->nb_entry_first_page = $core->blog->settings->system->nb_post_for_home; 204 } 198 205 self::serveDocument('home.html'); 199 206 $core->blog->publishScheduledEntries(); … … 203 210 } 204 211 } 205 212 206 213 public static function search() 207 214 { 208 215 $_ctx =& $GLOBALS['_ctx']; 209 216 $core =& $GLOBALS['core']; 210 217 211 218 $core->url->type='search'; 212 219 213 220 $GLOBALS['_search'] = !empty($_GET['q']) ? rawurldecode($_GET['q']) : ''; 214 221 if ($GLOBALS['_search']) { … … 217 224 $GLOBALS['_search_count'] = $core->blog->getPosts($params,true)->f(0); 218 225 } 219 226 220 227 self::serveDocument('search.html'); 221 228 } 222 229 223 230 public static function lang($args) 224 231 { 225 232 $_ctx =& $GLOBALS['_ctx']; 226 233 $core =& $GLOBALS['core']; 227 234 228 235 $n = self::getPageNumber($args); 229 236 $params = new ArrayObject(array( 230 237 'lang' => $args)); 231 238 232 239 $core->callBehavior('publicLangBeforeGetLangs',$params,$args); 233 240 234 241 $_ctx->langs = $core->blog->getLangs($params); 235 242 236 243 if ($_ctx->langs->isEmpty()) { 237 244 # The specified language does not exist. … … 247 254 } 248 255 } 249 256 250 257 public static function category($args) 251 258 { 252 259 $_ctx =& $GLOBALS['_ctx']; 253 260 $core =& $GLOBALS['core']; 254 261 255 262 $n = self::getPageNumber($args); 256 263 257 264 if ($args == '' && !$n) { 258 265 # No category was specified. … … 265 272 'post_type' => 'post', 266 273 'without_empty' => false)); 267 274 268 275 $core->callBehavior('publicCategoryBeforeGetCategories',$params,$args); 269 276 270 277 $_ctx->categories = $core->blog->getCategories($params); 271 278 272 279 if ($_ctx->categories->isEmpty()) { 273 280 # The specified category does no exist. … … 283 290 } 284 291 } 285 292 286 293 public static function archive($args) 287 294 { 288 295 $_ctx =& $GLOBALS['_ctx']; 289 296 $core =& $GLOBALS['core']; 290 297 291 298 $year = $month = $cat_url = null; 292 299 # Nothing or year and month … … 301 308 'month' => $m[2], 302 309 'type' => 'month')); 303 310 304 311 $core->callBehavior('publicArchiveBeforeGetDates',$params,$args); 305 312 306 313 $_ctx->archives = $core->blog->getDates($params); 307 314 308 315 if ($_ctx->archives->isEmpty()) { 309 316 # There is no entries for the specified period. … … 320 327 } 321 328 } 322 329 323 330 public static function post($args) 324 331 { … … 331 338 $_ctx =& $GLOBALS['_ctx']; 332 339 $core =& $GLOBALS['core']; 333 340 334 341 $core->blog->withoutPassword(false); 335 342 336 343 $params = new ArrayObject(array( 337 344 'post_url' => $args)); 338 345 339 346 $core->callBehavior('publicPostBeforeGetPosts',$params,$args); 340 347 341 348 $_ctx->posts = $core->blog->getPosts($params); 342 349 343 350 $_ctx->comment_preview = new ArrayObject(); 344 351 $_ctx->comment_preview['content'] = ''; … … 349 356 $_ctx->comment_preview['preview'] = false; 350 357 $_ctx->comment_preview['remember'] = false; 351 358 352 359 $core->blog->withoutPassword(true); 353 360 354 361 if ($_ctx->posts->isEmpty()) 355 362 { … … 361 368 $post_id = $_ctx->posts->post_id; 362 369 $post_password = $_ctx->posts->post_password; 363 370 364 371 # Password protected entry 365 372 if ($post_password != '' && !$_ctx->preview) … … 371 378 $pwd_cookie = array(); 372 379 } 373 380 374 381 # Check for match 375 382 if ((!empty($_POST['password']) && $_POST['password'] == $post_password) … … 385 392 } 386 393 } 387 394 388 395 $post_comment = 389 396 isset($_POST['c_name']) && isset($_POST['c_mail']) && 390 397 isset($_POST['c_site']) && isset($_POST['c_content']) && 391 398 $_ctx->posts->commentsActive(); 392 399 393 400 # Posting a comment 394 401 if ($post_comment) … … 402 409 exit; 403 410 } 404 411 405 412 $name = $_POST['c_name']; 406 413 $mail = $_POST['c_mail']; … … 408 415 $content = $_POST['c_content']; 409 416 $preview = !empty($_POST['preview']); 410 417 411 418 if ($content != '') 412 419 { 413 if ($core->blog->settings->system->wiki_comments) { 414 $core->initWikiComment(); 420 # --BEHAVIOR-- publicBeforeCommentTransform 421 $buffer = $core->callBehavior('publicBeforeCommentTransform',$content); 422 if ($buffer != '') { 423 $content = $buffer; 415 424 } else { 416 $core->initWikiSimpleComment(); 425 if ($core->blog->settings->system->wiki_comments) { 426 $core->initWikiComment(); 427 } else { 428 $core->initWikiSimpleComment(); 429 } 430 $content = $core->wikiTransform($content); 417 431 } 418 $content = $core->wikiTransform($content);419 432 $content = $core->HTMLfilter($content); 420 433 } 421 434 422 435 $_ctx->comment_preview['content'] = $content; 423 436 $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; … … 425 438 $_ctx->comment_preview['mail'] = $mail; 426 439 $_ctx->comment_preview['site'] = $site; 427 440 428 441 if ($preview) 429 442 { 430 443 # --BEHAVIOR-- publicBeforeCommentPreview 431 444 $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 432 445 433 446 $_ctx->comment_preview['preview'] = true; 434 447 } … … 444 457 $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 445 458 $cur->comment_ip = http::realIP(); 446 459 447 460 $redir = $_ctx->posts->getURL(); 448 461 $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?'; 449 462 450 463 try 451 464 { … … 453 466 throw new Exception(__('You must provide a valid email address.')); 454 467 } 455 468 456 469 # --BEHAVIOR-- publicBeforeCommentCreate 457 470 $core->callBehavior('publicBeforeCommentCreate',$cur); 458 if ($cur->post_id) { 471 if ($cur->post_id) { 459 472 $comment_id = $core->blog->addComment($cur); 460 473 461 474 # --BEHAVIOR-- publicAfterCommentCreate 462 475 $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 463 476 } 464 477 465 478 if ($cur->comment_status == 1) { 466 479 $redir_arg = 'pub=1'; … … 468 481 $redir_arg = 'pub=0'; 469 482 } 470 483 471 484 header('Location: '.$redir.$redir_arg); 472 485 } … … 478 491 } 479 492 } 480 493 481 494 # The entry 482 495 if ($_ctx->posts->trackbacksActive()) { … … 487 500 } 488 501 } 489 502 490 503 public static function preview($args) 491 504 { 492 505 $core = $GLOBALS['core']; 493 506 $_ctx = $GLOBALS['_ctx']; 494 507 495 508 if (!preg_match('#^(.+?)/([0-9a-z]{40})/(.+?)$#',$args,$m)) { 496 509 # The specified Preview URL is malformed. … … 513 526 } 514 527 } 515 528 516 529 public static function feed($args) 517 530 { … … 521 534 $post_id = null; 522 535 $subtitle = ''; 523 536 524 537 $mime = 'application/xml'; 525 538 526 539 $_ctx =& $GLOBALS['_ctx']; 527 540 $core =& $GLOBALS['core']; 528 541 529 542 if (preg_match('!^([a-z]{2}(-[a-z]{2})?)/(.*)$!',$args,$m)) { 530 543 $params = new ArrayObject(array('lang' => $m[1])); 531 544 532 545 $args = $m[3]; 533 546 534 547 $core->callBehavior('publicFeedBeforeGetLangs',$params,$args); 535 548 536 549 $_ctx->langs = $core->blog->getLangs($params); 537 550 538 551 if ($_ctx->langs->isEmpty()) { 539 552 # The specified language does not exist. … … 544 557 } 545 558 } 546 559 547 560 if (preg_match('#^rss2/xslt$#',$args,$m)) 548 561 { … … 573 586 return; 574 587 } 575 588 576 589 if ($cat_url) 577 590 { … … 579 592 'cat_url' => $cat_url, 580 593 'post_type' => 'post')); 581 594 582 595 $core->callBehavior('publicFeedBeforeGetCategories',$params,$args); 583 596 584 597 $_ctx->categories = $core->blog->getCategories($params); 585 598 586 599 if ($_ctx->categories->isEmpty()) { 587 600 # The specified category does no exist. … … 589 602 return; 590 603 } 591 604 592 605 $subtitle = ' - '.$_ctx->categories->cat_title; 593 606 } … … 597 610 'post_id' => $post_id, 598 611 'post_type' => '')); 599 612 600 613 $core->callBehavior('publicFeedBeforeGetPosts',$params,$args); 601 614 602 615 $_ctx->posts = $core->blog->getPosts($params); 603 616 604 617 if ($_ctx->posts->isEmpty()) { 605 618 # The specified post does not exist. … … 607 620 return; 608 621 } 609 622 610 623 $subtitle = ' - '.$_ctx->posts->post_title; 611 624 } 612 625 613 626 $tpl = $type; 614 627 if ($comments) { … … 620 633 } 621 634 $tpl .= '.xml'; 622 635 623 636 if ($type == 'atom') { 624 637 $mime = 'application/atom+xml'; 625 638 } 626 639 627 640 $_ctx->feed_subtitle = $subtitle; 628 641 629 642 header('X-Robots-Tag: '.context::robotsPolicy($core->blog->settings->system->robots_policy,'')); 630 643 self::serveDocument($tpl,$mime); … … 633 646 } 634 647 } 635 648 636 649 public static function trackback($args) 637 650 { … … 644 657 } 645 658 } 646 659 647 660 public static function rsd($args) 648 661 { 649 662 $core =& $GLOBALS['core']; 650 663 http::cache($GLOBALS['mod_files'],$GLOBALS['mod_ts']); 651 664 652 665 header('Content-Type: text/xml; charset=UTF-8'); 653 666 echo … … 658 671 " <engineLink>http://www.dotclear.org/</engineLink>\n". 659 672 ' <homePageLink>'.html::escapeHTML($core->blog->url)."</homePageLink>\n"; 660 673 661 674 if ($core->blog->settings->system->enable_xmlrpc) 662 675 { 663 676 $u = sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id); 664 677 665 678 echo 666 679 " <apis>\n". … … 671 684 " </apis>\n"; 672 685 } 673 686 674 687 echo 675 688 "</service>\n". 676 689 "</rsd>\n"; 677 690 } 678 691 679 692 public static function xmlrpc($args) 680 693 { … … 685 698 } 686 699 } 687 ?> -
inc/public/prepend.php
r2313 r2593 101 101 } 102 102 } 103 103 104 104 # If theme doesn't exist, stop everything 105 105 if (!$core->themes->moduleExists($__theme)) { … … 134 134 $__theme_tpl_path[] = $core->blog->themes_path.'/'.$__parent_theme.'/tpl'; 135 135 } 136 137 $core->tpl->setPath( 138 $__theme_tpl_path, 139 dirname(__FILE__).'/default-templates', 140 $core->tpl->getPath()); 141 136 $tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset'); 137 if (!empty($tplset) && is_dir(dirname(__FILE__).'/default-templates/'.$tplset)) { 138 $core->tpl->setPath( 139 $__theme_tpl_path, 140 dirname(__FILE__).'/default-templates/'.$tplset, 141 $core->tpl->getPath()); 142 } else { 143 $core->tpl->setPath( 144 $__theme_tpl_path, 145 $core->tpl->getPath()); 146 } 142 147 $core->url->mode = $core->blog->settings->system->url_scan; 143 148 … … 145 150 # --BEHAVIOR-- publicBeforeDocument 146 151 $core->callBehavior('publicBeforeDocument',$core); 147 152 148 153 $core->url->getDocument(); 149 154 150 155 # --BEHAVIOR-- publicAfterDocument 151 156 $core->callBehavior('publicAfterDocument',$core); … … 155 160 ,660); 156 161 } 157 ?>
Note: See TracChangeset
for help on using the changeset viewer.