Dotclear


Ignore:
Timestamp:
07/31/12 13:18:23 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
sexy
Message:

sexy step 1 : no more comments ...

Location:
inc/public
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/public/class.dc.template.php

    r833 r848  
    3232          $this->core =& $core; 
    3333           
    34           # Transitional tags 
    35           $this->addValue('EntryTrackbackCount',array($this,'EntryPingCount')); 
    36           $this->addValue('EntryTrackbackData',array($this,'EntryPingData')); 
    37           $this->addValue('EntryTrackbackLink',array($this,'EntryPingLink')); 
    38            
    3934          # l10n 
    4035          $this->addValue('lang',array($this,'l10n')); 
     
    8580          $this->addValue('CategoryDescription',array($this,'CategoryDescription')); 
    8681          $this->addValue('CategoryTitle',array($this,'CategoryTitle')); 
    87            
    88           # Comments 
    89           $this->addBlock('Comments',array($this,'Comments')); 
    90           $this->addValue('CommentAuthor',array($this,'CommentAuthor')); 
    91           $this->addValue('CommentAuthorDomain',array($this,'CommentAuthorDomain')); 
    92           $this->addValue('CommentAuthorLink',array($this,'CommentAuthorLink')); 
    93           $this->addValue('CommentAuthorMailMD5',array($this,'CommentAuthorMailMD5')); 
    94           $this->addValue('CommentAuthorURL',array($this,'CommentAuthorURL')); 
    95           $this->addValue('CommentContent',array($this,'CommentContent')); 
    96           $this->addValue('CommentDate',array($this,'CommentDate')); 
    97           $this->addValue('CommentTime',array($this,'CommentTime')); 
    98           $this->addValue('CommentEmail',array($this,'CommentEmail')); 
    99           $this->addValue('CommentEntryTitle',array($this,'CommentEntryTitle')); 
    100           $this->addValue('CommentFeedID',array($this,'CommentFeedID')); 
    101           $this->addValue('CommentID',array($this,'CommentID')); 
    102           $this->addBlock('CommentIf',array($this,'CommentIf')); 
    103           $this->addValue('CommentIfFirst',array($this,'CommentIfFirst')); 
    104           $this->addValue('CommentIfMe',array($this,'CommentIfMe')); 
    105           $this->addValue('CommentIfOdd',array($this,'CommentIfOdd')); 
    106           $this->addValue('CommentIP',array($this,'CommentIP')); 
    107           $this->addValue('CommentOrderNumber',array($this,'CommentOrderNumber')); 
    108           $this->addBlock('CommentsFooter',array($this,'CommentsFooter')); 
    109           $this->addBlock('CommentsHeader',array($this,'CommentsHeader')); 
    110           $this->addValue('CommentPostURL',array($this,'CommentPostURL')); 
    111           $this->addBlock('IfCommentAuthorEmail',array($this,'IfCommentAuthorEmail')); 
    112           $this->addValue('CommentHelp',array($this,'CommentHelp')); 
    113            
    114           # Comment preview 
    115           $this->addBlock('IfCommentPreview',array($this,'IfCommentPreview')); 
    116           $this->addValue('CommentPreviewName',array($this,'CommentPreviewName')); 
    117           $this->addValue('CommentPreviewEmail',array($this,'CommentPreviewEmail')); 
    118           $this->addValue('CommentPreviewSite',array($this,'CommentPreviewSite')); 
    119           $this->addValue('CommentPreviewContent',array($this,'CommentPreviewContent')); 
    120           $this->addValue('CommentPreviewCheckRemember',array($this,'CommentPreviewCheckRemember')); 
    12182           
    12283          # Entries 
     
    139100          $this->addValue('EntryCategoryURL',array($this,'EntryCategoryURL')); 
    140101          $this->addValue('EntryCategoryShortURL',array($this,'EntryCategoryShortURL')); 
    141           $this->addValue('EntryCommentCount',array($this,'EntryCommentCount')); 
    142102          $this->addValue('EntryContent',array($this,'EntryContent')); 
    143103          $this->addValue('EntryDate',array($this,'EntryDate')); 
     
    151111          $this->addValue('EntryLang',array($this,'EntryLang')); 
    152112          $this->addBlock('EntryNext',array($this,'EntryNext')); 
    153           $this->addValue('EntryPingCount',array($this,'EntryPingCount')); 
    154           $this->addValue('EntryPingData',array($this,'EntryPingData')); 
    155           $this->addValue('EntryPingLink',array($this,'EntryPingLink')); 
    156113          $this->addBlock('EntryPrevious',array($this,'EntryPrevious')); 
    157114          $this->addValue('EntryTitle',array($this,'EntryTitle')); 
     
    174131          $this->addValue('PaginationURL',array($this,'PaginationURL')); 
    175132           
    176           # Trackbacks 
    177           $this->addValue('PingBlogName',array($this,'PingBlogName')); 
    178           $this->addValue('PingContent',array($this,'PingContent')); 
    179           $this->addValue('PingDate',array($this,'PingDate')); 
    180           $this->addValue('PingEntryTitle',array($this,'PingEntryTitle')); 
    181           $this->addValue('PingFeedID',array($this,'PingFeedID')); 
    182           $this->addValue('PingID',array($this,'PingID')); 
    183           $this->addValue('PingIfFirst',array($this,'PingIfFirst')); 
    184           $this->addValue('PingIfOdd',array($this,'PingIfOdd')); 
    185           $this->addValue('PingIP',array($this,'PingIP')); 
    186           $this->addValue('PingNoFollow',array($this,'PingNoFollow')); 
    187           $this->addValue('PingOrderNumber',array($this,'PingOrderNumber')); 
    188           $this->addValue('PingPostURL',array($this,'PingPostURL')); 
    189           $this->addBlock('Pings',array($this,'Pings')); 
    190           $this->addBlock('PingsFooter',array($this,'PingsFooter')); 
    191           $this->addBlock('PingsHeader',array($this,'PingsHeader')); 
    192           $this->addValue('PingTime',array($this,'PingTime')); 
    193           $this->addValue('PingTitle',array($this,'PingTitle')); 
    194           $this->addValue('PingAuthorURL',array($this,'PingAuthorURL')); 
    195            
    196133          # System 
    197134          $this->addValue('SysBehavior',array($this,'SysBehavior')); 
    198135          $this->addBlock('SysIf',array($this,'SysIf')); 
    199           $this->addBlock('SysIfCommentPublished',array($this,'SysIfCommentPublished')); 
    200           $this->addBlock('SysIfCommentPending',array($this,'SysIfCommentPending')); 
    201136          $this->addBlock('SysIfFormError',array($this,'SysIfFormError')); 
    202137          $this->addValue('SysFeedSubtitle',array($this,'SysFeedSubtitle')); 
     
    430365                    'date' => 'post_dt', 
    431366                    'id' => 'post_id', 
    432                     'comment' => 'nb_comment', 
    433                     'trackback' => 'nb_trackback' 
    434                ), 
    435                'comment' => array( 
    436                     'author' => 'comment_author', 
    437                     'date' => 'comment_dt', 
    438                     'id' => 'comment_id' 
    439367               ) 
    440368          ); 
     
    12651193     has_category   (0|1)     #IMPLIED  -- post has a category (value : 1) or not (value : 0) 
    12661194     has_attachment (0|1)     #IMPLIED  -- post has attachments (value : 1) or not (value : 0) (see Attachment plugin for code) 
    1267      comments_active     (0|1)     #IMPLIED  -- comments are active for this post (value : 1) or not (value : 0) 
    1268      pings_active   (0|1)     #IMPLIED  -- trackbacks are active for this post (value : 1) or not (value : 0) 
    1269      show_comments  (0|1)     #IMPLIED  -- there are comments for this post (value : 1) or not (value : 0) 
    1270      show_pings     (0|1)     #IMPLIED  -- there are trackbacks for this post (value : 1) or not (value : 0) 
    12711195     operator  (and|or)  #IMPLIED  -- combination of conditions, if more than 1 specifiec (default: and) 
    12721196     url       CDATA     #IMPLIED  -- post has given url 
     
    13321256          } 
    13331257           
    1334           if (isset($attr['comments_active'])) { 
    1335                $sign = (boolean) $attr['comments_active'] ? '' : '!'; 
    1336                $if[] = $sign.'$_ctx->posts->commentsActive()'; 
    1337           } 
    1338            
    1339           if (isset($attr['pings_active'])) { 
    1340                $sign = (boolean) $attr['pings_active'] ? '' : '!'; 
    1341                $if[] = $sign.'$_ctx->posts->trackbacksActive()'; 
    1342           } 
    1343            
    1344           if (isset($attr['has_comment'])) { 
    1345                $sign = (boolean) $attr['has_comment'] ? '' : '!'; 
    1346                $if[] = $sign.'$_ctx->posts->hasComments()'; 
    1347           } 
    1348            
    1349           if (isset($attr['has_ping'])) { 
    1350                $sign = (boolean) $attr['has_ping'] ? '' : '!'; 
    1351                $if[] = $sign.'$_ctx->posts->hasTrackbacks()'; 
    1352           } 
    1353            
    1354           if (isset($attr['show_comments'])) { 
    1355                if ((boolean) $attr['show_comments']) { 
    1356                     $if[] = '($_ctx->posts->hasComments() || $_ctx->posts->commentsActive())'; 
    1357                } else { 
    1358                     $if[] = '(!$_ctx->posts->hasComments() && !$_ctx->posts->commentsActive())'; 
    1359                } 
    1360           } 
    1361            
    1362           if (isset($attr['show_pings'])) { 
    1363                if ((boolean) $attr['show_pings']) { 
    1364                     $if[] = '($_ctx->posts->hasTrackbacks() || $_ctx->posts->trackbacksActive())'; 
    1365                } else { 
    1366                     $if[] = '(!$_ctx->posts->hasTrackbacks() && !$_ctx->posts->trackbacksActive())'; 
    1367                } 
    1368           } 
    1369            
    13701258          $this->core->callBehavior('tplIfConditions','EntryIf',$attr,$content,$if); 
    13711259           
    13721260          if (count($if) != 0) { 
    13731261               return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; 
    1374           } else { 
     1262          } /* 
     1263          else { 
     1264               // Nothing in if statement => do not display content... 
    13751265               return $content; 
    13761266          } 
     1267          */ 
    13771268     } 
    13781269      
     
    17761667     } 
    17771668      
    1778      /*dtd 
    1779      <!ELEMENT tpl:EntryCommentCount - O -- Number of comments for entry --> 
    1780      <!ATTLIST tpl:EntryCommentCount 
    1781      none      CDATA     #IMPLIED  -- text to display for "no comment" (default: no comment) 
    1782      one       CDATA     #IMPLIED  -- text to display for "one comment" (default: one comment) 
    1783      more      CDATA     #IMPLIED  -- text to display for "more comments" (default: %s comments, %s is replaced by the number of comment) 
    1784      count_all CDATA     #IMPLIED  -- count comments and trackbacks 
    1785      > 
    1786      */ 
    1787      public function EntryCommentCount($attr) 
    1788      { 
    1789           $none = 'no comment'; 
    1790           $one = 'one comment'; 
    1791           $more = '%d comments'; 
    1792            
    1793           if (isset($attr['none'])) { 
    1794                $none = addslashes($attr['none']); 
    1795           } 
    1796           if (isset($attr['one'])) { 
    1797                $one = addslashes($attr['one']); 
    1798           } 
    1799           if (isset($attr['more'])) { 
    1800                $more = addslashes($attr['more']); 
    1801           } 
    1802            
    1803           if (empty($attr['count_all'])) { 
    1804                $operation = '$_ctx->posts->nb_comment'; 
    1805           } else { 
    1806                $operation = '($_ctx->posts->nb_comment + $_ctx->posts->nb_trackback)'; 
    1807           } 
    1808            
    1809           return 
    1810           "<?php if (".$operation." == 0) {\n". 
    1811           "  printf(__('".$none."'),".$operation.");\n". 
    1812           "} elseif (".$operation." == 1) {\n". 
    1813           "  printf(__('".$one."'),".$operation.");\n". 
    1814           "} else {\n". 
    1815           "  printf(__('".$more."'),".$operation.");\n". 
    1816           "} ?>"; 
    1817      } 
    1818       
    1819      /*dtd 
    1820      <!ELEMENT tpl:EntryPingCount - O -- Number of trackbacks for entry --> 
    1821      <!ATTLIST tpl:EntryPingCount 
    1822      none CDATA     #IMPLIED  -- text to display for "no ping" (default: no ping) 
    1823      one  CDATA     #IMPLIED  -- text to display for "one ping" (default: one ping) 
    1824      more CDATA     #IMPLIED  -- text to display for "more pings" (default: %s trackbacks, %s is replaced by the number of pings) 
    1825      > 
    1826      */ 
    1827      public function EntryPingCount($attr) 
    1828      { 
    1829           $none = 'no trackback'; 
    1830           $one = 'one trackback'; 
    1831           $more = '%d trackbacks'; 
    1832            
    1833           if (isset($attr['none'])) { 
    1834                $none = addslashes($attr['none']); 
    1835           } 
    1836           if (isset($attr['one'])) { 
    1837                $one = addslashes($attr['one']); 
    1838           } 
    1839           if (isset($attr['more'])) { 
    1840                $more = addslashes($attr['more']); 
    1841           } 
    1842            
    1843           return 
    1844           "<?php if (\$_ctx->posts->nb_trackback == 0) {\n". 
    1845           "  printf(__('".$none."'),(integer) \$_ctx->posts->nb_trackback);\n". 
    1846           "} elseif (\$_ctx->posts->nb_trackback == 1) {\n". 
    1847           "  printf(__('".$one."'),(integer) \$_ctx->posts->nb_trackback);\n". 
    1848           "} else {\n". 
    1849           "  printf(__('".$more."'),(integer) \$_ctx->posts->nb_trackback);\n". 
    1850           "} ?>"; 
    1851      } 
    1852       
    1853      /*dtd 
    1854      <!ELEMENT tpl:EntryPingData - O -- Display trackback RDF information --> 
    1855      */ 
    1856      public function EntryPingData($attr) 
    1857      { 
    1858           return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackData(); } ?>\n"; 
    1859      } 
    1860       
    1861      /*dtd 
    1862      <!ELEMENT tpl:EntryPingLink - O -- Entry trackback link --> 
    1863      */ 
    1864      public function EntryPingLink($attr) 
    1865      { 
    1866           return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackLink(); } ?>\n"; 
    1867      } 
    1868       
    18691669     /* Languages -------------------------------------- */ 
    18701670     /*dtd 
     
    20521852          $f = $this->getFilters($attr); 
    20531853          return '<?php echo '.sprintf($f,"context::PaginationURL(".$offset.")").'; ?>'; 
    2054      } 
    2055       
    2056      /* Comments --------------------------------------- */ 
    2057      /*dtd 
    2058      <!ELEMENT tpl:Comments - - -- Comments container --> 
    2059      <!ATTLIST tpl:Comments 
    2060      with_pings     (0|1)     #IMPLIED  -- include trackbacks in request 
    2061      lastn     CDATA     #IMPLIED  -- restrict the number of entries  
    2062      no_context (1|0)         #IMPLIED  -- Override context information 
    2063      sortby    (title|selected|author|date|id)    #IMPLIED  -- specify comments sort criteria (default : date) (multiple comma-separated sortby can be specified. Use "?asc" or "?desc" as suffix to provide an order for each sorby) 
    2064      order     (desc|asc)     #IMPLIED  -- result ordering (default: asc) 
    2065      age       CDATA     #IMPLIED  -- retrieve comments by maximum age (ex: -2 days, last month, last week) 
    2066      > 
    2067      */ 
    2068      public function Comments($attr,$content) 
    2069      { 
    2070           $p = ""; 
    2071           if (empty($attr['with_pings'])) { 
    2072                $p .= "\$params['comment_trackback'] = false;\n"; 
    2073           } 
    2074            
    2075           $lastn = 0; 
    2076           if (isset($attr['lastn'])) { 
    2077                $lastn = abs((integer) $attr['lastn'])+0; 
    2078           } 
    2079            
    2080           if ($lastn > 0) { 
    2081                $p .= "\$params['limit'] = ".$lastn.";\n"; 
    2082           } else { 
    2083                $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n"; 
    2084           } 
    2085            
    2086           if (empty($attr['no_context'])) 
    2087           { 
    2088                $p .= 
    2089                "if (\$_ctx->posts !== null) { ". 
    2090                     "\$params['post_id'] = \$_ctx->posts->post_id; ". 
    2091                     "\$core->blog->withoutPassword(false);\n". 
    2092                "}\n"; 
    2093                $p .= 
    2094                'if ($_ctx->exists("categories")) { '. 
    2095                     "\$params['cat_id'] = \$_ctx->categories->cat_id; ". 
    2096                "}\n"; 
    2097                 
    2098                $p .= 
    2099                'if ($_ctx->exists("langs")) { '. 
    2100                     "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ". 
    2101                "}\n"; 
    2102           } 
    2103            
    2104           if (!isset($attr['order'])) { 
    2105                $attr['order'] = 'asc'; 
    2106           } 
    2107            
    2108           $p .= "\$params['order'] = '".$this->getSortByStr($attr,'comment')."';\n"; 
    2109            
    2110           if (isset($attr['no_content']) && $attr['no_content']) { 
    2111                $p .= "\$params['no_content'] = true;\n"; 
    2112           } 
    2113            
    2114           if (isset($attr['age'])) { 
    2115                $age = $this->getAge($attr); 
    2116                $p .= !empty($age) ? "@\$params['sql'] .= ' AND P.post_dt > \'".$age."\'';\n" : ''; 
    2117           } 
    2118            
    2119           $res = "<?php\n"; 
    2120           $res .= $this->core->callBehavior("templatePrepareParams",  
    2121                array("tag" => "Comments","method" => "blog::getComments"),  
    2122                $attr,$content); 
    2123           $res .= $p; 
    2124           $res .= '$_ctx->comments = $core->blog->getComments($params); unset($params);'."\n"; 
    2125           $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n"; 
    2126            
    2127           if (!empty($attr['with_pings'])) { 
    2128                $res .= '$_ctx->pings = $_ctx->comments;'."\n"; 
    2129           } 
    2130            
    2131           $res .= "?>\n"; 
    2132            
    2133           $res .= 
    2134           '<?php while ($_ctx->comments->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->comments = null; ?>'; 
    2135            
    2136           return $res; 
    2137      } 
    2138       
    2139      /*dtd 
    2140      <!ELEMENT tpl:CommentAuthor - O -- Comment author --> 
    2141      */ 
    2142      public function CommentAuthor($attr) 
    2143      { 
    2144           $f = $this->getFilters($attr); 
    2145           return '<?php echo '.sprintf($f,"\$_ctx->comments->comment_author").'; ?>'; 
    2146      } 
    2147       
    2148      /*dtd 
    2149      <!ELEMENT tpl:CommentAuthorDomain - O -- Comment author website domain --> 
    2150      */ 
    2151      public function CommentAuthorDomain($attr) 
    2152      { 
    2153           return '<?php echo preg_replace("#^http(?:s?)://(.+?)/.*$#msu",\'$1\',$_ctx->comments->comment_site); ?>'; 
    2154      } 
    2155       
    2156      /*dtd 
    2157      <!ELEMENT tpl:CommentAuthorLink - O -- Comment author link --> 
    2158      */ 
    2159      public function CommentAuthorLink($attr) 
    2160      { 
    2161           $f = $this->getFilters($attr); 
    2162           return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorLink()').'; ?>'; 
    2163      } 
    2164       
    2165      /*dtd 
    2166      <!ELEMENT tpl:CommentAuthorMailMD5 - O -- Comment author email MD5 sum --> 
    2167      */ 
    2168      public function CommentAuthorMailMD5($attr) 
    2169      { 
    2170           return '<?php echo md5($_ctx->comments->comment_email) ; ?>'; 
    2171      } 
    2172       
    2173      /*dtd 
    2174      <!ELEMENT tpl:CommentAuthorURL - O -- Comment author URL --> 
    2175      */ 
    2176      public function CommentAuthorURL($attr) 
    2177      { 
    2178           $f = $this->getFilters($attr); 
    2179           return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorURL()').'; ?>'; 
    2180      } 
    2181       
    2182      /*dtd 
    2183      <!ELEMENT tpl:CommentContent - O --  Comment content --> 
    2184      <!ATTLIST tpl:CommentContent 
    2185      absolute_urls  (0|1)     #IMPLIED  -- convert URLS to absolute urls 
    2186      > 
    2187      */ 
    2188      public function CommentContent($attr) 
    2189      { 
    2190           $urls = '0'; 
    2191           if (!empty($attr['absolute_urls'])) { 
    2192                $urls = '1'; 
    2193           } 
    2194            
    2195           $f = $this->getFilters($attr); 
    2196           return '<?php echo '.sprintf($f,'$_ctx->comments->getContent('.$urls.')').'; ?>'; 
    2197      } 
    2198       
    2199      /*dtd 
    2200      <!ELEMENT tpl:CommentDate - O -- Comment date --> 
    2201      <!ATTLIST tpl:CommentDate 
    2202      format    CDATA     #IMPLIED  -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified) 
    2203      iso8601   CDATA     #IMPLIED  -- if set, tells that date format is ISO 8601 
    2204      rfc822    CDATA     #IMPLIED  -- if set, tells that date format is RFC 822 
    2205      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time 
    2206      > 
    2207      */ 
    2208      public function CommentDate($attr) 
    2209      { 
    2210           $format = ''; 
    2211           if (!empty($attr['format'])) { 
    2212                $format = addslashes($attr['format']); 
    2213           } 
    2214            
    2215           $iso8601 = !empty($attr['iso8601']); 
    2216           $rfc822 = !empty($attr['rfc822']); 
    2217           $type = (!empty($attr['upddt']) ? 'upddt' : ''); 
    2218            
    2219           $f = $this->getFilters($attr); 
    2220            
    2221           if ($rfc822) { 
    2222                return '<?php echo '.sprintf($f,"\$_ctx->comments->getRFC822Date('".$type."')").'; ?>'; 
    2223           } elseif ($iso8601) { 
    2224                return '<?php echo '.sprintf($f,"\$_ctx->comments->getISO8601Date('".$type."')").'; ?>'; 
    2225           } else { 
    2226                return '<?php echo '.sprintf($f,"\$_ctx->comments->getDate('".$format."','".$type."')").'; ?>'; 
    2227           } 
    2228      } 
    2229       
    2230      /*dtd 
    2231      <!ELEMENT tpl:CommentTime - O -- Comment date --> 
    2232      <!ATTLIST tpl:CommentTime 
    2233      format    CDATA     #IMPLIED  -- time format  
    2234      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time 
    2235      > 
    2236      */ 
    2237      public function CommentTime($attr) 
    2238      { 
    2239           $format = ''; 
    2240           if (!empty($attr['format'])) { 
    2241                $format = addslashes($attr['format']); 
    2242           } 
    2243           $type = (!empty($attr['upddt']) ? 'upddt' : ''); 
    2244          
    2245           $f = $this->getFilters($attr); 
    2246           return '<?php echo '.sprintf($f,"\$_ctx->comments->getTime('".$format."','".$type."')").'; ?>'; 
    2247      } 
    2248       
    2249      /*dtd 
    2250      <!ELEMENT tpl:CommentEmail - O -- Comment author email --> 
    2251      <!ATTLIST tpl:CommentEmail 
    2252      spam_protected (0|1)     #IMPLIED  -- protect email from spam (default: 1) 
    2253      > 
    2254      */ 
    2255      public function CommentEmail($attr) 
    2256      { 
    2257           $p = 'true'; 
    2258           if (isset($attr['spam_protected']) && !$attr['spam_protected']) { 
    2259                $p = 'false'; 
    2260           } 
    2261            
    2262           $f = $this->getFilters($attr); 
    2263           return '<?php echo '.sprintf($f,"\$_ctx->comments->getEmail(".$p.")").'; ?>'; 
    2264      } 
    2265       
    2266      /*dtd 
    2267      <!ELEMENT tpl:CommentEntryTitle - O -- Title of the comment entry --> 
    2268      */ 
    2269      public function CommentEntryTitle($attr) 
    2270      { 
    2271           $f = $this->getFilters($attr); 
    2272           return '<?php echo '.sprintf($f,'$_ctx->comments->post_title').'; ?>'; 
    2273      } 
    2274       
    2275      /*dtd 
    2276      <!ELEMENT tpl:CommentFeedID - O -- Comment feed ID --> 
    2277      */ 
    2278      public function CommentFeedID($attr) 
    2279      { 
    2280           $f = $this->getFilters($attr); 
    2281           return '<?php echo '.sprintf($f,'$_ctx->comments->getFeedID()').'; ?>'; 
    2282      } 
    2283       
    2284      /*dtd 
    2285      <!ELEMENT tpl:CommentID - O -- Comment ID --> 
    2286      */ 
    2287      public function CommentID($attr) 
    2288      { 
    2289           return '<?php echo $_ctx->comments->comment_id; ?>'; 
    2290      } 
    2291      
    2292      /*dtd 
    2293      <!ELEMENT tpl:CommentIf - - -- test container for comments --> 
    2294      <!ATTLIST tpl:CommentIf 
    2295      is_ping   (0|1)     #IMPLIED  -- test if comment is a trackback (value : 1) or not (value : 0) 
    2296      > 
    2297      */ 
    2298      public function CommentIf($attr,$content) 
    2299      { 
    2300           $if = array(); 
    2301           $is_ping = null; 
    2302            
    2303           if (isset($attr['is_ping'])) { 
    2304                $sign = (boolean) $attr['is_ping'] ? '' : '!'; 
    2305                $if[] = $sign.'$_ctx->comments->comment_trackback'; 
    2306           } 
    2307            
    2308           $this->core->callBehavior('tplIfConditions','CommentIf',$attr,$content,$if); 
    2309            
    2310           if (count($if) != 0) { 
    2311                return '<?php if('.implode(' && ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; 
    2312           } else { 
    2313                return $content; 
    2314           } 
    2315      } 
    2316       
    2317      /*dtd 
    2318      <!ELEMENT tpl:CommentIfFirst - O -- displays value if comment is the first one --> 
    2319      <!ATTLIST tpl:CommentIfFirst 
    2320      return    CDATA     #IMPLIED  -- value to display in case of success (default: first) 
    2321      > 
    2322      */ 
    2323      public function CommentIfFirst($attr) 
    2324      { 
    2325           $ret = isset($attr['return']) ? $attr['return'] : 'first'; 
    2326           $ret = html::escapeHTML($ret); 
    2327            
    2328           return 
    2329           '<?php if ($_ctx->comments->index() == 0) { '. 
    2330           "echo '".addslashes($ret)."'; } ?>"; 
    2331      } 
    2332       
    2333      /*dtd 
    2334      <!ELEMENT tpl:CommentIfMe - O -- displays value if comment is the from the entry author --> 
    2335      <!ATTLIST tpl:CommentIfMe 
    2336      return    CDATA     #IMPLIED  -- value to display in case of success (default: me) 
    2337      > 
    2338      */ 
    2339      public function CommentIfMe($attr) 
    2340      { 
    2341           $ret = isset($attr['return']) ? $attr['return'] : 'me'; 
    2342           $ret = html::escapeHTML($ret); 
    2343            
    2344           return 
    2345           '<?php if ($_ctx->comments->isMe()) { '. 
    2346           "echo '".addslashes($ret)."'; } ?>"; 
    2347      } 
    2348       
    2349      /*dtd 
    2350      <!ELEMENT tpl:CommentIfOdd - O -- displays value if comment is  at an odd position --> 
    2351      <!ATTLIST tpl:CommentIfOdd 
    2352      return    CDATA     #IMPLIED  -- value to display in case of success (default: odd) 
    2353      > 
    2354      */ 
    2355      public function CommentIfOdd($attr) 
    2356      { 
    2357           $ret = isset($attr['return']) ? $attr['return'] : 'odd'; 
    2358           $ret = html::escapeHTML($ret); 
    2359            
    2360           return 
    2361           '<?php if (($_ctx->comments->index()+1)%2) { '. 
    2362           "echo '".addslashes($ret)."'; } ?>"; 
    2363      } 
    2364       
    2365      /*dtd 
    2366      <!ELEMENT tpl:CommentIP - O -- Comment author IP --> 
    2367      */ 
    2368      public function CommentIP($attr) 
    2369      { 
    2370           return '<?php echo $_ctx->comments->comment_ip; ?>'; 
    2371      } 
    2372       
    2373      /*dtd 
    2374      <!ELEMENT tpl:CommentOrderNumber - O -- Comment order in page --> 
    2375      */ 
    2376      public function CommentOrderNumber($attr) 
    2377      { 
    2378           return '<?php echo $_ctx->comments->index()+1; ?>'; 
    2379      } 
    2380       
    2381      /*dtd 
    2382      <!ELEMENT tpl:CommentsFooter - - -- Last comments result container --> 
    2383      */ 
    2384      public function CommentsFooter($attr,$content) 
    2385      { 
    2386           return 
    2387           "<?php if (\$_ctx->comments->isEnd()) : ?>". 
    2388           $content. 
    2389           "<?php endif; ?>"; 
    2390      } 
    2391       
    2392      /*dtd 
    2393      <!ELEMENT tpl:CommentsHeader - - -- First comments result container --> 
    2394      */ 
    2395      public function CommentsHeader($attr,$content) 
    2396      { 
    2397           return 
    2398           "<?php if (\$_ctx->comments->isStart()) : ?>". 
    2399           $content. 
    2400           "<?php endif; ?>"; 
    2401      } 
    2402       
    2403      /*dtd 
    2404      <!ELEMENT tpl:CommentPostURL - O -- Comment Entry URL --> 
    2405      */ 
    2406      public function CommentPostURL($attr) 
    2407      { 
    2408           $f = $this->getFilters($attr); 
    2409           return '<?php echo '.sprintf($f,'$_ctx->comments->getPostURL()').'; ?>'; 
    2410      } 
    2411       
    2412      /*dtd 
    2413      <!ELEMENT tpl:IfCommentAuthorEmail - - -- Container displayed if comment author email is set --> 
    2414      */ 
    2415      public function IfCommentAuthorEmail($attr,$content) 
    2416      { 
    2417           return 
    2418           "<?php if (\$_ctx->comments->comment_email) : ?>". 
    2419           $content. 
    2420           "<?php endif; ?>"; 
    2421      } 
    2422       
    2423      /*dtd 
    2424      <!ELEMENT tpl:CommentHelp - 0 -- Comment syntax mini help --> 
    2425      */ 
    2426      public function CommentHelp($attr,$content) 
    2427      { 
    2428           return 
    2429           "<?php if (\$core->blog->settings->system->wiki_comments) {\n". 
    2430           "  echo __('Comments can be formatted using a simple wiki syntax.');\n". 
    2431           "} else {\n". 
    2432           "  echo __('HTML code is displayed as text and web addresses are automatically converted.');\n". 
    2433           "} ?>"; 
    2434      } 
    2435       
    2436      /* Comment preview -------------------------------- */ 
    2437      /*dtd 
    2438      <!ELEMENT tpl:IfCommentPreview - - -- Container displayed if comment is being previewed --> 
    2439      */ 
    2440      public function IfCommentPreview($attr,$content) 
    2441      { 
    2442           return 
    2443           '<?php if ($_ctx->comment_preview !== null && $_ctx->comment_preview["preview"]) : ?>'. 
    2444           $content. 
    2445           '<?php endif; ?>'; 
    2446      } 
    2447       
    2448      /*dtd 
    2449      <!ELEMENT tpl:CommentPreviewName - O -- Author name for the previewed comment --> 
    2450      */ 
    2451      public function CommentPreviewName($attr) 
    2452      { 
    2453           $f = $this->getFilters($attr); 
    2454           return '<?php echo '.sprintf($f,'$_ctx->comment_preview["name"]').'; ?>'; 
    2455      } 
    2456       
    2457      /*dtd 
    2458      <!ELEMENT tpl:CommentPreviewEmail - O -- Author email for the previewed comment --> 
    2459      */ 
    2460      public function CommentPreviewEmail($attr) 
    2461      { 
    2462           $f = $this->getFilters($attr); 
    2463           return '<?php echo '.sprintf($f,'$_ctx->comment_preview["mail"]').'; ?>'; 
    2464      } 
    2465       
    2466      /*dtd 
    2467      <!ELEMENT tpl:CommentPreviewSite - O -- Author site for the previewed comment --> 
    2468      */ 
    2469      public function CommentPreviewSite($attr) 
    2470      { 
    2471           $f = $this->getFilters($attr); 
    2472           return '<?php echo '.sprintf($f,'$_ctx->comment_preview["site"]').'; ?>'; 
    2473      } 
    2474       
    2475      /*dtd 
    2476      <!ELEMENT tpl:CommentPreviewContent - O -- Content of the previewed comment --> 
    2477      <!ATTLIST tpl:CommentPreviewContent 
    2478      raw  (0|1)     #IMPLIED  -- display comment in raw content 
    2479      > 
    2480      */ 
    2481      public function CommentPreviewContent($attr) 
    2482      { 
    2483           $f = $this->getFilters($attr); 
    2484            
    2485           if (!empty($attr['raw'])) { 
    2486                $co = '$_ctx->comment_preview["rawcontent"]'; 
    2487           } else { 
    2488                $co = '$_ctx->comment_preview["content"]'; 
    2489           } 
    2490            
    2491           return '<?php echo '.sprintf($f,$co).'; ?>'; 
    2492      } 
    2493       
    2494      /*dtd 
    2495      <!ELEMENT tpl:CommentPreviewCheckRemember - O -- checkbox attribute for "remember me" (same value as before preview) --> 
    2496      */ 
    2497      public function CommentPreviewCheckRemember($attr) 
    2498      { 
    2499           return 
    2500           "<?php if (\$_ctx->comment_preview['remember']) { echo ' checked=\"checked\"'; } ?>"; 
    2501      } 
    2502       
    2503      /* Trackbacks ------------------------------------- */ 
    2504      /*dtd 
    2505      <!ELEMENT tpl:PingBlogName - O -- Trackback blog name --> 
    2506      */ 
    2507      public function PingBlogName($attr) 
    2508      { 
    2509           $f = $this->getFilters($attr); 
    2510           return '<?php echo '.sprintf($f,'$_ctx->pings->comment_author').'; ?>'; 
    2511      } 
    2512       
    2513      /*dtd 
    2514      <!ELEMENT tpl:PingContent - O -- Trackback content --> 
    2515      */ 
    2516      public function PingContent($attr) 
    2517      { 
    2518           $f = $this->getFilters($attr); 
    2519           return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackContent()').'; ?>'; 
    2520      } 
    2521       
    2522      /*dtd 
    2523      <!ELEMENT tpl:PingDate - O -- Trackback date --> 
    2524      <!ATTLIST tpl:PingDate 
    2525      format    CDATA     #IMPLIED  -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified) 
    2526      iso8601   CDATA     #IMPLIED  -- if set, tells that date format is ISO 8601 
    2527      rfc822    CDATA     #IMPLIED  -- if set, tells that date format is RFC 822 
    2528      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time 
    2529      > 
    2530      */ 
    2531      public function PingDate($attr,$type='') 
    2532      { 
    2533           $format = ''; 
    2534           if (!empty($attr['format'])) { 
    2535                $format = addslashes($attr['format']); 
    2536           } 
    2537            
    2538           $iso8601 = !empty($attr['iso8601']); 
    2539           $rfc822 = !empty($attr['rfc822']); 
    2540           $type = (!empty($attr['upddt']) ? 'upddt' : ''); 
    2541            
    2542           $f = $this->getFilters($attr); 
    2543            
    2544           if ($rfc822) { 
    2545                return '<?php echo '.sprintf($f,"\$_ctx->pings->getRFC822Date('".$type."')").'; ?>'; 
    2546           } elseif ($iso8601) { 
    2547                return '<?php echo '.sprintf($f,"\$_ctx->pings->getISO8601Date('".$type."')").'; ?>'; 
    2548           } else { 
    2549                return '<?php echo '.sprintf($f,"\$_ctx->pings->getDate('".$format."','".$type."')").'; ?>'; 
    2550           } 
    2551      } 
    2552       
    2553      /*dtd 
    2554      <!ELEMENT tpl:PingTime - O -- Trackback date --> 
    2555      <!ATTLIST tpl:PingTime 
    2556      format    CDATA     #IMPLIED  -- time format  
    2557      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time 
    2558      > 
    2559      */ 
    2560      public function PingTime($attr) 
    2561      { 
    2562           $format = ''; 
    2563           if (!empty($attr['format'])) { 
    2564                $format = addslashes($attr['format']); 
    2565           } 
    2566           $type = (!empty($attr['upddt']) ? 'upddt' : ''); 
    2567            
    2568           $f = $this->getFilters($attr); 
    2569           return '<?php echo '.sprintf($f,"\$_ctx->pings->getTime('".$format."','".$type."')").'; ?>'; 
    2570      } 
    2571       
    2572      /*dtd 
    2573      <!ELEMENT tpl:PingEntryTitle - O -- Trackback entry title --> 
    2574      */ 
    2575      public function PingEntryTitle($attr) 
    2576      { 
    2577           $f = $this->getFilters($attr); 
    2578           return '<?php echo '.sprintf($f,'$_ctx->pings->post_title').'; ?>'; 
    2579      } 
    2580       
    2581      /*dtd 
    2582      <!ELEMENT tpl:PingFeedID - O -- Trackback feed ID --> 
    2583      */ 
    2584      public function PingFeedID($attr) 
    2585      { 
    2586           $f = $this->getFilters($attr); 
    2587           return '<?php echo '.sprintf($f,'$_ctx->pings->getFeedID()').'; ?>'; 
    2588      } 
    2589       
    2590      /*dtd 
    2591      <!ELEMENT tpl:PingID - O -- Trackback ID --> 
    2592      */ 
    2593      public function PingID($attr) 
    2594      { 
    2595           return '<?php echo $_ctx->pings->comment_id; ?>'; 
    2596      } 
    2597       
    2598      /*dtd 
    2599      <!ELEMENT tpl:PingIfFirst - O -- displays value if trackback is the first one --> 
    2600      <!ATTLIST tpl:PingIfFirst 
    2601      return    CDATA     #IMPLIED  -- value to display in case of success (default: first) 
    2602      > 
    2603      */ 
    2604      public function PingIfFirst($attr) 
    2605      { 
    2606           $ret = isset($attr['return']) ? $attr['return'] : 'first'; 
    2607           $ret = html::escapeHTML($ret); 
    2608            
    2609           return 
    2610           '<?php if ($_ctx->pings->index() == 0) { '. 
    2611           "echo '".addslashes($ret)."'; } ?>"; 
    2612      } 
    2613       
    2614      /*dtd 
    2615      <!ELEMENT tpl:PingIfOdd - O -- displays value if trackback is  at an odd position --> 
    2616      <!ATTLIST tpl:PingIfOdd 
    2617      return    CDATA     #IMPLIED  -- value to display in case of success (default: odd) 
    2618      > 
    2619      */ 
    2620      public function PingIfOdd($attr) 
    2621      { 
    2622           $ret = isset($attr['return']) ? $attr['return'] : 'odd'; 
    2623           $ret = html::escapeHTML($ret); 
    2624            
    2625           return 
    2626           '<?php if (($_ctx->pings->index()+1)%2) { '. 
    2627           "echo '".addslashes($ret)."'; } ?>"; 
    2628      } 
    2629       
    2630      /*dtd 
    2631      <!ELEMENT tpl:PingIP - O -- Trackback author IP --> 
    2632      */ 
    2633      public function PingIP($attr) 
    2634      { 
    2635           return '<?php echo $_ctx->pings->comment_ip; ?>'; 
    2636      } 
    2637       
    2638      /*dtd 
    2639      <!ELEMENT tpl:PingNoFollow - O -- displays 'rel="nofollow"' if set in blog --> 
    2640      */ 
    2641      public function PingNoFollow($attr) 
    2642      { 
    2643           return 
    2644           '<?php if($core->blog->settings->system->comments_nofollow) { '. 
    2645           'echo \' rel="nofollow"\';'. 
    2646           '} ?>'; 
    2647      } 
    2648       
    2649      /*dtd 
    2650      <!ELEMENT tpl:PingOrderNumber - O -- Trackback order in page --> 
    2651      */ 
    2652      public function PingOrderNumber($attr) 
    2653      { 
    2654           return '<?php echo $_ctx->pings->index()+1; ?>'; 
    2655      } 
    2656       
    2657      /*dtd 
    2658      <!ELEMENT tpl:PingPostURL - O -- Trackback Entry URL --> 
    2659      */ 
    2660      public function PingPostURL($attr) 
    2661      { 
    2662           $f = $this->getFilters($attr); 
    2663           return '<?php echo '.sprintf($f,'$_ctx->pings->getPostURL()').'; ?>'; 
    2664      } 
    2665       
    2666      /*dtd 
    2667      <!ELEMENT tpl:Pings - - -- Trackbacks container --> 
    2668      <!ATTLIST tpl:Pings 
    2669      with_pings     (0|1)     #IMPLIED  -- include trackbacks in request 
    2670      lastn     CDATA          #IMPLIED  -- restrict the number of entries  
    2671      no_context (1|0)         #IMPLIED  -- Override context information 
    2672      order     (desc|asc)     #IMPLIED  -- result ordering (default: asc) 
    2673      > 
    2674      */ 
    2675      public function Pings($attr,$content) 
    2676      { 
    2677           $p = 
    2678           "if (\$_ctx->posts !== null) { ". 
    2679                "\$params['post_id'] = \$_ctx->posts->post_id; ". 
    2680                "\$core->blog->withoutPassword(false);\n". 
    2681           "}\n"; 
    2682            
    2683           $p .= "\$params['comment_trackback'] = true;\n"; 
    2684            
    2685           $lastn = 0; 
    2686           if (isset($attr['lastn'])) { 
    2687                $lastn = abs((integer) $attr['lastn'])+0; 
    2688           } 
    2689            
    2690           if ($lastn > 0) { 
    2691                $p .= "\$params['limit'] = ".$lastn.";\n"; 
    2692           } else { 
    2693                $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n"; 
    2694           } 
    2695            
    2696           if (empty($attr['no_context'])) 
    2697           { 
    2698                $p .= 
    2699                'if ($_ctx->exists("categories")) { '. 
    2700                     "\$params['cat_id'] = \$_ctx->categories->cat_id; ". 
    2701                "}\n"; 
    2702                 
    2703                $p .= 
    2704                'if ($_ctx->exists("langs")) { '. 
    2705                     "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ". 
    2706                "}\n"; 
    2707           } 
    2708            
    2709           $order = 'asc'; 
    2710           if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) { 
    2711                $order = $attr['order']; 
    2712           } 
    2713            
    2714           $p .= "\$params['order'] = 'comment_dt ".$order."';\n"; 
    2715            
    2716           if (isset($attr['no_content']) && $attr['no_content']) { 
    2717                $p .= "\$params['no_content'] = true;\n"; 
    2718           } 
    2719            
    2720           $res = "<?php\n"; 
    2721           $res .= $p; 
    2722           $res .= $this->core->callBehavior("templatePrepareParams",  
    2723                array("tag" => "Pings","method" => "blog::getComments"),  
    2724                $attr,$content); 
    2725           $res .= '$_ctx->pings = $core->blog->getComments($params); unset($params);'."\n"; 
    2726           $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n"; 
    2727           $res .= "?>\n"; 
    2728            
    2729           $res .= 
    2730           '<?php while ($_ctx->pings->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->pings = null; ?>'; 
    2731            
    2732           return $res; 
    2733      } 
    2734       
    2735      /*dtd 
    2736      <!ELEMENT tpl:PingsFooter - - -- Last trackbacks result container --> 
    2737      */ 
    2738      public function PingsFooter($attr,$content) 
    2739      { 
    2740           return 
    2741           "<?php if (\$_ctx->pings->isEnd()) : ?>". 
    2742           $content. 
    2743           "<?php endif; ?>"; 
    2744      } 
    2745       
    2746      /*dtd 
    2747      <!ELEMENT tpl:PingsHeader - - -- First trackbacks result container --> 
    2748      */ 
    2749      public function PingsHeader($attr,$content) 
    2750      { 
    2751           return 
    2752           "<?php if (\$_ctx->pings->isStart()) : ?>". 
    2753           $content. 
    2754           "<?php endif; ?>"; 
    2755      } 
    2756       
    2757      /*dtd 
    2758      <!ELEMENT tpl:PingTitle - O -- Trackback title --> 
    2759      */ 
    2760      public function PingTitle($attr) 
    2761      { 
    2762           $f = $this->getFilters($attr); 
    2763           return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackTitle()').'; ?>'; 
    2764      } 
    2765       
    2766      /*dtd 
    2767      <!ELEMENT tpl:PingAuthorURL - O -- Trackback author URL --> 
    2768      */ 
    2769      public function PingAuthorURL($attr) 
    2770      { 
    2771           $f = $this->getFilters($attr); 
    2772           return '<?php echo '.sprintf($f,'$_ctx->pings->getAuthorURL()').'; ?>'; 
    27731854     } 
    27741855      
     
    28041885     has_tag             CDATA     #IMPLIED  -- tests if a named template tag exists (see Tag plugin for code) 
    28051886     blog_id             CDATA     #IMPLIED  -- tests if current blog ID is the one given in parameter 
    2806      comments_active     (0|1)     #IMPLIED  -- test if comments are enabled blog-wide  
    2807      pings_active        (0|1)     #IMPLIED  -- test if trackbacks are enabled blog-wide  
    2808      wiki_comments       (0|1)     #IMPLIED  -- test if wiki syntax is enabled for comments 
    28091887     operator            (and|or)  #IMPLIED  -- combination of conditions, if more than 1 specifiec (default: and) 
    28101888     > 
     
    28671945          } 
    28681946           
    2869           if (isset($attr['comments_active'])) { 
    2870                $sign = (boolean) $attr['comments_active'] ? '' : '!'; 
    2871                $if[] = $sign.'$core->blog->settings->system->allow_comments'; 
    2872           } 
    2873            
    2874           if (isset($attr['pings_active'])) { 
    2875                $sign = (boolean) $attr['pings_active'] ? '' : '!'; 
    2876                $if[] = $sign.'$core->blog->settings->system->allow_trackbacks'; 
    2877           } 
    2878          
    2879           if (isset($attr['wiki_comments'])) { 
    2880                $sign = (boolean) $attr['wiki_comments'] ? '' : '!'; 
    2881                $if[] = $sign.'$core->blog->settings->system->wiki_comments'; 
    2882           } 
    2883            
    28841947          if (isset($attr['search_count']) && 
    28851948               preg_match('/^((=|!|&gt;|&lt;)=|(&gt;|&lt;))\s*[0-9]+$/',trim($attr['search_count']))) { 
     
    28941957               return $content; 
    28951958          } 
    2896      } 
    2897       
    2898      /*dtd 
    2899      <!ELEMENT tpl:SysIfCommentPublished - - -- Container displayed if comment has been published --> 
    2900      */ 
    2901      public function SysIfCommentPublished($attr,$content) 
    2902      { 
    2903           return 
    2904           '<?php if (!empty($_GET[\'pub\'])) : ?>'. 
    2905           $content. 
    2906           '<?php endif; ?>'; 
    2907      } 
    2908       
    2909      /*dtd 
    2910      <!ELEMENT tpl:SysIfCommentPending - - -- Container displayed if comment is pending after submission --> 
    2911      */ 
    2912      public function SysIfCommentPending($attr,$content) 
    2913      { 
    2914           return 
    2915           '<?php if (isset($_GET[\'pub\']) && $_GET[\'pub\'] == 0) : ?>'. 
    2916           $content. 
    2917           '<?php endif; ?>'; 
    29181959     } 
    29191960      
  • inc/public/lib.urlhandlers.php

    r779 r848  
    339339 
    340340               $_ctx->posts = $core->blog->getPosts($params); 
    341                 
    342                $_ctx->comment_preview = new ArrayObject(); 
    343                $_ctx->comment_preview['content'] = ''; 
    344                $_ctx->comment_preview['rawcontent'] = ''; 
    345                $_ctx->comment_preview['name'] = ''; 
    346                $_ctx->comment_preview['mail'] = ''; 
    347                $_ctx->comment_preview['site'] = ''; 
    348                $_ctx->comment_preview['preview'] = false; 
    349                $_ctx->comment_preview['remember'] = false; 
    350341                
    351342               $core->blog->withoutPassword(true); 
     
    385376                    } 
    386377                     
    387                     $post_comment = 
    388                          isset($_POST['c_name']) && isset($_POST['c_mail']) && 
    389                          isset($_POST['c_site']) && isset($_POST['c_content']) && 
    390                          $_ctx->posts->commentsActive(); 
    391                      
    392                     # Posting a comment 
    393                     if ($post_comment) 
    394                     { 
    395                          # Spam trap 
    396                          if (!empty($_POST['f_mail'])) { 
    397                               http::head(412,'Precondition Failed'); 
    398                               header('Content-Type: text/plain'); 
    399                               echo "So Long, and Thanks For All the Fish"; 
    400                               # Exits immediately the application to preserve the server. 
    401                               exit; 
    402                          } 
    403                           
    404                          $name = $_POST['c_name']; 
    405                          $mail = $_POST['c_mail']; 
    406                          $site = $_POST['c_site']; 
    407                          $content = $_POST['c_content']; 
    408                          $preview = !empty($_POST['preview']); 
    409                           
    410                          if ($content != '') 
    411                          { 
    412                               if ($core->blog->settings->system->wiki_comments) { 
    413                                    $core->initWikiComment(); 
    414                               } else { 
    415                                    $core->initWikiSimpleComment(); 
    416                               } 
    417                               $content = $core->wikiTransform($content); 
    418                               $content = $core->HTMLfilter($content); 
    419                          } 
    420                           
    421                          $_ctx->comment_preview['content'] = $content; 
    422                          $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; 
    423                          $_ctx->comment_preview['name'] = $name; 
    424                          $_ctx->comment_preview['mail'] = $mail; 
    425                          $_ctx->comment_preview['site'] = $site; 
    426                           
    427                          if ($preview) 
    428                          { 
    429                               # --BEHAVIOR-- publicBeforeCommentPreview 
    430                               $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 
    431                                
    432                               $_ctx->comment_preview['preview'] = true; 
    433                          } 
    434                          else 
    435                          { 
    436                               # Post the comment 
    437                               $cur = $core->con->openCursor($core->prefix.'comment'); 
    438                               $cur->comment_author = $name; 
    439                               $cur->comment_site = html::clean($site); 
    440                               $cur->comment_email = html::clean($mail); 
    441                               $cur->comment_content = $content; 
    442                               $cur->post_id = $_ctx->posts->post_id; 
    443                               $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 
    444                               $cur->comment_ip = http::realIP(); 
    445                                
    446                               $redir = $_ctx->posts->getURL(); 
    447                               $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?'; 
    448                                
    449                               try 
    450                               { 
    451                                    if (!text::isEmail($cur->comment_email)) { 
    452                                         throw new Exception(__('You must provide a valid email address.')); 
    453                                    } 
    454                                     
    455                                    # --BEHAVIOR-- publicBeforeCommentCreate 
    456                                    $core->callBehavior('publicBeforeCommentCreate',$cur); 
    457                                    if ($cur->post_id) {                          
    458                                         $comment_id = $core->blog->addComment($cur); 
    459                                          
    460                                         # --BEHAVIOR-- publicAfterCommentCreate 
    461                                         $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 
    462                                    } 
    463                                     
    464                                    if ($cur->comment_status == 1) { 
    465                                         $redir_arg = 'pub=1'; 
    466                                    } else { 
    467                                         $redir_arg = 'pub=0'; 
    468                                    } 
    469                                     
    470                                    header('Location: '.$redir.$redir_arg); 
    471                               } 
    472                               catch (Exception $e) 
    473                               { 
    474                                    $_ctx->form_error = $e->getMessage(); 
    475                                    $_ctx->form_error; 
    476                               } 
    477                          } 
    478                     } 
    479                      
    480378                    # The entry 
    481379                    self::serveDocument('post.html'); 
     
    513411     { 
    514412          $type = null; 
    515           $comments = false; 
    516413          $cat_url = false; 
    517414          $post_id = null; 
     
    547444               return; 
    548445          } 
    549           elseif (preg_match('#^(atom|rss2)/comments/([0-9]+)$#',$args,$m)) 
    550           { 
    551                # Post comments feed 
    552                $type = $m[1]; 
    553                $comments = true; 
    554                $post_id = (integer) $m[2]; 
    555           } 
    556446          elseif (preg_match('#^(?:category/(.+)/)?(atom|rss2)(/comments)?$#',$args,$m)) 
    557447          { 
    558448               # All posts or comments feed 
    559449               $type = $m[2]; 
    560                $comments = !empty($m[3]); 
    561450               if (!empty($m[1])) { 
    562451                    $cat_url = $m[1]; 
     
    608497           
    609498          $tpl = $type; 
    610           if ($comments) { 
    611                $tpl .= '-comments'; 
    612                $_ctx->nb_comment_per_page = $core->blog->settings->system->nb_comment_per_feed; 
    613           } else { 
    614                $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed; 
    615                $_ctx->short_feed_items = $core->blog->settings->system->short_feed_items; 
    616           } 
     499          $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed; 
     500          $_ctx->short_feed_items = $core->blog->settings->system->short_feed_items; 
    617501          $tpl .= '.xml'; 
    618502           
     
    627511          if (!$comments && !$cat_url) { 
    628512               $core->blog->publishScheduledEntries(); 
    629           } 
    630      } 
    631       
    632      public static function trackback($args) 
    633      { 
    634           if (!preg_match('/^[0-9]+$/',$args)) { 
    635                # The specified trackback URL is not an number 
    636                self::p404(); 
    637           } else { 
    638                $tb = new dcTrackback($GLOBALS['core']); 
    639                $tb->receive($args); 
    640513          } 
    641514     } 
  • inc/public/rs.extension.php

    r270 r848  
    1313 
    1414$core->addBehavior('coreBlogGetPosts',array('rsExtendPublic','coreBlogGetPosts')); 
    15 $core->addBehavior('coreBlogGetComments',array('rsExtendPublic','coreBlogGetComments')); 
    1615 
    1716class rsExtendPublic 
     
    2221     } 
    2322      
    24      public static function coreBlogGetComments($rs) 
    25      { 
    26           $rs->extend('rsExtCommentPublic'); 
    27      } 
    2823} 
    2924 
     
    7469} 
    7570 
    76 class rsExtCommentPublic extends rsExtComment 
    77 { 
    78      public static function getContent($rs,$absolute_urls=false) 
    79      { 
    80           if ($rs->core->blog->settings->system->use_smilies) 
    81           { 
    82                $c = parent::getContent($rs,$absolute_urls); 
    83                 
    84                if (!isset($GLOBALS['__smilies'])) { 
    85                     $GLOBALS['__smilies'] = context::getSmilies($rs->core->blog); 
    86                } 
    87                return context::addSmilies($c); 
    88           } 
    89            
    90           return parent::getContent($rs,$absolute_urls); 
    91      } 
    92 } 
    9371?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map