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