Changeset 2578 for plugins/muppet/_public.php
- Timestamp:
- 08/22/10 14:45:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/muppet/_public.php
r2556 r2578 3 3 # 4 4 # This file is part of muppet, a plugin for Dotclear 2. 5 # 5 # 6 6 # Copyright (c) 2010 Osku and contributors 7 7 # … … 29 29 $_ctx =& $GLOBALS['_ctx']; 30 30 $core =& $GLOBALS['core']; 31 31 32 32 $core->blog->withoutPassword(false); 33 33 34 34 $params = new ArrayObject(); 35 35 $params['post_type'] = str_replace('preview', '', $core->url->type); 36 36 $params['post_url'] = $args; 37 37 38 38 $_ctx->posts = $core->blog->getPosts($params); 39 39 40 40 $_ctx->comment_preview = new ArrayObject(); 41 41 $_ctx->comment_preview['content'] = ''; … … 46 46 $_ctx->comment_preview['preview'] = false; 47 47 $_ctx->comment_preview['remember'] = false; 48 48 49 49 $core->blog->withoutPassword(true); 50 51 50 51 52 52 if ($_ctx->posts->isEmpty()) 53 53 { … … 59 59 $post_id = $_ctx->posts->post_id; 60 60 $post_password = $_ctx->posts->post_password; 61 61 62 62 # Password protected entry 63 63 if ($post_password != '' && !$_ctx->preview) … … 69 69 $pwd_cookie = array(); 70 70 } 71 71 72 72 # Check for match 73 73 if ((!empty($_POST['password']) && $_POST['password'] == $post_password) … … 83 83 } 84 84 } 85 85 86 86 $post_comment = 87 87 isset($_POST['c_name']) && isset($_POST['c_mail']) && 88 88 isset($_POST['c_site']) && isset($_POST['c_content']) && 89 89 $_ctx->posts->commentsActive(); 90 90 91 91 # Posting a comment 92 92 if ($post_comment) … … 100 100 exit; 101 101 } 102 102 103 103 $name = $_POST['c_name']; 104 104 $mail = $_POST['c_mail']; … … 106 106 $content = $_POST['c_content']; 107 107 $preview = !empty($_POST['preview']); 108 108 109 109 if ($content != '') 110 110 { … … 117 117 $content = $core->HTMLfilter($content); 118 118 } 119 119 120 120 $_ctx->comment_preview['content'] = $content; 121 121 $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; … … 123 123 $_ctx->comment_preview['mail'] = $mail; 124 124 $_ctx->comment_preview['site'] = $site; 125 125 126 126 if ($preview) 127 127 { 128 128 # --BEHAVIOR-- publicBeforeCommentPreview 129 129 $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 130 130 131 131 $_ctx->comment_preview['preview'] = true; 132 132 } … … 142 142 $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 143 143 $cur->comment_ip = http::realIP(); 144 144 145 145 $redir = $_ctx->posts->getURL(); 146 146 $redir .= strpos($redir,'?') !== false ? '&' : '?'; 147 147 148 148 try 149 149 { … … 154 154 # --BEHAVIOR-- publicBeforeCommentCreate 155 155 $core->callBehavior('publicBeforeCommentCreate',$cur); 156 if ($cur->post_id) { 156 if ($cur->post_id) { 157 157 $comment_id = $core->blog->addComment($cur); 158 158 159 159 # --BEHAVIOR-- publicAfterCommentCreate 160 160 $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 161 161 } 162 162 163 163 if ($cur->comment_status == 1) { 164 164 $redir_arg = 'pub=1'; … … 166 166 $redir_arg = 'pub=0'; 167 167 } 168 168 169 169 header('Location: '.$redir.$redir_arg); 170 170 } … … 176 176 } 177 177 } 178 178 179 179 $mytpl = $params['post_type']; 180 180 181 181 # The entry 182 182 $tpl = 'single-'.$mytpl.'.html'; … … 188 188 } 189 189 } 190 190 191 191 public static function singlepreview($args) 192 192 { 193 193 $core = $GLOBALS['core']; 194 194 $_ctx = $GLOBALS['_ctx']; 195 195 196 196 if (!preg_match('#^(.+?)/([0-9a-z]{40})/(.+?)$#',$args,$m)) { 197 197 # The specified Preview URL is malformed. … … 210 210 { 211 211 $_ctx->preview = true; 212 self::single ($post_url);212 self::singlepost($post_url); 213 213 } 214 214 } … … 216 216 217 217 public static function listpost($args) 218 { 218 { 219 219 $core = $GLOBALS['core']; 220 220 $_ctx = $GLOBALS['_ctx']; 221 221 222 222 $n = self::getPageNumber($args); 223 223 224 224 if ($args && !$n) 225 225 { … … 234 234 $GLOBALS['_page_number'] = $n; 235 235 } 236 236 237 237 $mytpl = $params['post_type']; 238 238 239 239 $_ctx->posts = $core->blog->getPosts($params); 240 240 241 241 # The entry 242 242 $tpl = 'list-'.$mytpl.'.html'; … … 245 245 } 246 246 self::serveDocument($tpl); 247 } 247 } 248 248 } 249 249 } … … 254 254 { 255 255 global $core; 256 256 257 257 if ($w->homeonly && $core->url->type != 'default') { 258 258 return; 259 259 } 260 260 261 261 $params = array( 262 262 'post_type' => $w->posttype, … … 264 264 'no_content'=>true, 265 265 'order'=>'post_dt desc'); 266 266 267 267 $rs = $core->blog->getPosts($params); 268 268 269 269 if ($rs->isEmpty()) { 270 270 return; 271 271 } 272 272 273 273 $res = 274 274 '<div class="selected">'. 275 275 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 276 276 '<ul>'; 277 277 278 278 while ($rs->fetch()) { 279 279 $res .= ' <li><a href="'.$rs->getURL().'">'.html::escapeHTML($rs->post_title).'</a></li> '; 280 280 } 281 281 282 282 $res .= '</ul></div>'; 283 283 284 284 return $res; 285 285 } … … 288 288 { 289 289 global $core; 290 290 291 291 if ($w->homeonly && $core->url->type != 'default') { 292 292 return; 293 293 } 294 294 295 295 $params['post_type'] = $w->posttype; 296 296 $params['limit'] = abs((integer) $w->limit); 297 297 $params['order'] = 'post_id desc'; 298 298 $params['no_content'] = true; 299 299 300 300 if ($w->category) 301 301 { … … 318 318 $rs = $core->blog->getPosts($params); 319 319 } 320 320 321 321 if ($rs->isEmpty()) { 322 322 return; 323 323 } 324 324 325 325 $res = 326 326 '<div class="lastposts">'. 327 327 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 328 328 '<ul>'; 329 329 330 330 while ($rs->fetch()) { 331 331 $res .= '<li><a href="'.$rs->getURL().'">'. 332 332 html::escapeHTML($rs->post_title).'</a></li>'; 333 333 } 334 334 335 335 $res .= '</ul></div>'; 336 336 337 337 return $res; 338 338 } … … 353 353 } 354 354 } 355 356 public static function publicBeforeSearchCount($s_params) 357 { 355 356 public static function publicBeforeSearchCount($s_params) 357 { 358 358 global $core; 359 359 $types = muppet::getPostTypes();
Note: See TracChangeset
for help on using the changeset viewer.