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 meta tag version collection and item class.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       GenericDB_Model
  8:  * @author           Jann Dieckmann
  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:  * Metatag version collection
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class cApiMetaTagVersionCollection extends ItemCollection {
 24:     /**
 25:      * Constructor to create an instance of this class.
 26:      *
 27:      * @throws cInvalidArgumentException
 28:      */
 29:     public function __construct() {
 30:         global $cfg;
 31:         parent::__construct($cfg['tab']['meta_tag_version'], 'idmetatagversion');
 32:         $this->_setItemClass('cApiMetaTagVersion');
 33: 
 34:         // set the join partners so that joins can be used via link() method
 35:         $this->_setJoinPartner('cApiArticleLanguageVersionCollection');
 36:         $this->_setJoinPartner('cApiMetaTypeCollection');
 37:     }
 38: 
 39:     /**
 40:      * Creates a meta tag entry.
 41:      *
 42:      * @param int    $idMetaTag
 43:      * @param int    $idArtLang
 44:      * @param int    $idMetaType
 45:      * @param string $metaValue
 46:      * @param string $version
 47:      *
 48:      * @return cApiMetaTagVersion
 49:      * @throws cDbException
 50:      * @throws cException
 51:      * @throws cInvalidArgumentException
 52:      */
 53:     public function create($idMetaTag, $idArtLang, $idMetaType, $metaValue, $version) {
 54: 
 55:         // create item
 56:         $item = $this->createNewItem();
 57: 
 58:         $item->set('idmetatag', $idMetaTag, false);
 59:         $item->set('idartlang', $idArtLang, false);
 60:         $item->set('idmetatype', $idMetaType, false);
 61:         $item->set('metavalue', $metaValue, false);
 62:         $item->set('version', $version, false);
 63:         $item->store();
 64: 
 65:         return $item;
 66:     }
 67: 
 68:     /**
 69:      * Returns a meta tag entry by article language and meta type and version.
 70:      *
 71:      * @param int $idArtLang
 72:      * @param int $idMetaType
 73:      * @param int $version
 74:      * @return cApiMetaTagVersion|NULL
 75:      * @throws cDbException
 76:      */
 77:     public function fetchByArtLangMetaTypeAndVersion($idArtLang, $idMetaType, $version) {
 78:         $sql = 'SELECT idmetatagversion FROM %s
 79:                 WHERE (idmetatype, version)
 80:                     IN (SELECT idmetatype, max(version)
 81:                     FROM %s
 82:                     WHERE idartlang = %d AND version <= %d AND idmetatype = %d group by idmetatype)
 83:                 AND idartlang = %d';
 84: 
 85:         $this->db->query(
 86:             $sql,
 87:             cRegistry::getDbTableName('meta_tag_version'),
 88:             cRegistry::getDbTableName('meta_tag_version'),
 89:             (int) $idArtLang,
 90:             (int) $version,
 91:             (int) $idMetaType,
 92:             (int) $idArtLang
 93:         );
 94: 
 95:         $this->db->nextRecord();
 96: 
 97:         return new cApiMetaTagVersion($this->db->f('idmetatagversion'));
 98:     }
 99: 
100:     /**
101:      * Returns idmetatagversions by where-clause
102:      *
103:      * @param string $where
104:      * @return int[]
105:      * @throws cDbException
106:      * @throws cException
107:      */
108:     public function fetchByArtLangAndMetaType($where) {
109:         $metaTagVersionColl = new cApiMetaTagVersionCollection();
110:         $metaTagVersionColl->select($where);
111: 
112:         while($item = $metaTagVersionColl->next()){
113:             $ids[] = $item->get('idmetatagversion');
114:         }
115:         return $ids;
116: 
117:     }
118: 
119: }
120: 
121: /**
122:  * Metatag version item
123:  *
124:  * @package Core
125:  * @subpackage GenericDB_Model
126:  */
127: class cApiMetaTagVersion extends Item
128: {
129:     /**
130:      * Constructor to create an instance of this class.
131:      *
132:      * @param mixed $id
133:      *         Specifies the ID of item to load
134:      *
135:      * @throws cDbException
136:      * @throws cException
137:      */
138:     public function __construct($id = false) {
139:         global $cfg;
140:         parent::__construct($cfg['tab']['meta_tag_version'], 'idmetatagversion');
141:         $this->setFilters(array(), array());
142:         if ($id !== false) {
143:             $this->loadByPrimaryKey($id);
144:         }
145:     }
146: 
147:     /**
148:      * Updates meta value of an entry.
149:      *
150:      * @param string $metaValue
151:      * @return bool
152:      * @throws cDbException
153:      * @throws cInvalidArgumentException
154:      */
155:     public function updateMetaValue($metaValue) {
156:         $this->set('metavalue', $metaValue, false);
157:         return $this->store();
158:     }
159: 
160:     /**
161:      * Marks this meta value as current.
162:      *
163:      * @return bool|void
164:      * @throws cDbException
165:      * @throws cException
166:      * @throws cInvalidArgumentException
167:      */
168:     public function markAsCurrent() {
169:         $metaTagColl = new cApiMetaTagCollection();
170:         $metaTag = $metaTagColl->fetchByArtLangAndMetaType($this->get('idartlang'), $this->get('idmetatype'));
171:         if ($metaTag != NULL) {
172:             $metaTag->set('metavalue', $this->get('metavalue'), false);
173:             return $metaTag->store();
174:         } else {
175:             $metaTag = new cApiMetaTagCollection();
176:             $metaTag->create($this->get('idartlang'), $this->get('idmetatype'), $this->get('metavalue'));
177:         }
178:     }
179: 
180:     /**
181:      * Marks this meta value as editable.
182:      *
183:      * @param int $version
184:      * @throws cDbException
185:      * @throws cException
186:      * @throws cInvalidArgumentException
187:      */
188:     public function markAsEditable($version) {
189:         $metaTagVersionColl = new cApiMetaTagVersionCollection();
190:         $metaTagVersionColl->create($this->get('idmetatag'), $this->get('idartlang'), $this->get('idmetatype'), $this->get('metavalue'), $version);
191:     }
192: 
193:     /**
194:      * Userdefined setter for meta tag fields.
195:      *
196:      * @see Item::setField()
197:      * @param string $name
198:      *         Field name
199:      * @param mixed $value
200:      *         Value to set
201:      * @param bool $safe
202:      *         Flag to run defined inFilter on passed value
203:      * @return bool
204:      */
205:     public function setField($name, $value, $safe = true) {
206:         switch ($name) {
207:             case 'idartlang':
208:                 $value = (int) $value;
209:                 break;
210:             case 'idmetatype':
211:                 $value = (int) $value;
212:                 break;
213:         }
214: 
215:         return parent::setField($name, $value, $safe);
216:     }
217: 
218: }
219: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0