Changeset 2566:9bf417837888 for inc/core/class.dc.rs.extensions.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.rs.extensions.php
r1179 r2566 26 26 /** 27 27 Returns whether post is editable. 28 28 29 29 @param rs Invisible parameter 30 30 @return <b>boolean</b> … … 36 36 return true; 37 37 } 38 38 39 39 # No user id in result ? false 40 40 if (!$rs->exists('user_id')) { 41 41 return false; 42 42 } 43 43 44 44 # If user is usage and owner of the entrie 45 45 if ($rs->core->auth->check('usage',$rs->core->blog->id) … … 47 47 return true; 48 48 } 49 49 50 50 return false; 51 51 } 52 52 53 53 /** 54 54 Returns whether post is deletable 55 55 56 56 @param rs Invisible parameter 57 57 @return <b>boolean</b> … … 63 63 return true; 64 64 } 65 65 66 66 # No user id in result ? false 67 67 if (!$rs->exists('user_id')) { 68 68 return false; 69 69 } 70 70 71 71 # If user has delete rights and is owner of the entrie 72 72 if ($rs->core->auth->check('delete',$rs->core->blog->id) … … 74 74 return true; 75 75 } 76 76 77 77 return false; 78 78 } 79 79 80 80 /** 81 81 Returns whether post is the first one of its day. 82 82 83 83 @param rs Invisible parameter 84 84 @return <b>boolean</b> … … 89 89 return true; 90 90 } 91 91 92 92 $cdate = date('Ymd',strtotime($rs->post_dt)); 93 93 $rs->movePrev(); … … 96 96 return $ndate != $cdate; 97 97 } 98 98 99 99 /** 100 100 Returns whether post is the last one of its day. 101 101 102 102 @param rs Invisible parameter 103 103 @return <b>boolean</b> … … 108 108 return true; 109 109 } 110 110 111 111 $cdate = date('Ymd',strtotime($rs->post_dt)); 112 112 $rs->moveNext(); … … 115 115 return $ndate != $cdate; 116 116 } 117 117 118 118 /** 119 119 Returns whether comments are enabled on post. 120 120 121 121 @param rs Invisible parameter 122 122 @return <b>boolean</b> … … 130 130 time()-($rs->core->blog->settings->system->comments_ttl*86400) < $rs->getTS()); 131 131 } 132 132 133 133 /** 134 134 Returns whether trackbacks are enabled on post. 135 135 136 136 @param rs Invisible parameter 137 137 @return <b>boolean</b> … … 145 145 time()-($rs->core->blog->settings->system->trackbacks_ttl*86400) < $rs->getTS()); 146 146 } 147 147 148 148 /** 149 149 Returns whether post has at least one comment. 150 150 151 151 @param rs Invisible parameter 152 152 @return <b>boolean</b> … … 156 156 return $rs->nb_comment > 0; 157 157 } 158 158 159 159 /** 160 160 Returns whether post has at least one trackbacks. 161 161 162 162 @return <b>boolean</b> 163 163 */ … … 176 176 return ($rs->getTS('upddt') + dt::getTimeOffset($rs->post_tz)) > $rs->getTS(); 177 177 } 178 178 179 179 /** 180 180 Returns full post URL. 181 181 182 182 @param rs Invisible parameter 183 183 @return <b>string</b> … … 189 189 ); 190 190 } 191 191 192 192 /** 193 193 Returns full post category URL. 194 194 195 195 @param rs Invisible parameter 196 196 @return <b>string</b> … … 200 200 return $rs->core->blog->url.$rs->core->url->getURLFor('category',html::sanitizeURL($rs->cat_url)); 201 201 } 202 202 203 203 /** 204 204 Returns whether post has an excerpt. 205 205 206 206 @param rs Invisible parameter 207 207 @return <b>boolean</b> … … 211 211 return $rs->post_excerpt_xhtml != ''; 212 212 } 213 213 214 214 /** 215 215 Returns post timestamp. 216 216 217 217 @param rs Invisible parameter 218 218 @param type <b>string</b> (dt|upddt|creadt) defaults to post_dt … … 229 229 } 230 230 } 231 231 232 232 /** 233 233 Returns post date formating according to the ISO 8601 standard. 234 234 235 235 @param rs Invisible parameter 236 236 @param type <b>string</b> (dt|upddt|creadt) defaults to post_dt … … 245 245 } 246 246 } 247 247 248 248 /** 249 249 Returns post date formating according to RFC 822. 250 250 251 251 @param rs Invisible parameter 252 252 @param type <b>string</b> (dt|upddt|creadt) defaults to post_dt … … 261 261 } 262 262 } 263 263 264 264 /** 265 265 Returns post date with <var>$format</var> as formatting pattern. If format 266 266 is empty, uses <var>date_format</var> blog setting. 267 267 268 268 @param rs Invisible parameter 269 269 @param format <b>string</b> Date format pattern … … 276 276 $format = $rs->core->blog->settings->system->date_format; 277 277 } 278 278 279 279 if ($type == 'upddt') { 280 280 return dt::dt2str($format,$rs->post_upddt,$rs->post_tz); … … 285 285 } 286 286 } 287 287 288 288 /** 289 289 Returns post time with <var>$format</var> as formatting pattern. If format 290 290 is empty, uses <var>time_format</var> blog setting. 291 291 292 292 @param rs Invisible parameter 293 293 @param format <b>string</b> Time format pattern … … 300 300 $format = $rs->core->blog->settings->system->time_format; 301 301 } 302 302 303 303 if ($type == 'upddt') { 304 304 return dt::dt2str($format,$rs->post_upddt,$rs->post_tz); … … 309 309 } 310 310 } 311 311 312 312 /** 313 313 Returns author common name using user_id, user_name, user_firstname and 314 314 user_displayname fields. 315 315 316 316 @param rs Invisible parameter 317 317 @return <b>string</b> … … 322 322 $rs->user_firstname, $rs->user_displayname); 323 323 } 324 324 325 325 /** 326 326 Returns author common name with a link if he specified one in its 327 327 preferences. 328 328 329 329 @param rs Invisible parameter 330 330 @return <b>string</b> … … 337 337 $res = '<a href="%2$s">%1$s</a>'; 338 338 } 339 339 340 340 return sprintf($res,html::escapeHTML($rs->getAuthorCN()),html::escapeHTML($url)); 341 341 } 342 342 343 343 /** 344 344 Returns author e-mail address. If <var>$encoded</var> is true, "@" sign is 345 345 replaced by "%40" and "." by "%2e". 346 346 347 347 @param rs Invisible parameter 348 348 @param encoded <b>boolean</b> Encode address. … … 356 356 return $rs->user_email; 357 357 } 358 358 359 359 /** 360 360 Returns post feed unique ID. 361 361 362 362 @param rs Invisible parameter 363 363 @return <b>string</b> … … 366 366 { 367 367 return 'urn:md5:'.md5($rs->core->blog->uid.$rs->post_id); 368 368 369 369 $url = parse_url($rs->core->blog->url); 370 370 $date_part = date('Y-m-d',strtotime($rs->post_creadt)); 371 371 372 372 return 'tag:'.$url['host'].','.$date_part.':'.$rs->post_id; 373 373 } 374 374 375 375 /** 376 376 Returns trackback RDF information block in HTML comment. 377 377 378 378 @param rs Invisible parameter 379 379 @return <b>string</b> … … 395 395 "<!]]><!---->\n"; 396 396 } 397 397 398 398 /** 399 399 Returns post trackback full URL. 400 400 401 401 @param rs Invisible parameter 402 402 @return <b>string</b> … … 406 406 return $rs->core->blog->url.$rs->core->url->getURLFor('trackback',$rs->post_id); 407 407 } 408 408 409 409 /** 410 410 Returns post content. If <var>$absolute_urls</var> is true, appends full 411 411 blog URL to each relative post URLs. 412 412 413 413 @param rs Invisible parameter 414 414 @param absolute_urls <b>boolean</b> With absolute URLs … … 423 423 } 424 424 } 425 425 426 426 /** 427 427 Returns post excerpt. If <var>$absolute_urls</var> is true, appends full 428 428 blog URL to each relative post URLs. 429 429 430 430 @param rs Invisible parameter 431 431 @param absolute_urls <b>boolean</b> With absolute URLs … … 440 440 } 441 441 } 442 442 443 443 /** 444 444 Returns post media count using a subquery. 445 445 446 446 @param rs Invisible parameter 447 447 @return <b>integer</b> … … 459 459 'FROM '.$rs->core->prefix.'post_media '. 460 460 'WHERE post_id = '.(integer) $rs->post_id.' '; 461 461 462 462 $res = (integer) $rs->core->con->select($strReq)->f(0); 463 463 $rs->_nb_media[$rs->index()] = $res; … … 483 483 Returns comment date with <var>$format</var> as formatting pattern. If 484 484 format is empty, uses <var>date_format</var> blog setting. 485 485 486 486 @param rs Invisible parameter 487 487 @param format <b>string</b> Date format pattern … … 494 494 $format = $rs->core->blog->settings->system->date_format; 495 495 } 496 496 497 497 if ($type == 'upddt') { 498 498 return dt::dt2str($format,$rs->comment_upddt,$rs->comment_tz); … … 501 501 } 502 502 } 503 503 504 504 /** 505 505 Returns comment time with <var>$format</var> as formatting pattern. If 506 506 format is empty, uses <var>time_format</var> blog setting. 507 507 508 508 @param rs Invisible parameter 509 509 @param format <b>string</b> Date format pattern … … 516 516 $format = $rs->core->blog->settings->system->time_format; 517 517 } 518 518 519 519 if ($type == 'upddt') { 520 520 return dt::dt2str($format,$rs->comment_updt,$rs->comment_tz); … … 523 523 } 524 524 } 525 525 526 526 /** 527 527 Returns comment timestamp. 528 528 529 529 @param rs Invisible parameter 530 530 @param type <b>string</b> (dt|upddt) defaults to comment_dt … … 539 539 } 540 540 } 541 541 542 542 /** 543 543 Returns comment date formating according to the ISO 8601 standard. 544 544 545 545 @param rs Invisible parameter 546 546 @param type <b>string</b> (dt|upddt) defaults to comment_dt … … 555 555 } 556 556 } 557 557 558 558 /** 559 559 Returns comment date formating according to RFC 822. 560 560 561 561 @param rs Invisible parameter 562 562 @param type <b>string</b> (dt|upddt) defaults to comment_dt … … 571 571 } 572 572 } 573 573 574 574 /** 575 575 Returns comment content. If <var>$absolute_urls</var> is true, appends full 576 576 blog URL to each relative post URLs. 577 577 578 578 @param rs Invisible parameter 579 579 @param absolute_urls <b>boolean</b> With absolute URLs … … 583 583 { 584 584 $res = $rs->comment_content; 585 585 586 586 if ($rs->core->blog->settings->system->comments_nofollow) { 587 587 $res = preg_replace_callback('#<a(.*?href=".*?".*?)>#ms',array('self','noFollowURL'),$res); 588 588 } 589 589 590 590 if ($absolute_urls) { 591 591 $res = html::absoluteURLs($res,$rs->getPostURL()); 592 592 } 593 593 594 594 return $res; 595 595 } 596 596 597 597 private static function noFollowURL($m) 598 598 { … … 600 600 return $m[0]; 601 601 } 602 602 603 603 return '<a'.$m[1].' rel="nofollow">'; 604 604 } 605 605 606 606 /** 607 607 Returns comment author link to his website if he specified one. 608 608 609 609 @param rs Invisible parameter 610 610 @return <b>string</b> … … 616 616 } 617 617 } 618 618 619 619 /** 620 620 Returns comment post full URL. 621 621 622 622 @param rs Invisible parameter 623 623 @return <b>string</b> … … 629 629 ); 630 630 } 631 631 632 632 /** 633 633 Returns comment author name in a link to his website if he specified one. 634 634 635 635 @param rs Invisible parameter 636 636 @return <b>string</b> … … 643 643 $res = '<a href="%2$s"%3$s>%1$s</a>'; 644 644 } 645 645 646 646 $nofollow = ''; 647 647 if ($rs->core->blog->settings->system->comments_nofollow) { 648 648 $nofollow = ' rel="nofollow"'; 649 649 } 650 650 651 651 return sprintf($res,html::escapeHTML($rs->comment_author),html::escapeHTML($url),$nofollow); 652 652 } 653 653 654 654 /** 655 655 Returns comment author e-mail address. If <var>$encoded</var> is true, 656 656 "@" sign is replaced by "%40" and "." by "%2e". 657 657 658 658 @param rs Invisible parameter 659 659 @param encoded <b>boolean</b> Encode address. … … 667 667 return $rs->comment_email; 668 668 } 669 669 670 670 /** 671 671 Returns trackback site title if comment is a trackback. 672 672 673 673 @param rs Invisible parameter 674 674 @return <b>string</b> … … 682 682 } 683 683 } 684 684 685 685 /** 686 686 Returns trackback content if comment is a trackback. 687 687 688 688 @param rs Invisible parameter 689 689 @return <b>string</b> … … 696 696 } 697 697 } 698 698 699 699 /** 700 700 Returns comment feed unique ID. 701 701 702 702 @param rs Invisible parameter 703 703 @return <b>string</b> … … 706 706 { 707 707 return 'urn:md5:'.md5($rs->core->blog->uid.$rs->comment_id); 708 708 709 709 $url = parse_url($rs->core->blog->url); 710 710 $date_part = date('Y-m-d',strtotime($rs->comment_dt)); 711 711 712 712 return 'tag:'.$url['host'].','.$date_part.':'.$rs->comment_id; 713 713 } 714 714 715 715 /** 716 716 Returns whether comment is from the post author. 717 717 718 718 @param rs Invisible parameter 719 719 @return <b>boolean</b> … … 748 748 return strtotime($rs->dt); 749 749 } 750 750 751 751 /** 752 752 @param rs Invisible parameter … … 757 757 return date('Y',strtotime($rs->dt)); 758 758 } 759 759 760 760 /** 761 761 @param rs Invisible parameter … … 766 766 return date('m',strtotime($rs->dt)); 767 767 } 768 768 769 769 /** 770 770 @param rs Invisible parameter … … 775 775 return date('d',strtotime($rs->dt)); 776 776 } 777 777 778 778 /** 779 779 Returns date month archive full URL. 780 780 781 781 @param rs Invisible parameter 782 782 @param core <b>dcCore</b> dcCore instance … … 786 786 { 787 787 $url = date('Y/m',strtotime($rs->dt)); 788 788 789 789 return $core->blog->url.$core->url->getURLFor('archive',$url); 790 790 } 791 791 792 792 /** 793 793 Returns whether date is the first of year. 794 794 795 795 @param rs Invisible parameter 796 796 @return <b>boolean</b> … … 801 801 return true; 802 802 } 803 803 804 804 $y = $rs->year(); 805 805 $rs->movePrev(); 806 806 $py = $rs->year(); 807 807 $rs->moveNext(); 808 808 809 809 return $y != $py; 810 810 } 811 811 812 812 /** 813 813 Returns whether date is the last of year. 814 814 815 815 @param rs Invisible parameter 816 816 @return <b>boolean</b> … … 821 821 return true; 822 822 } 823 823 824 824 $y = $rs->year(); 825 825 if ($rs->moveNext()) { … … 829 829 } 830 830 return false; 831 831 832 832 } 833 833 } … … 848 848 /** 849 849 Returns a user option. 850 850 851 851 @param rs Invisible parameter 852 852 @param name <b>string</b> Option name … … 856 856 { 857 857 $options = self::options($rs); 858 858 859 859 if (isset($options[$name])) { 860 860 return $options[$name]; … … 862 862 return null; 863 863 } 864 864 865 865 /** 866 866 Returns all user options. 867 867 868 868 @param rs Invisible parameter 869 869 @return <b>array</b> … … 878 878 } 879 879 } 880 ?>
Note: See TracChangeset
for help on using the changeset viewer.