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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the file information collection and item class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB_Model
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Konstantinos Katikakis
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: cInclude('includes', 'functions.file.php');
 19: 
 20: /**
 21:  * File information collection.
 22:  *
 23:  * @package Core
 24:  * @subpackage GenericDB_Model
 25:  */
 26: class cApiFileInformationCollection extends ItemCollection {
 27: 
 28:     /**
 29:      * Constructor
 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:      * @TODO  Pass additional fields as optional parameters
 40:      * @param string $typeContent type of the entry
 41:      * @param string $filename name of the file
 42:      * @param string $description an optional description
 43:      * @return cApiFileInformation the new item
 44:      */
 45:     public function create($typeContent, $filename, $description = '') {
 46:         $client = cRegistry::getClientId();
 47:         $auth = cRegistry::getAuth();
 48:         $item = new cApiFileInformation();
 49:         $item->loadByMany(array(
 50:             'idclient' => $client,
 51:             'type' => $typeContent,
 52:             'filename' => $filename
 53:         ));
 54:         if (!$item->isLoaded()) {
 55:             $item = $this->createNewItem();
 56: 
 57:             $item->set('idclient', $client);
 58:             $item->set('type', $typeContent);
 59:             $item->set('filename', $filename);
 60:             $item->set('created', date('Y-m-d H:i:s'));
 61:             $item->set('lastmodified', date('Y-m-d H:i:s'));
 62:             $item->set('author', $auth->auth['uid']);
 63:             $item->set('modifiedby', $auth->auth['uid']);
 64:             $item->set('description', $description);
 65:             $item->store();
 66: 
 67:             return $item;
 68:         } else {
 69:             return $this->updateFile($filename, $typeContent, $description);
 70:         }
 71:     }
 72: 
 73:     /**
 74:      * updates a new entry in the database
 75:      * @TODO  Pass additional fields as optional parameters
 76:      * @param string $filename name of the file
 77:      * @param string $typeContent type of the entry
 78:      * @param string $description an optional description
 79:      * @param string $newFilename an optional new filename
 80:      * @param string $author an optional author
 81:      * @return cApiFileInformation the updated item
 82:      */
 83:     public function updateFile($filename, $typeContent, $description = '', $newFilename = '', $author = '') {
 84:         $auth = cRegistry::getAuth();
 85:         $client = cRegistry::getClientId();
 86:         $item = new cApiFileInformation();
 87:         $item->loadByMany(array(
 88:             'idclient' => $client,
 89:             'type' => $typeContent,
 90:             'filename' => $filename
 91:         ));
 92:         $id = $item->get('idsfi');
 93:         if ($item->isLoaded()) {
 94:             $item->set('idsfi', $id);
 95:             $item->set('lastmodified', date('Y-m-d H:i:s'));
 96:             $item->set('description', $description);
 97:             $item->set('modifiedby', $auth->auth['uid']);
 98:             if (!empty($newFilename)) {
 99:                 $item->set('filename', $newFilename);
100:             }
101:             if (!empty($author)) {
102:                 $item->set('author', $author);
103:             }
104:             $item->store();
105:         }
106: 
107:         return $item;
108:     }
109: 
110:     /**
111:      * Deletes all found items in the table matching the passed field and it's
112:      * value.
113:      * Deletes also cached e entries and any existing properties.
114:      *
115:      * @param array $values with parameters
116:      * @return bool
117:      */
118:     public function removeFileInformation(array $values) {
119:         $item = new cApiFileInformation();
120:         $item->loadByMany($values);
121:         $idsfi = $item->get('idsfi');
122:         return $this->delete($idsfi);
123:     }
124: 
125:     /**
126:      * return an array with fileinformations from the database
127:      *
128:      * @param string $filename name of the file
129:      * @param string $type type of the entry
130:      * @return array
131:      */
132:     public function getFileInformation($filename, $type) {
133:         $client = cRegistry::getClientId();
134:         $fileInformation = array();
135:         $item = new cApiFileInformation();
136:         $item->loadByMany(array(
137:             'idclient' => $client,
138:             'type' => $type,
139:             'filename' => $filename
140:         ));
141:         if ($item->isLoaded()) {
142:             $fileInformation['idsfi'] = $item->get('idsfi');
143:             $fileInformation['created'] = $item->get('created');
144:             $fileInformation['lastmodified'] = $item->get('lastmodified');
145:             $fileInformation['author'] = cSecurity::unFilter($item->get('author'));
146:             $fileInformation['modifiedby'] = $item->get('modifiedby');
147:             $fileInformation['description'] = cSecurity::unFilter($item->get('description'));
148:         }
149:         return $fileInformation;
150:     }
151: }
152: 
153: /**
154:  * File information item.
155:  *
156:  * @package Core
157:  * @subpackage GenericDB_Model
158:  */
159: class cApiFileInformation extends Item {
160: 
161:     /**
162:      *
163:      * @param string $id
164:      */
165:     public function __construct($id = false) {
166:         global $cfg;
167:         parent::__construct($cfg['tab']['file_information'], 'idsfi');
168:         if ($id !== false) {
169:             $this->loadByPrimaryKey($id);
170:         }
171:     }
172: }
173: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen