Changeset 11689

Show
Ignore:
Timestamp:
08/23/07 09:36:59 (1 year ago)
Author:
netblade
Message:

Backporting [11688]: Added config option how to order search results

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/org.openpsa.products/config/config.inc

    r5789 r11689  
    77'schemadb_group' => 'file:/org/openpsa/products/config/schemadb_group_default.inc', 
    88'schemadb_businessarea' => 'file:/org/openpsa/products/config/schemadb_businessarea_default.inc', 
     9 
    910/* Whether to enable adding subcomponents to products */ 
    1011'enable_components' => true, 
    1112'root_group' => 0, 
    1213'root_businessarea' => 0, 
     14 
     15// Search related 
    1316'search_first' => false, 
    1417'search_default_to_all' => true, 
     18// How the search results should be indexed. You can use metadata and linked options, for example metadata.score 
     19'search_index_order' => array('productGroup', 'code'), 
     20 
    1521'group_list_products' => true, 
    1622'products_per_page' => 30, 
  • branches/MidCOM_2_8/org.openpsa.products/config/schemadb_config.inc

    r5115 r11689  
    3030            ), 
    3131        ), 
     32        'search_default_to_all' => array 
     33        ( 
     34            'description' => 'search all items on default', 
     35            'datatype' => 'text', 
     36            'location' => 'config', 
     37            'config_domain' => 'org.openpsa.products', 
     38            'config_key' => 'search_default_to_all', 
     39            'widget' => 'config_radiobox', 
     40            'widget_radiobox_choices' => array 
     41            ( 
     42                '' => 'default setting', 
     43                '1' => 'yes', 
     44                '0' => 'no', 
     45            ), 
     46        ), 
     47        'search_index_order' => array 
     48        ( 
     49            'description' => 'search index order', 
     50            'datatype' => 'text', 
     51            'location' => 'config', 
     52            'config_domain' => 'org.openpsa.products', 
     53            'config_key' => 'search_index_order', 
     54        ),    
    3255        'products_per_page' => array 
    3356        ( 
  • branches/MidCOM_2_8/org.openpsa.products/handler/product/search.php

    r11639 r11689  
    192192        $qb->end_group(); 
    193193 
     194        foreach ($this->_config->get('search_index_order') as $ordering) 
     195        { 
     196            if (preg_match('/\s*reversed?\s*/', $ordering)) 
     197            { 
     198                $reversed = true; 
     199                $ordering = preg_replace('/\s*reversed?\s*/', '', $ordering); 
     200            } 
     201            else 
     202            { 
     203                $reversed = false; 
     204            } 
     205             
     206            if ($ordering === 'metadata.score') 
     207            { 
     208                if (version_compare(mgd_version(), '1.8.2', '<')) 
     209                { 
     210                    $ordering = 'score'; 
     211                    $reversed = false; 
     212                } 
     213            } 
     214             
     215            if (   strpos($ordering, '.') 
     216                && !class_exists('midgard_query_builder')) 
     217            { 
     218                debug_add("Ordering by linked properties requires 1.8 series Midgard", MIDCOM_LOG_WARN); 
     219                continue; 
     220            } 
     221             
     222            if ($reversed) 
     223            { 
     224                $qb->add_order($ordering, 'DESC'); 
     225            } 
     226            else 
     227            { 
     228                $qb->add_order($ordering); 
     229            } 
     230        } 
     231 
    194232        $products = $qb->execute(); 
    195233 
     
    268306            $qb->end_group(); 
    269307        } 
     308 
     309        foreach ($this->_config->get('search_index_order') as $ordering) 
     310        { 
     311            if (preg_match('/\s*reversed?\s*/', $ordering)) 
     312            { 
     313                $reversed = true; 
     314                $ordering = preg_replace('/\s*reversed?\s*/', '', $ordering); 
     315            } 
     316            else 
     317            { 
     318                $reversed = false; 
     319            } 
     320             
     321            if ($ordering === 'metadata.score') 
     322            { 
     323                if (version_compare(mgd_version(), '1.8.2', '<')) 
     324                { 
     325                    $ordering = 'score'; 
     326                    $reversed = false; 
     327                } 
     328            } 
     329             
     330            if (   strpos($ordering, '.') 
     331                && !class_exists('midgard_query_builder')) 
     332            { 
     333                debug_add("Ordering by linked properties requires 1.8 series Midgard", MIDCOM_LOG_WARN); 
     334                continue; 
     335            } 
     336             
     337            if ($reversed) 
     338            { 
     339                $qb->add_order($ordering, 'DESC'); 
     340            } 
     341            else 
     342            { 
     343                $qb->add_order($ordering); 
     344            } 
     345        } 
    270346         
    271347        //mgd_debug_start(); 
     
    400476 
    401477        $filtered_products = array(); 
     478 
     479        foreach ($this->_config->get('search_index_order') as $ordering) 
     480        { 
     481            if (preg_match('/\s*reversed?\s*/', $ordering)) 
     482            { 
     483                $reversed = true; 
     484                $ordering = preg_replace('/\s*reversed?\s*/', '', $ordering); 
     485            } 
     486            else 
     487            { 
     488                $reversed = false; 
     489            } 
     490             
     491            if ($ordering === 'metadata.score') 
     492            { 
     493                if (version_compare(mgd_version(), '1.8.2', '<')) 
     494                { 
     495                    $ordering = 'score'; 
     496                    $reversed = false; 
     497                } 
     498            } 
     499             
     500            if (   strpos($ordering, '.') 
     501                && !class_exists('midgard_query_builder')) 
     502            { 
     503                debug_add("Ordering by linked properties requires 1.8 series Midgard", MIDCOM_LOG_WARN); 
     504                continue; 
     505            } 
     506             
     507            if ($reversed) 
     508            { 
     509                $qb->add_order($ordering, 'DESC'); 
     510            } 
     511            else 
     512            { 
     513                $qb->add_order($ordering); 
     514            } 
     515        } 
    402516 
    403517        $initial_products = $qb->execute(); 
     
    486600        } 
    487601 
     602        foreach ($this->_config->get('search_index_order') as $ordering) 
     603        { 
     604            if (preg_match('/\s*reversed?\s*/', $ordering)) 
     605            { 
     606                $reversed = true; 
     607                $ordering = preg_replace('/\s*reversed?\s*/', '', $ordering); 
     608            } 
     609            else 
     610            { 
     611                $reversed = false; 
     612            } 
     613             
     614            if ($ordering === 'metadata.score') 
     615            { 
     616                if (version_compare(mgd_version(), '1.8.2', '<')) 
     617                { 
     618                    $ordering = 'score'; 
     619                    $reversed = false; 
     620                } 
     621            } 
     622             
     623            if (   strpos($ordering, '.') 
     624                && !class_exists('midgard_query_builder')) 
     625            { 
     626                debug_add("Ordering by linked properties requires 1.8 series Midgard", MIDCOM_LOG_WARN); 
     627                continue; 
     628            } 
     629             
     630            if ($reversed) 
     631            { 
     632                $qb->add_order($ordering, 'DESC'); 
     633            } 
     634            else 
     635            { 
     636                $qb->add_order($ordering); 
     637            } 
     638        } 
     639 
    488640        $initial_products = $qb->execute(); 
    489641 
  • branches/MidCOM_2_8/org.openpsa.products/locale/default.en.txt

    r5551 r11689  
    2020---STRINGEND 
    2121 
     22---STRING business area schema database 
     23Business area schema database 
     24---STRINGEND 
     25 
    2226---STRING code 
    2327Code 
     
    4852---STRINGEND 
    4953 
     54---STRING fields available for matching are defined in schema 
     55Fields available for matching are defined in schema 
     56---STRINGEND 
     57 
     58---STRING file to import 
     59File to import 
     60---STRINGEND 
     61 
     62---STRING first row is headers 
     63First row is headers 
     64---STRINGEND 
     65 
    5066---STRING groups 
    5167Product groups 
     
    5672---STRINGEND 
    5773 
     74---STRING import 
     75Import 
     76---STRINGEND 
     77 
     78---STRING iso-latin-1 encoding 
     79ISO-Latin-1 encoding 
     80---STRINGEND 
     81 
     82---STRING list group products 
     83List group products 
     84---STRINGEND 
     85 
    5886---STRING material goods 
    5987Material goods 
     
    6492---STRINGEND 
    6593 
     94---STRING number of items in feed 
     95Number of items in feed 
     96---STRINGEND 
     97 
    6698---STRING org.openpsa.products 
    6799Product database 
     
    116148---STRINGEND 
    117149 
     150---STRING search all items on default 
     151Search all items on default 
     152---STRINGEND 
     153 
    118154---STRING service 
    119155Service 
     
    148184---STRINGEND 
    149185 
     186---STRING updated %s 
     187updated %s 
     188---STRINGEND 
     189 
    150190---STRING updated products 
    151191Updated products 
    152192---STRINGEND 
    153193 
     194---STRING whether to enable adding subcomponents to products 
     195Whether to enable adding subcomponents to products 
     196---STRINGEND 
     197 
    154198---STRING year 
    155199year 
    156200---STRINGEND 
    157201 
    158 ---STRING updated %s 
    159 updated %s 
    160 ---STRINGEND 
    161  
     202---STRING you can import csv files here 
     203You can import csv files here 
     204---STRINGEND 
     205 
     206---STRING search index order 
     207Search index order 
     208---STRINGEND 
  • branches/MidCOM_2_8/org.openpsa.products/locale/default.fi.txt

    r5551 r11689  
    148148---STRINGEND 
    149149 
     150---STRING updated %s 
     151pÀivitetty %s 
     152---STRINGEND 
     153 
    150154---STRING updated products 
    151155PÀivitetyt tuotteet 
     
    156160---STRINGEND 
    157161 
    158 ---STRING updated %s 
    159 pÀivitetty %s 
    160 ---STRINGEND 
    161  
     162---STRING business area schema database 
     163Bisnesalueen tietokantakuvaus 
     164---STRINGEND 
     165 
     166---STRING fields available for matching are defined in schema 
     167KÀytettÀvissÀ olevat kentÀt on mÀÀritelty tietokantakuvauksessa 
     168---STRINGEND 
     169 
     170---STRING file to import 
     171Tuotava tiedosto 
     172---STRINGEND 
     173 
     174---STRING first row is headers 
     175EnsimmÀinen rivi on otsikkotiedoille 
     176---STRINGEND 
     177 
     178---STRING import 
     179Tuo 
     180---STRINGEND 
     181 
     182---STRING iso-latin-1 encoding 
     183ISO-Latin1 -merkistö 
     184---STRINGEND 
     185 
     186---STRING list group products 
     187Listaa tuoteryhmÀt 
     188---STRINGEND 
     189 
     190---STRING number of items in feed 
     191Syötteen kohteiden lukumÀÀrÀ 
     192---STRINGEND 
     193 
     194---STRING search all items on default 
     195Etsi kaikista kohteista oletuksena 
     196---STRINGEND 
     197 
     198---STRING whether to enable adding subcomponents to products 
     199Sallitaanko komponenttien lisÀÀminen tuotteisiin 
     200---STRINGEND 
     201 
     202---STRING you can import csv files here 
     203Voit tuoda CSV-tiedostot tÀÀltÀ 
     204---STRINGEND 
     205 
     206---STRING search index order 
     207Haun tulosten jÀrjestely 
     208---STRINGEND