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 path resolve cache collection and item class and its helper.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       GenericDB_Model
  8:  * @author           Murat Purc <murat@purc.de>
  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: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Pathresolve cache static helper class
 19:  *
 20:  * @package Core
 21:  * @subpackage Util
 22:  */
 23: class cApiPathresolveCacheHelper {
 24: 
 25:     /**
 26:      * Flag to state state about created heap table.
 27:      *
 28:      * @var bool
 29:      */
 30:     protected static $_tableCreated = false;
 31: 
 32:     /**
 33:      * Checks configuration of heap table creation, it's existance and creates
 34:      * it if needed.
 35:      *
 36:      * @param array $cfg
 37:      *         Global CONTENIDO config array
 38:      *
 39:      * @throws cDbException
 40:      */
 41:     public static function setup($cfg) {
 42:         if (isset($cfg['pathresolve_heapcache']) && true === $cfg['pathresolve_heapcache'] && false === self::$_tableCreated) {
 43:             $db = cRegistry::getDb();
 44:             $tableName = $cfg['sql']['sqlprefix'] . '_pathresolve_cache';
 45: 
 46:             $sql = "SHOW TABLES LIKE '" . $db->escape($tableName) . "'";
 47:             $db->query($sql);
 48: 
 49:             if (!$db->nextRecord()) {
 50:                 // Important: This is really a hack! Don't use
 51:                 // pathresolve_heapcache if you are
 52:                 // not sure what it does.
 53:                 // @TODO: pls insert to this create table statetment MAX_ROWS.
 54:                 $sql = 'CREATE TABLE `' . $db->escape($tableName) . '` (
 55:                            `idpathresolvecache` INT(10) NOT NULL AUTO_INCREMENT,
 56:                            `path` VARCHAR(255) NOT NULL,
 57:                            `idcat` INT(10) NOT NULL,
 58:                            `idlang` INT(10) NOT NULL,
 59:                            `lastcached` INT(10) NOT NULL,
 60:                             PRIMARY KEY (`idpathresolvecache`)
 61:                         ) ENGINE = HEAP;';
 62:                 $db->query($sql);
 63:             }
 64:             self::$_tableCreated = true;
 65:         }
 66:     }
 67: 
 68: }
 69: 
 70: /**
 71:  * Pathresolve cache collection
 72:  *
 73:  * @package Core
 74:  * @subpackage GenericDB_Model
 75:  */
 76: class cApiPathresolveCacheCollection extends ItemCollection {
 77:     /**
 78:      * Constructor to create an instance of this class.
 79:      *
 80:      * @throws cDbException
 81:      * @throws cInvalidArgumentException
 82:      */
 83:     public function __construct() {
 84:         global $cfg;
 85:         cApiPathresolveCacheHelper::setup($cfg);
 86:         parent::__construct($cfg['sql']['sqlprefix'] . '_pathresolve_cache', 'idpathresolvecache');
 87:         $this->_setItemClass('cApiPathresolveCache');
 88:     }
 89: 
 90:     /**
 91:      * Creates a pathresolve cache entry.
 92:      *
 93:      * @param string $path
 94:      * @param int    $idcat
 95:      * @param int    $idlang
 96:      * @param string $lastcached [optional]
 97:      * @return cApiPathresolveCache
 98:      * @throws cDbException
 99:      * @throws cException
100:      * @throws cInvalidArgumentException
101:      */
102:     public function create($path, $idcat, $idlang, $lastcached = '') {
103:         $oItem = $this->createNewItem();
104: 
105:         if (empty($lastcached)) {
106:             $lastcached = time();
107:         }
108: 
109:         $oItem->set('path', $path, false);
110:         $oItem->set('idcat', $idcat, false);
111:         $oItem->set('idlang', $idlang, false);
112:         $oItem->set('lastcached', $lastcached, false);
113:         $oItem->store();
114: 
115:         return $oItem;
116:     }
117: 
118:     /**
119:      * Returns a last cached entry by path and language.
120:      *
121:      * @param string $path
122:      * @param int    $idlang
123:      * @return cApiPathresolveCache|NULL
124:      * @throws cDbException
125:      * @throws cException
126:      */
127:     public function fetchLatestByPathAndLanguage($path, $idlang) {
128:         $this->select("path LIKE '" . $this->db->escape($path) . "' AND idlang=" . (int) $idlang, '', 'lastcached DESC', '1');
129:         return $this->next();
130:     }
131: 
132:     /**
133:      * Deletes entry by category and language.
134:      *
135:      * @param int $idcat
136:      * @param int $idlang
137:      *
138:      * @throws cDbException
139:      * @throws cException
140:      * @throws cInvalidArgumentException
141:      */
142:     public function deleteByCategoryAndLanguage($idcat, $idlang) {
143:         $this->select('idcat=' . (int) $idcat . ' AND idlang=' . (int) $idlang);
144:         while (($oCode = $this->next()) !== false) {
145:             $this->delete($oCode->get('idpathresolvecache'));
146:         }
147:     }
148: 
149: }
150: 
151: /**
152:  * Pathresolve cache item
153:  *
154:  * @package Core
155:  * @subpackage GenericDB_Model
156:  */
157: class cApiPathresolveCache extends Item
158: {
159:     /**
160:      * Constructor to create an instance of this class.
161:      *
162:      * @param mixed $mId [optional]
163:      *                   Specifies the ID of item to load
164:      *                   
165:      * @throws cDbException
166:      * @throws cException
167:      */
168:     public function __construct($mId = false) {
169:         global $cfg;
170:         cApiPathresolveCacheHelper::setup($cfg);
171:         parent::__construct($cfg['sql']['sqlprefix'] . '_pathresolve_cache', 'idpathresolvecache');
172:         $this->setFilters(array(), array());
173:         if ($mId !== false) {
174:             $this->loadByPrimaryKey($mId);
175:         }
176:     }
177: 
178:     /**
179:      * Checks if item's cache time has expired.
180:      *
181:      * @throws cException If item has not been loaded before
182:      * @return bool
183:      */
184:     public function isCacheTimeExpired() {
185:         global $cfg;
186:         if (!$this->isLoaded()) {
187:             throw new cException('Item not loaded!');
188:         }
189:         $cacheTime = (isset($cfg['pathresolve_heapcache_time'])) ? $cfg['pathresolve_heapcache_time'] : 60 * 60 * 24;
190:         return $this->get('lastcached') + $cacheTime < time();
191:     }
192: 
193:     /**
194:      * Userdefined setter for pathresolve cache fields.
195:      *
196:      * @param string $name
197:      * @param mixed $value
198:      * @param bool $bSafe [optional]
199:      *         Flag to run defined inFilter on passed value
200:      *
201:      * @return bool
202:      */
203:     public function setField($name, $value, $bSafe = true) {
204:         switch ($name) {
205:             case 'idcat':
206:             case 'idlang':
207:                 $value = (int) $value;
208:                 break;
209:         }
210: 
211:         return parent::setField($name, $value, $bSafe);
212:     }
213: 
214: }
215: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0