Dotclear


Ignore:
Timestamp:
02/27/13 11:48:32 (12 years ago)
Author:
JcDenis
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.
Message:

merge with default branch in 2.5-RC

Location:
plugins/pages
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • plugins/pages/_public.php

    r877 r1107  
    102102          global $core, $_ctx; 
    103103           
    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')) { 
    105106               return; 
    106107          } 
     
    109110          $params['limit'] = abs((integer) $w->limit); 
    110111          $params['no_content'] = true; 
     112          $params['post_selected'] = false; 
    111113           
    112114          $sort = $w->sortby; 
     
    128130           
    129131          $res = 
    130           '<div class="pages">'. 
     132          ($w->content_only ? '' : '<div class="pages'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 
    131133          ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 
    132134          '<ul>'; 
     
    141143          } 
    142144           
    143           $res .= '</ul></div>'; 
     145          $res .= '</ul>'.($w->content_only ? '' : '</div>'); 
    144146           
    145147          return $res; 
  • plugins/pages/_public.php

    r1063 r1107  
    6161               { 
    6262                    $post_id = $_ctx->posts->post_id; 
    63                     $post_password = $_ctx->posts->post_password; 
    64                      
    65                     # Password protected entry 
    66                     if ($post_password != '' && !$_ctx->preview) 
    67                     { 
    68                          # Get passwords cookie 
    69                          if (isset($_COOKIE['dc_passwd'])) { 
    70                               $pwd_cookie = unserialize($_COOKIE['dc_passwd']); 
    71                          } else { 
    72                               $pwd_cookie = array(); 
    73                          } 
    74                           
    75                          # Check for match 
    76                          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                          else 
    83                          { 
    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 comment 
    95                     if ($post_comment) 
    96                     { 
    97                          # Spam trap 
    98                          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-- publicBeforeCommentPreview 
    132                               $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 
    133                                
    134                               $_ctx->comment_preview['preview'] = true; 
    135                          } 
    136                          else 
    137                          { 
    138                               # Post the comment 
    139                               $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                               try 
    152                               { 
    153                                    if (!text::isEmail($cur->comment_email)) { 
    154                                         throw new Exception(__('You must provide a valid email address.')); 
    155                                    } 
    156                                     
    157                                    # --BEHAVIOR-- publicBeforeCommentCreate 
    158                                    $core->callBehavior('publicBeforeCommentCreate',$cur); 
    159                                    if ($cur->post_id) {                          
    160                                         $comment_id = $core->blog->addComment($cur); 
    161                                     
    162                                         # --BEHAVIOR-- publicAfterCommentCreate 
    163                                         $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                      
    18263                    # The entry 
    18364                    $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates'); 
  • plugins/pages/list.php

    r877 r1107  
    8181          $selected = ''; 
    8282          if ($this->rs->post_selected) { 
    83                $selected = sprintf($img,__('selected'),'selected.png'); 
     83               $selected = sprintf($img,__('hidden'),'hidden.png'); 
    8484          } 
    8585           
  • plugins/pages/list.php

    r911 r1107  
    7979          } 
    8080           
    81           $protected = ''; 
    82           if ($this->rs->post_password) { 
    83                $protected = sprintf($img,__('protected'),'locker.png'); 
    84           } 
    85            
    8681          $selected = ''; 
    8782          if ($this->rs->post_selected) { 
     
    109104          '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. 
    110105          '<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>'. 
    112107          '</tr>'; 
    113108           
  • plugins/pages/page.php

    r877 r1107  
    3030$post_open_comment = false; 
    3131$post_open_tb = false; 
     32$post_selected = false; 
    3233 
    3334$post_media = array(); 
     
    5455     $status_combo[$v] = (string) $k; 
    5556} 
     57$img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    5658 
    5759# Formaters combo 
     
    7577unset($rs); 
    7678 
     79# Validation flag 
     80$bad_dt = false; 
    7781 
    7882# Get page informations 
     
    106110          $post_open_comment = (boolean) $post->post_open_comment; 
    107111          $post_open_tb = (boolean) $post->post_open_tb; 
     112          $post_selected = (boolean) $post->post_selected; 
    108113           
    109114          $page_title = __('Edit page'); 
     
    152157          $post_dt = ''; 
    153158     } 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          } 
    156172     } 
    157173      
    158174     $post_open_comment = !empty($_POST['post_open_comment']); 
    159175     $post_open_tb = !empty($_POST['post_open_tb']); 
     176     $post_selected = !empty($_POST['post_selected']); 
    160177     $post_lang = $_POST['post_lang']; 
    161178     $post_position = (integer) $_POST['post_position']; 
     
    173190} 
    174191 
    175 # Create or update post 
    176 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page) 
     192# Delete page 
     193if (!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 
     206if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page && !$bad_dt) 
    177207{ 
    178208     $cur = $core->con->openCursor($core->prefix.'post'); 
     
    196226     $cur->post_open_comment = (integer) $post_open_comment; 
    197227     $cur->post_open_tb = (integer) $post_open_tb; 
     228     $cur->post_selected = (integer) $post_selected; 
    198229      
    199230     if (isset($_POST['post_url'])) { 
     
    241272               $core->error->add($e->getMessage()); 
    242273          } 
    243      } 
    244 } 
    245  
    246 if (!empty($_POST['delete']) && $can_delete) 
    247 { 
    248      try { 
    249           # --BEHAVIOR-- adminBeforePageDelete 
    250           $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()); 
    255274     } 
    256275} 
     
    292311 
    293312if (!empty($_GET['upd'])) { 
    294           echo '<p class="message">'.__('Page has been successfully updated.').'</p>'; 
     313     dcPage::message(__('Page has been successfully updated.')); 
    295314} 
    296315elseif (!empty($_GET['crea'])) { 
    297           echo '<p class="message">'.__('Page has been successfully created.').'</p>'; 
     316     dcPage::message(__('Page has been successfully created.')); 
    298317} 
    299318elseif (!empty($_GET['attached'])) { 
    300      echo '<p class="message">'.__('File has been successfully attached.').'</p>'; 
     319     dcPage::message(__('File has been successfully attached.')); 
    301320} 
    302321elseif (!empty($_GET['rmattach'])) { 
    303      echo '<p class="message">'.__('Attachment has been successfully removed.').'</p>'; 
     322     dcPage::message(__('Attachment has been successfully removed.')); 
    304323} 
    305324 
     
    311330     $post_format = 'xhtml'; 
    312331      
    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.')); 
    314333} 
    315334 
     
    317336' &rsaquo; <a href="'.$p_url.'">'.__('Pages').'</a> &rsaquo; <span class="page-title">'.$page_title;  
    318337     if ($post_id) { 
    319           echo ' &ldquo;'.$post_title.'&rdquo;'; 
     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 ' &ldquo;'.$post_title.'&rdquo;'.' '.$img_status; 
    320355     } 
    321356echo '</span></h2>'; 
     
    410445      
    411446     '<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>'. 
    413448      
    414449     '<p><label for="post_format">'.__('Text formating:'). 
     
    419454     '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. 
    420455     __('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 
    421462     '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. 
    422463     __('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 
    424476     '<p><label for="post_position" class="classic">'.__('Page position:').' '. 
    425477     form::field('post_position',3,3,(string) $post_position). 
     
    594646} 
    595647 
     648# Controls comments or trakbacks capabilities 
     649function 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} 
    596669 
    597670# Show comments or trackbacks 
  • plugins/pages/page.php

    r1068 r1107  
    1818$post_dt = ''; 
    1919$post_format = $core->auth->getOption('post_format'); 
    20 $post_password = ''; 
    2120$post_url = ''; 
    2221$post_lang = $core->auth->getInfo('user_lang'); 
     
    9998          $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
    10099          $post_format = $post->post_format; 
    101           $post_password = $post->post_password; 
    102100          $post_url = $post->post_url; 
    103101          $post_lang = $post->post_lang; 
     
    178176     $post_selected = !empty($_POST['post_selected']); 
    179177     $post_lang = $_POST['post_lang']; 
    180      $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 
    181178     $post_position = (integer) $_POST['post_position']; 
    182179      
     
    218215     $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 
    219216     $cur->post_format = $post_format; 
    220      $cur->post_password = $post_password; 
    221217     $cur->post_lang = $post_lang; 
    222218     $cur->post_title = $post_title; 
     
    300296  <?php echo 
    301297  dcPage::jsDatePicker(). 
    302   dcPage::jsToolBar(). 
    303298  dcPage::jsModal(). 
    304299  dcPage::jsLoad('js/_post.js'). 
     
    485480     '<p><label for="post_lang">'.__('Page lang:'). 
    486481     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>'. 
    491482      
    492483     '<div class="lockable">'. 
Note: See TracChangeset for help on using the changeset viewer.

Sites map