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 content 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:  * Content Version collection
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class cApiContentVersionCollection extends ItemCollection {
 24:     /**
 25:      * Constructor to create an instance of this class.
 26:      *
 27:      * @throws cInvalidArgumentException
 28:      */
 29:     public function __construct() {
 30:         parent::__construct(cRegistry::getDbTableName('content_version'), 'idcontentversion');
 31:         $this->_setItemClass('cApiContentVersion');
 32: 
 33:         // set the join partners so that joins can be used via link() method
 34:         $this->_setJoinPartner('cApiArticleLanguageCollection');
 35:         $this->_setJoinPartner('cApiTypeCollection');
 36:     }
 37: 
 38:     /**
 39:      * Creates a content version entry.
 40:      *
 41:      * @param mixed[] $parameters {
 42:      *
 43:      * @return cApiContentVersion
 44:      * @throws cDbException
 45:      * @throws cException
 46:      * @throws cInvalidArgumentException
 47:      */
 48:     public function create(array $parameters) {
 49:         global $auth;
 50: 
 51:         if (empty($author)) {
 52:             $author = $auth->auth['uname'];
 53:         }
 54:         if (empty($created)) {
 55:             $created = date('Y-m-d H:i:s');
 56:         }
 57:         if (empty($lastmodified)) {
 58:             $lastmodified = date('Y-m-d H:i:s');
 59:         }
 60: 
 61:         $item = $this->createNewItem();
 62: 
 63:         // populate item w/ values
 64:         foreach (array_keys($parameters) as $key) {
 65:             $item->set($key, $parameters[$key]);
 66:         }
 67:     $item->store();
 68: 
 69:         return $item;
 70:     }
 71: 
 72:     /**
 73:      * Gets idcontentversions by where clause
 74:      *
 75:      * @param string $where
 76:      * @return array $ids
 77:      * @throws cDbException
 78:      * @throws cException
 79:      */
 80:     public function getIdsByWhereClause($where){
 81: 
 82:         $this->select($where);
 83: 
 84:         $ids = array();
 85:         while($item = $this->next()){
 86:             $ids[] = $item->get('idcontentversion');
 87:         }
 88:         return $ids;
 89: 
 90:     }
 91: 
 92: }
 93: 
 94: /**
 95:  * Content Version item
 96:  *
 97:  * @package Core
 98:  * @subpackage GenericDB_Model
 99:  */
100: class cApiContentVersion extends Item
101: {
102:     /**
103:      * Constructor to create an instance of this class.
104:      *
105:      * @param mixed $id
106:      *         Specifies the ID of item to load
107:      *
108:      * @throws cDbException
109:      * @throws cException
110:      */
111:     public function __construct($id = false) {
112:         parent::__construct(cRegistry::getDbTableName('content_version'), 'idcontentversion');
113:         $this->setFilters(array(), array());
114:         if ($id !== false) {
115:             $this->loadByPrimaryKey($id);
116:         }
117:     }
118: 
119:     /**
120:      * Userdefined setter for item fields.
121:      *
122:      * @param string $name
123:      * @param mixed $value
124:      * @param bool $safe
125:      *         Flag to run defined inFilter on passed value
126:      *
127:      * @return bool
128:      */
129:     public function setField($name, $value, $safe = true) {
130:         return parent::setField($name, $value, $safe);
131:     }
132: 
133:     /**
134:      * Mark this Content Version as current Content
135:      *
136:      * @throws cException
137:      */
138:     public function markAsCurrent() {
139: 
140:         // try to get item from database
141:         $content = new cApiContent();
142:         $succ = $content->loadByArticleLanguageIdTypeAndTypeId(
143:             $this->get('idartlang'),
144:             $this->get('idtype'),
145:             $this->get('typeid')
146:         );
147: 
148:         // create new item if none has been found
149:         if (!$succ) {
150:             $coll = new cApiContentCollection();
151:             $content = $coll->createNewItem();
152:         }
153: 
154:         // update/set attributes
155:         $content->set('idartlang', $this->get('idartlang'));
156:         $content->set('idtype', $this->get('idtype'));
157:         $content->set('typeid', $this->get('typeid'));
158:         $content->set('value', $this->get('value'));
159:         $content->set('author', $this->get('author'));
160:         $content->set('created', $this->get('created'));
161:         $content->set('lastmodified', $this->get('lastmodified'));
162: 
163:         // store item
164:         $content->store();
165:     }
166: 
167:     /**
168:      * Creates a new, editable Version with same properties as this Content Version
169:      *
170:      * @param string $version
171:      * @param mixed  $deleted
172:      * @throws cDbException
173:      * @throws cException
174:      * @throws cInvalidArgumentException
175:      */
176:     public function markAsEditable($version, $deleted) {
177: 
178:         // get parameters for editable version
179:         $parameters = $this->toArray();
180:         unset($parameters['idcontentversion']);
181:         $parameters['version'] = $version;
182: 
183:         // create editable version
184:         $contentVersionColl = new cApiContentVersionCollection();
185:         $contentVersion = $contentVersionColl->create($parameters);
186:         if ($deleted == 1) {
187:             $contentVersion->set('deleted', $deleted);
188:         }
189: 
190:         $contentVersion->store();
191: 
192:     }
193: 
194:     /**
195:      * Loads a content entry by its article language id, idtype, type id and version.
196:      *
197:      * @param mixed $contentParameters []{
198:      *
199:      * @return bool
200:      * 
201:      * @throws cException
202:      */
203:     public function loadByArticleLanguageIdTypeTypeIdAndVersion(array $contentParameters) {
204:         $props = array(
205:             'idartlang' => $contentParameters['idartlang'],
206:             'idtype' => $contentParameters['idtype'],
207:             'typeid' => $contentParameters['typeid'],
208:             'version' => $contentParameters['version']
209:         );
210:         $recordSet = $this->_oCache->getItemByProperties($props);
211:         if ($recordSet) {
212:             // entry in cache found, load entry from cache
213:             $this->loadByRecordSet($recordSet);
214:             return true;
215:         } else {
216:             $where = $this->db->prepare('idartlang = %d AND idtype = %d AND typeid = %d AND version <= %d GROUP BY pk desc LIMIT 1', $contentParameters['idartlang'], $contentParameters['idtype'], $contentParameters['typeid'], $contentParameters['version']);
217:             return $this->_loadByWhereClause($where);
218:         }
219: 
220:     }
221: 
222: }
223: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0