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 file information collection and item class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GenericDB_Model
  8:  * @author Konstantinos Katikakis
  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: cInclude('includes', 'functions.file.php');
 18: 
 19: /**
 20:  * File information collection.
 21:  *
 22:  * @package Core
 23:  * @subpackage GenericDB_Model
 24:  */
 25: class cApiFileInformationCollection extends ItemCollection {
 26:     /**
 27:      * Constructor to create an instance of this class.
 28:      *
 29:      * @throws cInvalidArgumentException
 30:      */
 31:     public function __construct() {
 32:         global $cfg;
 33:         parent::__construct($cfg['tab']['file_information'], 'idsfi');
 34:         $this->_setItemClass('cApiFileInformation');
 35:     }
 36: 
 37:     /**
 38:      * Creates a new entry in the database
 39:      *
 40:      * @todo  Pass additional fields as optional parameters
 41:      *
 42:      * @param string $typeContent
 43:      *                            type of the entry
 44:      * @param string $filename
 45:      *                            name of the file
 46:      * @param string $description [optional]
 47:      *                            an optional description
 48:      *
 49:      * @return cApiFileInformation
 50:      *         the new item
 51:      * 
 52:      * @throws cDbException
 53:      * @throws cException
 54:      * @throws cInvalidArgumentException
 55:      */
 56:     public function create($typeContent, $filename, $description = '') {
 57:         $client = cRegistry::getClientId();
 58:         $auth = cRegistry::getAuth();
 59:         $item = new cApiFileInformation();
 60:         $item->loadByMany(array(
 61:             'idclient' => $client,
 62:             'type' => $typeContent,
 63:             'filename' => $filename
 64:         ));
 65:         if (!$item->isLoaded()) {
 66:             $item = $this->createNewItem();
 67: 
 68:             $item->set('idclient', $client);
 69:             $item->set('type', $typeContent);
 70:             $item->set('filename', $filename);
 71:             $item->set('created', date('Y-m-d H:i:s'));
 72:             $item->set('lastmodified', date('Y-m-d H:i:s'));
 73:             $item->set('author', $auth->auth['uid']);
 74:             $item->set('modifiedby', $auth->auth['uid']);
 75:             $item->set('description', $description);
 76:             $item->store();
 77: 
 78:             return $item;
 79:         } else {
 80:             return $this->updateFile($filename, $typeContent, $description);
 81:         }
 82:     }
 83: 
 84:     /**
 85:      * updates a new entry in the database
 86:      *
 87:      * @todo  Pass additional fields as optional parameters
 88:      *
 89:      * @param string $filename
 90:      *                            name of the file
 91:      * @param string $typeContent
 92:      *                            type of the entry
 93:      * @param string $description [optional]
 94:      *                            an optional description
 95:      * @param string $newFilename [optional]
 96:      *                            an optional new filename
 97:      * @param string $author      [optional]
 98:      *                            an optional author
 99:      *
100:      * @return cApiFileInformation
101:      *                            the updated item
102:      * 
103:      * @throws cDbException
104:      * @throws cException
105:      * @throws cInvalidArgumentException
106:      */
107:     public function updateFile($filename, $typeContent, $description = '', $newFilename = '', $author = '') {
108:         $auth = cRegistry::getAuth();
109:         $client = cRegistry::getClientId();
110:         $item = new cApiFileInformation();
111:         $item->loadByMany(array(
112:             'idclient' => $client,
113:             'type' => $typeContent,
114:             'filename' => $filename
115:         ));
116:         $id = $item->get('idsfi');
117:         if ($item->isLoaded()) {
118:             $item->set('idsfi', $id);
119:             $item->set('lastmodified', date('Y-m-d H:i:s'));
120:             $item->set('description', $description);
121:             $item->set('modifiedby', $auth->auth['uid']);
122:             if (!empty($newFilename)) {
123:                 $item->set('filename', $newFilename);
124:             }
125:             if (!empty($author)) {
126:                 $item->set('author', $author);
127:             }
128:             $item->store();
129:         }
130: 
131:         return $item;
132:     }
133: 
134:     /**
135:      * Deletes all found items in the table matching the passed field and it's
136:      * value.
137:      * Deletes also cached e entries and any existing properties.
138:      *
139:      * @param array $values
140:      *         with parameters
141:      * @return bool
142:      * 
143:      * @throws cDbException
144:      * @throws cException
145:      */
146:     public function removeFileInformation(array $values) {
147:         $item = new cApiFileInformation();
148:         $item->loadByMany($values);
149:         $idsfi = $item->get('idsfi');
150:         return $this->delete($idsfi);
151:     }
152: 
153:     /**
154:      * return an array with fileinformations from the database
155:      *
156:      * @param string $filename
157:      *         name of the file
158:      * @param string $type
159:      *         type of the entry
160:      * @return array
161:      * 
162:      * @throws cDbException
163:      * @throws cException
164:      */
165:     public function getFileInformation($filename, $type) {
166:         $client = cRegistry::getClientId();
167:         $fileInformation = array();
168:         $item = new cApiFileInformation();
169:         $item->loadByMany(array(
170:             'idclient' => $client,
171:             'type' => $type,
172:             'filename' => $filename
173:         ));
174:         if ($item->isLoaded()) {
175:             $fileInformation['idsfi'] = $item->get('idsfi');
176:             $fileInformation['created'] = $item->get('created');
177:             $fileInformation['lastmodified'] = $item->get('lastmodified');
178:             $fileInformation['author'] = cSecurity::unFilter($item->get('author'));
179:             $fileInformation['modifiedby'] = $item->get('modifiedby');
180:             $fileInformation['description'] = cSecurity::unFilter($item->get('description'));
181:         }
182:         return $fileInformation;
183:     }
184: }
185: 
186: /**
187:  * File information item.
188:  *
189:  * @package Core
190:  * @subpackage GenericDB_Model
191:  */
192: class cApiFileInformation extends Item
193: {
194:     /**
195:      * Constructor to create an instance of this class.
196:      *
197:      * @param bool $id [optional]
198:      *
199:      * @throws cDbException
200:      * @throws cException
201:      */
202:     public function __construct($id = false) {
203:         global $cfg;
204:         parent::__construct($cfg['tab']['file_information'], 'idsfi');
205:         if ($id !== false) {
206:             $this->loadByPrimaryKey($id);
207:         }
208:     }
209: }
210: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0