Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentclassnamelist.php
Go to the documentation of this file.
1 <?php
11 class eZContentClassNameList extends eZSerializedObjectNameList
12 {
13 public function __construct( $serializedNameList = false )
14 {
15 parent::__construct( $serializedNameList );
16 }
17
18 function create( $serializedNamesString = false )
19 {
20 $object = new eZContentClassNameList( $serializedNamesString );
21 return $object;
22 }
23
24 function store( $contentClass )
25 {
26 if ( $this->hasDirtyData() && is_object($contentClass ) )
27 {
28 $classID = $contentClass->attribute( 'id' );
29 $classVersion = $contentClass->attribute( 'version' );
30 $languages = $contentClass->attribute( 'languages' );
31 $initialLanguageID = $contentClass->attribute( 'initial_language_id' );
32
33 // update existing
34 $contentClassNames = eZContentClassName::fetchList( $classID, $classVersion, array_keys( $languages ) );
35 foreach ( $contentClassNames as $className )
36 {
37 $languageLocale = $className->attribute( 'language_locale' );
38 $className->setAttribute( 'name', $this->nameByLanguageLocale( $languageLocale ) );
39 if ( $initialLanguageID == $className->attribute( 'language_id' ) )
40 $className->setAttribute( 'language_id', $initialLanguageID | 1 );
41
42 $className->sync(); // avoid unnecessary sql-updates if nothing changed
43
44 unset( $languages[$languageLocale] );
45 }
46
47 // create new
48 if ( count( $languages ) > 0 )
49 {
50 foreach ( $languages as $languageLocale => $language )
51 {
52 if ( !$language instanceof eZContentLanguage )
53 {
54 eZDebug::writeError( $languageLocale . ' is not a instance of eZContentLanguage', __METHOD__ );
55 continue;
56 }
57 $languageID = $language->attribute( 'id' );
58 if ( $initialLanguageID == $languageID )
59 $languageID = $initialLanguageID | 1;
60
61 $className = new eZContentClassName( array( 'contentclass_id' => $classID,
62 'contentclass_version' => $classVersion,
63 'language_locale' => $languageLocale,
64 'language_id' => $languageID,
65 'name' => $this->nameByLanguageLocale( $languageLocale ) ) );
66 $className->store();
67 }
68 }
69
70 $this->setHasDirtyData( false );
71 }
72 }
73
74 static function remove( $contentClass )
75 {
76 eZContentClassName::removeClassName( $contentClass->attribute( 'id' ), $contentClass->attribute( 'version' ) );
77 }
78 }
79
80 ?>
eZContentClassNameList
Definition: ezcontentclassnamelist.php:12
eZContentClassNameList\store
store( $contentClass)
Definition: ezcontentclassnamelist.php:24
eZContentClassNameList\__construct
__construct( $serializedNameList=false)
Definition: ezcontentclassnamelist.php:13
eZContentClassNameList\create
create( $serializedNamesString=false)
Definition: ezcontentclassnamelist.php:18
eZContentClassName
Definition: ezcontentclassname.php:12
eZContentClassName\fetchList
static fetchList( $classID, $classVersion, $languageLocaleList, $asObjects=true, $fields=null, $sorts=null, $limit=null)
Definition: ezcontentclassname.php:50
eZContentClassName\removeClassName
static removeClassName( $contentClassID, $contentClassVersion)
Definition: ezcontentclassname.php:117
eZContentLanguage
Definition: ezcontentlanguage.php:12
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZSerializedObjectNameList
Definition: ezserializedobjectnamelist.php:12
eZSerializedObjectNameList\nameByLanguageLocale
nameByLanguageLocale( $languageLocale)
Definition: ezserializedobjectnamelist.php:156
eZSerializedObjectNameList\hasDirtyData
hasDirtyData()
Definition: ezserializedobjectnamelist.php:277
eZSerializedObjectNameList\setHasDirtyData
setHasDirtyData( $hasDirtyData=true)
Definition: ezserializedobjectnamelist.php:286
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.