function get_search_request($args)
 {
     global $Sql, $Cache;
     $Cache->load('media');
     $weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1;
     require_once PATH_TO_ROOT . '/media/media_cats.class.php';
     $Cats = new MediaCats();
     $auth_cats = array();
     $Cats->build_children_id_list(0, $auth_cats);
     $auth_cats = !empty($auth_cats) ? " AND f.idcat IN (" . implode($auth_cats, ',') . ") " : '';
     $request = "SELECT " . $args['id_search'] . " AS id_search,\n            f.id AS id_content,\n            f.name AS title,\n            ( 2 * MATCH(f.name) AGAINST('" . $args['search'] . "') + MATCH(f.contents) AGAINST('" . $args['search'] . "') ) / 3 * " . $weight . " AS relevance, " . $Sql->concat("'../media/media.php?id='", "f.id", "'&cat='", "f.idcat") . " AS link\n            FROM " . PREFIX . "media f\n            WHERE ( MATCH(f.name) AGAINST('" . $args['search'] . "') OR MATCH(f.contents) AGAINST('" . $args['search'] . "') )" . $auth_cats . " ORDER BY relevance DESC " . $Sql->limit(0, MEDIA_MAX_SEARCH_RESULTS);
     return $request;
 }
예제 #2
0
 $array_cats = $js_array = array();
 if (!empty($_POST['filter'])) {
     $state = retrieve(POST, 'state', 'all', TSTRING);
     $cat = retrieve(POST, 'idcat', 0, TINTEGER);
     $sub_cats = retrieve(POST, 'sub_cats', false, TBOOL);
     if ($state == "visible") {
         $db_where = MEDIA_STATUS_APROBED;
     } elseif ($state == 'unvisible') {
         $db_where = MEDIA_STATUS_UNVISIBLE;
     } elseif ($state == 'unaprobed') {
         $db_where = MEDIA_STATUS_UNAPROBED;
     } else {
         $db_where = null;
     }
     if ($sub_cats) {
         $media_categories->build_children_id_list($cat, $array_cats, RECURSIVE_EXPLORATION, ADD_THIS_CATEGORY_IN_LIST, MEDIA_AUTH_READ);
     }
 } else {
     $cat = 0;
     $db_where = $sub_cats = null;
     $media_categories->build_children_id_list(0, $array_cats, RECURSIVE_EXPLORATION, ADD_THIS_CATEGORY_IN_LIST, MEDIA_AUTH_READ);
 }
 import('util/pagination');
 $Pagination = new Pagination();
 $nbr_media = 0;
 $result = $Sql->query_while("SELECT * FROM " . PREFIX . "media WHERE " . (!empty($array_cats) ? 'idcat IN (' . "'" . implode("', '", $array_cats) . "'" . ')' : 'idcat=' . (!empty($cat) ? $cat : 0)) . (is_null($db_where) ? '' : ' AND infos=' . $db_where) . " ORDER BY infos ASC, timestamp DESC" . $Sql->limit($Pagination->get_first_msg(NUM_MODO_MEDIA, 'p'), NUM_MODO_MEDIA), __LINE__, __FILE__);
 while ($row = $Sql->fetch_assoc($result)) {
     $nbr_media++;
     $js_array[] = $row['id'];
     $Template->assign_block_vars('files', array('ID' => $row['id'], 'NAME' => $row['name'], 'U_FILE' => url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $row['idcat'] . '+' . url_encode_rewrite($row['name']) . '.php'), 'U_EDIT' => url('media_action.php?edit=' . $row['id']), 'CAT' => !empty($MEDIA_CATS[$row['idcat']]) ? $MEDIA_CATS[$row['idcat']]['name'] : $LANG['unknow'], 'U_CAT' => url('media.php?cat=' . $row['idcat']), 'COLOR' => $row['infos'] == MEDIA_STATUS_UNVISIBLE ? '#FFEE99' : ($row['infos'] == MEDIA_STATUS_APROBED ? '#CCFFCC' : '#FFCCCC'), 'SHOW' => $row['infos'] == MEDIA_STATUS_APROBED ? ' checked="checked"' : '', 'HIDE' => $row['infos'] == MEDIA_STATUS_UNVISIBLE ? ' checked="checked"' : '', 'UNAPROBED' => $row['infos'] == MEDIA_STATUS_UNAPROBED ? ' checked="checked"' : ''));
 }