Changeset 1711 in ExiteCMS


Ignore:
Timestamp:
08/28/08 17:37:47 (3 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

Location:
trunk
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/modules.php

    r1626 r1711  
    211211                    $mod_search['title'] = isset($mod_search['title']) ? $mod_search['title'] : ("Search: ".$mod_search['name']); 
    212212                    $mod_search['version'] = isset($mod_search['version']) ? $mod_search['version'] : $mod_version; 
     213                    // get the max searchorder 
     214                    $result = dbquery("SELECT max(search_order) as max FROM ".$db_prefix."search"); 
     215                    if ($result) { 
     216                        $data = dbarray($result); 
     217                        $max = $data['max'] + 1; 
     218                    } else { 
     219                        $max = 1; 
     220                    } 
    213221                    // add it to the search table 
    214                     $result = dbquery("INSERT INTO ".$db_prefix."search (search_mod_id, search_name, search_title, search_version, search_fulltext, search_visibility)  
    215                         VALUES ('".$id."', '".$mod_search['name']."', '".$mod_search['title']."', '".$mod_search['version']."',  '".$mod_search['fulltext']."', '".$mod_search['visibility']."')"); 
     222                    $result = dbquery("INSERT INTO ".$db_prefix."search (search_mod_id, search_name, search_title, search_version, search_fulltext, search_visibility, search_order)  
     223                        VALUES ('".$id."', '".$mod_search['name']."', '".$mod_search['title']."', '".$mod_search['version']."',  '".$mod_search['fulltext']."', '".$mod_search['visibility']."', ".$max.")"); 
    216224                } 
    217225            } 
     
    543551                    $mod_search['title'] = isset($mod_search['title']) ? $mod_search['title'] : ("Search: ".$mod_search['name']); 
    544552                    $mod_search['version'] = isset($mod_search['version']) ? $mod_search['version'] : $mod_version; 
     553                    // get the max searchorder 
     554                    $result = dbquery("SELECT max(search_order) as max FROM ".$db_prefix."search"); 
     555                    if ($result) { 
     556                        $data = dbarray($result); 
     557                        $max = $data['max'] + 1; 
     558                    } else { 
     559                        $max = 1; 
     560                    } 
    545561                    // add it to the search table 
    546                     $result = dbquery("INSERT INTO ".$db_prefix."search (search_mod_id, search_name, search_title, search_version, search_fulltext, search_visibility)  
    547                         VALUES ('".$id."', '".$mod_search['name']."', '".$mod_search['title']."', '".$mod_search['version']."',  '".$mod_search['fulltext']."', '".$mod_search['visibility']."')"); 
     562                    $result = dbquery("INSERT INTO ".$db_prefix."search (search_mod_id, search_name, search_title, search_version, search_fulltext, search_visibility, search_order)  
     563                        VALUES ('".$id."', '".$mod_search['name']."', '".$mod_search['title']."', '".$mod_search['version']."',  '".$mod_search['fulltext']."', '".$mod_search['visibility']."', ".$max.")"); 
    548564                } 
    549565            } 
  • 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 
  • trunk/administration/tools/language_pack_English.php

    r1710 r1711  
    953953        $localestrings['423'] = "Search accessable for:"; 
    954954        $localestrings['424'] = "Save"; 
     955        $localestrings['425'] = "Move up in priority"; 
     956        $localestrings['426'] = "Move down in priority"; 
     957        $localestrings['427'] = "Up"; 
     958        $localestrings['428'] = "Down"; 
     959        $localestrings['429'] = "Order"; 
     960        $localestrings['430'] = "The order in which the searches are listed here determines the default search location"; 
    955961        load_localestrings($localestrings, LP_LOCALE, "admin.search", $step); 
    956962 
  • trunk/administration/tools/language_pack_Nederlands.php

    r1710 r1711  
    938938        $localestrings['423'] = "Zoekopdracht toegankelijk voor:"; 
    939939        $localestrings['424'] = "Opslaan"; 
     940        $localestrings['425'] = "Prioriteit verhogen"; 
     941        $localestrings['426'] = "Prioriteit verlagen"; 
     942        $localestrings['427'] = "Omhoog"; 
     943        $localestrings['428'] = "Omlaag"; 
     944        $localestrings['429'] = "Volgorde"; 
     945        $localestrings['430'] = "De volgorde waarin de zoeklocaties zijn opgelijst bepaald de standaard geselecteerde zoek locatie"; 
    940946        load_localestrings($localestrings, LP_LOCALE, "admin.search", $step); 
    941947 
  • trunk/files/locales/en.main.global.php

    r1710 r1711  
    33// locale       : English 
    44// locale name  : main.global 
    5 // generated on : Thu Aug 28 2008, 15:12:34 CEST 
     5// generated on : Thu Aug 28 2008, 17:02:30 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
  • trunk/includes/search/search.articles.php

    r1667 r1711  
    2020    if ($action == "") { 
    2121         
     22        // add the possible  search filters ($data is defined in the calling script!) 
     23        $data['search_filters'] = "date,users"; 
     24 
    2225        // get the list of all members 
    2326        if (!isset($content_filters['users'])) { 
  • trunk/includes/search/search.downloads.php

    r1667 r1711  
    2020    if ($action == "") { 
    2121         
    22             // no pre-processing required for this search 
     22        // add the possible  search filters ($data is defined in the calling script!) 
     23        $data['search_filters' ] = "date"; 
    2324 
    2425    } else { 
  • trunk/includes/search/search.forumattachments.php

    r1667 r1711  
    2020    if ($action == "") { 
    2121     
     22        // add the possible  search filters ($data is defined in the calling script!) 
     23        $data['search_filters' ] = "date,users,forums"; 
     24 
    2225        // get the list of all members 
    2326        if (!isset($content_filters['forums'])) { 
  • trunk/includes/search/search.forumposts.php

    r1667 r1711  
    1919 
    2020    if ($action == "") { 
    21          
     21 
     22        // add the possible  search filters ($data is defined in the calling script!) 
     23        $data['search_filters' ] = "date,users,forums"; 
     24 
    2225        // get the list of all members 
    2326        if (!isset($content_filters['forums'])) { 
  • trunk/includes/search/search.members.php

    r1667 r1711  
    2020    if ($action == "") { 
    2121         
    22             // no pre-processing required for this search 
     22        // add the possible  search filters ($data is defined in the calling script!) 
     23        $data['search_filters' ] = ""; 
     24 
    2325 
    2426    } else { 
  • trunk/includes/search/search.news.php

    r1667 r1711  
    2020    if ($action == "") { 
    2121     
     22        // add the possible  search filters ($data is defined in the calling script!) 
     23        $data['search_filters' ] = "date,users"; 
     24 
    2225        // get the list of all members 
    2326        if (!isset($content_filters['users'])) { 
  • trunk/includes/search/templates/search.articles.tpl

    r1620 r1711  
    3131    {/section} 
    3232{else} 
    33     <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id}checked='checked'{/if} onclick='javascript:show_filter("date,users");' /> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
     33    <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if}  onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
    3434{/if} 
    3535{***************************************************************************} 
  • trunk/includes/search/templates/search.downloads.tpl

    r1620 r1711  
    3333    {/section} 
    3434{else} 
    35     <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id}checked='checked'{/if} onclick='javascript:show_filter("date");' /> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
     35    <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if}  onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
    3636{/if} 
    3737{***************************************************************************} 
  • trunk/includes/search/templates/search.forumattachments.tpl

    r1620 r1711  
    3232    {/section} 
    3333{else} 
    34     <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id}checked='checked'{/if} onclick='javascript:show_filter("date,users,forums");' /> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
     34    <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if}  onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
    3535{/if} 
    3636{***************************************************************************} 
  • trunk/includes/search/templates/search.forumposts.tpl

    r1620 r1711  
    3131    {/section} 
    3232{else} 
    33     <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id}checked='checked'{/if}  onclick='javascript:show_filter("date,users,forums");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
     33    <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if}  onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
    3434{/if} 
    3535{***************************************************************************} 
  • trunk/includes/search/templates/search.members.tpl

    r1620 r1711  
    3131    {/section} 
    3232{else} 
    33     <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id}checked='checked'{/if} onclick='javascript:show_filter("");' /> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
     33    <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if}  onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
    3434{/if} 
    3535{***************************************************************************} 
  • trunk/includes/search/templates/search.news.tpl

    r1620 r1711  
    3131    {/section} 
    3232{else} 
    33     <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id}checked='checked'{/if} onclick='javascript:show_filter("date,users");' /> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
     33    <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if}  onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> 
    3434{/if} 
    3535{***************************************************************************} 
  • trunk/includes/templates/admin.search.tpl

    r1620 r1711  
    8686                <b>{$locale.402}</b> 
    8787            </td> 
     88            <td colspan='2' align='center' width='1%' class='tbl2' style='white-space:nowrap'> 
     89                <b>{$locale.429}</b> 
     90            </td> 
    8891            <td align='center' width='1%' class='tbl2' style='white-space:nowrap'> 
    8992                <b>{$locale.403}</b> 
     
    100103            <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 
    101104                {$searches[id].groupname} 
     105            </td> 
     106            <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 
     107                {$searches[id].search_order} 
     108            </td> 
     109            <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 
     110            {if $searches[id].order_up != 0} 
     111                {imagelink link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&amp;action=swap&amp;order1="|cat:$searches[id].search_order|cat:"&amp;order2="|cat:$searches[id].order_up image="up.gif" alt="$locale.425 title=$locale.427} 
     112            {/if} 
     113            {if $searches[id].order_down != 0} 
     114                {imagelink link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&amp;action=swap&amp;order1="|cat:$searches[id].search_order|cat:"&amp;order2="|cat:$searches[id].order_down image="down.gif" alt="$locale.426 title=$locale.428} 
     115            {/if} 
    102116            </td> 
    103117            <td align='left' width='1%' class='tbl1' style='white-space:nowrap'> 
     
    117131        {sectionelse} 
    118132        <tr> 
    119             <td align='center' colspan='3' class='tbl1'> 
     133            <td align='center' colspan='5' class='tbl1'> 
    120134                {$locale.408} 
    121135                <br /><br /> 
     
    124138        {/section} 
    125139        <tr> 
    126             <td align='center' colspan='3' class='tbl1'> 
     140            <td align='center' colspan='5' class='tbl1'> 
     141                <span class='smallalt'>{$locale.430}</span> 
     142            </td> 
     143        </tr> 
     144{*      <tr> 
     145            <td align='center' colspan='5' class='tbl1'> 
    127146                {buttonlink name=$locale.409 link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&amp;action=add"} 
    128147            </td> 
    129148        </tr> 
    130     </table> 
     149*}  </table> 
    131150{/if} 
    132151{include file="_closetable.tpl"} 
  • trunk/includes/templates/main.search.tpl

    r1626 r1711  
    151151        } 
    152152    } 
     153    {/literal} 
     154    show_filter("{$default_filter}"); 
    153155    </script> 
    154     {/literal} 
    155156    {include file="_closetable.tpl"} 
    156157        {include file="_opentable.tpl" name=$_name title=$locale.src428 state=$_state style=$_style} 
  • trunk/search.php

    r1626 r1711  
    103103} 
    104104 
    105 // do we have a search location? if not, get the first search item 
    106 if (!$search_id && count($variables['searches'])) { 
    107 //  $search_id = $variables['searches'][0]['search_id']; 
     105// find the id of the default selection 
     106if ($action == "") { 
     107    $variables['default_location'] = 9999999999; 
     108    $variables['default_filter'] = ""; 
     109    foreach($variables['searches'] as $key => $search) { 
     110        if ($search['search_order'] < $variables['default_location']) { 
     111            $variables['default_location'] = $search['search_order']; 
     112            $variables['default_filter'] = $search['search_filters']; 
     113            if (!isset($search['search_filters'])) _debug($search, true); 
     114        } 
     115    } 
    108116} 
     117 
    109118// store the selected search location 
    110119$variables['search_id'] = $search_id; 
Note: See TracChangeset for help on using the changeset viewer.