Dotclear

Changeset 1414:ce67e9c592b7 for admin


Ignore:
Timestamp:
08/16/13 15:48:37 (12 years ago)
Author:
Dsls
Branch:
twig
Message:
  • reworked breadcrumb
  • tuned checkboxes (need to see if it works for multiple values)
  • magic methods for dcForm are more intuitive now, getField method added
Location:
admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r1413 r1414  
    304304} 
    305305 
    306 $_ctx->fillPageTitle(__('Dashboard')); 
     306$_ctx->setBreadCrumb(__('Dashboard').' : '.html::escapeHTML($core->blog->name), false); 
    307307$core->tpl->display('index.html.twig'); 
    308308?> 
  • admin/js/_post.js

    r1280 r1414  
    127127               fn: function() { excerptTb.switchMode(formatField.value); }, 
    128128               cookie: 'dcx_post_excerpt', 
    129                hide: $('#post_excerpt').val() == '' 
     129               hide: $('#post_excerpt').val() == '', 
     130               legend_click: true 
    130131          }); 
    131132           
  • admin/plugin.php

    r1413 r1414  
    9090# No plugin or content found 
    9191if (!$has_content) { 
    92      $_ctx->fillPageTitle(__('Plugin not found')); 
     92     $_ctx->setBreadcrumb(__('Plugin not found')); 
    9393     $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 
    9494     $core->tpl->display('plugin.html.twig'); 
  • admin/post.php

    r1413 r1414  
    1515dcPage::check('usage,contentadmin'); 
    1616 
    17 function savePost($form) { 
    18      global $_ctx; 
    19      $_ctx->setAlert('save'); 
    20  
    21 } 
    22  
    23 function deletePost($form) { 
    24      print_r($form); exit; 
     17class PostActions  
     18{ 
     19     public static function savePost($form) { 
     20          global $_ctx, $core; 
     21          try { 
     22               $form->check($_ctx); 
     23               $_ctx->setAlert('save'); 
     24               $form->cat_id = (integer) $form->cat_id; 
     25      
     26               if (!empty($form->post_dt)) { 
     27                    try 
     28                    { 
     29                         $post_dt = strtotime($form->post_dt); 
     30                         if ($post_dt == false || $post_dt == -1) { 
     31                              $bad_dt = true; 
     32                              throw new Exception(__('Invalid publication date')); 
     33                         } 
     34                         $form->post_dt = date('Y-m-d H:i',$post_dt); 
     35                    } 
     36                    catch (Exception $e) 
     37                    { 
     38                         $core->error->add($e->getMessage()); 
     39                    } 
     40               } 
     41               $post_excerpt = $form->post_excerpt; 
     42               $post_content = $form->post_content; 
     43               $post_excerpt_xhtml = ''; 
     44               $post_content_xhtml = ''; 
     45               $core->blog->setPostContent( 
     46                    $form->id,$form->post_format,$form->post_lang, 
     47                    $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
     48               ); 
     49               $form->post_excerpt = $post_excerpt; 
     50               $form->post_content = $post_content; 
     51               $form->post_excerpt_xhtml = $post_excerpt_xhtml; 
     52               $form->post_content_xhtml = $post_content_xhtml; 
     53                
     54               $cur = $core->con->openCursor($core->prefix.'post'); 
     55      
     56               $cur->post_title = $form->post_title; 
     57               $cur->cat_id = $form->cat_id ? $form->cat_id : null; 
     58               $cur->post_dt = $form->post_dt ? date('Y-m-d H:i:00',strtotime($form->post_dt)) : ''; 
     59               $cur->post_format = $form->post_format; 
     60               $cur->post_password = $form->post_password; 
     61               $cur->post_lang = $form->post_lang; 
     62               $cur->post_title = $form->post_title; 
     63               $cur->post_excerpt = $form->post_excerpt; 
     64               $cur->post_excerpt_xhtml = $form->post_excerpt_xhtml; 
     65               $cur->post_content = $form->post_content; 
     66               $cur->post_content_xhtml = $form->post_content_xhtml; 
     67               $cur->post_notes = $form->post_notes; 
     68               $cur->post_status = $form->post_status; 
     69               $cur->post_selected = (integer) $form->post_selected; 
     70               $cur->post_open_comment = (integer) $form->post_open_comment; 
     71               $cur->post_open_tb = (integer) $form->post_open_tb; 
     72      
     73               if (!empty($form->post_url)) { 
     74                    $cur->post_url = $form->post_url; 
     75               } 
     76      
     77               # Update post 
     78               if ($form->id) 
     79               { 
     80                    # --BEHAVIOR-- adminBeforePostUpdate 
     81                    $core->callBehavior('adminBeforePostUpdate',$cur,$form->id); 
     82                     
     83                    $core->blog->updPost($form->id,$cur); 
     84                     
     85                    # --BEHAVIOR-- adminAfterPostUpdate 
     86                    $core->callBehavior('adminAfterPostUpdate',$cur,$form->id); 
     87                     
     88                    http::redirect('post.php?id='.$form->id.'&upd=1'); 
     89               } 
     90               else 
     91               { 
     92                    $cur->user_id = $core->auth->userID(); 
     93                                        # --BEHAVIOR-- adminBeforePostCreate 
     94                    $core->callBehavior('adminBeforePostCreate',$cur); 
     95                     
     96                    $return_id = $core->blog->addPost($cur); 
     97                     
     98                    # --BEHAVIOR-- adminAfterPostCreate 
     99                    $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
     100                     
     101                    http::redirect('post.php?id='.$return_id.'&crea=1'); 
     102               } 
     103 
     104     } catch (Exception $e) { 
     105          $ctx->setError($e->getMessage()); 
     106     } 
     107} 
     108     function deletePost($form) { 
     109          echo $form->id->getValue(); exit; 
     110     } 
    25111} 
    26112 
    27113$page_title = __('New entry'); 
    28  
     114$post_id=''; 
    29115$can_view_page = true; 
    30116$can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id); 
     
    67153$rs = $core->blog->getLangs(array('order'=>'asc')); 
    68154$all_langs = l10n::getISOcodes(0,1); 
    69 $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); 
     155$lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(0,1)); 
    70156while ($rs->fetch()) { 
    71157     if (isset($all_langs[$rs->post_lang])) { 
    72           $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; 
    73           unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); 
     158          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
     159          unset($lang_combo[__('Available')][$rs->post_lang]); 
    74160     } else { 
    75           $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; 
     161          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
    76162     } 
    77163} 
     
    83169     ->addField( 
    84170          new dcFieldText('post_title','', array( 
    85                'size'         => 20, 
     171               'maxlength'         => 255, 
    86172               'required'     => true, 
    87173               'label'        => __('Title')))) 
     
    100186     ->addField( 
    101187          new dcFieldSubmit('save',__('Save'),array( 
    102                'action' => 'savePost'))) 
     188               'action' => array('PostActions','savePost')))) 
    103189     ->addField( 
    104190          new dcFieldSubmit('delete',__('Delete'),array( 
     
    124210               "label" => __('Accept trackbacks')))) 
    125211     ->addField( 
    126           new dcFieldCheckbox ('post_selected',false,array( 
     212          new dcFieldCheckbox ('post_selected',array(1=>false),array( 
    127213               "label" => __('Selected entry')))) 
    128214     ->addField( 
     
    225311     $default_tab = 'comments'; 
    226312} 
    227  
     313$page_title_edit = __('Edit entry'); 
    228314$_ctx 
    229      ->fillPageTitle(html::escapeHTML($core->blog->name)) 
    230      ->fillPageTitle(__('Entries'),'posts.php') 
    231      ->fillPageTitle($page_title) 
     315     ->setBreadCrumb( 
     316          array( 
     317               html::escapeHTML($core->blog->name) => '', 
     318               __('Entries') => 'posts.php', 
     319               ($post_id ? $page_title_edit : $page_title) => '' 
     320     )) 
    232321     ->default_tab = $default_tab; 
    233322 
  • admin/posts.php

    r1413 r1414  
    187187 
    188188$_ctx 
    189      ->fillPageTitle(__('Entries'),'posts.php'); 
     189     ->setBreadCrumb(array(__('Entries') => 'posts.php')); 
    190190 
    191191 
Note: See TracChangeset for help on using the changeset viewer.

Sites map