Dotclear


Ignore:
Timestamp:
08/22/10 14:45:31 (13 years ago)
Author:
Osku
Message:

grumpf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/muppet/_public.php

    r2556 r2578  
    33# 
    44# This file is part of muppet, a plugin for Dotclear 2. 
    5 #  
     5# 
    66# Copyright (c) 2010 Osku and contributors 
    77# 
     
    2929               $_ctx =& $GLOBALS['_ctx']; 
    3030               $core =& $GLOBALS['core']; 
    31                 
     31 
    3232               $core->blog->withoutPassword(false); 
    33                 
     33 
    3434               $params = new ArrayObject(); 
    3535               $params['post_type'] = str_replace('preview', '', $core->url->type); 
    3636               $params['post_url'] = $args; 
    37                 
     37 
    3838               $_ctx->posts = $core->blog->getPosts($params); 
    39                 
     39 
    4040               $_ctx->comment_preview = new ArrayObject(); 
    4141               $_ctx->comment_preview['content'] = ''; 
     
    4646               $_ctx->comment_preview['preview'] = false; 
    4747               $_ctx->comment_preview['remember'] = false; 
    48                 
     48 
    4949               $core->blog->withoutPassword(true); 
    50                 
    51                 
     50 
     51 
    5252               if ($_ctx->posts->isEmpty()) 
    5353               { 
     
    5959                    $post_id = $_ctx->posts->post_id; 
    6060                    $post_password = $_ctx->posts->post_password; 
    61                      
     61 
    6262                    # Password protected entry 
    6363                    if ($post_password != '' && !$_ctx->preview) 
     
    6969                              $pwd_cookie = array(); 
    7070                         } 
    71                           
     71 
    7272                         # Check for match 
    7373                         if ((!empty($_POST['password']) && $_POST['password'] == $post_password) 
     
    8383                         } 
    8484                    } 
    85                      
     85 
    8686                    $post_comment = 
    8787                         isset($_POST['c_name']) && isset($_POST['c_mail']) && 
    8888                         isset($_POST['c_site']) && isset($_POST['c_content']) && 
    8989                         $_ctx->posts->commentsActive(); 
    90                      
     90 
    9191                    # Posting a comment 
    9292                    if ($post_comment) 
     
    100100                              exit; 
    101101                         } 
    102                           
     102 
    103103                         $name = $_POST['c_name']; 
    104104                         $mail = $_POST['c_mail']; 
     
    106106                         $content = $_POST['c_content']; 
    107107                         $preview = !empty($_POST['preview']); 
    108                           
     108 
    109109                         if ($content != '') 
    110110                         { 
     
    117117                              $content = $core->HTMLfilter($content); 
    118118                         } 
    119                           
     119 
    120120                         $_ctx->comment_preview['content'] = $content; 
    121121                         $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; 
     
    123123                         $_ctx->comment_preview['mail'] = $mail; 
    124124                         $_ctx->comment_preview['site'] = $site; 
    125                           
     125 
    126126                         if ($preview) 
    127127                         { 
    128128                              # --BEHAVIOR-- publicBeforeCommentPreview 
    129129                              $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 
    130                 
     130 
    131131                              $_ctx->comment_preview['preview'] = true; 
    132132                         } 
     
    142142                              $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 
    143143                              $cur->comment_ip = http::realIP(); 
    144                                
     144 
    145145                              $redir = $_ctx->posts->getURL(); 
    146146                              $redir .= strpos($redir,'?') !== false ? '&' : '?'; 
    147                                
     147 
    148148                              try 
    149149                              { 
     
    154154                                   # --BEHAVIOR-- publicBeforeCommentCreate 
    155155                                   $core->callBehavior('publicBeforeCommentCreate',$cur); 
    156                                    if ($cur->post_id) {                          
     156                                   if ($cur->post_id) { 
    157157                                        $comment_id = $core->blog->addComment($cur); 
    158                                     
     158 
    159159                                        # --BEHAVIOR-- publicAfterCommentCreate 
    160160                                        $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 
    161161                                   } 
    162                                     
     162 
    163163                                   if ($cur->comment_status == 1) { 
    164164                                        $redir_arg = 'pub=1'; 
     
    166166                                        $redir_arg = 'pub=0'; 
    167167                                   } 
    168                                     
     168 
    169169                                   header('Location: '.$redir.$redir_arg); 
    170170                              } 
     
    176176                         } 
    177177                    } 
    178                      
     178 
    179179                    $mytpl = $params['post_type']; 
    180                      
     180 
    181181                    # The entry 
    182182                    $tpl = 'single-'.$mytpl.'.html'; 
     
    188188          } 
    189189     } 
    190       
     190 
    191191     public static function singlepreview($args) 
    192192     { 
    193193          $core = $GLOBALS['core']; 
    194194          $_ctx = $GLOBALS['_ctx']; 
    195            
     195 
    196196          if (!preg_match('#^(.+?)/([0-9a-z]{40})/(.+?)$#',$args,$m)) { 
    197197               # The specified Preview URL is malformed. 
     
    210210               { 
    211211                    $_ctx->preview = true; 
    212                     self::single($post_url); 
     212                    self::singlepost($post_url); 
    213213               } 
    214214          } 
     
    216216 
    217217     public static function listpost($args) 
    218      {     
     218     { 
    219219          $core = $GLOBALS['core']; 
    220220          $_ctx = $GLOBALS['_ctx']; 
    221            
     221 
    222222          $n = self::getPageNumber($args); 
    223           
     223 
    224224          if ($args && !$n) 
    225225          { 
     
    234234                    $GLOBALS['_page_number'] = $n; 
    235235               } 
    236                 
     236 
    237237               $mytpl = $params['post_type']; 
    238                 
     238 
    239239               $_ctx->posts = $core->blog->getPosts($params); 
    240                      
     240 
    241241               # The entry 
    242242               $tpl = 'list-'.$mytpl.'.html'; 
     
    245245               } 
    246246               self::serveDocument($tpl); 
    247           }          
     247          } 
    248248     } 
    249249} 
     
    254254     { 
    255255          global $core; 
    256            
     256 
    257257          if ($w->homeonly && $core->url->type != 'default') { 
    258258               return; 
    259259          } 
    260            
     260 
    261261          $params = array( 
    262262               'post_type' => $w->posttype, 
     
    264264               'no_content'=>true, 
    265265               'order'=>'post_dt desc'); 
    266            
     266 
    267267          $rs = $core->blog->getPosts($params); 
    268            
     268 
    269269          if ($rs->isEmpty()) { 
    270270               return; 
    271271          } 
    272            
     272 
    273273          $res = 
    274274          '<div class="selected">'. 
    275275          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    276276          '<ul>'; 
    277            
     277 
    278278          while ($rs->fetch()) { 
    279279               $res .= ' <li><a href="'.$rs->getURL().'">'.html::escapeHTML($rs->post_title).'</a></li> '; 
    280280          } 
    281            
     281 
    282282          $res .= '</ul></div>'; 
    283            
     283 
    284284          return $res; 
    285285     } 
     
    288288     { 
    289289          global $core; 
    290            
     290 
    291291          if ($w->homeonly && $core->url->type != 'default') { 
    292292               return; 
    293293          } 
    294            
     294 
    295295          $params['post_type'] = $w->posttype; 
    296296          $params['limit'] = abs((integer) $w->limit); 
    297297          $params['order'] = 'post_id desc'; 
    298298          $params['no_content'] = true; 
    299            
     299 
    300300          if ($w->category) 
    301301          { 
     
    318318               $rs = $core->blog->getPosts($params); 
    319319          } 
    320            
     320 
    321321          if ($rs->isEmpty()) { 
    322322               return; 
    323323          } 
    324            
     324 
    325325          $res = 
    326326          '<div class="lastposts">'. 
    327327          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    328328          '<ul>'; 
    329            
     329 
    330330          while ($rs->fetch()) { 
    331331               $res .= '<li><a href="'.$rs->getURL().'">'. 
    332332               html::escapeHTML($rs->post_title).'</a></li>'; 
    333333          } 
    334            
     334 
    335335          $res .= '</ul></div>'; 
    336            
     336 
    337337          return $res; 
    338338     } 
     
    353353          } 
    354354     } 
    355       
    356      public static function publicBeforeSearchCount($s_params)  
    357      {  
     355 
     356     public static function publicBeforeSearchCount($s_params) 
     357     { 
    358358          global $core; 
    359359          $types = muppet::getPostTypes(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map