Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/xmlrpc/categorylist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: categorylist.php 9520 2002-05-08 13:05:20Z jb $
5 //
6 // Created on: <23-Oct-2000 17:53:46 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
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 the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // eZ article classes
28 // include_once( "ezarticle/classes/ezarticlecategory.php" );
29 // include_once( "ezarticle/classes/ezarticle.php" );
30 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
31 // include_once( "ezxmlrpc/classes/ezxmlrpcstruct.php" );
32 // include_once( "ezxmlrpc/classes/ezxmlrpcstring.php" );
33 // include_once( "classes/ezlocale.php" );
34 // include_once( "ezsitemanager/classes/ezsection.php" );
35
36 if ( $Command == "list" )
37 {
38 // usleep( 1000000 );
39
40 $list_categories = false;
41 $list_articles = false;
42 if ( is_object( $Data["ListType"] ) )
43 {
44 $ListType = $Data["ListType"]->value();
45 if ( is_object( $ListType["Catalogues"] ) )
46 $list_categories = true;
47 if ( is_object( $ListType["Elements"] ) )
48 $list_articles = true;
49 }
50
51 if ( !$list_categories and !$list_articles )
52 {
53 $list_categories = true;
54 $list_articles = true;
55 }
56
57 $offset = 0;
58 $max = -1;
59 $total = 0;
60
61 if ( is_object( $Data["Part"] ) )
62 {
63 $Part = $Data["Part"]->value();
64 $offset = $Part["Offset"]->value();
65 $max = $Part["Max"]->value();
66 }
67
68
69 $category = new eZArticleCategory( $ID );
70
71 $loc_max = $max;
72 $loc_offset = $offset;
73
74 $cat = array();
75 if ( $list_categories )
76 {
77 $categoryCount = $category->countByParent( $category, true, $User, true );
78 $total += $categoryCount;
79 if ( $loc_offset < $categoryCount )
80 {
81 $categoryList =& $category->getByParent( $category, true, "placement", $loc_offset, $loc_max, $User, true );
82 $loc_max -= count( $categoryList );
83
84 foreach ( $categoryList as $catItem )
85 {
86 $cat[] = new eZXMLRPCStruct( array( "URL" => createURLStruct( "ezarticle",
87 "category",
88 $catItem->id() ),
89 "Name" => new eZXMLRPCString( $catItem->name( false ) )
90 )
91 );
92 }
93 }
94 $loc_offset = max( 0, $loc_offset - $categoryCount );
95 }
96
97 $art = array();
98 if ( $list_articles )
99 {
100 $articleCount = $category->articleCount( true, true, true );
101 $total += $articleCount;
102 if ( $loc_max > 0 and $loc_offset >= 0 )
103 {
104 $articleList =& $category->articles( "alpha", true, true, $loc_offset, $loc_max, 0, true );
105 foreach( $articleList as $artItem )
106 {
107 $topic =& $artItem->topic();
108 $cols = array( "Publish date" => createDateTimeStruct( $artItem->published() ),
109 "Modification date" => createDateTimeStruct( $artItem->modified() ),
110 "Author" => new eZXMLRPCString( $artItem->authorText( false ) ),
111 "Topic" => new eZXMLRPCString( $topic->name() ),
112 );
113 $art[] = new eZXMLRPCStruct( array( "URL" => createURLStruct( "ezarticle",
114 "article",
115 $artItem->id() ),
116 "Name" => new eZXMLRPCString( $artItem->name( false ) ),
117 "Columns" => new eZXMLRPCStruct( $cols )
118 )
119 );
120 }
121 }
122 // if ( $offset > 0 )
123 // usleep( 5000000 );
124 }
125
126 $par = array();
127 if ( $offset == 0 )
128 {
129 $path =& $category->path();
130 if ( $category->id() != 0 )
131 {
132 $par[] = createURLStruct( "ezarticle", "category", 0 );
133 }
134 else
135 {
136 $par[] = createURLStruct( "ezarticle", "" );
137 }
138 foreach( $path as $item )
139 {
140 if ( $item[0] != $category->id() )
141 $par[] = createURLStruct( "ezarticle", "category", $item[0] );
142 }
143 }
144
145 $part_arr = array( "Offset" => new eZXMLRPCInt( $offset ),
146 "Total" => new eZXMLRPCInt( $total ) );
147 if ( $offset == 0 )
148 {
149 $part_arr["Begin"] = new eZXMLRPCBool( true );
150 }
151 if ( $total == $offset + count( $cat ) + count( $art ) )
152 {
153 $part_arr["End"] = new eZXMLRPCBool( true );
154 }
155 $part = new eZXMLRPCStruct( $part_arr );
156
157 if ( $offset == 0 )
158 $cols = new eZXMLRPCStruct( array( "Author" => new eZXMLRPCString( "text" ),
159 "Topic" => new eZXMLRPCString( "text" ),
160 "Publish date" => new eZXMLRPCString( "datetime" ),
161 "Modification date" => new eZXMLRPCString( "datetime" )
162 ) );
163
164 $section_id = eZArticleCategory::sectionIDStatic( $category->id() );
165 $section_lang = false;
166 if ( $section_id != 0 )
167 {
168 $section = new eZSection( $section_id );
169 $section_lang = $section->language();
170 }
171
172 if ( $articleCount >= count( $art ) && $categoryCount >= count( $cat ) )
173 {
174 $ret = array( "Catalogues" => $cat,
175 "Elements" => $art,
176 "Path" => $par,
177 "Part" => $part );
178 if ( $offset == 0 )
179 $ret["Columns"] = $cols;
180 if ( $section_lang != false )
181 {
182 $charsetLocale = new eZLocale( $section_lang );
183 $section_charset = $charsetLocale->languageISO();
184 $ret["Section"] = new eZXMLRPCStruct( array( "Language" => $section_lang,
185 "Charset" => $section_charset ) );
186 }
187 $ReturnData = new eZXMLRPCStruct( $ret );
188 }
189 else
190 {
191 if ( $articleCount < count( $art ) )
192 {
193 $Error = createErrorMessage( EZERROR_CUSTOM,
194 "The article count was lower than listed articles, probably a bug in eZ article",
195 EZARTICLE_WRONG_ARTICLE_COUNT );
196 }
197 else if ( $categoryCount < count( $cat ) )
198 {
199 $Error = createErrorMessage( EZERROR_CUSTOM,
200 "The category count was lower than listed categories, probably a bug in eZ article",
201 EZARTICLE_WRONG_CATEGORY_COUNT );
202 }
203 }
204 }
205 else if ( $Command == "tree" )
206 {
207 $cat = new eZArticleCategory();
208 // $cat->setName( "test" );
209 $tree =& categoryTree( $cat, $User );
210 $ReturnData = createTreeStruct( $tree, "ezarticle", "category" );
211 }
212 else if ( $Command == "search" )
213 {
214 $keywords = $Data["Keywords"]->value();
215 $texts = array();
216 foreach( $keywords as $keyword )
217 {
218 $texts[] = $keyword->value();
219 }
220 $elements = array();
221 $result =& eZArticleCategory::search( $texts, true, "name", $User );
222 foreach( $result as $item )
223 {
224 $itemid = $item->id();
225 $catid = $item->parent( false );
226 $cat = new eZArticleCategory();
227 $cat->get( $catid );
228 $element = array();
229 $element["Name"] = new eZXMLRPCString( $item->name( false ) );
230 $element["CategoryName"] = new eZXMLRPCString( $cat->name( false ) );
231 $element["Location"] = createURLStruct( "ezarticle", "category", $item->id() );
232 $element["CategoryLocation"] = createURLStruct( "ezarticle", "category", $catid );
233 $element["WebURL"] = new eZXMLRPCString( rewriteWebURL( "/article/archive/$itemid/" ) );
234 $element["CategoryWebURL"] = new eZXMLRPCString( rewriteWebURL( "/article/archive/$catid/" ) );
235 $elements[] = new eZXMLRPCStruct( $element );
236 }
237 $ret = array( "Elements" => new eZXMLRPCArray( $elements ) );
238 handleSearchData( $ret );
239 $ReturnData = new eZXMLRPCStruct( $ret );
240 }
241
242 function &categoryTree( $cat, &$User )
243 {
244 $children =& eZArticleCategory::getByParent( $cat, true, 'placement', 0, -1, $User, true );
245 $child_array = array();
246 foreach( $children as $child )
247 {
248 $child_array[] = categoryTree( $child, $user );
249 // break;
250 }
251 $section_id = eZArticleCategory::sectionIDStatic( $cat->id() );
252 $section_lang = false;
253 if ( $section_id != 0 )
254 {
255 $section = new eZSection( $section_id );
256 $section_lang = $section->language();
257 }
258 $item = array( "ID" => $cat->id(),
259 "Name" => $cat->name( false ),
260 "Children" => $child_array );
261 if ( $section_lang != false )
262 {
263 $charsetLocale = new eZLocale( $section_lang );
264 $section_charset = $charsetLocale->languageISO();
265 $item["Section"] = new eZXMLRPCStruct( array( "Language" => $section_lang,
266 "Charset" => $section_charset ) );
267 }
268 return $item;
269 }
270
271 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: admin/adlist.php:86
$topic
foreach( $authorArray as $author) $topic
Definition: admin/articleedit.php:852
$articleCount
$articleCount
Definition: admin/articlelist.php:456
$total
else $total["inctax"]
Definition: checkout.php:1359
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleCategory\sectionIDStatic
static sectionIDStatic($categoryID)
Definition: ezarticlecategory.php:662
eZArticleCategory\getByParent
getByParent( $parent, $showAll=false, $sortby='placement', $offset=0, $max=-1, $user=false, $check_write=false)
Definition: ezarticlecategory.php:373
eZArticleCategory\search
& search( $name, $showAll=false, $sortby='placement', $user=false)
Definition: ezarticlecategory.php:282
eZLocale
Definition: ezlocale.php:119
eZSection
Definition: ezsection.php:45
eZXMLRPCArray
Definition: ezxmlrpcarray.php:37
eZXMLRPCBool
Definition: ezxmlrpcbool.php:37
eZXMLRPCInt
Definition: ezxmlrpcint.php:37
eZXMLRPCString
Definition: ezxmlrpcstring.php:37
eZXMLRPCStruct
Definition: ezxmlrpcstruct.php:37
$item
$item
Definition: classes/admin/linklist.php:228
$result
$result
Definition: companysearch.php:94
$tree
$tree
Definition: ezad/admin/categoryedit.php:172
$ListType
$ListType
Definition: ezaddress/admin/datasupplier.php:31
categoryTree
if( $Command=="list") else if( $Command=="tree") else if( $Command=="search")& categoryTree( $cat, &$User)
Definition: ezarticle/xmlrpc/categorylist.php:242
EZARTICLE_WRONG_CATEGORY_COUNT
const EZARTICLE_WRONG_CATEGORY_COUNT
Definition: ezarticle/xmlrpc/datasupplier.php:30
EZARTICLE_WRONG_ARTICLE_COUNT
const EZARTICLE_WRONG_ARTICLE_COUNT
Definition: ezarticle/xmlrpc/datasupplier.php:31
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$Error
if(isset( $EditButton)) if(!empty( $CancelButton)) if(!empty( $PreviewButton)) if( $Action=="preview") switch( $Action) $Error
Definition: ezforum/user/messageedit.php:134
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$offset
$offset
Definition: ezstats/admin/cron.php:51
$element
if(! $parent) $element
Definition: folder.php:64
$elements
$elements
Definition: formedit.php:355
$articleList
$articleList
Definition: pendinglist.php:112
$ReturnData
$ReturnData
Definition: tag.php:48
$part
$part
Definition: tag.php:46
$part_arr
foreach( $tagList as $tag) $part_arr
Definition: tag.php:42
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.