Dotclear

Changeset 1147:2e5cb79e4782


Ignore:
Timestamp:
03/08/13 15:37:34 (12 years ago)
Author:
Dsls <dsls@…>
Branch:
twig
Message:

Oops, I did it again (c).

Fist draft of merge from formfilters to dctwig. lists need to be broken up too.

From now all post lists are broken.

Files:
3 added
13 edited

Legend:

Unmodified
Added
Removed
  • admin/posts.php

    r796 r1147  
    1212 
    1313require dirname(__FILE__).'/../inc/admin/prepend.php'; 
    14  
     14global $_ctx; 
    1515dcPage::check('usage,contentadmin'); 
    1616 
     
    4848     # Filter form we'll put in html_block 
    4949     $users_combo = $categories_combo = array(); 
    50      $users_combo['-'] = $categories_combo['-'] = ''; 
    5150     while ($users->fetch()) 
    5251     { 
     
    6160     } 
    6261      
    63      $categories_combo[__('None')] = 'NULL'; 
     62 
     63# Getting categories 
     64$categories_combo = array(); 
     65try { 
     66     $categories = $core->blog->getCategories(array('post_type'=>'post')); 
    6467     while ($categories->fetch()) { 
    65           $categories_combo[str_repeat('&nbsp;&nbsp;',$categories->level-1).($categories->level-1 == 0 ? '' : '&bull; '). 
    66                html::escapeHTML($categories->cat_title). 
    67                ' ('.$categories->nb_post.')'] = $categories->cat_id; 
     68          $categories_combo[$categories->cat_id] =  
     69               str_repeat('&nbsp;&nbsp;',$categories->level-1). 
     70               ($categories->level-1 == 0 ? '' : '&bull; '). 
     71               html::escapeHTML($categories->cat_title); 
    6872     } 
    69       
     73} catch (Exception $e) { } 
    7074     $status_combo = array( 
    71      '-' => '' 
    7275     ); 
    7376     foreach ($core->blog->getAllPostStatus() as $k => $v) { 
    74           $status_combo[$v] = (string) $k; 
     77          $status_combo[(string) $k] = (string)$v; 
    7578     } 
    7679      
    7780     $selected_combo = array( 
    78      '-' => '', 
    79      __('selected') => '1', 
    80      __('not selected') => '0' 
     81     '1' => __('is selected'), 
     82     '0' => __('is not selected') 
    8183     ); 
    8284      
    8385     # Months array 
    84      $dt_m_combo['-'] = ''; 
    8586     while ($dates->fetch()) { 
    86           $dt_m_combo[dt::str('%B %Y',$dates->ts())] = $dates->year().$dates->month(); 
     87          $dt_m_combo[$dates->year().$dates->month()] = dt::str('%B %Y',$dates->ts()); 
    8788     } 
    8889      
    89      $lang_combo['-'] = ''; 
    9090     while ($langs->fetch()) { 
    9191          $lang_combo[$langs->post_lang] = $langs->post_lang; 
    9292     } 
    93       
    94      $sortby_combo = array( 
    95      __('Date') => 'post_dt', 
    96      __('Title') => 'post_title', 
    97      __('Category') => 'cat_title', 
    98      __('Author') => 'user_id', 
    99      __('Status') => 'post_status', 
    100      __('Selected') => 'post_selected' 
    101      ); 
    102       
    103      $order_combo = array( 
    104      __('Descending') => 'desc', 
    105      __('Ascending') => 'asc' 
    106      ); 
    10793} 
     94$form = new dcForm($core,'post','post.php'); 
     95 
    10896 
    10997# Actions combo box 
     
    136124$core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); 
    137125 
    138 /* Get posts 
    139 -------------------------------------------------------- */ 
    140 $user_id = !empty($_GET['user_id']) ?   $_GET['user_id'] : ''; 
    141 $cat_id = !empty($_GET['cat_id']) ?     $_GET['cat_id'] : ''; 
    142 $status = isset($_GET['status']) ? $_GET['status'] : ''; 
    143 $selected = isset($_GET['selected']) ?  $_GET['selected'] : ''; 
    144 $month = !empty($_GET['month']) ?       $_GET['month'] : ''; 
    145 $lang = !empty($_GET['lang']) ?         $_GET['lang'] : ''; 
    146 $sortby = !empty($_GET['sortby']) ?     $_GET['sortby'] : 'post_dt'; 
    147 $order = !empty($_GET['order']) ?       $_GET['order'] : 'desc'; 
    148126 
    149 $show_filters = false; 
    150127 
    151 $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; 
    152 $nb_per_page =  30; 
    153  
    154 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 
    155      if ($nb_per_page != $_GET['nb']) { 
    156           $show_filters = true; 
     128class monthComboFilter extends comboFilter { 
     129     public function applyFilter($params) { 
     130          $month=$this->avalues['values'][0]; 
     131          $params['post_month'] = substr($month,4,2); 
     132          $params['post_year'] = substr($month,0,4); 
    157133     } 
    158      $nb_per_page = (integer) $_GET['nb']; 
    159134} 
    160  
    161 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 
    162 $params['no_content'] = true; 
    163  
    164 # - User filter 
    165 if ($user_id !== '' && in_array($user_id,$users_combo)) { 
    166      $params['user_id'] = $user_id; 
    167      $show_filters = true; 
    168 } else { 
    169      $user_id=''; 
    170 } 
    171  
    172 # - Categories filter 
    173 if ($cat_id !== '' && in_array($cat_id,$categories_combo)) { 
    174      $params['cat_id'] = $cat_id; 
    175      $show_filters = true; 
    176 } else { 
    177      $cat_id=''; 
    178 } 
    179  
    180 # - Status filter 
    181 if ($status !== '' && in_array($status,$status_combo)) { 
    182      $params['post_status'] = $status; 
    183      $show_filters = true; 
    184 } else { 
    185      $status=''; 
    186 } 
    187  
    188 # - Selected filter 
    189 if ($selected !== '' && in_array($selected,$selected_combo)) { 
    190      $params['post_selected'] = $selected; 
    191      $show_filters = true; 
    192 } else { 
    193      $selected=''; 
    194 } 
    195  
    196 # - Month filter 
    197 if ($month !== '' && in_array($month,$dt_m_combo)) { 
    198      $params['post_month'] = substr($month,4,2); 
    199      $params['post_year'] = substr($month,0,4); 
    200      $show_filters = true; 
    201 } else { 
    202      $month=''; 
    203 } 
    204  
    205 # - Lang filter 
    206 if ($lang !== '' && in_array($lang,$lang_combo)) { 
    207      $params['post_lang'] = $lang; 
    208      $show_filters = true; 
    209 } else { 
    210      $lang=''; 
    211 } 
    212  
    213 # - Sortby and order filter 
    214 if ($sortby !== '' && in_array($sortby,$sortby_combo)) { 
    215      if ($order !== '' && in_array($order,$order_combo)) { 
    216           $params['order'] = $sortby.' '.$order; 
    217      } else { 
    218           $order='desc'; 
    219      } 
    220       
    221      if ($sortby != 'post_dt' || $order != 'desc') { 
    222           $show_filters = true; 
    223      } 
    224 } else { 
    225      $sortby='post_dt'; 
    226      $order='desc'; 
    227 } 
    228  
    229 # Get posts 
    230 try { 
    231      $posts = $core->blog->getPosts($params); 
    232      $counter = $core->blog->getPosts($params,true); 
    233      $post_list = new adminPostList($core,$posts,$counter->f(0)); 
    234 } catch (Exception $e) { 
    235      $core->error->add($e->getMessage()); 
    236 } 
    237  
    238135/* DISPLAY 
    239136-------------------------------------------------------- */ 
    240 $starting_script = dcPage::jsLoad('js/_posts_list.js'); 
    241 if (!$show_filters) { 
    242      $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 
    243 } 
     137$filterSet = new dcFilterSet($core,'fposts','posts.php'); 
    244138 
    245 dcPage::open(__('Entries'),$starting_script); 
     139$filterSet 
     140     ->addFilter(new comboFilter( 
     141          'users',__('Author'), __('Author'), 'user_id', $users_combo)) 
     142     ->addFilter(new comboFilter( 
     143          'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) 
     144     ->addFilter(new comboFilter( 
     145          'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) 
     146     ->addFilter(new comboFilter( 
     147          'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) 
     148     ->addFilter(new booleanFilter( 
     149          'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) 
     150     ->addFilter(new monthComboFilter( 
     151          'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) 
     152     ->addFilter(new textFilter( 
     153          'search',__('Contains'),__('The entry contains'), 'search',20,255)); 
    246154 
    247 if (!$core->error->flag()) 
    248 { 
    249      echo  
    250      '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; <span class="page-title">'.__('Entries').'</span></h2>'. 
    251      '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; 
    252       
    253      if (!$show_filters) { 
    254           echo '<p><a id="filter-control" class="form-control" href="#">'. 
    255           __('Filters').'</a></p>'; 
    256      } 
    257       
    258      echo 
    259      '<form action="posts.php" method="get" id="filters-form">'. 
    260      '<fieldset><legend>'.__('Filters').'</legend>'. 
    261      '<div class="three-cols">'. 
    262      '<div class="col">'. 
    263      '<label for="user_id">'.__('Author:'). 
    264      form::combo('user_id',$users_combo,$user_id).'</label> '. 
    265      '<label for="cat_id">'.__('Category:'). 
    266      form::combo('cat_id',$categories_combo,$cat_id).'</label> '. 
    267      '<label for="status">'.__('Status:'). 
    268      form::combo('status',$status_combo,$status).'</label> '. 
    269      '</div>'. 
    270       
    271      '<div class="col">'. 
    272      '<label for="selected">'.__('Selected:'). 
    273      form::combo('selected',$selected_combo,$selected).'</label> '. 
    274      '<label for="month">'.__('Month:'). 
    275      form::combo('month',$dt_m_combo,$month).'</label> '. 
    276      '<label for="lang">'.__('Lang:'). 
    277      form::combo('lang',$lang_combo,$lang).'</label> '. 
    278      '</div>'. 
    279       
    280      '<div class="col">'. 
    281      '<p><label for="sortby">'.__('Order by:'). 
    282      form::combo('sortby',$sortby_combo,$sortby).'</label> '. 
    283      '<label for="order">'.__('Sort:'). 
    284      form::combo('order',$order_combo,$order).'</label></p>'. 
    285      '<p><label for="nb" class="classic">'.  form::field('nb',3,3,$nb_per_page).' '. 
    286      __('Entries per page').'</label></p> '. 
    287      '<p><input type="submit" value="'.__('Apply filters').'" /></p>'. 
    288      '</div>'. 
    289      '</div>'. 
    290      '<br class="clear" />'. //Opera sucks 
    291      '</fieldset>'. 
    292      '</form>'; 
    293       
    294      # Show posts 
    295      $post_list->display($page,$nb_per_page, 
    296      '<form action="posts_actions.php" method="post" id="form-entries">'. 
    297       
    298      '%s'. 
    299       
    300      '<div class="two-cols">'. 
    301      '<p class="col checkboxes-helpers"></p>'. 
    302       
    303      '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
    304      form::combo('action',$combo_action). 
    305      '<input type="submit" value="'.__('ok').'" /></p>'. 
    306      form::hidden(array('user_id'),$user_id). 
    307      form::hidden(array('cat_id'),$cat_id). 
    308      form::hidden(array('status'),$status). 
    309      form::hidden(array('selected'),$selected). 
    310      form::hidden(array('month'),$month). 
    311      form::hidden(array('lang'),$lang). 
    312      form::hidden(array('sortby'),$sortby). 
    313      form::hidden(array('order'),$order). 
    314      form::hidden(array('page'),$page). 
    315      form::hidden(array('nb'),$nb_per_page). 
    316      $core->formNonce(). 
    317      '</div>'. 
    318      '</form>' 
    319      ); 
    320 } 
     155$filterSet->setup(); 
    321156 
    322 dcPage::helpBlock('core_posts'); 
    323 dcPage::close(); 
     157$_ctx 
     158     ->fillPageTitle(__('Entries'),'posts.php'); 
     159$params=new ArrayObject(); 
     160$filterSet->applyFilters($params); 
     161$_ctx->filters = '['.print_r($params->getArrayCopy(),true).']'; 
     162 
     163$core->tpl->display('posts.html.twig'); 
     164 
     165 
    324166?> 
  • admin/style/default.css

    r1065 r1147  
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    1212*/ 
    13  
    14 /* ------------------------------------------------------------------ html */ 
    1513body { 
    1614     font: 75%/1.5em Helvetica,Arial,sans-serif; 
     
    4038     margin-bottom: 0.6em; 
    4139} 
     40 
    4241h2 { 
    4342     color: #666; 
     
    5251     font-size: 1.2em; 
    5352} 
     53 
    5454p, div.p { 
    5555     margin: 0 0 1em 0; 
    5656} 
     57 
    5758hr { 
    5859     height: 1px; 
     
    6162     border-style: solid; 
    6263} 
     64 
    6365pre, code { 
    6466     font: 100% "Andale Mono","Courier New",monospace; 
     
    7779     cursor: help; 
    7880} 
     81 
    7982 
    8083/* LAYOUT 
     
    148151     height: 2em; 
    149152} 
    150 #info-box1 p { 
    151      margin: 0; 
    152      display: inline; 
    153 } 
    154153#info-box1 select { 
    155154     width: 15em; 
     
    197196     padding: 1em; 
    198197     background: #fff; 
     198     -webkit-border-radius: .5em; 
     199     -moz-border-radius: .5em; 
    199200     border-radius: .5em; 
    200201     border: 1px solid #ddd; 
     
    254255     background: #dfdfdf; 
    255256     text-decoration: none; 
     257     -webkit-border-top-left-radius: .3em; 
     258     -webkit-border-top-right-radius: .3em; 
     259     -moz-border-radius-topleft: .3em; 
     260     -moz-border-radius-topright: .3em; 
    256261     border-top-left-radius: .3em; 
    257262     border-top-right-radius: .3em; 
     
    277282     float: left; 
    278283     margin-top: 1.2em; 
    279      margin-bottom: 3em; 
     284     margin-bottom: 1em; 
    280285} 
    281286#main-menu h3 { 
     
    297302     padding: .2em 0 0 32px; 
    298303     background-repeat: no-repeat; 
    299      background-position: 12px .4em; 
     304     background-position: 12px .2em; 
    300305} 
    301306#main-menu a { 
     
    335340#footer { 
    336341     clear: both; 
    337      padding: .75em 0; 
    338      background: #575859 url(dc_logo_small.png) no-repeat 8px bottom; 
     342     padding: .75em 2em; 
     343     margin: 6em 15px .5em 15px; 
     344     -webkit-border-radius: .3em; 
     345     -moz-border-radius: .3em; 
     346     border-radius: .3em; 
     347     background: #575859 url(dc_logo_small.png) no-repeat right bottom; 
    339348     color: #fff; 
    340349} 
     
    369378     border: 1px solid #999; 
    370379     padding: 1em 1em 0 1em; 
     380     -moz-border-radius: 4px; 
     381     -webkit-border-radius: 4px; 
    371382     border-radius: 4px; 
    372383} 
     
    433444     color: #666; 
    434445} 
     446 
    435447#dashboard-items { 
    436448     float: left; 
     
    501513     border: 1px solid #ccc; 
    502514     border-left: 1em solid #E5E3DA; 
     515     -moz-border-radius: .3em; 
     516     -webkit-border-radius: .3em; 
    503517     border-radius: .3em; 
    504518} 
     
    538552     height: 500px; 
    539553} 
     554 
    540555#add-file-f { 
    541556     position: relative; 
     
    621636     display: inline; 
    622637} 
     638 
    623639#default-favs h3 { 
    624640     margin-top: 2em; 
    625641     margin-bottom: 1em; 
    626642} 
     643 
    627644.fav-list { 
    628645     list-style-type: none; 
     
    651668     border: 1px solid #ddd; 
    652669     padding: .2em; 
     670     -moz-border-radius: .5em; 
     671     -webkit-border-radius: .5em; 
    653672     border-radius: .5em; 
    654673} 
     
    745764     border: 1px solid #f3f3f3; 
    746765     cursor: pointer; 
     766     -moz-border-radius: 4px; 
     767     -webkit-border-radius: 4px; 
    747768     border-radius: 4px; 
    748769} 
     
    783804} 
    784805#help-button { 
    785      position: fixed; 
    786      top: 3.2em; 
     806     position: absolute; 
     807     top: 6.2em; 
    787808     right: 0px; 
    788809     cursor: pointer; 
     
    794815     text-transform: capitalize; 
    795816     padding: .33em .75em .33em 1em; 
    796      border-radius: 1em 0 0 1em; 
     817     -moz-border-radius: 1em 0 0 1em; 
     818     -webkit-border-top-left-radius: 1em; 
     819     -webkit-border-bottom-left-radius: 1em; 
    797820     color: #444; 
    798821} 
     
    856879div.message, p.message,  
    857880div.static-msg, p.static-msg { 
    858      padding: 0.5em 0.5em 0.5em 48px; 
     881     padding: 0.5em 0.5em 0.5em 40px; 
    859882     margin-bottom: 1em; 
     883     -moz-border-radius: 8px; 
     884     -webkit-border-radius: 8px; 
    860885     border-radius: 8px; 
    861886} 
     
    865890} 
    866891div.error, p.error { 
    867      background: #ffdec8 url(msg-error.png) no-repeat .7em .7em; 
    868      color: #000; 
     892     background: #e5bfbf url(msg-error.png) no-repeat 5px 5px; 
     893     color: #600; 
    869894} 
    870895div.message, p.message,  
    871896div.static-msg, p.static-msg { 
    872      background: #666 url(msg-std.png) no-repeat .7em .7em; 
     897     background: #666 url(msg-std.png) no-repeat 5px 5px; 
    873898     color: #fff; 
    874899} 
     
    917942     vertical-align: middle; 
    918943} 
     944 
    919945/* Si quelque chose a besoin d'être caché sauf pour les revues d'écran */ 
    920946.hidden { 
     
    951977     overflow: auto; 
    952978} 
     979 
    953980.grid { 
    954981     background: transparent repeat url('grid.png') 0 0; 
    955982} 
     983 
    956984.line p { 
    957985     margin: 0; 
     
    960988     color: #666; 
    961989} 
     990 
    962991ul.nice { 
    963992     margin: 1em 0; 
     
    9861015     right: 0; 
    9871016} 
    988 .distrib img { 
    989      display: block; 
    990      float: right; 
    991      margin-top: -1em; 
    992 } 
    9931017/* TABLES 
    9941018-------------------------------------------------------- */ 
     
    10081032     margin-bottom: .5em; 
    10091033} 
    1010  
    10111034th, td { 
    10121035     border-width: 0 0 1px 0; 
     
    10181041th { 
    10191042     text-align: left; 
    1020      border-bottom-color: #666; 
    10211043} 
    10221044.noborder td, td.noborder, .noborder th, th.noborder { 
    10231045     border-width: 0; 
    10241046} 
     1047 
    10251048table .maximal, table.maximal { 
    10261049     width: 100%; 
     
    10291052     width: 1px; 
    10301053} 
     1054 
    10311055table .nowrap { 
    10321056     white-space: nowrap; 
    10331057     vertical-align: top; 
    1034 } 
    1035 table.settings, table.prefs { 
    1036      width: 80%; 
    1037 } 
    1038 table.settings th:first-child, table.prefs th:first-child { 
    1039      width: 20%; 
    1040 } 
    1041 table.settings th + th, table.prefs th + th { 
    1042      width: 30%; 
    1043 } 
    1044 table.settings th + th + th, table.prefs th + th + th { 
    1045      width: 10%; 
    1046 } 
    1047 table.settings th:last-child, table.prefs th:last-child { 
    1048      width: 40%; 
    10491058} 
    10501059 
     
    11191128     font-weight: normal; 
    11201129} 
     1130 
    11211131input, textarea, select { 
    11221132     background: #f9f9f9; 
     
    11261136     border-color: #000 #ccc #ccc #000; 
    11271137} 
    1128 input.invalid, textarea.invalid, select.invalid { 
    1129      border: 1px solid red; 
    1130      background: #fff;  
    1131      color: red; 
    1132      box-shadow: 0 0 0 1px rgba(218, 62, 90, 0.3) 
    1133 } 
    11341138input, textarea, select, option { 
    11351139     font: 1em "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif; 
     
    11511155     background: transparent; 
    11521156} 
     1157 
    11531158label { 
    11541159     display: block; 
     
    11621167     color: #666; 
    11631168} 
    1164 span.form-note { 
    1165      font-style:italic; 
    1166      font-weight: normal; 
    1167      color: #666; 
    1168 } 
    11691169p.form-note.warn, p.form-note.info, p.warning { 
    11701170     font-style: normal; 
     
    11721172} 
    11731173p.form-note.warn, p.warning { 
    1174      background: #ffd url(warning.png) no-repeat .3em .3em; 
     1174     background: #ffd url(warning.png) no-repeat .2em .2em; 
    11751175     border: 1px solid #f0c020; 
    11761176} 
    11771177p.form-note.info { 
    1178      background: #eef url(info.png) no-repeat .3em .2em; 
     1178     background: #eef url(info.png) no-repeat .2em .2em; 
    11791179     border: 1px solid #99f; 
    11801180} 
     
    11961196     resize: vertical; 
    11971197} 
     1198 
    11981199label.required { 
    11991200     font-weight: bold; 
     
    12081209p.field { 
    12091210     position: relative; 
    1210       
     1211 
    12111212} 
    12121213p.field label { 
     
    12201221     top: 0; 
    12211222} 
     1223 
    12221224label .maximal, textarea.maximal, input.maximal { 
    12231225     width: 100%; 
     
    12341236     padding-left: 20px; 
    12351237} 
     1238 
     1239a#toggle-filters { 
     1240     font-weight: bold; 
     1241     background: url(../images/plus.png) no-repeat 0 0; 
     1242     padding-left: 20px; 
     1243} 
     1244 
     1245a#toggle-filters.opened { 
     1246     background: url(../images/minus.png) no-repeat 0 0; 
     1247} 
     1248 
    12361249.constrained { 
    12371250     margin: 0; 
     
    12621275     padding: .1em .5em 0 .5em; 
    12631276     text-shadow: 0 1px 1px rgba(0,0,0,.3); 
     1277     -webkit-border-radius: .2em; 
     1278     -moz-border-radius: .2em; 
    12641279     border-radius: .2em; 
    12651280     margin-bottom: .1em; 
     
    13431358} 
    13441359a.button.add { 
     1360     -webkit-border-radius: .5em; 
     1361     -moz-border-radius: .5em; 
    13451362     border-radius: .5em; 
    13461363     margin-bottom: .1em;      
    1347      background: #2C8FD1 url(../images/add.png) no-repeat 6px center; 
     1364     background: #2C8FD1 url(add.png) no-repeat 6px center; 
    13481365     color: #fff; 
    13491366     padding: .2em 16px .2em 30px; 
     
    13541371} 
    13551372 
    1356 /* jQuery Autocomplete plugin */ 
    1357 .ac_results { 
    1358      padding: 0px; 
    1359      border: 1px dotted #f90; 
    1360      background-color: white; 
    1361      overflow: hidden; 
    1362      z-index: 99999; 
    1363 } 
    1364 .ac_results ul { 
    1365      width: 100%; 
    1366      list-style-position: outside; 
    1367      list-style: none; 
    1368      padding: 0; 
    1369      margin: 0; 
    1370 } 
    1371 .ac_results li { 
    1372      margin: 0px; 
    1373      padding: 2px 5px; 
    1374      cursor: default; 
    1375      display: block; 
    1376      font: menu; 
    1377      font-size: 1em; 
    1378      line-height: 16px; 
    1379      overflow: hidden; 
    1380 } 
    1381 .ac_loading { 
    1382      background: transparent url('loader.gif') right center no-repeat; 
    1383 } 
    1384 .ac_over { 
    1385      background-color: #06c; 
    1386      color: white; 
    1387 } 
     1373form#filters {font-size: 100%; background: #f0f0f0; padding: 1em; border-radius: .5em; border: 1px solid #ddd;} 
     1374form#filters .margintop {padding-top: 1.33em;} 
     1375form#filters ul, form#filters p {list-style-type:none;margin: 0; padding: 0 0 .5em 0; margin-left: 1em;} 
     1376form#filters .col30 {border-left: 1px solid #999;} 
     1377form#filters .col30 h3 {margin-left: 1em;} 
     1378 
     1379p.line, li.line { position: relative; padding: 3px 0 0 28px; margin: 0 0 1em 0;} 
     1380li.line input[type=submit] {position: absolute; left:0;top:0; padding: 0 .1em; margin: 0;} 
     1381li.line input[type=checkbox], li.line input[type=checkbox] {position: absolute; left: 0; top: .2em; padding: 0 .1em; margin: 0;} 
     1382li.line select { margin-right: 2em;} 
     1383li.line label { display: block; width: 8em; float: left;} 
     1384li.line label img {margin-right: 8px;} 
     1385li.line span.or { 
     1386     text-align: right; 
     1387     margin-left: 5em; 
     1388     font-weight: bold; 
     1389} 
     1390p.line label.or + select {margin-left: 2em;} 
     1391li.line { padding: 0 0 0 20px; height: 1em;} 
     1392li.line label {width: auto;} 
     1393 
     1394#available_filters input[type=submit] {padding: 0 .1em; margin-left: .5em;} 
     1395 
     1396div.pagination span, div.pagination a { 
     1397     margin-right: 1em; 
     1398} 
  • inc/admin/class.dc.admincontext.php

    r1091 r1147  
    4545                
    4646               'admin_url'    => DC_ADMIN_URL, 
    47                'theme_url'    => DC_ADMIN_URL.'index.php?tf=', 
     47               'theme_url'    => '', 
    4848               'plugin_url'   => DC_ADMIN_URL.'index.php?pf=', 
    4949                
  • inc/admin/class.dc.form.php

    r1090 r1147  
    1313 
    1414/** 
    15  * Template form node 
    16  */ 
     15* dcFormNode 
     16* 
     17* @uses     Twig_Node 
     18* 
     19*/ 
    1720class dcFormNode extends Twig_Node 
    1821{ 
     
    3033     { 
    3134          $compiler 
    32                ->addDebugInfo($this) 
    33                ->write("\$context['dc_form']->beginForm('". 
    34                     $this->getAttribute('name')."');\n") 
     35               ->addDebugInfo($this); 
     36          $compiler 
     37               ->write("\$context['dc_form']->beginForm(") 
     38               ->subcompile($this->getAttribute('name')) 
     39               ->write(");\n"); 
     40          $compiler 
    3541               ->subcompile($this->getNode('body')) 
    3642               ->write("\$context['dc_form']->renderHiddenWidgets();\n") 
     
    4955          $lineno = $token->getLine(); 
    5056          $stream = $this->parser->getStream(); 
    51           $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 
     57          $name = $this->parser->getExpressionParser()->parseExpression(); 
    5258          $stream->expect(Twig_Token::BLOCK_END_TYPE); 
    5359          $body = $this->parser->subparse(array($this,'decideBlockEnd'),true); 
     
    7783     protected $core; 
    7884     protected $twig; 
    79      protected $blocks; 
    8085     protected $forms; 
    8186     protected $currentForm; 
     87     protected $blocks; 
    8288      
    8389     public function __construct($core) 
     
    96102     } 
    97103      
     104     public function addTemplate($tpl) { 
     105          $t = $this->twig->loadTemplate($tpl); 
     106          $this->blocks = array_merge($this->blocks,$t->getBlocks()); 
     107     } 
     108 
    98109     public function getGlobals() 
    99110     { 
     
    137148     } 
    138149      
    139      public function renderWidget($name,$attributes=array()) 
     150     public function renderBlock($name,$attr) { 
     151          echo $this->template->renderBlock( 
     152               $name, 
     153               $attr, 
     154               $this->blocks 
     155          ); 
     156     } 
     157 
     158     public function getCurrentForm() { 
     159          return $this->currentForm; 
     160     } 
     161 
     162     public function renderWidget($name,$attributes=array(),$extra=array()) 
    140163     { 
    141164          $field = $this->currentForm->$name; 
    142165          if ($field) { 
    143                echo $this->template->renderBlock( 
     166               $attr = $field->getAttributes(); 
     167               if (isset($attr['attr'])) { 
     168                    $attr['attr'] = array_merge($attr['attr'],$attributes); 
     169               } else { 
     170                    $attr['attr'] = $attributes; 
     171               } 
     172               $this->renderBlock( 
    144173                    $field->getWidgetBlock(), 
    145174                    array_merge( 
    146                          $field->getAttributes(), 
    147                          array('attr' => $attributes) 
    148                     ), 
    149                     $this->blocks 
     175                         $attr, 
     176                         $extra 
     177                    ) 
    150178               ); 
    151179          } 
     
    197225 
    198226/** 
    199  * Template form 
    200  */ 
     227* dcForm - Template form 
     228* 
     229*/ 
    201230class dcForm 
    202231{ 
     
    211240     protected $errors; 
    212241      
    213      private function addNonce() 
     242 
     243    /** 
     244     * addNonce -- adds dc nonce to form fields 
     245     *  
     246     * @access protected 
     247     * 
     248     * @return nothing 
     249     */ 
     250     protected function addNonce() 
    214251     { 
    215252          $this->addField( 
     
    219256     } 
    220257      
    221      protected function getNID($nid) 
     258 
     259    /** 
     260     * Defines Name & ID from field 
     261     *  
     262     * @param mixed $nid either an array (name, id) or a string (name only, id will be set to null). 
     263     * 
     264     * @access protected 
     265     * 
     266     * @return nothing. 
     267     */ 
     268     protected function setNID($nid) 
    222269     { 
    223270          if (is_array($nid)) { 
     
    231278     } 
    232279      
     280     public function getContext() { 
     281          return array(); 
     282     } 
     283 
     284    /** 
     285     * Class constructor 
     286     *  
     287     * @param mixed  $core   dotclear core 
     288     * @param mixed  $name   form name 
     289     * @param mixed  $action form action 
     290     * @param string $method form method ('GET' or 'POST') 
     291     * 
     292     * @access public 
     293     * 
     294     * @return mixed Value. 
     295     */ 
    233296     public function __construct($core,$name,$action,$method='POST') 
    234297     { 
    235298          $this->core = $core; 
    236           $this->getNID($name); 
     299          $this->setNID($name); 
    237300          $this->method = $method; 
    238301          $this->action = $action; 
     
    247310     } 
    248311      
     312 
     313    /** 
     314     * Returns form name 
     315     *  
     316     * @access public 
     317     * 
     318     * @return mixed Value. 
     319     */ 
    249320     public function getName() 
    250321     { 
     
    270341     } 
    271342      
     343     public function removeField(dcField $f) { 
     344          $n = $f->getName(); 
     345          if (isset($this->fields[$n])){ 
     346               unset($this->fields[$n]); 
     347          } 
     348 
     349     } 
     350     public function renameField($field,$newname) { 
     351          $oldname = $field->getName(); 
     352          if (isset($this->fields[$oldname])) { 
     353               unset($this->fields[$oldname]); 
     354               $field->setName($newname); 
     355               $this->fields[$newname] = $field; 
     356          } 
     357          //print_r($this->fields); 
     358     } 
    272359     public function begin() 
    273360     { 
     
    292379     public function __get($name) 
    293380     { 
    294           return isset($this->fields[$name]) ?  
     381          return isset($this->fields[$name]) ? 
    295382               $this->fields[$name] : null; 
    296383     } 
    297       
     384 
    298385     public function __set($name,$value) 
    299386     { 
     
    302389          } 
    303390     } 
    304       
     391 
    305392     public function isSubmitted() 
    306393     { 
    307394          $from = $this->method == 'POST' ? $_POST : $_GET; 
    308           echo "form fields :\n"; 
    309      } 
    310       
    311      public function setup() 
    312      { 
     395     } 
     396 
     397     protected function setupFields() { 
    313398          $from = $this->method == 'POST' ? $_POST : $_GET; 
    314399          foreach ($this->fields as $f) { 
    315400               $f->setup($from); 
    316401          } 
     402     } 
     403 
     404     protected function handleActions($submitted) { 
     405          foreach ($submitted as $f) { 
     406               $action = $f->getAction(); 
     407               if ($action != NULL) { 
     408                    $ret = call_user_func($action,$this); 
     409               } 
     410          } 
     411     } 
     412 
     413     protected function getSubmittedFields() { 
     414          $s = array(); 
    317415          foreach ($this->submitfields as $f) { 
    318416               if ($f->isDefined()) { 
    319                     $ret = call_user_func($f->getAction(),$this); 
    320                     return; 
     417                    $s[$f->getName()] = $f; 
    321418               } 
    322419          } 
    323      } 
    324       
     420          return $s; 
     421     } 
     422 
     423     public function setup() 
     424     { 
     425          $this->setupFields(); 
     426          $submitted = $this->getSubmittedFields(); 
     427          $this->handleActions($submitted); 
     428     } 
     429 
    325430     public function check() 
    326431     { 
     
    352457     protected $defined; 
    353458      
    354      protected function getNID($nid) 
     459     protected function setNID($nid) 
    355460     { 
    356461          if (is_array($nid)) { 
     
    365470     public function __construct($name,$value,$attributes=array()) 
    366471     { 
    367           $this->getNID($name); 
     472          $this->setNID($name); 
    368473          $this->attributes = $attributes; 
    369           $this->value = $value; 
     474          $this->setValue($value); 
    370475          $this->attributes['name'] = $this->name; 
    371476          $this->attributes['id'] = $this->id; 
     477          $this->defined = false; 
     478     } 
     479      
     480     public function setValue($value) { 
     481          $this->value = $value; 
    372482          $this->attributes['value'] = $this->value; 
    373           $this->defined = false; 
    374      } 
    375       
     483     } 
     484 
     485     public function getValue() { 
     486          return $this->value; 
     487     } 
     488 
    376489     public function __toString() 
    377490     { 
     
    395508          return $this->name; 
    396509     } 
    397       
     510     public function setName($name) { 
     511          $this->setNID($name); 
     512          $this->attributes['name'] = $this->name; 
     513          $this->attributes['id'] = $this->id; 
     514     } 
     515 
    398516     public function check() 
    399517     { 
     
    406524     } 
    407525      
     526     public function parseValue($from) { 
     527          if (isset($from[$this->id])) { 
     528               return $from[$this->id]; 
     529          } 
     530          return null; 
     531     } 
     532 
    408533     public function setup($from) 
    409534     { 
    410           if (isset($from[$this->id])) { 
    411                $this->value = $from[$this->id]; 
     535          $value = $this->parseValue($from); 
     536          if ($value !== null) { 
     537               $this->setValue($value); 
    412538               $this->defined = true; 
    413539          } 
     
    488614          if (isset($attributes['action'])) { 
    489615               $this->action = $attributes['action']; 
     616          } else { 
     617               $this->action = NULL; 
    490618          } 
    491619     } 
     
    527655     } 
    528656 
     657     public function parseValue($from) { 
     658 
     659          $v = parent::parseValue($from); 
     660          if (!isset($this->options[$v])) { 
     661               return $this->value; 
     662          } else { 
     663               return $v; 
     664          } 
     665     } 
    529666} 
    530667?> 
  • inc/admin/default-templates/auth.html.twig

    r1089 r1147  
    1818<body id="dotclear-admin" class="auth"> 
    1919 
    20 {% form auth %} 
     20{% form 'auth' %} 
    2121<div id="login-screen"> 
    2222<h1>{{vendor_name}}</h1> 
  • inc/admin/default-templates/form_layout.html.twig

    r1001 r1147  
    1818{% block field_textarea %} 
    1919{% spaceless %} 
    20      {{ block('label') }} 
     20     {{ block('startlabel') }} 
    2121    <textarea {{ block('field_attr') }}>{{ value }}</textarea> 
     22    {{ block('endlabel') }} 
    2223{% endspaceless %} 
    2324{% endblock field_textarea %} 
     
    3839{% spaceless %} 
    3940    {% set type = type|default('text') %} 
    40     {{ block('label') }} 
     41    {{ block('startlabel') }} 
    4142     <input type="{{ type }}" {{ block('field_attr') }} {% if value is not empty %}value="{{ value }}" {% endif %} /> 
     43    {{ block('endlabel') }} 
    4244{% endspaceless %} 
    4345{% endblock field_input %} 
     
    8082{% block field_combo %} 
    8183{% spaceless %} 
    82     {{ block('label') }} 
     84    {{ block('startlabel') }} 
    8385    <select {{ block('field_attr') }}> 
    8486        {{ block('field_options') }} 
    8587    </select> 
     88    {{ block('endlabel') }} 
    8689{% endspaceless %} 
    8790{% endblock field_combo %} 
    88  
     91{# 
    8992{% block label %} 
    9093{% spaceless %} 
     
    9497{% endspaceless %} 
    9598{% endblock label %} 
     99#} 
     100 
     101{% block startlabel %} 
     102{% spaceless %} 
     103    {% if label is not empty %} 
     104        {% if required is not empty %} 
     105            {% set labelclass = labelclass + " required" %} 
     106        {% endif %} 
     107        <label for="{{name}}" {% if labelclass is not empty %}class="{{labelclass}}"{% endif %} {% if required is not empty %}<abbr title="{{__('Required field')}}">*</abbr>{% else %}>{% endif %} {{label}} 
     108        {% if nestedlabel is empty %}</label> {% endif %} 
     109    {% endif %} 
     110{% endspaceless %} 
     111{% endblock startlabel %} 
     112 
     113{% block endlabel %} 
     114{% spaceless %} 
     115    {% if label is not empty %} 
     116        {% if nestedlabel is not empty %}</label>{% endif %} 
     117    {% endif %} 
     118{% endspaceless %} 
     119{% endblock endlabel %} 
     120 
  • inc/admin/default-templates/index.html.twig

    r1099 r1147  
    2828          <div id="quick"> 
    2929               <h3>{{__('Quick entry')}}</h3> 
    30                {% form quickentry %} 
     30               {% form 'quickentry' %} 
    3131                    <fieldset><legend>{{__('New entry')}}</legend> 
    3232                         <p class="col">{{ form_field('post_title',{'class':'maximal'}) }}</p> 
  • inc/admin/default-templates/layout.html.twig

    r1089 r1147  
    1919<body id="dotclear-admin{% if safe_mode %} safe-mode{% endif %}"> 
    2020     <div id="header"> 
    21           <ul id="prelude"> 
    22                <li><a href="#content">{{__('To content')}}</a></li> 
    23                <li><a href="#main-menu">{{__('To menu')}}</a></li> 
    24           </ul> 
     21          {% block prelude %} 
     22               <ul id="prelude"> 
     23                    <li><a href="#content">{{__('To content')}}</a></li> 
     24                    <li><a href="#main-menu">{{__('To menu')}}</a></li> 
     25               </ul> 
     26          {% endblock %} 
    2527          <div id="top"><h1><a href="index.php">{{vendor_name}}</a></h1></div> 
    2628          <div id="info-boxes"> 
    2729               <div id="info-box1"> 
    28                  {% form switchblog_menu %} 
     30                 {% form 'switchblog_menu' %} 
    2931                    {% if blog_count > 1 and blog_count < 20 %} 
    30                          <p>{{ form_field('switchblog') }}</p> 
    31                          <noscript><p>{{ form_field('switchblog_submit') }}</p></noscript> 
     32                         {{ form_field('switchblog',{},{'nestedlabel' : true, labelclass:'classic'}) }} 
     33                         <noscript>{{ form_field('switchblog_submit') }}</noscript> 
    3234                    {% else %} 
    33                          <p>{{__('Blog:')}} <strong title="{{current_blog.url}}">{{current_blog.name}}</strong> 
    34                          {% if blogs is not empty %} - <a href="blogs.php">{{__('Change blog')}}</a>{% endif %}</p> 
     35                         {{__('Blog:')}} <strong title="{{current_blog.url}}">{{current_blog.name}}</strong> 
     36                         {% if blogs is not empty %} - <a href="blogs.php">{{__('Change blog')}}</a>{% endif %} 
    3537                    {% endif %} 
    36                     <p><a href="{{current_blog.url}}" onclick="window.open(this.href);return false;" title="{{__('Go to site')}} ({{__('new window')}})">{{__('Go to site')}} <img src="{{theme_url}}images/outgoing.png" alt="" /></a></p> 
     38                    <a href="{{current_blog.url}}" onclick="window.open(this.href);return false;" title="{{__('Go to site')}} ({{__('new window')}})">{{__('Go to site')}} <img src="{{theme_url}}images/outgoing.png" alt="" /></a> 
    3739                 {% endform %} 
    3840               </div> 
  • inc/admin/default-templates/post.html.twig

    r1088 r1147  
    1616 
    1717<div class="multi-part" title="{{__('Edit entry')}}" id="edit-entry"> 
    18 {% form post %} 
     18{% form 'post' %} 
    1919<div id="entry-wrapper"> 
    2020     <div id="entry-content"> 
  • inc/admin/default-templates/style/default.css

    r1085 r1147  
    13561356     background-color: #2373A8; 
    13571357} 
    1358  
     1358form#filters {font-size: 100%; background: #f0f0f0; padding: 1em; border-radius: .5em; border: 1px solid #ddd;} 
     1359form#filters .margintop {padding-top: 1.33em;} 
     1360form#filters ul, form#filters p {list-style-type:none;margin: 0; padding: 0 0 .5em 0; margin-left: 1em;} 
     1361form#filters .col30 {border-left: 1px solid #999;} 
     1362form#filters .col30 h3 {margin-left: 1em;} 
     1363 
     1364p.line, li.line { position: relative; padding: 3px 0 0 28px; margin: 0 0 1em 0;} 
     1365li.line input[type=submit] {position: absolute; left:0;top:0; padding: 0 .1em; margin: 0;} 
     1366li.line input[type=checkbox], li.line input[type=checkbox] {position: absolute; left: 0; top: .2em; padding: 0 .1em; margin: 0;} 
     1367li.line select { margin-right: 2em;} 
     1368li.line label { display: block; width: 8em; float: left;} 
     1369li.line label img {margin-right: 8px;} 
     1370li.line span.or { 
     1371     text-align: right; 
     1372     margin-left: 5em; 
     1373     font-weight: bold; 
     1374} 
     1375p.line label.or + select {margin-left: 2em;} 
     1376li.line { padding: 0 0 0 20px; height: 1em;} 
     1377li.line label {width: auto;} 
     1378 
     1379#available_filters input[type=submit] {padding: 0 .1em; margin-left: .5em;} 
     1380 
     1381div.pagination span, div.pagination a { 
     1382     margin-right: 1em; 
     1383} 
    13591384/* jQuery Autocomplete plugin */ 
    13601385.ac_results { 
  • inc/core/class.dc.core.php

    r1099 r1147  
    155155          ); 
    156156          $this->tpl->addExtension(new dcFormExtension($this)); 
     157          $this->tpl->addExtension(new dcFilterSetExtension($this)); 
    157158          $this->tpl->addExtension(new dcTabExtension($this)); 
    158159     } 
  • inc/prepend.php

    r1092 r1147  
    6868$__autoload['dcFormExtension']               = dirname(__FILE__).'/admin/class.dc.form.php'; 
    6969$__autoload['dcTabExtension']           = dirname(__FILE__).'/admin/class.dc.tab.php'; 
     70$__autoload['dcFilterSetExtension']               = dirname(__FILE__).'/admin/class.dc.filter.php'; 
    7071 
    7172# Clearbricks extensions 
  • plugins/aboutConfig/admtpl/index.html.twig

    r1092 r1147  
    1313  {% tab local('local',__('blog settings')) %} 
    1414    {% if local_settings is not empty %} 
    15     {% form local_nav_form %} 
     15    {% form 'local_nav_form' %} 
    1616     <p class="anchor-nav">{{ form_field('local_nav') }} {{ form_field('local_nav_submit') }}</p> 
    1717    {% endform %} 
    1818    {% endif %} 
    1919 
    20     {% form local_settings_form %} 
     20    {% form 'local_settings_form' %} 
    2121    {% for ns, setting in local_settings %} 
    2222     <table class="settings" id="local_{{ ns }}"><caption>{{ ns }}</caption> 
     
    4747  {% tab global('global',__('global settings')) %} 
    4848    {% if global_settings is not empty %} 
    49     {% form global_nav_form %} 
     49    {% form 'global_nav_form' %} 
    5050     <p class="anchor-nav">{{ form_field('global_nav') }} {{ form_field('global_nav_submit') }}</p> 
    5151    {% endform %} 
    5252    {% endif %} 
    5353 
    54     {% form global_settings_form %} 
     54    {% form 'global_settings_form' %} 
    5555    {% for ns, setting in global_settings %} 
    5656     <table class="settings" id="global_{{ ns }}"><caption>{{ ns }}</caption> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map