Changeset 1711 in ExiteCMS for trunk/administration/search.php


Ignore:
Timestamp:
08/28/08 17:37:47 (4 years ago)
Author:
hverton
Message:

updated the search module to determine the default search location based on the priority order in the search admin module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/search.php

    r1626 r1711  
    9898    $variables['usergroups'] = getusergroups(false); 
    9999} 
     100 
    100101// toggle the search status 
    101102if ($action == "setstatus") { 
     
    108109} 
    109110 
     111// swap the order of two records 
     112if ($action == "swap") { 
     113    // check the parameters passed 
     114    $order1 = (isset($_GET['order1']) && isNum($_GET['order1'])) ? $_GET['order1'] : 0; 
     115    $order2 = (isset($_GET['order2']) && isNum($_GET['order2'])) ? $_GET['order2'] : 0; 
     116    if ($order1 != 0 && $order2 != 0 && $order1 != $order2) { 
     117        $result1 = dbquery("SELECT search_id FROM ".$db_prefix."search WHERE search_order = '".$order1."'"); 
     118        $result2 = dbquery("SELECT search_id FROM ".$db_prefix."search WHERE search_order = '".$order2."'"); 
     119        if ($result1 && $result2) { 
     120            // everything checks out, swap 'm! 
     121            $data = dbarray($result1); 
     122            $result = dbquery("UPDATE ".$db_prefix."search SET search_order = ".$order2." WHERE search_id = ".$data['search_id']); 
     123            $data = dbarray($result2); 
     124            $result = dbquery("UPDATE ".$db_prefix."search SET search_order = ".$order1." WHERE search_id = ".$data['search_id']); 
     125        } 
     126    } 
     127    // return to the overview screen 
     128    $action = ""; 
     129} 
     130 
    110131// no action specified: show the search overview 
    111132if ($action == "") { 
    112133    // generate the searches overview 
    113     $searches = array(); 
    114     $searchindex = array(); 
    115     $result = dbquery("SELECT s.*, m.mod_folder FROM ".$db_prefix."search s LEFT JOIN ".$db_prefix."modules m ON s.search_mod_id = m.mod_id"); 
     134    $variables['searches'] = array(); 
     135    $result = dbquery("SELECT s.*, m.mod_folder FROM ".$db_prefix."search s LEFT JOIN ".$db_prefix."modules m ON s.search_mod_id = m.mod_id ORDER BY search_order"); 
    116136    while ($data = dbarray($result)) { 
    117137        // get the title for this search 
     
    132152        $data['groupname'] = getgroupname($data['search_visibility']); 
    133153            // store the search record 
    134         $searches[$data['search_id']] = $data; 
    135         $searchindex[] = $data['search_title']."_>_".$data['search_id']; 
    136     } 
    137     //make sure the modules are properly sorted 
    138     sort($searchindex); 
    139     $variables['search'] = array(); 
    140     foreach($searchindex as $index) { 
    141         $variables['searches'][] = $searches[substr(strstr($index,"_>_"),3)]; 
     154        $variables['searches'][] = $data; 
    142155    } 
    143156    // reload the locale for this module 
    144157    locale_load("admin.search"); 
     158} 
     159 
     160// add the previous and next id's 
     161foreach($variables['searches'] as $key => $value) { 
     162    $variables['searches'][$key]['order_down'] = isset($variables['searches'][$key+1]) ? $variables['searches'][$key+1]['search_order'] : 0; 
     163    $variables['searches'][$key]['order_up'] = isset($variables['searches'][$key-1]) ? $variables['searches'][$key-1]['search_order'] : 0; 
    145164} 
    146165 
Note: See TracChangeset for help on using the changeset viewer.