Dotclear


Ignore:
Timestamp:
02/27/13 11:48:32 (13 years ago)
Author:
JcDenis
Branch:
sexy
Parents:
880:02c78f56f430 (diff), 1105:ce855d61f9ce (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.
Message:

merge with default branch in 2.5-RC

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.rs.extensions.php

    r852 r1107  
    117117      
    118118     /** 
     119     Returns whether post has been updated since publication. 
     120 
     121     @return <b>boolean</b> 
     122     */ 
     123     public static function isRepublished($rs) 
     124     { 
     125          return ($rs->getTS('upddt') + dt::getTimeOffset($rs->post_tz)) > $rs->getTS(); 
     126     } 
     127      
     128     /** 
    119129     Returns full post URL. 
    120130      
  • inc/core/class.dc.rs.extensions.php

    r912 r1107  
    117117      
    118118     /** 
    119      Returns whether comments are enabled on post. 
    120       
    121      @param    rs   Invisible parameter 
    122      @return   <b>boolean</b> 
    123      */ 
    124      public static function commentsActive($rs) 
    125      { 
    126           return 
    127           $rs->core->blog->settings->system->allow_comments 
    128           && $rs->post_open_comment 
    129           && ($rs->core->blog->settings->system->comments_ttl == 0 || 
    130           time()-($rs->core->blog->settings->system->comments_ttl*86400) < $rs->getTS()); 
    131      } 
    132       
    133      /** 
    134      Returns whether trackbacks are enabled on post. 
    135       
    136      @param    rs   Invisible parameter 
    137      @return   <b>boolean</b> 
    138      */ 
    139      public static function trackbacksActive($rs) 
    140      { 
    141           return 
    142           $rs->core->blog->settings->system->allow_trackbacks 
    143           && $rs->post_open_tb 
    144           && ($rs->core->blog->settings->system->trackbacks_ttl == 0 || 
    145           time()-($rs->core->blog->settings->system->trackbacks_ttl*86400) < $rs->getTS()); 
    146      } 
    147       
    148      /** 
    149      Returns whether post has at least one comment. 
    150       
    151      @param    rs   Invisible parameter 
    152      @return   <b>boolean</b> 
    153      */ 
    154      public static function hasComments($rs) 
    155      { 
    156           return $rs->nb_comment > 0; 
    157      } 
    158       
    159      /** 
    160      Returns whether post has at least one trackbacks. 
    161       
    162      @return   <b>boolean</b> 
    163      */ 
    164      public static function hasTrackbacks($rs) 
    165      { 
    166           return $rs->nb_trackback > 0; 
    167      } 
    168  
    169      /** 
    170119     Returns whether post has been updated since publication. 
    171120 
     
    188137                    $rs->post_type,html::sanitizeURL($rs->post_url) 
    189138               ); 
    190      } 
    191       
    192      /** 
    193      Returns full post category URL. 
    194       
    195      @param    rs   Invisible parameter 
    196      @return   <b>string</b> 
    197      */ 
    198      public static function getCategoryURL($rs) 
    199      { 
    200           return $rs->core->blog->url.$rs->core->url->getURLFor('category',html::sanitizeURL($rs->cat_url)); 
    201139     } 
    202140      
     
    374312      
    375313     /** 
    376      Returns trackback RDF information block in HTML comment. 
    377       
    378      @param    rs   Invisible parameter 
    379      @return   <b>string</b> 
    380      */ 
    381      public static function getTrackbackData($rs) 
    382      { 
    383           return 
    384           "<![CDATA[>\n". 
    385           "<!--[\n". 
    386           '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n". 
    387           '  xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n". 
    388           '  xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n". 
    389           "<rdf:Description\n". 
    390           '  rdf:about="'.$rs->getURL().'"'."\n". 
    391           '  dc:identifier="'.$rs->getURL().'"'."\n". 
    392           '  dc:title="'.htmlspecialchars($rs->post_title,ENT_COMPAT,'UTF-8').'"'."\n". 
    393           '  trackback:ping="'.$rs->getTrackbackLink().'" />'."\n". 
    394           "</rdf:RDF>\n". 
    395           "<!]]><!---->\n"; 
    396      } 
    397       
    398      /** 
    399      Returns post trackback full URL. 
    400       
    401      @param    rs   Invisible parameter 
    402      @return   <b>string</b> 
    403      */ 
    404      public static function getTrackbackLink($rs) 
    405      { 
    406           return $rs->core->blog->url.$rs->core->url->getURLFor('trackback',$rs->post_id); 
    407      } 
    408       
    409      /** 
    410314     Returns post content. If <var>$absolute_urls</var> is true, appends full 
    411315     blog URL to each relative post URLs. 
     
    441345     } 
    442346      
    443      /** 
    444      Returns post media count using a subquery. 
    445       
    446      @param    rs   Invisible parameter 
    447      @return   <b>integer</b> 
    448      */ 
    449      public static function countMedia($rs) 
    450      { 
    451           if (isset($rs->_nb_media[$rs->index()])) 
    452           { 
    453                return $rs->_nb_media[$rs->index()]; 
    454           } 
    455           else 
    456           { 
    457                $strReq = 
    458                'SELECT count(media_id) '. 
    459                'FROM '.$rs->core->prefix.'post_media '. 
    460                'WHERE post_id = '.(integer) $rs->post_id.' '; 
    461                 
    462                $res = (integer) $rs->core->con->select($strReq)->f(0); 
    463                $rs->_nb_media[$rs->index()] = $res; 
    464                return $res; 
    465           } 
    466      } 
    467 } 
    468  
    469 /** 
    470 @ingroup DC_CORE 
    471 @brief Dotclear comment record helpers. 
    472  
    473 This class adds new methods to database comment results. 
    474 You can call them on every record comming from dcBlog::getComments and similar 
    475 methods. 
    476  
    477 @warning You should not give the first argument (usualy $rs) of every described 
    478 function. 
    479 */ 
    480 class rsExtComment 
    481 { 
    482      /** 
    483      Returns comment date with <var>$format</var> as formatting pattern. If 
    484      format is empty, uses <var>date_format</var> blog setting. 
    485       
    486      @param    rs   Invisible parameter 
    487      @param    format    <b>string</b>       Date format pattern 
    488      @param    type <b>string</b>       (dt|upddt) defaults to comment_dt 
    489      @return   <b>string</b> 
    490      */ 
    491      public static function getDate($rs,$format,$type='') 
    492      { 
    493           if (!$format) { 
    494                $format = $rs->core->blog->settings->system->date_format; 
    495           } 
    496            
    497           if ($type == 'upddt') { 
    498                return dt::dt2str($format,$rs->comment_upddt,$rs->comment_tz); 
    499           } else { 
    500                return dt::dt2str($format,$rs->comment_dt); 
    501           } 
    502      } 
    503       
    504      /** 
    505      Returns comment time with <var>$format</var> as formatting pattern. If 
    506      format is empty, uses <var>time_format</var> blog setting. 
    507       
    508      @param    rs   Invisible parameter 
    509      @param    format    <b>string</b>       Date format pattern 
    510      @param    type <b>string</b>       (dt|upddt) defaults to comment_dt 
    511      @return   <b>string</b> 
    512      */ 
    513      public static function getTime($rs,$format,$type='') 
    514      { 
    515           if (!$format) { 
    516                $format = $rs->core->blog->settings->system->time_format; 
    517           } 
    518            
    519           if ($type == 'upddt') { 
    520                return dt::dt2str($format,$rs->comment_updt,$rs->comment_tz); 
    521           } else { 
    522                return dt::dt2str($format,$rs->comment_dt); 
    523           } 
    524      } 
    525       
    526      /** 
    527      Returns comment timestamp. 
    528       
    529      @param    rs   Invisible parameter 
    530      @param    type <b>string</b>       (dt|upddt) defaults to comment_dt 
    531      @return   <b>integer</b> 
    532      */ 
    533      public static function getTS($rs,$type='') 
    534      { 
    535           if ($type == 'upddt') { 
    536                return strtotime($rs->comment_upddt); 
    537           } else { 
    538                return strtotime($rs->comment_dt); 
    539           } 
    540      } 
    541       
    542      /** 
    543      Returns comment date formating according to the ISO 8601 standard. 
    544       
    545      @param    rs   Invisible parameter 
    546      @param    type <b>string</b>       (dt|upddt) defaults to comment_dt 
    547      @return   <b>string</b> 
    548      */ 
    549      public static function getISO8601Date($rs,$type='') 
    550      { 
    551           if ($type == 'upddt') { 
    552                return dt::iso8601($rs->getTS($type)+dt::getTimeOffset($rs->comment_tz),$rs->comment_tz); 
    553           } else { 
    554                return dt::iso8601($rs->getTS(),$rs->comment_tz); 
    555           } 
    556      } 
    557       
    558      /** 
    559      Returns comment date formating according to RFC 822. 
    560       
    561      @param    rs   Invisible parameter 
    562      @param    type <b>string</b>       (dt|upddt) defaults to comment_dt 
    563      @return   <b>string</b> 
    564      */ 
    565      public static function getRFC822Date($rs,$type='') 
    566      { 
    567           if ($type == 'upddt') { 
    568                return dt::rfc822($rs->getTS($type)+dt::getTimeOffset($rs->comment_tz),$rs->comment_tz); 
    569           } else { 
    570                return dt::rfc822($rs->getTS(),$rs->comment_tz); 
    571           } 
    572      } 
    573       
    574      /** 
    575      Returns comment content. If <var>$absolute_urls</var> is true, appends full 
    576      blog URL to each relative post URLs. 
    577       
    578      @param    rs   Invisible parameter 
    579      @param    absolute_urls  <b>boolean</b>      With absolute URLs 
    580      @return   <b>string</b> 
    581      */ 
    582      public static function getContent($rs,$absolute_urls=false) 
    583      { 
    584           $res = $rs->comment_content; 
    585            
    586           if ($rs->core->blog->settings->system->comments_nofollow) { 
    587                $res = preg_replace_callback('#<a(.*?href=".*?".*?)>#ms',array('self','noFollowURL'),$res); 
    588           } 
    589            
    590           if ($absolute_urls) { 
    591                $res = html::absoluteURLs($res,$rs->getPostURL()); 
    592           } 
    593            
    594           return $res; 
    595      } 
    596       
    597      private static function noFollowURL($m) 
    598      { 
    599           if (preg_match('/rel="nofollow"/',$m[1])) { 
    600                return $m[0]; 
    601           } 
    602            
    603           return '<a'.$m[1].' rel="nofollow">'; 
    604      } 
    605       
    606      /** 
    607      Returns comment author link to his website if he specified one. 
    608       
    609      @param    rs   Invisible parameter 
    610      @return   <b>string</b> 
    611      */ 
    612      public static function getAuthorURL($rs) 
    613      { 
    614           if (trim($rs->comment_site)) { 
    615                return trim($rs->comment_site); 
    616           } 
    617      } 
    618       
    619      /** 
    620      Returns comment post full URL. 
    621       
    622      @param    rs   Invisible parameter 
    623      @return   <b>string</b> 
    624      */ 
    625      public static function getPostURL($rs) 
    626      { 
    627           return $rs->core->blog->url.$rs->core->getPostPublicURL( 
    628                     $rs->post_type,html::sanitizeURL($rs->post_url) 
    629                ); 
    630      } 
    631       
    632      /** 
    633      Returns comment author name in a link to his website if he specified one. 
    634       
    635      @param    rs   Invisible parameter 
    636      @return   <b>string</b> 
    637      */ 
    638      public static function getAuthorLink($rs) 
    639      { 
    640           $res = '%1$s'; 
    641           $url = $rs->getAuthorURL(); 
    642           if ($url) { 
    643                $res = '<a href="%2$s"%3$s>%1$s</a>'; 
    644           } 
    645            
    646           $nofollow = ''; 
    647           if ($rs->core->blog->settings->system->comments_nofollow) { 
    648                $nofollow = ' rel="nofollow"'; 
    649           } 
    650            
    651           return sprintf($res,html::escapeHTML($rs->comment_author),html::escapeHTML($url),$nofollow); 
    652      } 
    653       
    654      /** 
    655      Returns comment author e-mail address. If <var>$encoded</var> is true, 
    656      "@" sign is replaced by "%40" and "." by "%2e". 
    657       
    658      @param    rs   Invisible parameter 
    659      @param    encoded   <b>boolean</b>      Encode address. 
    660      @return   <b>string</b> 
    661      */ 
    662      public static function getEmail($rs,$encoded=true) 
    663      { 
    664           if ($encoded) { 
    665                return strtr($rs->comment_email,array('@'=>'%40','.'=>'%2e')); 
    666           } 
    667           return $rs->comment_email; 
    668      } 
    669       
    670      /** 
    671      Returns trackback site title if comment is a trackback. 
    672       
    673      @param    rs   Invisible parameter 
    674      @return   <b>string</b> 
    675      */ 
    676      public static function getTrackbackTitle($rs) 
    677      { 
    678           if ($rs->comment_trackback == 1 && 
    679           preg_match('|<p><strong>(.*?)</strong></p>|msU',$rs->comment_content, 
    680           $match)) { 
    681                return html::decodeEntities($match[1]); 
    682           } 
    683      } 
    684       
    685      /** 
    686      Returns trackback content if comment is a trackback. 
    687       
    688      @param    rs   Invisible parameter 
    689      @return   <b>string</b> 
    690      */ 
    691      public static function getTrackbackContent($rs) 
    692      { 
    693           if ($rs->comment_trackback == 1) { 
    694                return preg_replace('|<p><strong>.*?</strong></p>|msU','', 
    695                $rs->comment_content); 
    696           } 
    697      } 
    698       
    699      /** 
    700      Returns comment feed unique ID. 
    701       
    702      @param    rs   Invisible parameter 
    703      @return   <b>string</b> 
    704      */ 
    705      public static function getFeedID($rs) 
    706      { 
    707           return 'urn:md5:'.md5($rs->core->blog->uid.$rs->comment_id); 
    708            
    709           $url = parse_url($rs->core->blog->url); 
    710           $date_part = date('Y-m-d',strtotime($rs->comment_dt)); 
    711            
    712           return 'tag:'.$url['host'].','.$date_part.':'.$rs->comment_id; 
    713      } 
    714       
    715      /** 
    716      Returns whether comment is from the post author. 
    717       
    718      @param    rs   Invisible parameter 
    719      @return   <b>boolean</b> 
    720      */ 
    721      public static function isMe($rs) 
    722      { 
    723           return 
    724           $rs->comment_email && $rs->comment_site && 
    725           $rs->comment_email == $rs->user_email && 
    726           $rs->comment_site == $rs->user_url; 
    727      } 
    728347} 
    729348 
Note: See TracChangeset for help on using the changeset viewer.

Sites map