[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZURLObjectLink class 4 // 5 // Created on: <04-Jul-2003 13:14:41 wy> 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 /*! \file ezurlobjectlink.php 30 */ 31 32 /*! 33 \class eZURLObjectLink ezurlobjectlink.php 34 \ingroup eZDatatype 35 \brief The class eZURLObjectLink does 36 37 */ 38 39 include_once ( 'kernel/classes/ezpersistentobject.php' ); 40 41 class eZURLObjectLink extends eZPersistentObject 42 { 43 /*! 44 Constructor 45 */ 46 function eZURLObjectLink( $row ) 47 { 48 $this->eZPersistentObject( $row ); 49 } 50 51 function definition() 52 { 53 return array( 'fields' => array( 'url_id' => array( 'name' => 'URLID', 54 'datatype' => 'integer', 55 'default' => 0, 56 'required' => true, 57 'foreign_class' => 'eZURL', 58 'foreign_attribute' => 'id', 59 'multiplicity' => '1..*' ), 60 'contentobject_attribute_id' => array( 'name' => 'ContentObjectAttributeID', 61 'datatype' => 'integer', 62 'default' => 0, 63 'required' => true, 64 'foreign_class' => 'eZContentObjectAttribute', 65 'foreign_attribute' => 'id', 66 'multiplicity' => '1..*' ), 67 'contentobject_attribute_version' => array( 'name' => 'ContentObjectAttributeVersion', 68 'datatype' => 'integer', 69 'default' => 0, 70 'short_name' => 'contentobject_attr_version', 71 'required' => true ) ), 72 'keys' => array( 'url_id', 'contentobject_attribute_id', 'contentobject_attribute_version' ), 73 'sort' => array( 'url_id' => 'asc' ), 74 'class_name' => 'eZURLObjectLink', 75 'name' => 'ezurl_object_link' ); 76 } 77 78 /*! 79 \static 80 */ 81 function create( $urlID, $contentObjectAttributeID, $contentObjectAttributeVersion ) 82 { 83 $row = array( 84 'url_id' => $urlID, 85 'contentobject_attribute_id' => $contentObjectAttributeID, 86 'contentobject_attribute_version' => $contentObjectAttributeVersion ); 87 return new eZURLObjectLink( $row ); 88 } 89 90 /*! 91 \static 92 \return the url object for id \a $id. 93 */ 94 function fetch( $urlID, $contentObjectAttributeID, $contentObjectAttributeVersion, $asObject = true ) 95 { 96 return eZPersistentObject::fetchObject( eZURLObjectLink::definition(), 97 null, 98 array( 'url_id' => $urlID, 99 'contentobject_attribute_id' => $contentObjectAttributeID, 100 'contentobject_attribute_version' => $contentObjectAttributeVersion ), 101 $asObject ); 102 } 103 104 /*! 105 \static 106 \return \c true if the URL \a $urlID has any object links 107 */ 108 function hasObjectLinkList( $urlID ) 109 { 110 $rows = eZPersistentObject::fetchObjectList( eZURLObjectLink::definition(), 111 array(), 112 array( 'url_id' => $urlID ), 113 array(), 114 null, 115 false, 116 false, 117 array( array( 'name' => 'count', 118 'operation' => 'count( url_id )' ) ) ); 119 return ( $rows[0]['count'] > 0 ); 120 } 121 122 /*! 123 \static 124 \return all object versions which has the link. 125 */ 126 function &fetchObjectVersionList( $urlID, $parameters = false ) 127 { 128 $objectVersionList = array(); 129 $urlObjectLinkList = eZPersistentObject::fetchObjectList( eZURLObjectLink::definition(), 130 null, 131 array( 'url_id' => $urlID ), 132 null, 133 $parameters, 134 true ); 135 $storedVersionList = array(); 136 foreach ( array_keys( $urlObjectLinkList ) as $key ) 137 { 138 $urlObjectLink =& $urlObjectLinkList[$key]; 139 $objectAttributeID = $urlObjectLink->attribute( 'contentobject_attribute_id' ); 140 $objectAttributeVersion = $urlObjectLink->attribute( 'contentobject_attribute_version' ); 141 $objectAttribute = eZContentObjectAttribute::fetch( $objectAttributeID, $objectAttributeVersion ); 142 if ( $objectAttribute ) // Object and version has been deleted 143 { 144 $objectID = $objectAttribute->attribute( 'contentobject_id' ); 145 $objectVersion = $objectAttribute->attribute( 'version' ); 146 $object =& eZContentObject::fetch( $objectID ); 147 if ( $object ) 148 { 149 $versionObject =& $object->version( $objectVersion ); 150 $versionID = $versionObject->attribute( 'id' ); 151 if ( !in_array( $versionID, $storedVersionList ) ) 152 { 153 $objectVersionList[] =& $versionObject; 154 $storedVersionList[] = $versionID; 155 } 156 } 157 } 158 } 159 return $objectVersionList; 160 } 161 162 /*! 163 Get url object count 164 \param urld id 165 */ 166 function fetchObjectVersionCount( $urlID ) 167 { 168 return count( eZPersistentObject::fetchObjectList( eZURLObjectLink::definition(), 169 null, 170 array( 'url_id' => $urlID ), 171 null, 172 null, 173 true ) ); 174 } 175 176 /*! 177 \static 178 Removes all links for the object attribute \a $contentObjectAttributeID and version \a $contentObjectVersion. 179 If \a $contentObjectVersion is \c false then all versions are removed as well. 180 */ 181 function removeURLlinkList( $contentObjectAttributeID, $contentObjectAttributeVersion ) 182 { 183 $conditions = array( 'contentobject_attribute_id' => $contentObjectAttributeID ); 184 if ( $contentObjectAttributeVersion !== false ) 185 $conditions['contentobject_attribute_version'] = $contentObjectAttributeVersion; 186 eZPersistentObject::removeObject( eZURLObjectLink::definition(), 187 $conditions ); 188 } 189 190 191 /*! 192 \static 193 \return all links for the contenobject attribute ID \a $contenObjectAttributeID and version \a $contenObjectVersion. 194 If \a $contentObjectVersion is \c false then all links for all versions are returned. 195 */ 196 function fetchLinkList( $contentObjectAttributeID, $contentObjectAttributeVersion, $asObject = true ) 197 { 198 $linkList = array(); 199 $conditions = array( 'contentobject_attribute_id' => $contentObjectAttributeID ); 200 if ( $contentObjectAttributeVersion !== false ) 201 $conditions['contentobject_attribute_version'] = $contentObjectAttributeVersion; 202 $urlObjectLinkList = eZPersistentObject::fetchObjectList( eZURLObjectLink::definition(), 203 null, 204 $conditions, 205 null, 206 null, 207 $asObject ); 208 foreach ( array_keys( $urlObjectLinkList ) as $key ) 209 { 210 $urlObjectLink =& $urlObjectLinkList[$key]; 211 if ( $asObject ) 212 { 213 $linkID = $urlObjectLink->attribute( 'url_id' ); 214 $link = eZURL::fetch( $linkID ); 215 $linkList[] =& $link; 216 } 217 else 218 { 219 $linkID = $urlObjectLink['url_id']; 220 $linkList[] = $linkID; 221 } 222 } 223 return $linkList; 224 } 225 226 /*! 227 \static 228 Clear view cache for every object which contains URL with given link ID \a $urlID. 229 */ 230 function clearCacheForObjectLink( $urlID ) 231 { 232 include_once ( "kernel/classes/ezcontentcachemanager.php" ); 233 $urlObjectLinkList = eZPersistentObject::fetchObjectList( eZURLObjectLink::definition(), 234 null, 235 array( 'url_id' => $urlID ), 236 null, 237 null, 238 true ); 239 foreach ( $urlObjectLinkList as $urlObjectLink ) 240 { 241 $objectAttributeID = $urlObjectLink->attribute( 'contentobject_attribute_id' ); 242 $objectAttributeVersion = $urlObjectLink->attribute( 'contentobject_attribute_version' ); 243 $objectAttribute = eZContentObjectAttribute::fetch( $objectAttributeID, $objectAttributeVersion ); 244 if ( $objectAttribute ) 245 { 246 $objectID = $objectAttribute->attribute( 'contentobject_id' ); 247 $objectVersion = $objectAttribute->attribute( 'version' ); 248 eZContentCacheManager::clearContentCacheIfNeeded( $objectID, $objectVersion ); 249 } 250 } 251 } 252 253 254 /// \privatesection 255 var $URLID; 256 var $ContentObjectAttributeID; 257 var $ContentObjectAttributeVersion; 258 } 259 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |