Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezrssexportitem.php
Go to the documentation of this file.
1 <?php
18 class eZRSSExportItem extends eZPersistentObject
19 {
20 public $SourceNodeID;
21 static function definition()
22 {
23 return array( 'fields' => array( 'id' => array( 'name' => 'ID',
24 'datatype' => 'integer',
25 'default' => 0,
26 'required' => true ),
27 'rssexport_id' => array( 'name' => 'RSSExportID',
28 'datatype' => 'integer',
29 'default' => '',
30 'required' => true,
31 'foreign_class' => 'eZRSSExport',
32 'foreign_attribute' => 'id',
33 'multiplicity' => '1..*' ),
34 'source_node_id' => array( 'name' => 'SourceNodeID',
35 'datatype' => 'integer',
36 'default' => '',
37 'required' => true,
38 'foreign_class' => 'eZContentObjectTreeNode',
39 'foreign_attribute' => 'node_id',
40 'multiplicity' => '1..*' ),
41 'class_id' => array( 'name' => 'ClassID',
42 'datatype' => 'integer',
43 'default' => '',
44 'required' => true,
45 'foreign_class' => 'eZContentClass',
46 'foreign_attribute' => 'id',
47 'multiplicity' => '1..*' ),
48 'description' => array( 'name' => 'Description',
49 'datatype' => 'string',
50 'default' => '',
51 'required' => true ),
52 'category' => array( 'name' => 'Category',
53 'datatype' => 'string',
54 'default' => '',
55 'required' => false ),
56 'title' => array( 'name' => 'Title',
57 'datatype' => 'string',
58 'default' => '',
59 'required' => true ),
60 'enclosure' => array( 'name' => 'Enclosure',
61 'datatype' => 'string',
62 'default' => '',
63 'required' => false ),
64 'status' => array( 'name' => 'Status',
65 'datatype' => 'integer',
66 'default' => 0,
67 'required' => true ),
68 'subnodes' => array( 'name' => 'Subnodes',
69 'datatype' => 'integer',
70 'default' => 0,
71 'required' => true ) ),
72 'keys' => array( 'id', 'status' ),
73 'function_attributes' => array( 'class_attributes' => 'classAttributes',
74 'source_node' => 'sourceNode',
75 'source_path' => 'sourcePath' ),
76 'increment_key' => 'id',
77 'class_name' => 'eZRSSExportItem',
78 'name' => 'ezrss_export_item' );
79 }
80
88 static function create( $rssexport_id )
89 {
90 $row = array( 'id' => null,
91 'rssexport_id' => $rssexport_id,
92 'source_node_id' => 0,
93 'class_id' => 1,
94 'url_id' => '',
95 'description' => '',
96 'title' => '',
97 'enclosure' => '',
98 'status' => eZRSSExport::STATUS_DRAFT,
99 'subnodes' => 0);
100 return new eZRSSExportItem( $row );
101 }
102
103 function &classAttributes()
104 {
105 if ( isset( $this->ClassID ) and $this->ClassID )
106 {
107 $contentClass = eZContentClass::fetch( $this->ClassID );
108 if ( $contentClass )
109 $attributes = $contentClass->fetchAttributes();
110 else
111 $attributes = null;
112 }
113 else
114 $attributes = null;
115 return $attributes;
116 }
117
118 function &sourcePath()
119 {
120 $retValue = null;
121 if ( isset( $this->SourceNodeID ) and $this->SourceNodeID )
122 {
123 $objectNode = eZContentObjectTreeNode::fetch( $this->SourceNodeID );
124 if ( isset( $objectNode ) )
125 {
126 $path_array = $objectNode->attribute( 'path_array' );
127 $path_array_count = count( $path_array );
128 for ( $i = 0; $i < $path_array_count; ++$i )
129 {
130 $treenode = eZContentObjectTreeNode::fetch( $path_array[$i], false, false );
131 if ( is_array( $treenode ) && array_key_exists( 'name', $treenode ) )
132 {
133 if ( $i == 0 )
134 {
135 $retValue = $treenode['name'];
136 }
137 else
138 {
139 $retValue .= '/' . $treenode['name'];
140 }
141 }
142 }
143 }
144 }
145 return $retValue;
146 }
147
148 function &sourceNode()
149 {
150 if ( isset( $this->SourceNodeID ) and $this->SourceNodeID )
151 {
152 $sourceNode = eZContentObjectTreeNode::fetch( $this->SourceNodeID );
153 }
154 else
155 $sourceNode = null;
156 return $sourceNode;
157 }
158
165 static function fetch( $id, $asObject = true, $status = eZRSSExport::STATUS_VALID )
166 {
167 return eZPersistentObject::fetchObject( eZRSSExportItem::definition(),
168 null,
169 array( "id" => $id,
170 'status' => $status ),
171 $asObject );
172 }
173
174 /*
175 Fetches the items belonging to the specified RSSExport
176 example: fetchFilteredList( array( 'rssexport_id' => 24 ) )
177
178 \param array, example: array( 'rssexport_id' => 24 )
179
180 \return array containing RSSExport Items
181 */
182 static function fetchFilteredList( $cond, $asObject = true, $status = eZRSSExport::STATUS_VALID )
183 {
184 return eZPersistentObject::fetchObjectList( eZRSSExportItem::definition(),
185 null, $cond, array( 'id' => 'asc',
186 'status' => $status ), null,
187 $asObject );
188 }
189
190 static function getAttributeMappings( $rssSources )
191 {
192 if( is_array( $rssSources ) && count( $rssSources ) )
193 {
194 foreach( $rssSources as $rssSource )
195 {
196 // fetch path for class attribute to RSS field mapping
197 $node = eZContentObjectTreeNode::fetch( $rssSource->SourceNodeID );
198 if ( is_object( $node ) )
199 {
200 $attributeMappings[] = array( $rssSource, $node );
201 }
202 }
203
204 // sort the array so nodes with deeper path are first
205 // for class attribute to RSS field mapping
206 usort( $attributeMappings, function ( $a, $b ) {
207 $a_cnt = count( $a[1]->attribute( 'path_array' ) );
208 $b_cnt = count( $b[1]->attribute( 'path_array' ) );
209
210 return ( $a_cnt == $b_cnt ) ? 0 : ( ( $a_cnt > $b_cnt ) ? 1 : -1 );
211 });
212 }
213
214 return $attributeMappings;
215 }
216
224 static function fetchNodeList( $rssSources, $objectListFilter )
225 {
226 // compose parameters for several subtrees
227 if( is_array( $rssSources ) && count( $rssSources ) )
228 {
229 foreach( $rssSources as $rssSource )
230 {
231 // Do not include subnodes
232 if ( !intval( $rssSource->Subnodes ) )
233 {
234 $depth = 1;
235 }
236 else // Fetch objects even from subnodes
237 {
238 $depth = 0;
239 }
240
241 $nodesParams[] = array( 'ParentNodeID' => $rssSource->SourceNodeID,
242 'ResultID' => $rssSource->ID,
243 'Depth' => $depth,
244 'DepthOperator' => 'eq',
245 'MainNodeOnly' => $objectListFilter['main_node_only'],
246 'ClassFilterType' => 'include',
247 'ClassFilterArray' => array( intval( $rssSource->ClassID ) )
248 );
249 }
250
251 $listParams = array( 'Limit' => $objectListFilter['number_of_objects'],
252 'SortBy' => array( 'published', false )
253 );
254
255 $nodeList = eZContentObjectTreeNode::subTreeMultiPaths( $nodesParams, $listParams );
256 }
257 else
258 $nodeList = null;
259 return $nodeList;
260 }
261
262 }
263
264 ?>
eZContentClass\fetch
static fetch( $id, $asObject=true, $version=eZContentClass::VERSION_STATUS_DEFINED, $user_id=false, $parent_id=null)
Definition: ezcontentclass.php:1116
eZContentObjectTreeNode\fetch
static fetch( $nodeID=false, $lang=false, $asObject=true, $conditions=false)
Definition: ezcontentobjecttreenode.php:3058
eZContentObjectTreeNode\subTreeMultiPaths
static subTreeMultiPaths( $nodesParams, $listParams=NULL)
Definition: ezcontentobjecttreenode.php:2157
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\count
static count( $def, $conds=null, $field=null)
Definition: ezpersistentobject.php:187
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
eZRSSExportItem
Handles RSS Export Item in eZ Publish.
Definition: ezrssexportitem.php:19
eZRSSExportItem\definition
static definition()
Definition: ezrssexportitem.php:21
eZRSSExportItem\sourceNode
& sourceNode()
Definition: ezrssexportitem.php:148
eZRSSExportItem\classAttributes
& classAttributes()
Definition: ezrssexportitem.php:103
eZRSSExportItem\sourcePath
& sourcePath()
Definition: ezrssexportitem.php:118
eZRSSExportItem\getAttributeMappings
static getAttributeMappings( $rssSources)
Definition: ezrssexportitem.php:190
eZRSSExportItem\fetchNodeList
static fetchNodeList( $rssSources, $objectListFilter)
Definition: ezrssexportitem.php:224
eZRSSExportItem\fetchFilteredList
static fetchFilteredList( $cond, $asObject=true, $status=eZRSSExport::STATUS_VALID)
Definition: ezrssexportitem.php:182
eZRSSExportItem\create
static create( $rssexport_id)
Definition: ezrssexportitem.php:88
eZRSSExportItem\$SourceNodeID
$SourceNodeID
Definition: ezrssexportitem.php:20
eZRSSExportItem\fetch
static fetch( $id, $asObject=true, $status=eZRSSExport::STATUS_VALID)
Definition: ezrssexportitem.php:165
eZRSSExport\STATUS_VALID
const STATUS_VALID
Definition: ezrssexport.php:33
eZRSSExport\STATUS_DRAFT
const STATUS_DRAFT
Definition: ezrssexport.php:34
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.