- Timestamp:
- Apr 11, 2005, 10:31:50 PM (20 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/element_set_global.php
r760 r762 31 31 * 32 32 */ 33 34 $user['nb_image_line'] = 6; // temporary35 33 36 34 if (!defined('PHPWG_ROOT_PATH')) … … 41 39 42 40 // +-----------------------------------------------------------------------+ 43 // | empty caddie | 44 // +-----------------------------------------------------------------------+ 45 if (isset($_GET['empty'])) 46 { 41 // | functions | 42 // +-----------------------------------------------------------------------+ 43 44 /** 45 * returns the list of uniq keywords among given elements 46 * 47 * @param array element_ids 48 */ 49 function get_elements_keywords($element_ids) 50 { 51 if (0 == count($element_ids)) 52 { 53 return array(); 54 } 55 56 $keywords = array(); 57 47 58 $query = ' 59 SELECT keywords 60 FROM '.IMAGES_TABLE.' 61 WHERE id IN ('.implode(',', $element_ids).') 62 ;'; 63 $result = pwg_query($query); 64 while ($row = mysql_fetch_array($result)) 65 { 66 if (isset($row['keywords']) and !empty($row['keywords'])) 67 { 68 $keywords = array_merge($keywords, explode(',', $row['keywords'])); 69 } 70 } 71 return array_unique($keywords); 72 } 73 74 // +-----------------------------------------------------------------------+ 75 // | caddie management | 76 // +-----------------------------------------------------------------------+ 77 if (isset($_POST['submit_caddie'])) 78 { 79 if (isset($_POST['caddie_action'])) 80 { 81 switch ($_POST['caddie_action']) 82 { 83 case 'empty_all' : 84 { 85 $query = ' 48 86 DELETE FROM '.CADDIE_TABLE.' 49 87 WHERE user_id = '.$user['id'].' 50 88 ;'; 51 pwg_query($query); 89 pwg_query($query); 90 break; 91 } 92 case 'empty_selected' : 93 { 94 if (isset($_POST['selection']) and count($_POST['selection']) > 0) 95 { 96 $query = ' 97 DELETE 98 FROM '.CADDIE_TABLE.' 99 WHERE element_id IN ('.implode(',', $_POST['selection']).') 100 AND user_id = '.$user['id'].' 101 ;'; 102 pwg_query($query); 103 } 104 else 105 { 106 // TODO : add error 107 } 108 break; 109 } 110 } 111 } 112 else 113 { 114 // TODO : add error 115 } 52 116 } 53 117 … … 62 126 63 127 // echo '<pre>'; 64 // print_r($_POST ['selection']);128 // print_r($_POST); 65 129 // echo '</pre>'; 66 130 // exit(); … … 100 164 $associated = array_from_query($query, 'image_id'); 101 165 166 // TODO : if $associable array is empty, no further actions 102 167 $associable = array_diff($collection, $associated); 103 168 … … 137 202 update_category(array($_POST['dissociate'])); 138 203 } 204 205 $datas = array(); 206 $dbfields = array('primary' => array('id'), 'update' => array()); 207 208 if (!empty($_POST['add_keywords']) or $_POST['remove_keyword'] != '0') 209 { 210 array_push($dbfields['update'], 'keywords'); 211 } 212 213 $formfields = array('author', 'name', 'date_creation'); 214 foreach ($formfields as $formfield) 215 { 216 if ($_POST[$formfield.'_action'] != 'leave') 217 { 218 array_push($dbfields['update'], $formfield); 219 } 220 } 221 222 // updating elements is useful only if needed... 223 if (count($dbfields['update']) > 0) 224 { 225 $query = ' 226 SELECT id, keywords 227 FROM '.IMAGES_TABLE.' 228 WHERE id IN ('.implode(',', $collection).') 229 ;'; 230 $result = pwg_query($query); 231 232 while ($row = mysql_fetch_array($result)) 233 { 234 $data = array(); 235 $data['id'] = $row['id']; 236 237 if (!empty($_POST['add_keywords'])) 238 { 239 $data['keywords'] = 240 implode( 241 ',', 242 array_unique( 243 array_merge( 244 get_keywords(empty($row['keywords']) ? '' : $row['keywords']), 245 get_keywords($_POST['add_keywords']) 246 ) 247 ) 248 ); 249 } 250 251 if ($_POST['remove_keyword'] != '0') 252 { 253 if (!isset($data['keywords'])) 254 { 255 $data['keywords'] = empty($row['keywords']) ? '' : $row['keywords']; 256 } 257 258 $data['keywords'] = 259 implode( 260 ',', 261 array_unique( 262 array_diff( 263 get_keywords($data['keywords']), 264 array($_POST['remove_keyword']) 265 ) 266 ) 267 ); 268 269 if ($data['keywords'] == '') 270 { 271 unset($data['keywords']); 272 } 273 } 274 275 if ('set' == $_POST['author_action']) 276 { 277 $data['author'] = $_POST['author']; 278 279 if ('' == $data['author']) 280 { 281 unset($data['author']); 282 } 283 } 284 285 if ('set' == $_POST['name_action']) 286 { 287 $data['name'] = $_POST['name']; 288 289 if ('' == $data['name']) 290 { 291 unset($data['name']); 292 } 293 } 294 295 if ('set' == $_POST['date_creation_action']) 296 { 297 $data['date_creation'] = 298 $_POST['date_creation_year'] 299 .'-'.$_POST['date_creation_month'] 300 .'-'.$_POST['date_creation_day'] 301 ; 302 } 303 304 array_push($datas, $data); 305 } 306 echo '<pre>'; print_r($datas); echo '</pre>'; 307 mass_updates(IMAGES_TABLE, $dbfields, $datas); 308 } 139 309 } 140 310 … … 145 315 array('element_set_global' => 'admin/element_set_global.tpl')); 146 316 147 $form_action = PHPWG_ROOT_PATH.'admin.php?page=element_set_global'; 317 $base_url = PHPWG_ROOT_PATH.'admin.php'; 318 319 // $form_action = $base_url.'?page=element_set_global'; 148 320 149 321 $template->assign_vars( … … 151 323 'L_SUBMIT'=>$lang['submit'], 152 324 153 'U_E MPTY_CADDIE'=>add_session_id($form_action.'&empty=1'),325 'U_ELEMENTS_LINE'=>$base_url.get_query_string_diff(array('display')), 154 326 155 'F_ACTION'=> add_session_id($form_action)327 'F_ACTION'=>$base_url.get_query_string_diff(array()), 156 328 ) 157 329 ); … … 202 374 display_select_cat_wrapper($query, array(), $blockname, true); 203 375 376 $blockname = 'remove_keyword_option'; 377 378 $template->assign_block_vars( 379 $blockname, 380 array('VALUE'=> 0, 381 'OPTION' => '------------' 382 )); 383 384 $query = ' 385 SELECT element_id 386 FROM '.CADDIE_TABLE.' 387 WHERE user_id = '.$user['id'].' 388 ;'; 389 $keywords = get_elements_keywords(array_from_query($query, 'element_id')); 390 391 foreach ($keywords as $keyword) 392 { 393 $template->assign_block_vars( 394 $blockname, 395 array('VALUE'=> $keyword, 396 'OPTION' => $keyword 397 )); 398 } 399 400 // creation date 401 $day = 402 empty($_POST['date_creation_day']) ? date('j') : $_POST['date_creation_day']; 403 get_day_list('date_creation_day', $day); 404 405 if (!empty($_POST['date_creation_month'])) 406 { 407 $month = $_POST['date_creation_month']; 408 } 409 else 410 { 411 $month = date('n'); 412 } 413 get_month_list('date_creation_month', $month); 414 415 if (!empty($_POST['date_creation_year'])) 416 { 417 $year = $_POST['date_creation_year']; 418 } 419 else 420 { 421 $year = date('Y'); 422 } 423 $template->assign_vars(array('DATE_CREATION_YEAR_VALUE'=>$year)); 424 204 425 // +-----------------------------------------------------------------------+ 205 426 // | global mode thumbnails | 206 427 // +-----------------------------------------------------------------------+ 428 429 $page['nb_image_line'] = !empty($_GET['display']) ? $_GET['display'] : 5; 207 430 208 431 $query = ' … … 240 463 241 464 // create a new line ? 242 if (++$row_number == $ user['nb_image_line'])465 if (++$row_number == $page['nb_image_line']) 243 466 { 244 467 $template->assign_block_vars('thumbnails.line', array()); -
trunk/doc/ChangeLog
r761 r762 1 2005-04-11 Pierrick LE GALL <pierrick /at/ phpwebgallery {dot} net> 2 3 * functions get_day_list and get_month_list moved from search.php 4 to include/functions.inc.php : these functions are now also used 5 in admin/element_set_global.php 6 7 * elements batch management improved : ability to set the number 8 of elements to display per line, ability to set {author, name, 9 creation date} fields, ability to add and remove keywords, ability 10 to take selected elements out of caddie 11 1 12 2005-03-31 Pierrick LE GALL <pierrick at phpwebgallery dot net> 2 13 -
trunk/include/functions.inc.php
r755 r762 640 640 return $array; 641 641 } 642 643 /** 644 * instantiate number list for days in a template block 645 * 646 * @param string blockname 647 * @param string selection 648 */ 649 function get_day_list($blockname, $selection) 650 { 651 global $template; 652 653 $template->assign_block_vars( 654 $blockname, array('SELECTED' => '', 'VALUE' => 0, 'OPTION' => '--')); 655 656 for ($i = 1; $i <= 31; $i++) 657 { 658 $selected = ''; 659 if ($i == (int)$selection) 660 { 661 $selected = 'selected="selected"'; 662 } 663 $template->assign_block_vars( 664 $blockname, array('SELECTED' => $selected, 665 'VALUE' => $i, 666 'OPTION' => str_pad($i, 2, '0', STR_PAD_LEFT))); 667 } 668 } 669 670 /** 671 * instantiate month list in a template block 672 * 673 * @param string blockname 674 * @param string selection 675 */ 676 function get_month_list($blockname, $selection) 677 { 678 global $template, $lang; 679 680 $template->assign_block_vars( 681 $blockname, array('SELECTED' => '', 682 'VALUE' => 0, 683 'OPTION' => '------------')); 684 685 for ($i = 1; $i <= 12; $i++) 686 { 687 $selected = ''; 688 if ($i == (int)$selection) 689 { 690 $selected = 'selected="selected"'; 691 } 692 $template->assign_block_vars( 693 $blockname, array('SELECTED' => $selected, 694 'VALUE' => $i, 695 'OPTION' => $lang['month'][$i])); 696 } 697 } 642 698 ?> -
trunk/search.php
r688 r762 134 134 } 135 135 //----------------------------------------------------- template initialization 136 /**137 * instantiate number list for days in a template block138 *139 * @param string blockname140 * @param string selection141 */142 function get_day_list($blockname, $selection)143 {144 global $template;145 146 $template->assign_block_vars(147 $blockname, array('SELECTED' => '', 'VALUE' => 0, 'OPTION' => '--'));148 149 for ($i = 1; $i <= 31; $i++)150 {151 $selected = '';152 if ($i == (int)$selection)153 {154 $selected = 'selected="selected"';155 }156 $template->assign_block_vars(157 $blockname, array('SELECTED' => $selected,158 'VALUE' => $i,159 'OPTION' => str_pad($i, 2, '0', STR_PAD_LEFT)));160 }161 }162 163 /**164 * instantiate month list in a template block165 *166 * @param string blockname167 * @param string selection168 */169 function get_month_list($blockname, $selection)170 {171 global $template, $lang;172 173 $template->assign_block_vars(174 $blockname, array('SELECTED' => '',175 'VALUE' => 0,176 'OPTION' => '------------'));177 178 for ($i = 1; $i <= 12; $i++)179 {180 $selected = '';181 if ($i == (int)$selection)182 {183 $selected = 'selected="selected"';184 }185 $template->assign_block_vars(186 $blockname, array('SELECTED' => $selected,187 'VALUE' => $i,188 'OPTION' => $lang['month'][$i]));189 }190 }191 136 192 137 // start date -
trunk/template/default/admin/element_set_global.tpl
r755 r762 1 <p style="text-align:center"><a href="{U_EMPTY_CADDIE}">Empty caddie</a></p>2 3 1 <form action="{F_ACTION}" method="post"> 4 2 5 associate to 6 <select style="width:400px" name="associate" size="1"> 7 <!-- BEGIN associate_option --> 8 <option {associate_option.SELECTED} value="{associate_option.VALUE}">{associate_option.OPTION}</option> 9 <!-- END associate_option --> 10 </select> 3 <fieldset> 11 4 12 <br />dissociate from 13 <select style="width:400px" name="dissociate" size="1"> 14 <!-- BEGIN dissociate_option --> 15 <option {dissociate_option.SELECTED} value="{dissociate_option.VALUE}">{dissociate_option.OPTION}</option> 16 <!-- END dissociate_option --> 17 </select> 5 <legend>Caddie management</legend> 18 6 19 <br />target 20 <input type="radio" name="target" value="all" /> all 21 <input type="radio" name="target" value="selection" /> selection 7 <ul style="list-style-type:none;"> 8 <li><input type="radio" name="caddie_action" value="empty_all" /> Empty caddie</li> 9 <li><input type="radio" name="caddie_action" value="empty_selected" /> Take selected elements out of caddie</li> 10 </ul> 11 12 <p style="text-align:center;"><input type="submit" value="{L_SUBMIT}" name="submit_caddie" class="bouton" /></p> 13 14 </fieldset> 15 16 <fieldset> 17 18 <legend>Form</legend> 19 20 <table> 21 22 <tr> 23 <td>associate to category</td> 24 <td> 25 <select style="width:400px" name="associate" size="1"> 26 <!-- BEGIN associate_option --> 27 <option {associate_option.SELECTED} value="{associate_option.VALUE}">{associate_option.OPTION}</option> 28 <!-- END associate_option --> 29 </select> 30 </td> 31 </tr> 32 33 <tr> 34 <td>dissociate from category</td> 35 <td> 36 <select style="width:400px" name="dissociate" size="1"> 37 <!-- BEGIN dissociate_option --> 38 <option {dissociate_option.SELECTED} value="{dissociate_option.VALUE}">{dissociate_option.OPTION}</option> 39 <!-- END dissociate_option --> 40 </select> 41 </td> 42 </tr> 43 44 <tr> 45 <td>add keywords</td> 46 <td><input type="text" name="add_keywords" value="" /></td> 47 </tr> 48 49 <tr> 50 <td>remove keyword</td> 51 <td> 52 <select name="remove_keyword"> 53 <!-- BEGIN remove_keyword_option --> 54 <option value="{remove_keyword_option.VALUE}">{remove_keyword_option.OPTION}</option> 55 <!-- END remove_keyword_option --> 56 </select> 57 </td> 58 </tr> 59 60 <tr> 61 <td>author</td> 62 <td> 63 <input type="radio" name="author_action" value="leave" checked="checked" /> leave unchanged 64 <input type="radio" name="author_action" value="unset" /> unset 65 <input type="radio" name="author_action" value="set" id="author_action_set" /> set to 66 <input onmousedown="document.getElementById('author_action_set').checked = true;" type="text" name="author" value="" /> 67 </td> 68 </tr> 69 70 <tr> 71 <td>title</td> 72 <td> 73 <input type="radio" name="name_action" value="leave" checked="checked" /> leave unchanged 74 <input type="radio" name="name_action" value="unset" /> unset 75 <input type="radio" name="name_action" value="set" id="name_action_set" /> set to 76 <input onmousedown="document.getElementById('name_action_set').checked = true;" type="text" name="name" value="" /> 77 </td> 78 </tr> 79 80 <tr> 81 <td>creation date</td> 82 <td> 83 <input type="radio" name="date_creation_action" value="leave" checked="checked" /> leave unchanged 84 <input type="radio" name="date_creation_action" value="unset" /> unset 85 <input type="radio" name="date_creation_action" value="set" id="date_creation_action_set" /> set to 86 <select onmousedown="document.getElementById('date_creation_action_set').checked = true;" name="date_creation_day"> 87 <!-- BEGIN date_creation_day --> 88 <option {date_creation_day.SELECTED} value="{date_creation_day.VALUE}">{date_creation_day.OPTION}</option> 89 <!-- END date_creation_day --> 90 </select> 91 <select onmousedown="document.getElementById('date_creation_action_set').checked = true;" name="date_creation_month"> 92 <!-- BEGIN date_creation_month --> 93 <option {date_creation_month.SELECTED} value="{date_creation_month.VALUE}">{date_creation_month.OPTION}</option> 94 <!-- END date_creation_month --> 95 </select> 96 <input onmousedown="document.getElementById('date_creation_action_set').checked = true;" 97 name="date_creation_year" 98 type="text" 99 size="4" 100 maxlength="4" 101 value="{DATE_CREATION_YEAR_VALUE}" /> 102 </td> 103 </tr> 104 105 </table> 106 107 <p style="text-align:center;"> 108 target 109 <input type="radio" name="target" value="all" /> all 110 <input type="radio" name="target" value="selection" checked="checked" /> selection 111 </p> 112 22 113 23 <br /><input type="submit" value="{L_SUBMIT}" name="submit" class="bouton" /> 114 <p style="text-align:center;"><input type="submit" value="{L_SUBMIT}" name="submit" class="bouton" /></p> 115 116 </fieldset> 117 118 <fieldset> 119 120 <legend>Elements</legend> 24 121 25 122 <!-- BEGIN thumbnails --> … … 42 139 <!-- END thumbnails --> 43 140 141 </fieldset> 142 143 <fieldset> 144 145 <legend>Display options</legend> 146 147 <p>elements per line : 148 <a href="{U_ELEMENTS_LINE}&display=4">4</a> 149 | <a href="{U_ELEMENTS_LINE}&display=5">5</a> 150 | <a href="{U_ELEMENTS_LINE}&display=6">6</a> 151 | <a href="{U_ELEMENTS_LINE}&display=7">7</a> 152 | <a href="{U_ELEMENTS_LINE}&display=8">8</a> 153 | <a href="{U_ELEMENTS_LINE}&display=9">9</a> 154 | <a href="{U_ELEMENTS_LINE}&display=10">10</a> 155 </p> 156 157 </fieldset> 158 44 159 </form>
Note: See TracChangeset
for help on using the changeset viewer.