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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • 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:     /**
 26:      * Constructor to create an instance of this class.
 27:      */
 28:     public function __construct() {
 29:         parent::__construct(cRegistry::getDbTableName('content_version'), 'idcontentversion');
 30:         $this->_setItemClass('cApiContentVersion');
 31: 
 32:         // set the join partners so that joins can be used via link() method
 33:         $this->_setJoinPartner('cApiArticleLanguageCollection');
 34:         $this->_setJoinPartner('cApiTypeCollection');
 35:     }
 36: 
 37:     /**
 38:      * Creates a content version entry.
 39:      *
 40:      * @param mixed[] $parameters{
 41:      *  @type int $idContent
 42:      *  @type int $idArtLang
 43:      *  @type int $idType
 44:      *  @type int $typeId
 45:      *  @type string $value
 46:      *  @type int $version
 47:      *  @type string $author
 48:      *  @type string $created
 49:      *  @type string $lastModified
 50:      * }
 51:      * @return cApiContentVersion
 52:      */
 53:     public function create(array $parameters) {
 54:         global $auth;
 55: 
 56:         if (empty($author)) {
 57:             $author = $auth->auth['uname'];
 58:         }
 59:         if (empty($created)) {
 60:             $created = date('Y-m-d H:i:s');
 61:         }
 62:         if (empty($lastmodified)) {
 63:             $lastmodified = date('Y-m-d H:i:s');
 64:         }
 65: 
 66:         $item = $this->createNewItem();
 67: 
 68:         // populate item w/ values
 69:         foreach (array_keys($parameters) as $key) {
 70:             $item->set($key, $parameters[$key]);
 71:         }
 72:     $item->store();
 73: 
 74:         return $item;
 75:     }
 76: 
 77:     /**
 78:      * Gets idcontentversions by where clause
 79:      *
 80:      * @param string $where
 81:      * @return array $ids
 82:      */
 83:     public function getIdsByWhereClause($where){
 84: 
 85:         $this->select($where);
 86: 
 87:         $ids = array();
 88:         while($item = $this->next()){
 89:             $ids[] = $item->get('idcontentversion');
 90:         }
 91:         return $ids;
 92: 
 93:     }
 94: 
 95: }
 96: 
 97: /**
 98:  * Content Version item
 99:  *
100:  * @package Core
101:  * @subpackage GenericDB_Model
102:  */
103: class cApiContentVersion extends Item {
104: 
105:     /**
106:      * Constructor to create an instance of this class.
107:      *
108:      * @param mixed $id
109:      *         Specifies the ID of item to load
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:     public function markAsCurrent() {
137: 
138:         // try to get item from database
139:         $content = new cApiContent();
140:         $succ = $content->loadByArticleLanguageIdTypeAndTypeId(
141:             $this->get('idartlang'),
142:             $this->get('idtype'),
143:             $this->get('typeid')
144:         );
145: 
146:         // create new item if none has been found
147:         if (!$succ) {
148:             $coll = new cApiContentCollection();
149:             $content = $coll->createNewItem();
150:         }
151: 
152:         // update/set attributes
153:         $content->set('idartlang', $this->get('idartlang'));
154:         $content->set('idtype', $this->get('idtype'));
155:         $content->set('typeid', $this->get('typeid'));
156:         $content->set('value', $this->get('value'));
157:         $content->set('author', $this->get('author'));
158:         $content->set('created', $this->get('created'));
159:         $content->set('lastmodified', $this->get('lastmodified'));
160: 
161:         // store item
162:         $content->store();
163: 
164:     }
165: 
166:     /**
167:      * Creates a new, editable Version with same properties as this Content Version
168:      *
169:      * @param string $version
170:      * @param mixed $deleted
171:      */
172:     public function markAsEditable($version, $deleted) {
173: 
174:         // get parameters for editable version
175:         $parameters = $this->toArray();
176:         unset($parameters['idcontentversion']);
177:         $parameters['version'] = $version;
178: 
179:         // create editable version
180:         $contentVersionColl = new cApiContentVersionCollection();
181:         $contentVersion = $contentVersionColl->create($parameters);
182:         if ($deleted == 1) {
183:             $contentVersion->set('deleted', $deleted);
184:         }
185: 
186:         $contentVersion->store();
187: 
188:     }
189: 
190:     /**
191:      * Loads a content entry by its article language id, idtype, type id and version.
192:      *
193:      * @param mixed $contentParameters[]{
194:      *  @type int idartlang
195:      *  @type int idtype
196:      *  @type int typeid
197:      *  @type int $version
198:      * }
199:      * @return bool
200:      */
201:     public function loadByArticleLanguageIdTypeTypeIdAndVersion(array $contentParameters) {
202:         //$db = cRegistry::getDb();
203:         $props = array(
204:             'idartlang' => $contentParameters['idartlang'],
205:             'idtype' => $contentParameters['idtype'],
206:             'typeid' => $contentParameters['typeid'],
207:             'version' => $contentParameters['version']
208:         );
209:         $recordSet = $this->_oCache->getItemByProperties($props);
210:         if ($recordSet) {
211:             // entry in cache found, load entry from cache
212:             $this->loadByRecordSet($recordSet);
213:             return true;
214:         } else {
215:             $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']);
216:             return $this->_loadByWhereClause($where);
217:         }
218: 
219:     }
220: 
221: }
222: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0