Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cApiAction
  • cApiActionCollection
  • cApiActionlog
  • cApiActionlogCollection
  • cApiArea
  • cApiAreaCollection
  • cApiArticle
  • cApiArticleCollection
  • cApiArticleLanguage
  • cApiArticleLanguageCollection
  • cApiArticleLanguageVersion
  • cApiArticleLanguageVersionCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiContentVersion
  • cApiContentVersionCollection
  • cApiDbfs
  • cApiDbfsCollection
  • cApiFile
  • cApiFileCollection
  • cApiFileInformation
  • cApiFileInformationCollection
  • cApiFrameFile
  • cApiFrameFileCollection
  • cApiFrontendGroup
  • cApiFrontendGroupCollection
  • cApiFrontendGroupMember
  • cApiFrontendGroupMemberCollection
  • cApiFrontendPermission
  • cApiFrontendPermissionCollection
  • cApiFrontendUser
  • cApiFrontendUserCollection
  • cApiGroup
  • cApiGroupCollection
  • cApiGroupMember
  • cApiGroupMemberCollection
  • cApiGroupProperty
  • cApiGroupPropertyCollection
  • cApiInUse
  • cApiInUseCollection
  • cApiIso3166
  • cApiIso3166Collection
  • cApiIso6392
  • cApiIso6392Collection
  • cApiKeyword
  • cApiKeywordCollection
  • cApiLanguage
  • cApiLanguageCollection
  • cApiLayout
  • cApiLayoutCollection
  • cApiMailLog
  • cApiMailLogCollection
  • cApiMailLogSuccess
  • cApiMailLogSuccessCollection
  • cApiMetaTag
  • cApiMetaTagCollection
  • cApiMetaTagVersion
  • cApiMetaTagVersionCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserPasswordRequest
  • cApiUserPasswordRequestCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the collections and items for search tracking
  5:  *
  6:  * @package Core
  7:  * @subpackage GenericDB_Model
  8:  * @author Mischa Holz
  9:  * @copyright four for business AG <www.4fb.de>
 10:  * @license http://www.contenido.org/license/LIZENZ.txt
 11:  * @link http://www.4fb.de
 12:  * @link http://www.contenido.org
 13:  */
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Tracking collection
 18:  *
 19:  * @package Core
 20:  * @subpackage GenericDB_Model
 21:  */
 22: class cApiSearchTrackingCollection extends ItemCollection {
 23:     /**
 24:      * Constructor to create an instance of this class.
 25:      *
 26:      * @throws cInvalidArgumentException
 27:      */
 28:     public function __construct() {
 29:         global $cfg;
 30:         parent::__construct($cfg['tab']['search_tracking'], 'idsearchtracking');
 31: 
 32:         $this->_setItemClass('cApiSearchTracking');
 33:     }
 34: 
 35:     /**
 36:      * Create a new tracking row
 37:      *
 38:      * @param string $searchTerm
 39:      *                          Term the user searched for
 40:      * @param int    $searchResults
 41:      *                          Number of results
 42:      * @param string $timestamp [optional]
 43:      *                          Timestamp of the search
 44:      * @param int    $idclient  [optional]
 45:      *                          Client
 46:      * @param int    $idlang    [optional]
 47:      *                          Language
 48:      *
 49:      * @return bool
 50:      * @throws cDbException
 51:      * @throws cException
 52:      * @throws cInvalidArgumentException
 53:      */
 54:     public function create($searchTerm, $searchResults, $timestamp = "", $idclient = 0, $idlang = 0) {
 55:         $item = $this->createNewItem();
 56:         $item->set("searchterm", $searchTerm);
 57:         $item->set("results", $searchResults);
 58:         $item->set("datesearched", ($timestamp == "") ? date('Y-m-d H:i:s') : $timestamp);
 59:         $item->set("idclient", ($idclient == 0) ? cRegistry::getClientId() : $idclient);
 60:         $item->set("idlang", ($idlang == 0) ? cRegistry::getLanguageId() : $idlang);
 61: 
 62:         return $item->store();
 63:     }
 64: 
 65:     /**
 66:      * Track a search if the setting allows it.
 67:      *
 68:      * @param string $searchTerm
 69:      *         Term the user searched for
 70:      * @param int    $resultCount
 71:      *         Number of results
 72:      *
 73:      * @return bool
 74:      * @throws cDbException
 75:      * @throws cException
 76:      * @throws cInvalidArgumentException
 77:      */
 78:     public function trackSearch($searchTerm, $resultCount) {
 79:         if (getEffectiveSetting("search", "term_tracking", "on") != "on") {
 80:             return false;
 81:         }
 82: 
 83:         return $this->create($searchTerm, $resultCount);
 84:     }
 85: 
 86:     /**
 87:      * Select all search terms of this client and language and sort them by
 88:      * popularity
 89:      *
 90:      * @param int $idclient [optional]
 91:      *                      Use this client instead of the current one
 92:      * @param int $idlang   [optional]
 93:      *                      Use this language instead of the current one
 94:      * @return bool
 95:      * @throws cDbException
 96:      */
 97:     public function selectPopularSearchTerms($idclient = 0, $idlang = 0) {
 98:         return $this->select('idclient=' . (($idclient == 0) ? cRegistry::getClientId() : $idclient) . ' AND idlang=' . (($idlang == 0) ? cRegistry::getLanguageId() : $idlang), 'searchterm, idsearchtracking, idclient, idlang, results, datesearched', 'COUNT(searchterm) DESC');
 99:     }
100: 
101:     /**
102:      * Select all entries about one search term for this client and language
103:      * sorted by the date
104:      *
105:      * @param string $term
106:      *                         Term the user searched for
107:      * @param int    $idclient [optional]
108:      *                         Use this client instead of the current one
109:      * @param int    $idlang   [optional]
110:      *                         Use this language instead of the current one
111:      * @return bool
112:      * @throws cDbException
113:      */
114:     public function selectSearchTerm($term, $idclient = 0, $idlang = 0) {
115:         return $this->select('searchterm=\'' . addslashes($term) . '\' AND idclient=' . (($idclient == 0) ? cRegistry::getClientId() : $idclient) . ' AND idlang=' . (($idlang == 0) ? cRegistry::getLanguageId() : $idlang), '', 'datesearched DESC');
116:     }
117: 
118: }
119: 
120: /**
121:  * SearchTracking item
122:  *
123:  * @package Core
124:  * @subpackage GenericDB_Model
125:  */
126: class cApiSearchTracking extends Item
127: {
128:     /**
129:      * Constructor to create an instance of this class.
130:      *
131:      * @param bool $mId [optional]
132:      *                  Item Id
133:      *                  
134:      * @throws cDbException
135:      * @throws cException
136:      */
137:     public function __construct($mId = false) {
138:         global $cfg;
139: 
140:         parent::__construct($cfg['tab']['search_tracking'], 'idsearchtracking');
141:         $this->setFilters(array(
142:             'addslashes'
143:         ), array(
144:             'stripslashes'
145:         ));
146: 
147:         if ($mId !== false) {
148:             $this->loadByPrimaryKey($mId);
149:         }
150:     }
151: 
152: }
153: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0