Changeset 1670 for trunk/admin
- Timestamp:
- Dec 16, 2006, 1:14:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/ws_checker.php
r1663 r1670 26 26 // +-----------------------------------------------------------------------+ 27 27 28 // +-----------------------------------------------------------------------+29 // | functions |30 // +-----------------------------------------------------------------------+31 32 // Function to migrate be useful for ws33 function official_req()34 {35 return array(36 'random' /* Random order */37 , 'list' /* list on MBt & z0rglub request */38 , 'maxviewed' /* hit > 0 and hit desc order */39 , 'recent' /* recent = Date_available desc order */40 , 'highrated' /* avg_rate > 0 and desc order */41 , 'oldest' /* Date_available asc order */42 , 'lessviewed' /* hit asc order */43 , 'lowrated' /* avg_rate asc order */44 , 'undescribed' /* description missing */45 , 'unnamed' /* new name missing */46 , 'portraits' /* width < height (portrait oriented) */47 , 'landscapes' /* width > height (landscape oriented) */48 , 'squares' /* width ~ height (square form) */49 );50 }51 52 function expand_id_list($ids)53 {54 $tid = array();55 foreach ( $ids as $id )56 {57 if ( is_numeric($id) )58 {59 $tid[] = (int) $id;60 }61 else62 {63 $range = explode( '-', $id );64 if ( is_numeric($range[0]) and is_numeric($range[1]) )65 {66 $from = min($range[0],$range[1]);67 $to = max($range[0],$range[1]);68 for ($i = $from; $i <= $to; $i++)69 {70 $tid[] = (int) $i;71 }72 }73 }74 }75 $result = array_unique ($tid); // remove duplicates...76 sort ($result);77 return $result;78 }79 80 function check_target($list)81 {82 if ( $list !== '' )83 {84 $type = explode('/',$list); // Find type list85 if ( !in_array($type[0],array('list','cat','tag') ) )86 {87 $type[0] = 'list'; // Assume an id list88 }89 $ids = explode( ',',$type[1] );90 $list = $type[0] . '/';91 92 // 1,2,21,3,22,4,5,9-12,6,11,12,13,2,4,6,93 94 $result = expand_id_list( $ids );95 96 // 1,2,3,4,5,6,9,10,11,12,13,21,22,97 // I would like98 // 1-6,9-13,21-2299 $serial[] = $result[0]; // To be shifted100 foreach ($result as $k => $id)101 {102 $next_less_1 = (isset($result[$k + 1]))? $result[$k + 1] - 1:-1;103 if ( $id == $next_less_1 and end($serial)=='-' )104 { // nothing to do105 }106 elseif ( $id == $next_less_1 )107 {108 $serial[]=$id;109 $serial[]='-';110 }111 else112 {113 $serial[]=$id; // end serie or non serie114 }115 }116 $null = array_shift($serial); // remove first value117 $list .= array_shift($serial); // add the real first one118 $separ = ',';119 foreach ($serial as $id)120 {121 $list .= ($id=='-') ? '' : $separ . $id;122 $separ = ($id=='-') ? '-':','; // add comma except if hyphen123 }124 }125 return $list;126 }127 128 28 // Next evolution... 129 29 // Out of parameter WS management
Note: See TracChangeset
for help on using the changeset viewer.