[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/classes/datatypes/ezmedia/ -> ezmedia.php (source)

   1  <?php
   2  //
   3  // Definition of eZBinaryFile class
   4  //
   5  // Created on: <30-Apr-2002 16:47:08 bf>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*!
  30    \class eZMedia ezmedia.php
  31    \ingroup eZDatatype
  32    \brief The class eZMedia handles registered media files
  33  
  34  */
  35  
  36  include_once ( "lib/ezdb/classes/ezdb.php" );
  37  include_once ( "kernel/classes/ezpersistentobject.php" );
  38  include_once ( "kernel/classes/ezcontentclassattribute.php" );
  39  
  40  class eZMedia extends eZPersistentObject
  41  {
  42      function eZMedia( $row )
  43      {
  44          $this->eZPersistentObject( $row );
  45      }
  46  
  47      function definition()
  48      {
  49          return array( "fields" => array( "contentobject_attribute_id" => array( 'name' => "ContentObjectAttributeID",
  50                                                                                  'datatype' => 'integer',
  51                                                                                  'default' => 0,
  52                                                                                  'required' => true,
  53                                                                                  'foreign_class' => 'eZContentObjectAttribute',
  54                                                                                  'foreign_attribute' => 'id',
  55                                                                                  'multiplicity' => '1..*' ),
  56                                           "version" => array( 'name' => "Version",
  57                                                               'datatype' => 'integer',
  58                                                               'default' => 0,
  59                                                               'required' => true ),
  60                                           "filename" => array( 'name' => "Filename",
  61                                                                'datatype' => 'string',
  62                                                                'default' => '',
  63                                                                'required' => true ),
  64                                           "original_filename" => array( 'name' => "OriginalFilename",
  65                                                                         'datatype' => 'string',
  66                                                                         'default' => '',
  67                                                                         'required' => true ),
  68                                           "mime_type" => array( 'name' => "MimeType",
  69                                                                 'datatype' => 'string',
  70                                                                 'default' => '',
  71                                                                 'required' => true ),
  72                                           "width" => array( 'name' => "Width",
  73                                                             'datatype' => 'integer',
  74                                                             'default' => 0,
  75                                                             'required' => true ),
  76                                           "height" => array( 'name' => "Height",
  77                                                              'datatype' => 'integer',
  78                                                              'default' => 0,
  79                                                              'required' => true ),
  80                                           "has_controller" => array( 'name' => "HasController",
  81                                                                      'datatype' => 'integer',
  82                                                                      'default' => 0,
  83                                                                      'required' => true ),
  84                                           "controls" => array( 'name' => "Controls",
  85                                                                'datatype' => 'string',
  86                                                                'default' => '',
  87                                                                'required' => true ),
  88                                           "is_autoplay" => array( 'name' => "IsAutoplay",
  89                                                                   'datatype' => 'integer',
  90                                                                   'default' => 0,
  91                                                                   'required' => true ),
  92                                           "pluginspage" => array( 'name' => "Pluginspage",
  93                                                                   'datatype' => 'string',
  94                                                                   'default' => '',
  95                                                                   'required' => true ),
  96                                           "quality" => array( 'name' => 'Quality',
  97                                                               'datatype' => 'string',
  98                                                               'default' => '',
  99                                                               'required' => true ),
 100                                           "is_loop" => array( 'name' => "IsLoop",
 101                                                               'datatype' => 'integer',
 102                                                               'default' => 0,
 103                                                               'required' => true ) ),
 104                        "keys" => array( "contentobject_attribute_id", "version" ),
 105                        'function_attributes' => array( 'filesize' => 'filesize',
 106                                                        'filepath' => 'filepath',
 107                                                        'mime_type_category' => 'mimeTypeCategory',
 108                                                        'mime_type_part' => 'mimeTypePart' ),
 109                        "relations" => array( "contentobject_attribute_id" => array( "class" => "ezcontentobjectattribute",
 110                                                                                     "field" => "id" ),
 111                                              "version" => array( "class" => "ezcontentobjectattribute",
 112                                                                  "field" => "version" )),
 113                        "class_name" => "eZMedia",
 114                        "name" => "ezmedia" );
 115      }
 116  
 117      function &fileSize()
 118      {
 119          $fileInfo = $this->storedFileInfo();
 120  
 121          // VS-DBFILE
 122          require_once ( 'kernel/classes/ezclusterfilehandler.php' );
 123          $file = eZClusterFileHandler::instance( $fileInfo['filepath'] );
 124  
 125          if ( $file->exists() )
 126              $fileSize = $file->size();
 127          else
 128              $fileSize = 0;
 129          return $fileSize;
 130      }
 131  
 132      function &filePath()
 133      {
 134          $fileInfo = $this->storedFileInfo();
 135          return $fileInfo['filepath'];
 136      }
 137  
 138      function &mimeTypeCategory()
 139      {
 140          $types = explode( "/", eZPersistentObject::attribute( "mime_type" ) );
 141          return $types[0];
 142      }
 143  
 144      function &mimeTypePart()
 145      {
 146          $types = explode( "/", eZPersistentObject::attribute( "mime_type" ) );
 147          return $types[1];
 148      }
 149  
 150      function create( $contentObjectAttributeID, $version )
 151      {
 152          $row = array( "contentobject_attribute_id" => $contentObjectAttributeID,
 153                        "version" => $version,
 154                        "filename" => "",
 155                        "original_filename" => "",
 156                        "mime_type" => "",
 157                        "width" => "0",
 158                        "height" => "0",
 159                        "controller" => true,
 160                        "autoplay" => true,
 161                        "pluginspage" => "",
 162                        "is_loop" => false,
 163                        "quality" => "",
 164                        "controls" => ""
 165                        );
 166          return new eZMedia( $row );
 167      }
 168  
 169      function fetch( $id, $version, $asObject = true )
 170      {
 171          if( $version == null )
 172          {
 173              return eZPersistentObject::fetchObjectList( eZMedia::definition(),
 174                                                          null,
 175                                                          array( "contentobject_attribute_id" => $id ),
 176                                                          null,
 177                                                          null,
 178                                                          $asObject );
 179          }
 180          else
 181          {
 182              return eZPersistentObject::fetchObject( eZMedia::definition(),
 183                                                      null,
 184                                                      array( "contentobject_attribute_id" => $id,
 185                                                             "version" => $version ),
 186                                                      $asObject );
 187          }
 188      }
 189  
 190      function remove( $id, $version )
 191      {
 192          if( $version == null )
 193          {
 194              eZPersistentObject::removeObject( eZMedia::definition(),
 195                                                array( "contentobject_attribute_id" => $id ) );
 196          }
 197          else
 198          {
 199              eZPersistentObject::removeObject( eZMedia::definition(),
 200                                                array( "contentobject_attribute_id" => $id,
 201                                                       "version" => $version ) );
 202          }
 203      }
 204  
 205      function storedFileInfo()
 206      {
 207          $fileName = $this->attribute( 'filename' );
 208          $mimeType = $this->attribute( 'mime_type' );
 209          $originalFileName = $this->attribute( 'original_filename' );
 210  
 211          $storageDir = eZSys::storageDirectory();
 212  
 213          $group = '';
 214          $type = '';
 215          if ( $mimeType )
 216              list( $group, $type ) = explode( '/', $mimeType );
 217  
 218          $filePath = $storageDir . '/original/' . $group . '/' . $fileName;
 219  
 220          return array( 'filename' => $fileName,
 221                        'original_filename' => $originalFileName,
 222                        'filepath' => $filePath,
 223                        'mime_type' => $mimeType );
 224      }
 225  
 226      var $ContentObjectAttributeID;
 227      var $Filename;
 228      var $OriginalFilename;
 229      var $MimeType;
 230      var $Width;
 231      var $Height;
 232      var $HasController;
 233      var $Controls;
 234      var $IsLoop;
 235      var $IsAutoplay;
 236      var $Pluginspage;
 237      var $Quality;
 238  }
 239  
 240  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7