Changes in [1138:11db80678704:1153:1e48950b05af]
- Files:
-
- 173 added
- 166 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/posts.php
r1102 r1153 12 12 13 13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 14 14 global $_ctx; 15 15 dcPage::check('usage,contentadmin'); 16 16 … … 48 48 # Filter form we'll put in html_block 49 49 $users_combo = $categories_combo = array(); 50 $users_combo['-'] = $categories_combo['-'] = '';51 50 while ($users->fetch()) 52 51 { … … 61 60 } 62 61 63 $categories_combo[__('None')] = 'NULL'; 62 63 # Getting categories 64 $categories_combo = array(); 65 try { 66 $categories = $core->blog->getCategories(array('post_type'=>'post')); 64 67 while ($categories->fetch()) { 65 $categories_combo[str_repeat(' ',$categories->level-1).($categories->level-1 == 0 ? '' : '• '). 66 html::escapeHTML($categories->cat_title). 67 ' ('.$categories->nb_post.')'] = $categories->cat_id; 68 $categories_combo[$categories->cat_id] = 69 str_repeat(' ',$categories->level-1). 70 ($categories->level-1 == 0 ? '' : '• '). 71 html::escapeHTML($categories->cat_title); 68 72 } 69 73 } catch (Exception $e) { } 70 74 $status_combo = array( 71 '-' => ''72 75 ); 73 76 foreach ($core->blog->getAllPostStatus() as $k => $v) { 74 $status_combo[ $v] = (string) $k;77 $status_combo[(string) $k] = (string)$v; 75 78 } 76 79 77 80 $selected_combo = array( 78 '-' => '', 79 __('selected') => '1', 80 __('not selected') => '0' 81 '1' => __('is selected'), 82 '0' => __('is not selected') 81 83 ); 82 84 83 85 # Months array 84 $dt_m_combo['-'] = '';85 86 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()); 87 88 } 88 89 89 $lang_combo['-'] = '';90 90 while ($langs->fetch()) { 91 91 $lang_combo[$langs->post_lang] = $langs->post_lang; 92 92 } 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 );107 93 } 94 $form = new dcForm($core,'post','post.php'); 95 108 96 109 97 # Actions combo box … … 138 126 $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); 139 127 140 /* Get posts141 -------------------------------------------------------- */142 $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : '';143 $cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id'] : '';144 $status = isset($_GET['status']) ? $_GET['status'] : '';145 $selected = isset($_GET['selected']) ? $_GET['selected'] : '';146 $month = !empty($_GET['month']) ? $_GET['month'] : '';147 $lang = !empty($_GET['lang']) ? $_GET['lang'] : '';148 $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'post_dt';149 $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';150 128 151 $show_filters = false;152 129 153 $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; 154 $nb_per_page = 30; 155 156 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 157 if ($nb_per_page != $_GET['nb']) { 158 $show_filters = true; 130 class monthdcFilterCombo extends dcFilterCombo { 131 public function applyFilter($params) { 132 $month=$this->avalues['values'][0]; 133 $params['post_month'] = substr($month,4,2); 134 $params['post_year'] = substr($month,0,4); 159 135 } 160 $nb_per_page = (integer) $_GET['nb'];161 136 } 162 163 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);164 $params['no_content'] = true;165 166 # - User filter167 if ($user_id !== '' && in_array($user_id,$users_combo)) {168 $params['user_id'] = $user_id;169 $show_filters = true;170 } else {171 $user_id='';172 }173 174 # - Categories filter175 if ($cat_id !== '' && in_array($cat_id,$categories_combo)) {176 $params['cat_id'] = $cat_id;177 $show_filters = true;178 } else {179 $cat_id='';180 }181 182 # - Status filter183 if ($status !== '' && in_array($status,$status_combo)) {184 $params['post_status'] = $status;185 $show_filters = true;186 } else {187 $status='';188 }189 190 # - Selected filter191 if ($selected !== '' && in_array($selected,$selected_combo)) {192 $params['post_selected'] = $selected;193 $show_filters = true;194 } else {195 $selected='';196 }197 198 # - Month filter199 if ($month !== '' && in_array($month,$dt_m_combo)) {200 $params['post_month'] = substr($month,4,2);201 $params['post_year'] = substr($month,0,4);202 $show_filters = true;203 } else {204 $month='';205 }206 207 # - Lang filter208 if ($lang !== '' && in_array($lang,$lang_combo)) {209 $params['post_lang'] = $lang;210 $show_filters = true;211 } else {212 $lang='';213 }214 215 # - Sortby and order filter216 if ($sortby !== '' && in_array($sortby,$sortby_combo)) {217 if ($order !== '' && in_array($order,$order_combo)) {218 $params['order'] = $sortby.' '.$order;219 } else {220 $order='desc';221 }222 223 if ($sortby != 'post_dt' || $order != 'desc') {224 $show_filters = true;225 }226 } else {227 $sortby='post_dt';228 $order='desc';229 }230 231 # Get posts232 try {233 $posts = $core->blog->getPosts($params);234 $counter = $core->blog->getPosts($params,true);235 $post_list = new adminPostList($core,$posts,$counter->f(0));236 } catch (Exception $e) {237 $core->error->add($e->getMessage());238 }239 240 137 /* DISPLAY 241 138 -------------------------------------------------------- */ 242 $starting_script = dcPage::jsLoad('js/_posts_list.js'); 243 if (!$show_filters) { 244 $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 245 } 139 $filterSet = new dcFilterSet($core,'fposts','posts.php'); 246 140 247 dcPage::open(__('Entries'),$starting_script); 141 $filterSet 142 ->addFilter(new dcFilterRichCombo( 143 'users',__('Author'), __('Author'), 'user_id', $users_combo,array( 144 'multiple' => true))) 145 ->addFilter(new dcFilterRichCombo( 146 'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) 147 ->addFilter(new dcFilterRichCombo( 148 'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) 149 ->addFilter(new dcFilterRichCombo( 150 'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) 151 ->addFilter(new dcFilterCombo( 152 'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) 153 ->addFilter(new monthdcFilterCombo( 154 'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) 155 ->addFilter(new dcFilterText( 156 'search',__('Contains'),__('The entry contains'), 'search',20,255)); 248 157 249 if (!$core->error->flag())250 {251 echo252 '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Entries').'</span></h2>'.253 '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>';254 255 if (!$show_filters) {256 echo '<p><a id="filter-control" class="form-control" href="#">'.257 __('Filters').'</a></p>';258 }259 260 echo261 '<form action="posts.php" method="get" id="filters-form">'.262 '<fieldset><legend>'.__('Filters').'</legend>'.263 '<div class="three-cols">'.264 '<div class="col">'.265 '<label for="user_id">'.__('Author:').266 form::combo('user_id',$users_combo,$user_id).'</label> '.267 '<label for="cat_id">'.__('Category:').268 form::combo('cat_id',$categories_combo,$cat_id).'</label> '.269 '<label for="status">'.__('Status:').270 form::combo('status',$status_combo,$status).'</label> '.271 '</div>'.272 273 '<div class="col">'.274 '<label for="selected">'.__('Selected:').275 form::combo('selected',$selected_combo,$selected).'</label> '.276 '<label for="month">'.__('Month:').277 form::combo('month',$dt_m_combo,$month).'</label> '.278 '<label for="lang">'.__('Lang:').279 form::combo('lang',$lang_combo,$lang).'</label> '.280 '</div>'.281 282 '<div class="col">'.283 '<p><label for="sortby">'.__('Order by:').284 form::combo('sortby',$sortby_combo,$sortby).'</label> '.285 '<label for="order">'.__('Sort:').286 form::combo('order',$order_combo,$order).'</label></p>'.287 '<p><label for="nb" class="classic">'. form::field('nb',3,3,$nb_per_page).' '.288 __('Entries per page').'</label></p> '.289 '<p><input type="submit" value="'.__('Apply filters').'" /></p>'.290 '</div>'.291 '</div>'.292 '<br class="clear" />'. //Opera sucks293 '</fieldset>'.294 '</form>';295 296 # Show posts297 $post_list->display($page,$nb_per_page,298 '<form action="posts_actions.php" method="post" id="form-entries">'.299 300 '%s'.301 302 '<div class="two-cols">'.303 '<p class="col checkboxes-helpers"></p>'.304 305 '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '.306 form::combo('action',$combo_action).307 '<input type="submit" value="'.__('ok').'" /></p>'.308 form::hidden(array('user_id'),$user_id).309 form::hidden(array('cat_id'),$cat_id).310 form::hidden(array('status'),$status).311 form::hidden(array('selected'),$selected).312 form::hidden(array('month'),$month).313 form::hidden(array('lang'),$lang).314 form::hidden(array('sortby'),$sortby).315 form::hidden(array('order'),$order).316 form::hidden(array('page'),$page).317 form::hidden(array('nb'),$nb_per_page).318 $core->formNonce().319 '</div>'.320 '</form>'321 );322 }323 158 324 dcPage::helpBlock('core_posts'); 325 dcPage::close(); 159 160 $lposts = new dcItemList ($core,array('lposts','form-entries'),'posts_actions.php'); 161 $lposts->addTemplate('posts_cols.html.twig'); 162 163 $lposts->setFilterSet($filterSet); 164 165 $lposts 166 ->addColumn(new dcColumn('title',__('Title'),'post_title')) 167 ->addColumn(new dcColumn('cat',__('Category'),'cat_title')) 168 ->addColumn(new dcColumn('date',__('Date'),'post_date')) 169 ->addColumn(new dcColumn('datetime',__('Date and Time'),'post_date')) 170 ->addColumn(new dcColumn('author',__('Author'),'post_author')) 171 ->addColumn(new dcColumn('status',__('Status'),'post_status')); 172 173 174 $lposts->setup(); 175 $filterSet->setup(); 176 177 $_ctx 178 ->fillPageTitle(__('Entries'),'posts.php'); 179 $params=new ArrayObject(); 180 $filterSet->applyFilters($params); 181 $posts = $core->blog->getPosts($params); 182 $lposts->setEntries($posts); 183 $_ctx->filters = '['.print_r($params->getArrayCopy(),true).']'; 184 185 $core->tpl->display('posts.html.twig'); 186 187 326 188 ?> -
admin/style/default.css
r1065 r1147 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 12 */ 13 14 /* ------------------------------------------------------------------ html */15 13 body { 16 14 font: 75%/1.5em Helvetica,Arial,sans-serif; … … 40 38 margin-bottom: 0.6em; 41 39 } 40 42 41 h2 { 43 42 color: #666; … … 52 51 font-size: 1.2em; 53 52 } 53 54 54 p, div.p { 55 55 margin: 0 0 1em 0; 56 56 } 57 57 58 hr { 58 59 height: 1px; … … 61 62 border-style: solid; 62 63 } 64 63 65 pre, code { 64 66 font: 100% "Andale Mono","Courier New",monospace; … … 77 79 cursor: help; 78 80 } 81 79 82 80 83 /* LAYOUT … … 148 151 height: 2em; 149 152 } 150 #info-box1 p {151 margin: 0;152 display: inline;153 }154 153 #info-box1 select { 155 154 width: 15em; … … 197 196 padding: 1em; 198 197 background: #fff; 198 -webkit-border-radius: .5em; 199 -moz-border-radius: .5em; 199 200 border-radius: .5em; 200 201 border: 1px solid #ddd; … … 254 255 background: #dfdfdf; 255 256 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; 256 261 border-top-left-radius: .3em; 257 262 border-top-right-radius: .3em; … … 277 282 float: left; 278 283 margin-top: 1.2em; 279 margin-bottom: 3em;284 margin-bottom: 1em; 280 285 } 281 286 #main-menu h3 { … … 297 302 padding: .2em 0 0 32px; 298 303 background-repeat: no-repeat; 299 background-position: 12px . 4em;304 background-position: 12px .2em; 300 305 } 301 306 #main-menu a { … … 335 340 #footer { 336 341 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; 339 348 color: #fff; 340 349 } … … 369 378 border: 1px solid #999; 370 379 padding: 1em 1em 0 1em; 380 -moz-border-radius: 4px; 381 -webkit-border-radius: 4px; 371 382 border-radius: 4px; 372 383 } … … 433 444 color: #666; 434 445 } 446 435 447 #dashboard-items { 436 448 float: left; … … 501 513 border: 1px solid #ccc; 502 514 border-left: 1em solid #E5E3DA; 515 -moz-border-radius: .3em; 516 -webkit-border-radius: .3em; 503 517 border-radius: .3em; 504 518 } … … 538 552 height: 500px; 539 553 } 554 540 555 #add-file-f { 541 556 position: relative; … … 621 636 display: inline; 622 637 } 638 623 639 #default-favs h3 { 624 640 margin-top: 2em; 625 641 margin-bottom: 1em; 626 642 } 643 627 644 .fav-list { 628 645 list-style-type: none; … … 651 668 border: 1px solid #ddd; 652 669 padding: .2em; 670 -moz-border-radius: .5em; 671 -webkit-border-radius: .5em; 653 672 border-radius: .5em; 654 673 } … … 745 764 border: 1px solid #f3f3f3; 746 765 cursor: pointer; 766 -moz-border-radius: 4px; 767 -webkit-border-radius: 4px; 747 768 border-radius: 4px; 748 769 } … … 783 804 } 784 805 #help-button { 785 position: fixed;786 top: 3.2em;806 position: absolute; 807 top: 6.2em; 787 808 right: 0px; 788 809 cursor: pointer; … … 794 815 text-transform: capitalize; 795 816 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; 797 820 color: #444; 798 821 } … … 856 879 div.message, p.message, 857 880 div.static-msg, p.static-msg { 858 padding: 0.5em 0.5em 0.5em 4 8px;881 padding: 0.5em 0.5em 0.5em 40px; 859 882 margin-bottom: 1em; 883 -moz-border-radius: 8px; 884 -webkit-border-radius: 8px; 860 885 border-radius: 8px; 861 886 } … … 865 890 } 866 891 div.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; 869 894 } 870 895 div.message, p.message, 871 896 div.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; 873 898 color: #fff; 874 899 } … … 917 942 vertical-align: middle; 918 943 } 944 919 945 /* Si quelque chose a besoin d'être caché sauf pour les revues d'écran */ 920 946 .hidden { … … 951 977 overflow: auto; 952 978 } 979 953 980 .grid { 954 981 background: transparent repeat url('grid.png') 0 0; 955 982 } 983 956 984 .line p { 957 985 margin: 0; … … 960 988 color: #666; 961 989 } 990 962 991 ul.nice { 963 992 margin: 1em 0; … … 986 1015 right: 0; 987 1016 } 988 .distrib img {989 display: block;990 float: right;991 margin-top: -1em;992 }993 1017 /* TABLES 994 1018 -------------------------------------------------------- */ … … 1008 1032 margin-bottom: .5em; 1009 1033 } 1010 1011 1034 th, td { 1012 1035 border-width: 0 0 1px 0; … … 1018 1041 th { 1019 1042 text-align: left; 1020 border-bottom-color: #666;1021 1043 } 1022 1044 .noborder td, td.noborder, .noborder th, th.noborder { 1023 1045 border-width: 0; 1024 1046 } 1047 1025 1048 table .maximal, table.maximal { 1026 1049 width: 100%; … … 1029 1052 width: 1px; 1030 1053 } 1054 1031 1055 table .nowrap { 1032 1056 white-space: nowrap; 1033 1057 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%;1049 1058 } 1050 1059 … … 1119 1128 font-weight: normal; 1120 1129 } 1130 1121 1131 input, textarea, select { 1122 1132 background: #f9f9f9; … … 1126 1136 border-color: #000 #ccc #ccc #000; 1127 1137 } 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 }1134 1138 input, textarea, select, option { 1135 1139 font: 1em "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif; … … 1151 1155 background: transparent; 1152 1156 } 1157 1153 1158 label { 1154 1159 display: block; … … 1162 1167 color: #666; 1163 1168 } 1164 span.form-note {1165 font-style:italic;1166 font-weight: normal;1167 color: #666;1168 }1169 1169 p.form-note.warn, p.form-note.info, p.warning { 1170 1170 font-style: normal; … … 1172 1172 } 1173 1173 p.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; 1175 1175 border: 1px solid #f0c020; 1176 1176 } 1177 1177 p.form-note.info { 1178 background: #eef url(info.png) no-repeat . 3em .2em;1178 background: #eef url(info.png) no-repeat .2em .2em; 1179 1179 border: 1px solid #99f; 1180 1180 } … … 1196 1196 resize: vertical; 1197 1197 } 1198 1198 1199 label.required { 1199 1200 font-weight: bold; … … 1208 1209 p.field { 1209 1210 position: relative; 1210 1211 1211 1212 } 1212 1213 p.field label { … … 1220 1221 top: 0; 1221 1222 } 1223 1222 1224 label .maximal, textarea.maximal, input.maximal { 1223 1225 width: 100%; … … 1234 1236 padding-left: 20px; 1235 1237 } 1238 1239 a#toggle-filters { 1240 font-weight: bold; 1241 background: url(../images/plus.png) no-repeat 0 0; 1242 padding-left: 20px; 1243 } 1244 1245 a#toggle-filters.opened { 1246 background: url(../images/minus.png) no-repeat 0 0; 1247 } 1248 1236 1249 .constrained { 1237 1250 margin: 0; … … 1262 1275 padding: .1em .5em 0 .5em; 1263 1276 text-shadow: 0 1px 1px rgba(0,0,0,.3); 1277 -webkit-border-radius: .2em; 1278 -moz-border-radius: .2em; 1264 1279 border-radius: .2em; 1265 1280 margin-bottom: .1em; … … 1343 1358 } 1344 1359 a.button.add { 1360 -webkit-border-radius: .5em; 1361 -moz-border-radius: .5em; 1345 1362 border-radius: .5em; 1346 1363 margin-bottom: .1em; 1347 background: #2C8FD1 url( ../images/add.png) no-repeat 6px center;1364 background: #2C8FD1 url(add.png) no-repeat 6px center; 1348 1365 color: #fff; 1349 1366 padding: .2em 16px .2em 30px; … … 1354 1371 } 1355 1372 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 } 1373 form#filters {font-size: 100%; background: #f0f0f0; padding: 1em; border-radius: .5em; border: 1px solid #ddd;} 1374 form#filters .margintop {padding-top: 1.33em;} 1375 form#filters ul, form#filters p {list-style-type:none;margin: 0; padding: 0 0 .5em 0; margin-left: 1em;} 1376 form#filters .col30 {border-left: 1px solid #999;} 1377 form#filters .col30 h3 {margin-left: 1em;} 1378 1379 p.line, li.line { position: relative; padding: 3px 0 0 28px; margin: 0 0 1em 0;} 1380 li.line input[type=submit] {position: absolute; left:0;top:0; padding: 0 .1em; margin: 0;} 1381 li.line input[type=checkbox], li.line input[type=checkbox] {position: absolute; left: 0; top: .2em; padding: 0 .1em; margin: 0;} 1382 li.line select { margin-right: 2em;} 1383 li.line label { display: block; width: 8em; float: left;} 1384 li.line label img {margin-right: 8px;} 1385 li.line span.or { 1386 text-align: right; 1387 margin-left: 5em; 1388 font-weight: bold; 1389 } 1390 p.line label.or + select {margin-left: 2em;} 1391 li.line { padding: 0 0 0 20px; height: 1em;} 1392 li.line label {width: auto;} 1393 1394 #available_filters input[type=submit] {padding: 0 .1em; margin-left: .5em;} 1395 1396 div.pagination span, div.pagination a { 1397 margin-right: 1em; 1398 } -
inc/admin/class.dc.admincontext.php
r1128 r1153 12 12 if (!defined('DC_RC_PATH')) { return; } 13 13 14 15 class dcProxy { 16 protected $object; 17 protected $attributes; 18 protected $methods; 19 protected $default; 20 protected $denyfirst; 21 22 /** 23 * valuesToArray - converts a list of strings to an array having these strings as keys. 24 * 25 * @param mixed $val the list to convert. 26 * @access protected 27 * @return mixed Value The resulting array 28 */ 29 protected function valuesToArray($val) { 30 $arr = array(); 31 foreach ($val as $k) { 32 $arr[$k]=true; 33 } 34 return $arr; 35 } 36 37 protected function isAllowed ($name,$list) { 38 if ($this->denyfirst) { 39 return isset($list[$name]); 40 } else { 41 return !isset($list[$name]); 42 } 43 } 44 45 public function __construct($object,$rights,$default='',$denyfirst=true) { 46 $this->object = $object; 47 $this->attributes = array(); 48 $this->methods = array(); 49 $this->denyfirst = $denyfirst; 50 if (isset($rights['attr'])) { 51 $this->attributes = $this->valuesToArray($rights['attr']); 52 } 53 if (isset($rights['methods'])) { 54 $this->methods = $this->valuesToArray($rights['methods']); 55 } 56 } 57 58 public function __get($name) { 59 if ($this->isAllowed($name,$this->attributes)) { 60 return $this->object->$name; 61 } else { 62 return $this->default; 63 } 64 } 65 66 public function __call($name,$args) { 67 if ($this->isAllowed($name,$this->methods) && 68 is_callable(array($this->object,$name))) { 69 return call_user_func_array(array($this->object,$name),$args); 70 } else { 71 return $this->default; 72 } 73 74 } 75 } 76 77 class dcArrayProxy extends dcProxy implements ArrayAccess { 78 public function offsetExists ($offset) { 79 return (isset($this->value[$offset])); 80 } 81 public function offsetGet ($offset) { 82 return new ProxyValue($this->object[$offset],$this->rights); 83 } 84 public function offsetSet ($offset ,$value ) { 85 // Do nothing, we are read only 86 } 87 public function offsetUnset ($offset) { 88 // Do nothing, we are read only 89 } 90 } 91 92 14 93 /** 15 *@ingroup DC_CORE16 * @brief Template extension for admin context. 17 * 18 *This extends template environment with tools required in admin context.19 20 class dcAdminContext extends dcContext94 @ingroup DC_CORE 95 @brief Template extension for admin context 96 97 This extends template environment with tools required in admin context. 98 */ 99 class dcAdminContext extends Twig_Extension 21 100 { 101 protected $core; 102 protected $globals = array(); 103 protected $protected_globals = array(); 104 protected $memory = array(); 105 22 106 public function __construct($core) 23 107 { 24 parent::__construct($core); 25 26 $this->protected_globals = array_merge($this->protected_globals,array( 108 $this->core = $core; 109 110 # Globals editable via context 111 $this->globals = array(); 112 113 # Globals not editable via context 114 $this->protected_globals = array( 115 'messages' => array( 116 'static' => array(), 117 'lists' => array(), 118 'alert' => '', 119 'errors' => array() 120 ), 121 27 122 'page_title' => array(), 28 123 'page_global' => false, 29 124 30 125 'admin_url' => DC_ADMIN_URL, 31 'theme_url' => DC_ADMIN_URL.'index.php?tf=',126 'theme_url' => '', 32 127 'plugin_url' => DC_ADMIN_URL.'index.php?pf=', 33 )); 34 } 35 36 /** 37 * Returns a list of global variables to add to the existing list. 38 * 39 * This merges overloaded variables with defined variables. 40 * 41 * @return array An array of global variables 42 */ 128 129 'version' => DC_VERSION, 130 'vendor_name' => DC_VENDOR_NAME, 131 132 'safe_mode' => isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'], 133 'debug_mode' => DC_DEBUG 134 ); 135 } 136 137 /** 138 Prevent call crash from template on method that return this class 139 */ 140 public function __toString() 141 { 142 return ''; 143 } 144 145 /** 146 Test a global variable 147 148 @param string $name Name of the variable to test 149 @return boolean 150 */ 151 public function __isset($name) 152 { 153 return isset($this->globals[$name]); 154 } 155 156 /** 157 Add a global variable 158 159 @param string $name Name of the variable 160 @param mixed $value Value of the variable 161 */ 162 public function __set($name,$value) 163 { 164 /* 165 # Overload protect 166 if ($value === null && isset($this->globals[$name])) { 167 unset($this->globals[$name]); 168 } 169 elseif (!isset($this->globals[$name])) { 170 throw new Exception('Modification of overloaded globals has no effect'); 171 } 172 //*/ 173 $this->globals[$name] = $value; 174 } 175 176 /** 177 Get a global variable 178 179 @param string $name Name of the variable 180 @return mixed Value of the variable or null 181 */ 182 public function __get($name) 183 { 184 return isset($this->globals[$name]) ? $this->globals[$name] : null; 185 } 186 187 /** 188 Returns a list of filters to add to the existing list. 189 190 @return array An array of filters 191 */ 192 public function getFilters() 193 { 194 return array( 195 'trans' => new Twig_Filter_Function("__", array('is_safe' => array('html'))) 196 ); 197 } 198 199 /** 200 Returns a list of functions to add to the existing list. 201 202 @return array An array of functions 203 */ 204 public function getFunctions() 205 { 206 return array( 207 '__' => new Twig_Function_Function("__", array('is_safe' => array('html'))), 208 'debug_info' => new Twig_Function_Method($this, 'getDebugInfo', array('is_safe' => array('html'))), 209 'memorize' => new Twig_Function_Method($this, 'setMemory', array('is_safe' => array('html'))), 210 'memorized' => new Twig_Function_Method($this, 'getMemory', array('is_safe' => array('html'))) 211 ); 212 } 213 214 /** 215 Returns a list of global variables to add to the existing list. 216 217 This merges overloaded variables with defined variables. 218 219 @return array An array of global variables 220 */ 43 221 public function getGlobals() 44 222 { … … 65 243 66 244 /** 67 * Fill the page title. 68 * 69 * $title can be: 70 * - a string for page title part or 71 * - TRUE to add blog name at the begining of title or 72 * - NULL to empty/reset title 73 * 74 * @param mixed $title A title part 75 * @param boolean $url Link of the title part 76 * @return object self 77 */ 245 Returns the name of the extension. 246 247 @return string The extension name 248 */ 249 public function getName() 250 { 251 return 'AdminContext'; 252 } 253 254 255 /** 256 Add an informational message 257 258 @param string $message A message 259 @return object self 260 */ 261 public function setSafeMode($safe_mode) 262 { 263 $this->protected_globals['safe_mode'] = (boolean) $safe_mode; 264 return $this; 265 } 266 267 /** 268 Add an informational message 269 270 @param string $message A message 271 @return object self 272 */ 273 public function addMessageStatic($message) 274 { 275 $this->protected_globals['messages']['static'][] = $message; 276 return $this; 277 } 278 279 /** 280 Add a list of informational messages 281 282 @param string $message A title 283 @param array $message A list of messages 284 @return object self 285 */ 286 public function addMessagesList($title,$messages) 287 { 288 $this->protected_globals['messages']['lists'][$title] = $messages; 289 return $this; 290 } 291 292 /** 293 Set an important message 294 295 @param string $message A message 296 @return object self 297 */ 298 public function setAlert($message) 299 { 300 $this->protected_globals['messages']['alert'] = $message; 301 return $this; 302 } 303 304 /** 305 Add an error message 306 307 @param string Error message 308 @return object self 309 */ 310 public function addError($error) 311 { 312 $this->protected_globals['messages']['errors'][] = $error; 313 return $this; 314 } 315 316 /** 317 Check if there is an error message 318 319 @return boolean 320 */ 321 public function hasError() 322 { 323 return !empty($this->protected_globals['messages']['errors']); 324 } 325 326 /** 327 Fill the page title 328 329 $title can be: 330 a string for page title part or 331 TRUE to add blog name at the begining of title or 332 NULL to empty/reset title 333 334 @param mixed $title A title part 335 @param boolean $url Link of the title part 336 @return object self 337 */ 78 338 public function fillPageTitle($title,$url='') 79 339 { … … 95 355 96 356 /** 97 *Check if a page title is set98 357 Check if a page title is set 358 */ 99 359 public function hasPageTitle() 100 360 { … … 103 363 104 364 /** 105 *Get list of blogs106 365 Get list of blogs 366 */ 107 367 protected function getBlogs() 108 368 { … … 116 376 while ($rs_blogs->fetch()) { 117 377 $blogs[$rs_blogs->blog_id] = $rs_blogs->blog_name.' - '.$rs_blogs->blog_url; 118 $this->protected_globals['blogs'][$rs_blogs->blog_id] = array( 119 'id' => $rs_blogs->blog_id, 120 'name' => $rs_blogs->blog_name, 121 'desc' => $rs_blogs->blog_desc, 122 'url' => $rs_blogs->blog_url, 123 'creadt' => $rs_blogs->blog_creadt, 124 'upddt' => $rs_blogs->blog_upddt 125 ); 378 $this->protected_globals['blogs'][$rs_blogs->blog_id] = 379 new dcArrayProxy($rs_blogs, array( 380 'blog_id','blog_name','blog_desc','blog_url','blog_creadt','blog_upddt')); 126 381 } 127 382 } … … 140 395 141 396 /** 142 *Get current blog information143 397 Get current blog information 398 */ 144 399 protected function getCurrentBlog() 145 400 { 146 401 $this->protected_globals['current_blog'] = $this->core->auth->blog_count ? 147 array( 148 'id' => $this->core->blog->id, 149 'name' => $this->core->blog->name, 150 'desc' => $this->core->blog->desc, 151 'url' => $this->core->blog->url, 152 'host' => $this->core->blog->host, 153 'creadt' => $this->core->blog->creadt, 154 'upddt' => $this->core->blog->upddt 155 ) : array( 402 new dcProxy($this->core->blog,array( 403 'id','name','desc','url','host','creadt','upddt' 404 )) : array( 156 405 'id' => '', 157 406 'name' => '', … … 165 414 166 415 /** 167 *Get current user information168 416 Get current user information 417 */ 169 418 protected function getCurrentUser() 170 419 { … … 214 463 215 464 /** 216 *Get sidebar menus217 465 Get sidebar menus 466 */ 218 467 protected function getMenus() 219 468 { … … 235 484 } 236 485 } 486 487 /** 488 Get an array of debug/dev infos 489 */ 490 public function getDebugInfo() 491 { 492 if (!DC_DEBUG) { 493 return array(); 494 } 495 496 $di = array( 497 'global_vars' => implode(', ',array_keys($GLOBALS)), 498 'memory' => array( 499 'usage' => memory_get_usage(), 500 'size' => files::size(memory_get_usage()) 501 ), 502 'xdebug' => array() 503 ); 504 505 if (function_exists('xdebug_get_profiler_filename')) { 506 507 $url = http::getSelfURI(); 508 $url .= strpos($url,'?') === false ? '?' : '&'; 509 $url .= 'XDEBUG_PROFILE'; 510 511 $di['xdebug'] = array( 512 'elapse_time' => xdebug_time_index(), 513 'profiler_file' => xdebug_get_profiler_filename(), 514 'profiler_url' => $url 515 ); 516 517 /* xdebug configuration: 518 zend_extension = /.../xdebug.so 519 xdebug.auto_trace = On 520 xdebug.trace_format = 0 521 xdebug.trace_options = 1 522 xdebug.show_mem_delta = On 523 xdebug.profiler_enable = 0 524 xdebug.profiler_enable_trigger = 1 525 xdebug.profiler_output_dir = /tmp 526 xdebug.profiler_append = 0 527 xdebug.profiler_output_name = timestamp 528 */ 529 } 530 531 return $di; 532 } 533 534 /** 535 Add a value in a namespace memory 536 537 This help keep variable when recalling Twig macros 538 539 @param string $ns A namespace 540 @param string $str A value to memorize in this namespace 541 */ 542 public function setMemory($ns,$str) 543 { 544 if (!array_key_exists($ns,$this->memory) || !in_array($str,$this->memory[$ns])) { 545 $this->memory[$ns][] = $str; 546 } 547 } 548 549 /** 550 Check if a value is previously memorized in a namespace 551 552 @param string $ns A namespace 553 @param string $str A value to search in this namespace 554 @return array True if exists 555 */ 556 public function getMemory($ns,$str) 557 { 558 return array_key_exists($ns,$this->memory) && in_array($str,$this->memory[$ns]); 559 } 237 560 } 238 561 ?> -
inc/admin/class.dc.form.php
r1137 r1153 13 13 14 14 /** 15 * Template form node 16 */ 15 * dcFormNode 16 * 17 * @uses Twig_Node 18 * 19 */ 17 20 class dcFormNode extends Twig_Node 18 21 { … … 30 33 { 31 34 $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 35 41 ->subcompile($this->getNode('body')) 36 42 ->write("\$context['dc_form']->renderHiddenWidgets();\n") … … 49 55 $lineno = $token->getLine(); 50 56 $stream = $this->parser->getStream(); 51 $name = $ stream->expect(Twig_Token::NAME_TYPE)->getValue();57 $name = $this->parser->getExpressionParser()->parseExpression(); 52 58 $stream->expect(Twig_Token::BLOCK_END_TYPE); 53 59 $body = $this->parser->subparse(array($this,'decideBlockEnd'),true); … … 77 83 protected $core; 78 84 protected $twig; 79 protected $blocks;80 85 protected $forms; 81 86 protected $currentForm; 87 protected $blocks; 82 88 83 89 public function __construct($core) 84 90 { 85 91 $this->core = $core; 86 $this->tpl = 'form_layout.html.twig';92 $this->tpl = array('@forms/form_layout.html.twig'); 87 93 $this->forms = array(); 94 $this->blocks = array(); 88 95 $this->currentForm = null; 89 96 } … … 92 99 { 93 100 $this->twig = $environment; 94 $this->template = $this->twig->loadTemplate($this->tpl); 95 $this->blocks = $this->template->getBlocks(); 96 } 97 101 $this->twig->getLoader()->addPath(dirname(__FILE__).'/default-templates/forms','forms'); 102 foreach ($this->tpl as $tpl) { 103 $this->template = $this->twig->loadTemplate($tpl); 104 $this->blocks = array_merge($this->blocks,$this->template->getBlocks()); 105 } 106 } 107 108 public function addTemplate($tpl) { 109 $this->tpl[]=$tpl; 110 if (isset($this->twig)) { 111 $this->template = $this->twig->loadTemplate($tpl); 112 $this->blocks = array_merge($this->blocks,$this->template->getBlocks()); 113 } 114 } 115 98 116 public function getGlobals() 99 117 { … … 104 122 { 105 123 return array( 106 'form_field' => new Twig_Function_Method(107 $this,108 'renderWidget',124 new Twig_SimpleFunction( 125 'widget', 126 array($this,'renderWidget'), 109 127 array('is_safe' => array('html')) 110 128 ), 111 '_form_is_choice_group' => new Twig_Function_Method(112 $this,113 'isChoiceGroup',129 new Twig_SimpleFunction( 130 'haswidget', 131 array($this,'hasWidget'), 114 132 array('is_safe' => array('html')) 115 133 ), 116 '_form_is_choice_selected' => new Twig_Function_Method( 117 $this, 118 'isChoiceSelected', 134 new Twig_SimpleFunction( 135 'form_field', 136 array($this,'renderField'), 137 array('is_safe' => array('html')) 138 ), 139 new Twig_SimpleFunction( 140 '_form_is_choice_group', 141 array($this,'isChoiceGroup'), 142 array('is_safe' => array('html')) 143 ), 144 new Twig_SimpleFunction( 145 '_form_is_choice_selected', 146 array($this,'isChoiceSelected'), 119 147 array('is_safe' => array('html')) 120 148 ) … … 137 165 } 138 166 139 public function renderWidget($name,$attributes=array()) 167 public function hasWidget($name) { 168 return isset($this->blocks[$name]); 169 } 170 public function renderWidget($name,$attr) { 171 if (!isset($this->blocks[$name])) 172 return ''; 173 echo $this->template->renderBlock( 174 $name, 175 $attr, 176 $this->blocks 177 ); 178 } 179 180 public function getCurrentForm() { 181 return $this->currentForm; 182 } 183 184 public function renderField($name,$attributes=array(),$extra=array()) 140 185 { 141 186 $field = $this->currentForm->$name; 142 187 if ($field) { 143 echo $this->template->renderBlock( 188 $attr = $field->getAttributes($attributes); 189 if (isset($attr['attr'])) { 190 $attr['attr'] = array_merge($attr['attr'],$attributes); 191 } else { 192 $attr['attr'] = $attributes; 193 } 194 $this->renderWidget( 144 195 $field->getWidgetBlock(), 145 196 array_merge( 146 $field->getAttributes(), 147 array('attr' => $attributes) 148 ), 149 $this->blocks 197 $attr, 198 $extra 199 ) 150 200 ); 151 201 } … … 155 205 { 156 206 foreach ($this->currentForm->getHiddenFields() as $h) { 157 $this->render Widget($h->getName());207 $this->renderField($h->getName()); 158 208 } 159 209 } … … 197 247 198 248 /** 199 * Template form 200 */ 249 * dcForm - Template form 250 * 251 */ 201 252 class dcForm 202 253 { … … 211 262 protected $errors; 212 263 213 private function addNonce() 264 public function addTemplate($t) { 265 $this->core->tpl->getExtension('dc_form')->addTemplate($t); 266 } 267 268 /** 269 * addNonce -- adds dc nonce to form fields 270 * 271 * @access protected 272 * 273 * @return nothing 274 */ 275 protected function addNonce() 214 276 { 215 277 $this->addField( … … 219 281 } 220 282 221 protected function getNID($nid) 283 284 /** 285 * Defines Name & ID from field 286 * 287 * @param mixed $nid either an array (name, id) or a string (name only, id will be set to null). 288 * 289 * @access protected 290 * 291 * @return nothing. 292 */ 293 protected function setNID($nid) 222 294 { 223 295 if (is_array($nid)) { … … 231 303 } 232 304 305 public function getContext() { 306 return array(); 307 } 308 309 /** 310 * Class constructor 311 * 312 * @param mixed $core dotclear core 313 * @param mixed $name form name 314 * @param mixed $action form action 315 * @param string $method form method ('GET' or 'POST') 316 * 317 * @access public 318 * 319 * @return mixed Value. 320 */ 233 321 public function __construct($core,$name,$action,$method='POST') 234 322 { 235 323 $this->core = $core; 236 $this-> getNID($name);324 $this->setNID($name); 237 325 $this->method = $method; 238 326 $this->action = $action; … … 247 335 } 248 336 337 338 /** 339 * Returns form name 340 * 341 * @access public 342 * 343 * @return mixed Value. 344 */ 249 345 public function getName() 250 346 { … … 270 366 } 271 367 368 public function removeField(dcField $f) { 369 $n = $f->getName(); 370 if (isset($this->fields[$n])){ 371 unset($this->fields[$n]); 372 } 373 374 } 375 public function renameField($field,$newname) { 376 $oldname = $field->getName(); 377 if (isset($this->fields[$oldname])) { 378 unset($this->fields[$oldname]); 379 $field->setName($newname); 380 $this->fields[$newname] = $field; 381 } 382 } 272 383 public function begin() 273 384 { … … 292 403 public function __get($name) 293 404 { 294 return isset($this->fields[$name]) ? 405 return isset($this->fields[$name]) ? 295 406 $this->fields[$name] : null; 296 407 } 297 408 298 409 public function __set($name,$value) 299 410 { 300 411 if (isset($this->fields[$name])) { 301 $this->fields[$name]->set Attribute('value',$value);302 } 303 } 304 412 $this->fields[$name]->setValue($value); 413 } 414 } 415 305 416 public function isSubmitted() 306 417 { 307 418 $from = $this->method == 'POST' ? $_POST : $_GET; 308 echo "form fields :\n"; 309 } 310 311 public function setup() 312 { 419 } 420 421 protected function setupFields() { 313 422 $from = $this->method == 'POST' ? $_POST : $_GET; 314 423 foreach ($this->fields as $f) { 315 424 $f->setup($from); 316 425 } 426 } 427 428 protected function handleActions($submitted) { 429 foreach ($submitted as $f) { 430 $action = $f->getAction(); 431 if ($action != NULL) { 432 $ret = call_user_func($action,$this); 433 } 434 } 435 } 436 437 protected function getSubmittedFields() { 438 $s = array(); 317 439 foreach ($this->submitfields as $f) { 318 440 if ($f->isDefined()) { 319 $ret = call_user_func($f->getAction(),$this); 320 return; 441 $s[$f->getName()] = $f; 321 442 } 322 443 } 323 } 324 444 return $s; 445 } 446 447 public function setup() 448 { 449 $this->setupFields(); 450 $submitted = $this->getSubmittedFields(); 451 $this->handleActions($submitted); 452 } 453 325 454 public function check() 326 455 { … … 344 473 * Template form field 345 474 */ 346 abstract class dcField 347 { 348 protected $ attributes;475 abstract class dcField implements Countable 476 { 477 protected $options; 349 478 protected $name; 350 protected $value ;479 protected $values; 351 480 protected $id; 481 protected $multiple; 352 482 protected $defined; 353 483 354 protected function getNID($nid)484 protected function setNID($nid) 355 485 { 356 486 if (is_array($nid)) { … … 363 493 } 364 494 365 public function __construct($name,$value ,$attributes=array())366 { 367 $this-> getNID($name);368 $this-> attributes = $attributes;369 $this->value = $value;370 $this->attributes['name'] = $this->name;371 $this->attributes['id'] = $this->id;372 $this-> attributes['value'] = $this->value;495 public function __construct($name,$values,$options=array()) 496 { 497 $this->setNID($name); 498 $this->options = new ArrayObject($options); 499 if ($values === NULL){ 500 $values = array(); 501 } 502 $this->setValues($values); 373 503 $this->defined = false; 374 } 375 504 $this->multiple = (isset($options['multiple']) && $options['multiple']); 505 506 } 507 508 public function setValue($value,$offset=0) { 509 $this->values[$offset] = $value; 510 } 511 512 public function setValues($values) { 513 if (is_array($values)) { 514 $this->values = $values; 515 } elseif ($values !== NULL) { 516 $this->values = array($values); 517 } 518 519 } 520 521 public function getValues() { 522 return $this->values; 523 } 524 525 public function getValue($offset=0) { 526 if (isset($this->values[$offset])) { 527 return $this->values[$offset]; 528 } 529 } 530 531 public function addValue($value) { 532 $this->values[] = $value; 533 } 534 public function delValue($offset) { 535 if (isset($this->values[$offset])) { 536 array_splice($this->values,$offset,1); 537 } 538 } 539 540 public function count() { 541 return count($this->values); 542 } 543 376 544 public function __toString() 377 545 { 378 return (string) $this->value;546 return join(',',$this->values); 379 547 } 380 548 381 549 abstract public function getWidgetBlock(); 382 550 383 public function setAttribute($name,$value) 384 { 385 $this->attributes[$name] = $value; 386 } 387 388 public function getAttributes() 389 { 390 return $this->attributes; 391 } 392 551 public function getAttributes($options) 552 { 553 $offset = isset($options['offset']) ? $options['offset'] : 0; 554 555 $attr = $this->options->getArrayCopy(); 556 if (isset($this->values[$offset])) { 557 $attr['value'] = $this->values[$offset]; 558 } else { 559 $attr['value'] = $this->getDefaultValue(); 560 } 561 if ($offset==0) { 562 $attr['id']=$this->id; 563 } 564 $attr['name'] = $this->name; 565 if ($this->multiple) { 566 $attr['name'] = $attr['name'].'[]'; 567 } 568 return $attr; 569 } 570 571 public function getDefaultValue() { 572 return ''; 573 } 574 393 575 public function getName() 394 576 { 395 577 return $this->name; 396 578 } 397 579 580 public function setName($name) { 581 $this->setNID($name); 582 } 583 398 584 public function check() 399 585 { 400 if (!$this->defined && $this-> attributes['defined']) {586 if (!$this->defined && $this->options['mandatory']) { 401 587 throw new InvalidFieldException(sprintf( 402 588 'Field "%s" is mandatory', … … 406 592 } 407 593 594 public function parseValues($from) { 595 if (isset($from[$this->name])) { 596 $n = $from[$this->name]; 597 if (!is_array($n)) { 598 $n = array($n); 599 } 600 return $n; 601 } 602 return array(); 603 } 604 408 605 public function setup($from) 409 606 { 410 if (isset($from[$this->id])) { 411 $this->value = $from[$this->id]; 607 $values = $this->parseValues($from); 608 if (count($values)) { 609 $this->setValues($values); 412 610 $this->defined = true; 413 611 } … … 420 618 } 421 619 620 422 621 /** 423 622 * Template form field of type "password" … … 473 672 return "field_checkbox"; 474 673 } 674 675 public function getDefaultValue() { 676 return 0; 677 } 475 678 } 476 679 … … 481 684 { 482 685 protected $action; 483 484 public function __construct($name,$value,$attributes=array()) 485 { 486 parent::__construct($name,$value,$attributes); 487 488 if (isset($attributes['action'])) { 489 $this->action = $attributes['action']; 490 } 491 } 492 686 687 public function __construct($name,$values,$options=array()) 688 { 689 parent::__construct($name,$values,$options); 690 691 if (isset($options['action'])) { 692 $this->action = $options['action']; 693 } else { 694 $this->action = NULL; 695 } 696 } 697 493 698 public function getAction() 494 699 { … … 513 718 class dcFieldCombo extends dcField 514 719 { 515 protected $options; 516 517 public function __construct($name,$value,$options,$attributes=array()) 518 { 519 $this->options = $options; 520 parent::__construct($name,$value,$attributes); 521 $this->attributes['options']=$options; 720 protected $combo; 721 722 public function __construct($name,$value,$combo,$options=array()) 723 { 724 $this->combo = $combo; 725 parent::__construct($name,$value,$options); 522 726 } 523 727 … … 527 731 } 528 732 529 } 733 public function getDefaultValue() { 734 return current($this->combo); 735 } 736 737 public function parseValues($from) { 738 $values = parent::parseValues($from); 739 if (!is_array($values)) { 740 $values = array($values); 741 } 742 foreach ($values as &$v) { 743 if (!isset($this->combo[$v])) 744 $v = $this->getDefaultValue(); 745 } 746 return $values; 747 } 748 749 public function getAttributes($options) { 750 $attr = parent::getAttributes($options); 751 $attr['options'] = $this->combo; 752 return $attr; 753 } 754 } 755 530 756 ?> -
inc/admin/default-templates/auth.html.twig
r1089 r1147 18 18 <body id="dotclear-admin" class="auth"> 19 19 20 {% form auth%}20 {% form 'auth' %} 21 21 <div id="login-screen"> 22 22 <h1>{{vendor_name}}</h1> -
inc/admin/default-templates/index.html.twig
r1099 r1147 28 28 <div id="quick"> 29 29 <h3>{{__('Quick entry')}}</h3> 30 {% form quickentry%}30 {% form 'quickentry' %} 31 31 <fieldset><legend>{{__('New entry')}}</legend> 32 32 <p class="col">{{ form_field('post_title',{'class':'maximal'}) }}</p> -
inc/admin/default-templates/layout.html.twig
r1089 r1147 19 19 <body id="dotclear-admin{% if safe_mode %} safe-mode{% endif %}"> 20 20 <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 %} 25 27 <div id="top"><h1><a href="index.php">{{vendor_name}}</a></h1></div> 26 28 <div id="info-boxes"> 27 29 <div id="info-box1"> 28 {% form switchblog_menu%}30 {% form 'switchblog_menu' %} 29 31 {% 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> 32 34 {% 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 %} 35 37 {% 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> 37 39 {% endform %} 38 40 </div> -
inc/admin/default-templates/post.html.twig
r1088 r1147 16 16 17 17 <div class="multi-part" title="{{__('Edit entry')}}" id="edit-entry"> 18 {% form post%}18 {% form 'post' %} 19 19 <div id="entry-wrapper"> 20 20 <div id="entry-content"> -
inc/admin/default-templates/style/default.css
r1085 r1147 1356 1356 background-color: #2373A8; 1357 1357 } 1358 1358 form#filters {font-size: 100%; background: #f0f0f0; padding: 1em; border-radius: .5em; border: 1px solid #ddd;} 1359 form#filters .margintop {padding-top: 1.33em;} 1360 form#filters ul, form#filters p {list-style-type:none;margin: 0; padding: 0 0 .5em 0; margin-left: 1em;} 1361 form#filters .col30 {border-left: 1px solid #999;} 1362 form#filters .col30 h3 {margin-left: 1em;} 1363 1364 p.line, li.line { position: relative; padding: 3px 0 0 28px; margin: 0 0 1em 0;} 1365 li.line input[type=submit] {position: absolute; left:0;top:0; padding: 0 .1em; margin: 0;} 1366 li.line input[type=checkbox], li.line input[type=checkbox] {position: absolute; left: 0; top: .2em; padding: 0 .1em; margin: 0;} 1367 li.line select { margin-right: 2em;} 1368 li.line label { display: block; width: 8em; float: left;} 1369 li.line label img {margin-right: 8px;} 1370 li.line span.or { 1371 text-align: right; 1372 margin-left: 5em; 1373 font-weight: bold; 1374 } 1375 p.line label.or + select {margin-left: 2em;} 1376 li.line { padding: 0 0 0 20px; height: 1em;} 1377 li.line label {width: auto;} 1378 1379 #available_filters input[type=submit] {padding: 0 .1em; margin-left: .5em;} 1380 1381 div.pagination span, div.pagination a { 1382 margin-right: 1em; 1383 } 1359 1384 /* jQuery Autocomplete plugin */ 1360 1385 .ac_results { -
inc/core/class.dc.blog.php
r1052 r1152 805 805 806 806 if (!empty($params['user_id'])) { 807 $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."'";807 $strReq .= "AND U.user_id ".$this->con->in($params['user_id'])." "; 808 808 } 809 809 -
inc/core/class.dc.core.php
r1128 r1153 96 96 $this->addFormater('xhtml', create_function('$s','return $s;')); 97 97 $this->addFormater('wiki', array($this,'wikiTransform')); 98 99 $this->tpl = new dcTemplate(DC_TPL_CACHE,'$core->tpl',$this); 98 $this->loadTemplateEnvironment(); 100 99 } 101 100 … … 119 118 120 119 return new $c($this); 120 } 121 122 /** 123 Create template environment (Twig_Environment instance) 124 125 default-templates path must be added from admin|public/prepend.php with: 126 $core->tpl->getLoader()->addPath('PATH_TO/default-templates'); 127 Selected theme path must be added with: 128 $core->tpl->getLoader()->prependPath('PATH_TO/MY_THEME'); 129 */ 130 public function loadTemplateEnvironment() 131 { 132 $cache_dir = path::real(DC_TPL_CACHE.'/twtpl',false); 133 if (!is_dir($cache_dir)) { 134 try { 135 files::makeDir($cache_dir); 136 } catch (Exception $e) { 137 $cache_dir = false; 138 } 139 } 140 141 $this->tpl = new Twig_Environment( 142 new Twig_Loader_Filesystem(dirname(__FILE__).'/../swf'), 143 array( 144 'auto_reload' => true, 145 'autoescape' => false, 146 'base_template_class' => 'Twig_Template', 147 'cache' => $cache_dir, 148 'charset' => 'UTF-8', 149 'debug' => DC_DEBUG, 150 'optimizations' => -1, 151 'strict_variables' => 0 //DC_DEBUG // Please fix undefined variables! 152 ) 153 ); 154 $this->tpl->addExtension(new dcFormExtension($this)); 155 $this->tpl->addExtension(new dcTabExtension($this)); 121 156 } 122 157 -
inc/prepend.php
r1128 r1153 46 46 $__autoload['dcWorkspace'] = dirname(__FILE__).'/core/class.dc.workspace.php'; 47 47 $__autoload['dcPrefs'] = dirname(__FILE__).'/core/class.dc.prefs.php'; 48 //$__autoload['dcTwigPage'] = dirname(__FILE__).'/core/class.dc.twig.page.php'; 49 $__autoload['dcTemplate'] = dirname(__FILE__).'/core/class.dc.template.php'; 50 $__autoload['dcContext'] = dirname(__FILE__).'/core/class.dc.context.php'; 48 $__autoload['dcTwigPage'] = dirname(__FILE__).'/core/class.dc.twig.page.php'; 51 49 52 50 $__autoload['rsExtPost'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; … … 64 62 $__autoload['adminUserList'] = dirname(__FILE__).'/admin/lib.pager.php'; 65 63 66 $__autoload['dcPublicContext'] = dirname(__FILE__).'/public/class.dc.publiccontext.php'; 67 //$__autoload['dcTemplate'] = dirname(__FILE__).'/public/class.dc.template.php'; 68 //$__autoload['context'] = dirname(__FILE__).'/public/lib.tpl.context.php'; 64 $__autoload['dcTemplate'] = dirname(__FILE__).'/public/class.dc.template.php'; 65 $__autoload['context'] = dirname(__FILE__).'/public/lib.tpl.context.php'; 69 66 $__autoload['dcUrlHandlers'] = dirname(__FILE__).'/public/lib.urlhandlers.php'; 70 67 $__autoload['dcForm'] = dirname(__FILE__).'/admin/class.dc.form.php'; 71 68 $__autoload['dcFormExtension'] = dirname(__FILE__).'/admin/class.dc.form.php'; 72 69 $__autoload['dcTabExtension'] = dirname(__FILE__).'/admin/class.dc.tab.php'; 70 $__autoload['dcItemList'] = dirname(__FILE__).'/admin/class.dc.list.php'; 71 72 foreach (array('dcFilterSet', 'dcFilter','dcFilterCombo','dcFilterText','dcFilterBoolean') as $c) { 73 $__autoload[$c] = dirname(__FILE__).'/admin/class.dc.filter.php'; 74 } 73 75 74 76 # Clearbricks extensions … … 77 79 78 80 if (@is_dir('/usr/lib/twig')) { 79 define('TWIG_PATH','/usr/lib/ twig');80 } elseif (is_dir(dirname(__FILE__).'/libs/ twig')) {81 define('TWIG_PATH',dirname(__FILE__).'/libs/ twig');81 define('TWIG_PATH','/usr/lib/Twig'); 82 } elseif (is_dir(dirname(__FILE__).'/libs/Twig')) { 83 define('TWIG_PATH',dirname(__FILE__).'/libs/Twig'); 82 84 } elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) { 83 85 define('TWIG_PATH',$_SERVER['TWIG_PATH']); … … 146 148 # Constants 147 149 define('DC_ROOT',path::real(dirname(__FILE__).'/..')); 148 define('DC_VERSION','2.5- RC');150 define('DC_VERSION','2.5-dev'); 149 151 define('DC_DIGESTS',dirname(__FILE__).'/digests'); 150 152 define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); -
plugins/aboutConfig/admtpl/index.html.twig
r1092 r1147 13 13 {% tab local('local',__('blog settings')) %} 14 14 {% if local_settings is not empty %} 15 {% form local_nav_form%}15 {% form 'local_nav_form' %} 16 16 <p class="anchor-nav">{{ form_field('local_nav') }} {{ form_field('local_nav_submit') }}</p> 17 17 {% endform %} 18 18 {% endif %} 19 19 20 {% form local_settings_form%}20 {% form 'local_settings_form' %} 21 21 {% for ns, setting in local_settings %} 22 22 <table class="settings" id="local_{{ ns }}"><caption>{{ ns }}</caption> … … 47 47 {% tab global('global',__('global settings')) %} 48 48 {% if global_settings is not empty %} 49 {% form global_nav_form%}49 {% form 'global_nav_form' %} 50 50 <p class="anchor-nav">{{ form_field('global_nav') }} {{ form_field('global_nav_submit') }}</p> 51 51 {% endform %} 52 52 {% endif %} 53 53 54 {% form global_settings_form%}54 {% form 'global_settings_form' %} 55 55 {% for ns, setting in global_settings %} 56 56 <table class="settings" id="global_{{ ns }}"><caption>{{ ns }}</caption>
Note: See TracChangeset
for help on using the changeset viewer.