eZ Publish  [4.0]
ezcontentobjecttranslation.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Created on: <12-Jun-2002 16:25:40 bf>
00004 //
00005 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00006 // SOFTWARE NAME: eZ Publish
00007 // SOFTWARE RELEASE: 4.0.x
00008 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00009 // SOFTWARE LICENSE: GNU General Public License v2.0
00010 // NOTICE: >
00011 //   This program is free software; you can redistribute it and/or
00012 //   modify it under the terms of version 2.0  of the GNU General
00013 //   Public License as published by the Free Software Foundation.
00014 //
00015 //   This program is distributed in the hope that it will be useful,
00016 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //   GNU General Public License for more details.
00019 //
00020 //   You should have received a copy of version 2.0 of the GNU General
00021 //   Public License along with this program; if not, write to the Free
00022 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00023 //   MA 02110-1301, USA.
00024 //
00025 //
00026 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00027 //
00028 
00029 /*!
00030   \class eZContentObjectTranslation ezcontentobjecttranslation.php
00031   \brief eZContentObjectTranslation handles translation a translation of content objects
00032   \ingroup eZKernel
00033 
00034   \sa eZContentObject eZContentObjectVersion eZContentObjectTranslation
00035 */
00036 
00037 class eZContentObjectTranslation
00038 {
00039     function eZContentObjectTranslation( $contentObjectID, $version, $languageCode )
00040     {
00041         $this->ContentObjectID = $contentObjectID;
00042         $this->Version = $version;
00043         $this->LanguageCode = $languageCode;
00044         $this->Locale = null;
00045     }
00046 
00047     function languageCode()
00048     {
00049         return $this->LanguageCode;
00050     }
00051 
00052     function attributes()
00053     {
00054         return array( 'contentobject_id',
00055                       'version',
00056                       'language_code',
00057                       'locale' );
00058     }
00059 
00060     function hasAttribute( $attribute )
00061     {
00062         return in_array( $attribute, $this->attributes() );
00063     }
00064 
00065     function attribute( $attribute )
00066     {
00067         if ( $attribute == 'contentobject_id' )
00068             return $this->ContentObjectID;
00069         else if ( $attribute == 'version' )
00070             return $this->Version;
00071         else if ( $attribute == 'language_code' )
00072             return $this->LanguageCode;
00073         else if ( $attribute == 'locale' )
00074             return $this->locale();
00075         else
00076         {
00077             eZDebug::writeError( "Attribute '$attribute' does not exist", 'eZContentObjectTranslation::attribute' );
00078             return null;
00079         }
00080     }
00081 
00082     function locale()
00083     {
00084         if ( $this->Locale !== null )
00085             return $this->Locale;
00086         //include_once( 'lib/ezlocale/classes/ezlocale.php' );
00087         $this->Locale = eZLocale::instance( $this->LanguageCode );
00088         return $this->Locale;
00089     }
00090 
00091     /*!
00092      Returns the attributes for the current content object translation.
00093     */
00094     function objectAttributes( $asObject = true )
00095     {
00096         return eZContentObjectVersion::fetchAttributes( $this->Version, $this->ContentObjectID, $this->LanguageCode, $asObject );
00097     }
00098 
00099     /// The content object identifier
00100     public $ContentObjectID;
00101     /// Contains the content object
00102     public $Version;
00103 
00104     /// Contains the language code for the current translation
00105     public $LanguageCode;
00106 }
00107 ?>