Changeset 1107:3943962d69b8 for plugins/pages
- Timestamp:
- 02/27/13 11:48:32 (12 years ago)
- 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. - Location:
- plugins/pages
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pages/_public.php
r877 r1107 102 102 global $core, $_ctx; 103 103 104 if ($w->homeonly && $core->url->type != 'default') { 104 if (($w->homeonly == 1 && $core->url->type != 'default') || 105 ($w->homeonly == 2 && $core->url->type == 'default')) { 105 106 return; 106 107 } … … 109 110 $params['limit'] = abs((integer) $w->limit); 110 111 $params['no_content'] = true; 112 $params['post_selected'] = false; 111 113 112 114 $sort = $w->sortby; … … 128 130 129 131 $res = 130 '<div class="pages">'.132 ($w->content_only ? '' : '<div class="pages'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 131 133 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 132 134 '<ul>'; … … 141 143 } 142 144 143 $res .= '</ul> </div>';145 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 144 146 145 147 return $res; -
plugins/pages/_public.php
r1063 r1107 61 61 { 62 62 $post_id = $_ctx->posts->post_id; 63 $post_password = $_ctx->posts->post_password;64 65 # Password protected entry66 if ($post_password != '' && !$_ctx->preview)67 {68 # Get passwords cookie69 if (isset($_COOKIE['dc_passwd'])) {70 $pwd_cookie = unserialize($_COOKIE['dc_passwd']);71 } else {72 $pwd_cookie = array();73 }74 75 # Check for match76 if ((!empty($_POST['password']) && $_POST['password'] == $post_password)77 || (isset($pwd_cookie[$post_id]) && $pwd_cookie[$post_id] == $post_password))78 {79 $pwd_cookie[$post_id] = $post_password;80 setcookie('dc_passwd',serialize($pwd_cookie),0,'/');81 }82 else83 {84 self::serveDocument('password-form.html','text/html',false);85 return;86 }87 }88 89 $post_comment =90 isset($_POST['c_name']) && isset($_POST['c_mail']) &&91 isset($_POST['c_site']) && isset($_POST['c_content']) &&92 $_ctx->posts->commentsActive();93 94 # Posting a comment95 if ($post_comment)96 {97 # Spam trap98 if (!empty($_POST['f_mail'])) {99 http::head(412,'Precondition Failed');100 header('Content-Type: text/plain');101 echo "So Long, and Thanks For All the Fish";102 # Exits immediately the application to preserve the server.103 exit;104 }105 106 $name = $_POST['c_name'];107 $mail = $_POST['c_mail'];108 $site = $_POST['c_site'];109 $content = $_POST['c_content'];110 $preview = !empty($_POST['preview']);111 112 if ($content != '')113 {114 if ($core->blog->settings->system->wiki_comments) {115 $core->initWikiComment();116 } else {117 $core->initWikiSimpleComment();118 }119 $content = $core->wikiTransform($content);120 $content = $core->HTMLfilter($content);121 }122 123 $_ctx->comment_preview['content'] = $content;124 $_ctx->comment_preview['rawcontent'] = $_POST['c_content'];125 $_ctx->comment_preview['name'] = $name;126 $_ctx->comment_preview['mail'] = $mail;127 $_ctx->comment_preview['site'] = $site;128 129 if ($preview)130 {131 # --BEHAVIOR-- publicBeforeCommentPreview132 $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview);133 134 $_ctx->comment_preview['preview'] = true;135 }136 else137 {138 # Post the comment139 $cur = $core->con->openCursor($core->prefix.'comment');140 $cur->comment_author = $name;141 $cur->comment_site = html::clean($site);142 $cur->comment_email = html::clean($mail);143 $cur->comment_content = $content;144 $cur->post_id = $_ctx->posts->post_id;145 $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1;146 $cur->comment_ip = http::realIP();147 148 $redir = $_ctx->posts->getURL();149 $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?';150 151 try152 {153 if (!text::isEmail($cur->comment_email)) {154 throw new Exception(__('You must provide a valid email address.'));155 }156 157 # --BEHAVIOR-- publicBeforeCommentCreate158 $core->callBehavior('publicBeforeCommentCreate',$cur);159 if ($cur->post_id) {160 $comment_id = $core->blog->addComment($cur);161 162 # --BEHAVIOR-- publicAfterCommentCreate163 $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id);164 }165 166 if ($cur->comment_status == 1) {167 $redir_arg = 'pub=1';168 } else {169 $redir_arg = 'pub=0';170 }171 172 header('Location: '.$redir.$redir_arg);173 }174 catch (Exception $e)175 {176 $_ctx->form_error = $e->getMessage();177 $_ctx->form_error;178 }179 }180 }181 182 63 # The entry 183 64 $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates'); -
plugins/pages/list.php
r877 r1107 81 81 $selected = ''; 82 82 if ($this->rs->post_selected) { 83 $selected = sprintf($img,__(' selected'),'selected.png');83 $selected = sprintf($img,__('hidden'),'hidden.png'); 84 84 } 85 85 -
plugins/pages/list.php
r911 r1107 79 79 } 80 80 81 $protected = '';82 if ($this->rs->post_password) {83 $protected = sprintf($img,__('protected'),'locker.png');84 }85 86 81 $selected = ''; 87 82 if ($this->rs->post_selected) { … … 109 104 '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. 110 105 '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. 111 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$ protected.' '.$attach.'</td>'.106 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$attach.'</td>'. 112 107 '</tr>'; 113 108 -
plugins/pages/page.php
r877 r1107 30 30 $post_open_comment = false; 31 31 $post_open_tb = false; 32 $post_selected = false; 32 33 33 34 $post_media = array(); … … 54 55 $status_combo[$v] = (string) $k; 55 56 } 57 $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 56 58 57 59 # Formaters combo … … 75 77 unset($rs); 76 78 79 # Validation flag 80 $bad_dt = false; 77 81 78 82 # Get page informations … … 106 110 $post_open_comment = (boolean) $post->post_open_comment; 107 111 $post_open_tb = (boolean) $post->post_open_tb; 112 $post_selected = (boolean) $post->post_selected; 108 113 109 114 $page_title = __('Edit page'); … … 152 157 $post_dt = ''; 153 158 } else { 154 $post_dt = strtotime($_POST['post_dt']); 155 $post_dt = date('Y-m-d H:i',$post_dt); 159 try 160 { 161 $post_dt = strtotime($_POST['post_dt']); 162 if ($post_dt == false || $post_dt == -1) { 163 $bad_dt = true; 164 throw new Exception(__('Invalid publication date')); 165 } 166 $post_dt = date('Y-m-d H:i',$post_dt); 167 } 168 catch (Exception $e) 169 { 170 $core->error->add($e->getMessage()); 171 } 156 172 } 157 173 158 174 $post_open_comment = !empty($_POST['post_open_comment']); 159 175 $post_open_tb = !empty($_POST['post_open_tb']); 176 $post_selected = !empty($_POST['post_selected']); 160 177 $post_lang = $_POST['post_lang']; 161 178 $post_position = (integer) $_POST['post_position']; … … 173 190 } 174 191 175 # Create or update post 176 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page) 192 # Delete page 193 if (!empty($_POST['delete']) && $can_delete) 194 { 195 try { 196 # --BEHAVIOR-- adminBeforePageDelete 197 $core->callBehavior('adminBeforePageDelete',$post_id); 198 $core->blog->delPost($post_id); 199 http::redirect($p_url); 200 } catch (Exception $e) { 201 $core->error->add($e->getMessage()); 202 } 203 } 204 205 # Create or update page 206 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page && !$bad_dt) 177 207 { 178 208 $cur = $core->con->openCursor($core->prefix.'post'); … … 196 226 $cur->post_open_comment = (integer) $post_open_comment; 197 227 $cur->post_open_tb = (integer) $post_open_tb; 228 $cur->post_selected = (integer) $post_selected; 198 229 199 230 if (isset($_POST['post_url'])) { … … 241 272 $core->error->add($e->getMessage()); 242 273 } 243 }244 }245 246 if (!empty($_POST['delete']) && $can_delete)247 {248 try {249 # --BEHAVIOR-- adminBeforePageDelete250 $core->callBehavior('adminBeforePageDelete',$post_id);251 $core->blog->delPost($post_id);252 http::redirect($p_url);253 } catch (Exception $e) {254 $core->error->add($e->getMessage());255 274 } 256 275 } … … 292 311 293 312 if (!empty($_GET['upd'])) { 294 echo '<p class="message">'.__('Page has been successfully updated.').'</p>';313 dcPage::message(__('Page has been successfully updated.')); 295 314 } 296 315 elseif (!empty($_GET['crea'])) { 297 echo '<p class="message">'.__('Page has been successfully created.').'</p>';316 dcPage::message(__('Page has been successfully created.')); 298 317 } 299 318 elseif (!empty($_GET['attached'])) { 300 echo '<p class="message">'.__('File has been successfully attached.').'</p>';319 dcPage::message(__('File has been successfully attached.')); 301 320 } 302 321 elseif (!empty($_GET['rmattach'])) { 303 echo '<p class="message">'.__('Attachment has been successfully removed.').'</p>';322 dcPage::message(__('Attachment has been successfully removed.')); 304 323 } 305 324 … … 311 330 $post_format = 'xhtml'; 312 331 313 echo '<p class="message">'.__('Don\'t forget to validate your XHTML conversion by saving your post.').'</p>';332 dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 314 333 } 315 334 … … 317 336 ' › <a href="'.$p_url.'">'.__('Pages').'</a> › <span class="page-title">'.$page_title; 318 337 if ($post_id) { 319 echo ' “'.$post_title.'”'; 338 switch ($post_status) { 339 case 1: 340 $img_status = sprintf($img_status_pattern,__('published'),'check-on.png'); 341 break; 342 case 0: 343 $img_status = sprintf($img_status_pattern,__('unpublished'),'check-off.png'); 344 break; 345 case -1: 346 $img_status = sprintf($img_status_pattern,__('scheduled'),'scheduled.png'); 347 break; 348 case -2: 349 $img_status = sprintf($img_status_pattern,__('pending'),'check-wrn.png'); 350 break; 351 default: 352 $img_status = ''; 353 } 354 echo ' “'.$post_title.'”'.' '.$img_status; 320 355 } 321 356 echo '</span></h2>'; … … 410 445 411 446 '<p><label for="post_dt">'.__('Published on:'). 412 form::field('post_dt',16,16,$post_dt ).'</label></p>'.447 form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).'</label></p>'. 413 448 414 449 '<p><label for="post_format">'.__('Text formating:'). … … 419 454 '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. 420 455 __('Accept comments').'</label></p>'. 456 ($core->blog->settings->system->allow_comments ? 457 (isContributionAllowed($post_id,strtotime($post_dt),true) ? 458 '' : 459 '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this page.').'</p>') : 460 '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>'). 461 421 462 '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. 422 463 __('Accept trackbacks').'</label></p>'. 423 464 ($core->blog->settings->system->allow_trackbacks ? 465 (isContributionAllowed($post_id,strtotime($post_dt),false) ? 466 '' : 467 '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this page.').'</p>') : 468 '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'). 469 470 '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. 471 __('Hide').'</label></p>'. 472 '<p class="form-note">'. 473 __('If checked this page will be active but not listed in widget Pages.'). 474 '</p>'. 475 424 476 '<p><label for="post_position" class="classic">'.__('Page position:').' '. 425 477 form::field('post_position',3,3,(string) $post_position). … … 594 646 } 595 647 648 # Controls comments or trakbacks capabilities 649 function isContributionAllowed($id,$dt,$com=true) 650 { 651 global $core; 652 653 if (!$id) { 654 return true; 655 } 656 if ($com) { 657 if (($core->blog->settings->system->comments_ttl == 0) || 658 (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 659 return true; 660 } 661 } else { 662 if (($core->blog->settings->system->trackbacks_ttl == 0) || 663 (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 664 return true; 665 } 666 } 667 return false; 668 } 596 669 597 670 # Show comments or trackbacks -
plugins/pages/page.php
r1068 r1107 18 18 $post_dt = ''; 19 19 $post_format = $core->auth->getOption('post_format'); 20 $post_password = '';21 20 $post_url = ''; 22 21 $post_lang = $core->auth->getInfo('user_lang'); … … 99 98 $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 100 99 $post_format = $post->post_format; 101 $post_password = $post->post_password;102 100 $post_url = $post->post_url; 103 101 $post_lang = $post->post_lang; … … 178 176 $post_selected = !empty($_POST['post_selected']); 179 177 $post_lang = $_POST['post_lang']; 180 $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null;181 178 $post_position = (integer) $_POST['post_position']; 182 179 … … 218 215 $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 219 216 $cur->post_format = $post_format; 220 $cur->post_password = $post_password;221 217 $cur->post_lang = $post_lang; 222 218 $cur->post_title = $post_title; … … 300 296 <?php echo 301 297 dcPage::jsDatePicker(). 302 dcPage::jsToolBar().303 298 dcPage::jsModal(). 304 299 dcPage::jsLoad('js/_post.js'). … … 485 480 '<p><label for="post_lang">'.__('Page lang:'). 486 481 form::combo('post_lang',$lang_combo,$post_lang).'</label></p>'. 487 488 '<p><label for="post_password">'.__('Page password:').489 form::field('post_password',10,32,html::escapeHTML($post_password),'maximal').490 '</label></p>'.491 482 492 483 '<div class="lockable">'.
Note: See TracChangeset
for help on using the changeset viewer.