[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/classes/ -> ezsearchlog.php (source)

   1  <?php
   2  //
   3  // Definition of eZSearchLog class
   4  //
   5  // Created on: <08-Aug-2002 10:27:21 bf>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*!
  30    \class eZSearchLog ezsearchlog.php
  31    \brief eZSearchLog handles logging of search phrases
  32  
  33  */
  34  
  35  include_once ( 'lib/ezdb/classes/ezdb.php' );
  36  
  37  class eZSearchLog
  38  {
  39      /*!
  40      */
  41      function eZSearchLog()
  42      {
  43  
  44      }
  45  
  46      /*!
  47       Logs a search query so that we can retreive statistics afterwords.
  48      */
  49      function addPhrase( $phrase, $returnCount )
  50      {
  51          $db =& eZDB::instance();
  52          $db->begin();
  53  
  54          $phrase = strtolower( trim( $phrase ) );
  55          $phrase = $db->escapeString( $phrase );
  56  
  57          // find or store the phrase
  58          $phraseRes = $db->arrayQuery( "SELECT id FROM ezsearch_search_phrase WHERE phrase='$phrase'" );
  59  
  60          if ( count( $phraseRes ) == 1 )
  61          {
  62              $phraseID = $phraseRes[0]['id'];
  63              $db->query( "UPDATE ezsearch_search_phrase
  64                           SET    phrase_count = phrase_count + 1,
  65                                  result_count = result_count + $returnCount
  66                           WHERE  id = $phraseID" );
  67          }
  68          else
  69          {
  70              $db->query( "INSERT INTO
  71                                ezsearch_search_phrase ( phrase, phrase_count, result_count )
  72                           VALUES ( '$phrase', 1, $returnCount )" );
  73  
  74              /* when breaking BC: delete next line */
  75              $phraseID = $db->lastSerialID( 'ezsearch_search_phrase', 'id' );
  76          }
  77  
  78          /* when breaking BC: delete next lines */
  79          /* ezsearch_return_count is not used any more by eZ publish
  80             but perhaps someone else added some functionality... */
  81          $time = mktime();
  82          // store the search result
  83          $db->query( "INSERT INTO
  84                             ezsearch_return_count ( phrase_id, count, time )
  85                       VALUES ( '$phraseID', '$returnCount', '$time' )" );
  86          /* end of BC breaking delete*/
  87  
  88          $db->commit();
  89      }
  90  
  91      /*!
  92       Returns the most frequent search phrases, which did not get hits.
  93      */
  94      function &mostFrequentPhraseArray( $parameters = array( ) )
  95      {
  96          $db =& eZDB::instance();
  97  
  98          $query = 'SELECT phrase_count, result_count / phrase_count AS result_count, id, phrase
  99                    FROM   ezsearch_search_phrase
 100                    ORDER BY phrase_count DESC';
 101  
 102          $phraseArray = $db->arrayQuery( $query, $parameters );
 103  
 104          return $phraseArray;
 105      }
 106  
 107      /*!
 108       \static
 109       Removes all stored phrases and search match counts from the database.
 110      */
 111      function removeStatistics()
 112      {
 113          $db =& eZDB::instance();
 114          $query = "DELETE FROM ezsearch_search_phrase";
 115          $db->query( $query );
 116          /* when breaking BC: delete those two lines */
 117          $query = "DELETE FROM ezsearch_return_count";
 118          $db->query( $query );
 119      }
 120  }
 121  
 122  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7