tiki  21.2
About: Tiki Wiki is a Groupware/CMS (Content Management System) solution that has features like Wikis, Forums, Blogs, Articles, Image Gallery, Map Server, Link Directory, Multilingual Support, Bug Tracker, RSS Feeds etc. Latest release 21 with Long Term Support (LTS).
  Fossies Dox: tiki-21.2.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

11.php
Go to the documentation of this file.
1 <?php
19 require_once 'PEAR/REST.php';
20 
34 {
38  var $_rest;
39 
40  function __construct($config, $options = array())
41  {
42  $this->_rest = new PEAR_REST($config, $options);
43  }
44 
45  function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false, $channel = false)
46  {
47  $categorylist = $this->_rest->retrieveData($base . 'c/categories.xml', false, false, $channel);
48  if (PEAR::isError($categorylist)) {
49  return $categorylist;
50  }
51 
52  $ret = array();
53  if (!is_array($categorylist['c']) || !isset($categorylist['c'][0])) {
54  $categorylist['c'] = array($categorylist['c']);
55  }
56 
57  PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
58 
59  foreach ($categorylist['c'] as $progress => $category) {
60  $category = $category['_content'];
61  $packagesinfo = $this->_rest->retrieveData($base .
62  'c/' . urlencode($category) . '/packagesinfo.xml', false, false, $channel);
63 
64  if (PEAR::isError($packagesinfo)) {
65  continue;
66  }
67 
68  if (!is_array($packagesinfo) || !isset($packagesinfo['pi'])) {
69  continue;
70  }
71 
72  if (!is_array($packagesinfo['pi']) || !isset($packagesinfo['pi'][0])) {
73  $packagesinfo['pi'] = array($packagesinfo['pi']);
74  }
75 
76  foreach ($packagesinfo['pi'] as $packageinfo) {
77  if (empty($packageinfo)) {
78  continue;
79  }
80 
81  $info = $packageinfo['p'];
82  $package = $info['n'];
83  $releases = isset($packageinfo['a']) ? $packageinfo['a'] : false;
84  unset($latest);
85  unset($unstable);
86  unset($stable);
87  unset($state);
88 
89  if ($releases) {
90  if (!isset($releases['r'][0])) {
91  $releases['r'] = array($releases['r']);
92  }
93 
94  foreach ($releases['r'] as $release) {
95  if (!isset($latest)) {
96  if ($dostable && $release['s'] == 'stable') {
97  $latest = $release['v'];
98  $state = 'stable';
99  }
100  if (!$dostable) {
101  $latest = $release['v'];
102  $state = $release['s'];
103  }
104  }
105 
106  if (!isset($stable) && $release['s'] == 'stable') {
107  $stable = $release['v'];
108  if (!isset($unstable)) {
109  $unstable = $stable;
110  }
111  }
112 
113  if (!isset($unstable) && $release['s'] != 'stable') {
114  $unstable = $release['v'];
115  $state = $release['s'];
116  }
117 
118  if (isset($latest) && !isset($state)) {
119  $state = $release['s'];
120  }
121 
122  if (isset($latest) && isset($stable) && isset($unstable)) {
123  break;
124  }
125  }
126  }
127 
128  if ($basic) { // remote-list command
129  if (!isset($latest)) {
130  $latest = false;
131  }
132 
133  if ($dostable) {
134  // $state is not set if there are no releases
135  if (isset($state) && $state == 'stable') {
136  $ret[$package] = array('stable' => $latest);
137  } else {
138  $ret[$package] = array('stable' => '-n/a-');
139  }
140  } else {
141  $ret[$package] = array('stable' => $latest);
142  }
143 
144  continue;
145  }
146 
147  // list-all command
148  if (!isset($unstable)) {
149  $unstable = false;
150  $state = 'stable';
151  if (isset($stable)) {
152  $latest = $unstable = $stable;
153  }
154  } else {
155  $latest = $unstable;
156  }
157 
158  if (!isset($latest)) {
159  $latest = false;
160  }
161 
162  $deps = array();
163  if ($latest && isset($packageinfo['deps'])) {
164  if (!is_array($packageinfo['deps']) ||
165  !isset($packageinfo['deps'][0])
166  ) {
167  $packageinfo['deps'] = array($packageinfo['deps']);
168  }
169 
170  $d = false;
171  foreach ($packageinfo['deps'] as $dep) {
172  if ($dep['v'] == $latest) {
173  $d = unserialize($dep['d']);
174  }
175  }
176 
177  if ($d) {
178  if (isset($d['required'])) {
179  if (!class_exists('PEAR_PackageFile_v2')) {
180  require_once 'PEAR/PackageFile/v2.php';
181  }
182 
183  if (!isset($pf)) {
184  $pf = new PEAR_PackageFile_v2;
185  }
186 
187  $pf->setDeps($d);
188  $tdeps = $pf->getDeps();
189  } else {
190  $tdeps = $d;
191  }
192 
193  foreach ($tdeps as $dep) {
194  if ($dep['type'] !== 'pkg') {
195  continue;
196  }
197 
198  $deps[] = $dep;
199  }
200  }
201  }
202 
203  $info = array(
204  'stable' => $latest,
205  'summary' => $info['s'],
206  'description' => $info['d'],
207  'deps' => $deps,
208  'category' => $info['ca']['_content'],
209  'unstable' => $unstable,
210  'state' => $state
211  );
212  $ret[$package] = $info;
213  }
214  }
215 
216  PEAR::popErrorHandling();
217  return $ret;
218  }
219 
226  function listCategories($base, $channel = false)
227  {
228  $categorylist = $this->_rest->retrieveData($base . 'c/categories.xml', false, false, $channel);
229  if (PEAR::isError($categorylist)) {
230  return $categorylist;
231  }
232 
233  if (!is_array($categorylist) || !isset($categorylist['c'])) {
234  return array();
235  }
236 
237  if (isset($categorylist['c']['_content'])) {
238  // only 1 category
239  $categorylist['c'] = array($categorylist['c']);
240  }
241 
242  return $categorylist['c'];
243  }
244 
253  function listCategory($base, $category, $info = false, $channel = false)
254  {
255  if ($info == false) {
256  $url = '%s'.'c/%s/packages.xml';
257  } else {
258  $url = '%s'.'c/%s/packagesinfo.xml';
259  }
260  $url = sprintf($url,
261  $base,
262  urlencode($category));
263 
264  // gives '404 Not Found' error when category doesn't exist
265  $packagelist = $this->_rest->retrieveData($url, false, false, $channel);
266  if (PEAR::isError($packagelist)) {
267  return $packagelist;
268  }
269  if (!is_array($packagelist)) {
270  return array();
271  }
272 
273  if ($info == false) {
274  if (!isset($packagelist['p'])) {
275  return array();
276  }
277  if (!is_array($packagelist['p']) ||
278  !isset($packagelist['p'][0])) { // only 1 pkg
279  $packagelist = array($packagelist['p']);
280  } else {
281  $packagelist = $packagelist['p'];
282  }
283  return $packagelist;
284  }
285 
286  // info == true
287  if (!isset($packagelist['pi'])) {
288  return array();
289  }
290 
291  if (!is_array($packagelist['pi']) ||
292  !isset($packagelist['pi'][0])) { // only 1 pkg
293  $packagelist_pre = array($packagelist['pi']);
294  } else {
295  $packagelist_pre = $packagelist['pi'];
296  }
297 
298  $packagelist = array();
299  foreach ($packagelist_pre as $i => $item) {
300  // compatibility with r/<latest.txt>.xml
301  if (isset($item['a']['r'][0])) {
302  // multiple releases
303  $item['p']['v'] = $item['a']['r'][0]['v'];
304  $item['p']['st'] = $item['a']['r'][0]['s'];
305  } elseif (isset($item['a'])) {
306  // first and only release
307  $item['p']['v'] = $item['a']['r']['v'];
308  $item['p']['st'] = $item['a']['r']['s'];
309  }
310 
311  $packagelist[$i] = array('attribs' => $item['p']['r'],
312  '_content' => $item['p']['n'],
313  'info' => $item['p']);
314  }
315 
316  return $packagelist;
317  }
318 
327  function betterStates($state, $include = false)
328  {
329  static $states = array('snapshot', 'devel', 'alpha', 'beta', 'stable');
330  $i = array_search($state, $states);
331  if ($i === false) {
332  return false;
333  }
334  if ($include) {
335  $i--;
336  }
337  return array_slice($states, $i + 1);
338  }
339 }
340 ?>
PEAR_REST_11\listCategories
listCategories($base, $channel=false)
Definition: 11.php:226
$base
$base
Definition: route.php:276
$latest
$latest
Definition: tiki-export_wiki_pages.php:33
PEAR_PackageFile_v2
Definition: v2.php:30
$pf
$pf
Definition: tiki-user_bookmarks.php:87
PEAR_REST_11\$_rest
$_rest
Definition: 11.php:38
PEAR_REST_11\betterStates
betterStates($state, $include=false)
Definition: 11.php:327
elseif
if(isset($_GET['msg'])) elseif(isset( $_SESSION[ 'msg']))
Definition: tiki-setup.php:370
php
PEAR\isError
static isError($data, $code=null)
Definition: PEAR.php:296
$info
if(strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !=false) global $info
Definition: editmode.php:12
$url
$url
Definition: include_socialnetworks.php:15
$options
$options
Definition: get_strings.php:50
$d
$d
Definition: tiki-calendar_setup.php:178
$config
foreach($_REQUEST['channels'] as $info) $config
Definition: tiki-channel.php:41
PEAR_REST_11
Definition: 11.php:34
PEAR_REST_11\listCategory
listCategory($base, $category, $info=false, $channel=false)
Definition: 11.php:253
PEAR_REST_11\__construct
__construct($config, $options=array())
Definition: 11.php:40
PEAR_ERROR_RETURN
const PEAR_ERROR_RETURN
Definition: PEAR.php:24
$item
$item
Definition: tracker_force_fill.php:38
PEAR_REST
Definition: REST.php:36
PEAR_REST_11\listAll
listAll($base, $dostable, $basic=true, $searchpackage=false, $searchsummary=false, $channel=false)
Definition: 11.php:45
$i
$i
Definition: tiki-objectpermissions.php:543