Changeset 2566:9bf417837888 for plugins/pages/_public.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pages/_public.php
r1674 r2566 30 30 $_ctx =& $GLOBALS['_ctx']; 31 31 $core =& $GLOBALS['core']; 32 32 33 33 $core->blog->withoutPassword(false); 34 34 35 35 $params = new ArrayObject(array( 36 36 'post_type' => 'page', 37 37 'post_url' => $args)); 38 38 39 39 $core->callBehavior('publicPagesBeforeGetPosts',$params,$args); 40 40 41 41 $_ctx->posts = $core->blog->getPosts($params); 42 42 43 43 $_ctx->comment_preview = new ArrayObject(); 44 44 $_ctx->comment_preview['content'] = ''; … … 49 49 $_ctx->comment_preview['preview'] = false; 50 50 $_ctx->comment_preview['remember'] = false; 51 51 52 52 $core->blog->withoutPassword(true); 53 54 53 54 55 55 if ($_ctx->posts->isEmpty()) 56 56 { … … 62 62 $post_id = $_ctx->posts->post_id; 63 63 $post_password = $_ctx->posts->post_password; 64 64 65 65 # Password protected entry 66 66 if ($post_password != '' && !$_ctx->preview) … … 72 72 $pwd_cookie = array(); 73 73 } 74 74 75 75 # Check for match 76 76 if ((!empty($_POST['password']) && $_POST['password'] == $post_password) … … 86 86 } 87 87 } 88 88 89 89 $post_comment = 90 90 isset($_POST['c_name']) && isset($_POST['c_mail']) && 91 91 isset($_POST['c_site']) && isset($_POST['c_content']) && 92 92 $_ctx->posts->commentsActive(); 93 93 94 94 # Posting a comment 95 95 if ($post_comment) … … 103 103 exit; 104 104 } 105 105 106 106 $name = $_POST['c_name']; 107 107 $mail = $_POST['c_mail']; … … 109 109 $content = $_POST['c_content']; 110 110 $preview = !empty($_POST['preview']); 111 111 112 112 if ($content != '') 113 113 { … … 120 120 $content = $core->HTMLfilter($content); 121 121 } 122 122 123 123 $_ctx->comment_preview['content'] = $content; 124 124 $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; … … 126 126 $_ctx->comment_preview['mail'] = $mail; 127 127 $_ctx->comment_preview['site'] = $site; 128 128 129 129 if ($preview) 130 130 { 131 131 # --BEHAVIOR-- publicBeforeCommentPreview 132 132 $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 133 133 134 134 $_ctx->comment_preview['preview'] = true; 135 135 } … … 145 145 $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 146 146 $cur->comment_ip = http::realIP(); 147 147 148 148 $redir = $_ctx->posts->getURL(); 149 149 $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?'; 150 150 151 151 try 152 152 { … … 154 154 throw new Exception(__('You must provide a valid email address.')); 155 155 } 156 156 157 157 # --BEHAVIOR-- publicBeforeCommentCreate 158 158 $core->callBehavior('publicBeforeCommentCreate',$cur); 159 if ($cur->post_id) { 159 if ($cur->post_id) { 160 160 $comment_id = $core->blog->addComment($cur); 161 161 162 162 # --BEHAVIOR-- publicAfterCommentCreate 163 163 $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 164 164 } 165 165 166 166 if ($cur->comment_status == 1) { 167 167 $redir_arg = 'pub=1'; … … 169 169 $redir_arg = 'pub=0'; 170 170 } 171 171 172 172 header('Location: '.$redir.$redir_arg); 173 173 } … … 179 179 } 180 180 } 181 181 182 182 # The entry 183 183 if ($_ctx->posts->trackbacksActive()) { … … 189 189 } 190 190 } 191 191 192 192 public static function pagespreview($args) 193 193 { 194 194 $core = $GLOBALS['core']; 195 195 $_ctx = $GLOBALS['_ctx']; 196 196 197 197 if (!preg_match('#^(.+?)/([0-9a-z]{40})/(.+?)$#',$args,$m)) { 198 198 # The specified Preview URL is malformed. … … 223 223 { 224 224 global $core, $_ctx; 225 225 226 226 if (($w->homeonly == 1 && $core->url->type != 'default') || 227 227 ($w->homeonly == 2 && $core->url->type == 'default')) { 228 228 return; 229 229 } 230 230 231 231 $params['post_type'] = 'page'; 232 232 $params['limit'] = abs((integer) $w->limit); 233 233 $params['no_content'] = true; 234 234 $params['post_selected'] = false; 235 235 236 236 $sort = $w->sortby; 237 237 if (!in_array($sort,array('post_title','post_position','post_dt'))) { 238 238 $sort = 'post_title'; 239 239 } 240 240 241 241 $order = $w->orderby; 242 242 if ($order != 'asc') { … … 244 244 } 245 245 $params['order'] = $sort.' '.$order; 246 246 247 247 $rs = $core->blog->getPosts($params); 248 248 249 249 if ($rs->isEmpty()) { 250 250 return; 251 251 } 252 252 253 253 $res = 254 254 ($w->content_only ? '' : '<div class="pages'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 255 255 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 256 256 '<ul>'; 257 257 258 258 while ($rs->fetch()) { 259 259 $class = ''; … … 264 264 html::escapeHTML($rs->post_title).'</a></li>'; 265 265 } 266 266 267 267 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 268 268 269 269 return $res; 270 270 } 271 271 } 272 ?>
Note: See TracChangeset
for help on using the changeset viewer.