Changeset 16098
- Timestamp:
- 04/15/08 17:28:19 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/MidCOM_2_8/midcom.helper.replicator/exporter/staging2live.php
r16096 r16098 55 55 if (isset($this->exportability[$object->guid])) 56 56 { 57 /* 57 58 $GLOBALS['midcom_helper_replicator_logger']->push_prefix('exporter'); 58 59 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "\$this->exportability already set, returning " . (int)$this->exportability[$object->guid]); 59 60 $GLOBALS['midcom_helper_replicator_logger']->pop_prefix(); 61 */ 60 62 return $this->exportability[$object->guid]; 61 63 } … … 313 315 function serialize_children(&$object) 314 316 { 315 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "serialize_children called");317 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "serialize_children called"); 316 318 $serializations = array(); 317 319 if ( $object->metadata->deleted branches/MidCOM_2_8/midcom.helper.replicator/queuemanager.php
r16096 r16098 85 85 * @todo refactor to smaller methods 86 86 * @todo query for subscriptions only once 87 * @todo raise UIMessage in style of 'N object queued to subscription X' 87 88 */ 88 89 function add_to_queue(&$object, $rewrite_to_delete = false) … … 219 220 { 220 221 $msg = "Marked GUID '{$export_guid}' as exported to queue \"{$subscription->title}\""; 221 $GLOBALS['midcom_helper_replicator_logger']->log($msg);222 //$GLOBALS['midcom_helper_replicator_logger']->log($msg); 222 223 debug_add($msg); 223 224 } … … 237 238 } 238 239 239 /** 240 * Gets/creates the path for subscriptions spool dir 241 * @todo make a smarter recursive directory creator 242 */ 243 function _get_subscription_basedir(&$subscription) 240 function list_path_items($path) 241 { 242 $path = preg_replace('%/{2,}|/$%', '', $path); 243 $ret = array(); 244 $dp = opendir($path); 245 if (!$dp) 246 { 247 return false; 248 } 249 250 while (($file_name = readdir($dp)) !== false) 251 { 252 if ( $file_name == '.' 253 || $file_name == '..') 254 { 255 continue; 256 } 257 $file_path = "{$path}/{$file_name}"; 258 if (is_dir($file_path)) 259 { 260 $ret = array_merge($ret, midcom_helper_replicator_queuemanager::list_path_items($file_path)); 261 continue; 262 } 263 $ret[] = $file_path; 264 } 265 closedir($dp); 266 267 sort($ret); 268 return $ret; 269 } 270 271 function get_sg_basedir(&$subscription) 244 272 { 245 273 // Normalize basedir, no trailing slash and no consecutive slashes … … 259 287 debug_pop(); 260 288 } 261 262 289 // Append sitegroup name 263 290 $sitegroup_base = "{$global_base}/" . $this->safe_sg_name($subscription->sitegroup); … … 276 303 debug_pop(); 277 304 } 305 return $sitegroup_base; 306 } 307 308 /** 309 * Gets/creates the path for subscriptions spool dir 310 * @todo make a smarter recursive directory creator 311 */ 312 function get_subscription_basedir(&$subscription) 313 { 314 $sitegroup_base = $this->get_sg_basedir($subscription); 315 if ($sitegroup_base === false) 316 { 317 return false; 318 } 278 319 279 320 $subscription_path = "{$sitegroup_base}/{$subscription->guid}"; … … 294 335 } 295 336 296 function _get_subscription_quarantine_basedir(&$subscription) 297 { 298 $global_base = $this->_config->get('queue_root_dir'); 299 if (!is_dir($global_base)) 300 { 301 // The configuration key might have dynamic part to it 302 debug_push_class(__CLASS__, __FUNCTION__); 303 debug_add("directory {$global_base} does not exist, creating", MIDCOM_LOG_DEBUG); 304 if (!mkdir($global_base)) 305 { 306 // TODO: Error reporting 307 debug_add("could not create directory {$global_base}", MIDCOM_LOG_ERROR); 308 debug_pop(); 309 return false; 310 } 311 debug_pop(); 312 } 313 314 // Append sitegroup name 315 $sitegroup_base = "{$global_base}/" . $this->safe_sg_name($subscription->sitegroup); 316 if (!is_dir($sitegroup_base)) 317 { 318 // The configuration key might have dynamic part to it 319 debug_push_class(__CLASS__, __FUNCTION__); 320 debug_add("directory {$sitegroup_base} does not exist, creating", MIDCOM_LOG_DEBUG); 321 if (!mkdir($sitegroup_base)) 322 { 323 // TODO: Error reporting 324 debug_add("could not create directory {$sitegroup_base}", MIDCOM_LOG_ERROR); 325 debug_pop(); 326 return false; 327 } 328 debug_pop(); 329 } 337 function get_subscription_quarantine_basedir(&$subscription) 338 { 339 $sitegroup_base = $this->get_sg_basedir($subscription); 340 if ($sitegroup_base === false) 341 { 342 return false; 343 } 344 330 345 $subscription_path = "{$sitegroup_base}/{$subscription->guid}-quarantine"; 331 346 if (!is_dir($subscription_path)) … … 347 362 function _get_subscription_quarantine_queuedir(&$subscription) 348 363 { 349 $quarantine_path = $this-> _get_subscription_quarantine_basedir($subscription);364 $quarantine_path = $this->get_subscription_quarantine_basedir($subscription); 350 365 if ($quarantine_path === false) 351 366 { … … 373 388 function _get_subscription_queue_basedir(&$subscription) 374 389 { 375 $subscription_path = $this-> _get_subscription_basedir($subscription);390 $subscription_path = $this->get_subscription_basedir($subscription); 376 391 if ($subscription_path === false) 377 392 { … … 462 477 } 463 478 464 465 479 /** 466 480 * Helper for process_queue, removes processed items, quarantines failed ones … … 486 500 continue; 487 501 } 488 $GLOBALS['midcom_helper_replicator_logger']->log("File {$item_path} removed from queue \"{$subscription->title}\"");502 //$GLOBALS['midcom_helper_replicator_logger']->log("File {$item_path} removed from queue \"{$subscription->title}\""); 489 503 unset($items_paths[$item_key]); 490 504 } … … 495 509 debug_pop(); 496 510 } 511 512 497 513 498 514 /** … … 541 557 return false; 542 558 } 543 $GLOBALS['midcom_helper_replicator_logger']->log("Read {$item_key} from queue \"{$subscription->title}\" file {$item_path}");559 //$GLOBALS['midcom_helper_replicator_logger']->log("Read {$item_key} from queue \"{$subscription->title}\" file {$item_path}"); 544 560 $items_paths[$item_key] = $item_path; 545 561 unset($item_key, $item_path); … … 650 666 /** 651 667 * Helper for process_queue, processes given subscriptions queues 668 * @todo use list_path_items ?? 652 669 */ 653 670 function _process_queue_subscription(&$subscription) 654 671 { 655 672 debug_push_class(__CLASS__, __FUNCTION__); 656 $subscription_path = $this-> _get_subscription_basedir($subscription);673 $subscription_path = $this->get_subscription_basedir($subscription); 657 674 if ($subscription_path === false) 658 675 { branches/MidCOM_2_8/midcom.helper.replicator/style/midcom-helper-replicator-list.php
r12765 r16098 2 2 3 3 <?php 4 // Check queue directory status4 // FIXME: the configs may have all kinds of dynamic parts, also should be per subscription 5 5 if (!is_dir($data['local_config']->get('queue_root_dir'))) 6 6 { … … 41 41 <thead> 42 42 <tr> 43 <th><abbr title="<?php echo $_MIDCOM->i18n->get_string('queued / quarantined items', 'midcom.helper.replicator'); ?>"><?php echo $_MIDCOM->i18n->get_string('status', 'midcom.helper.replicator'); ?></abbr></th> 43 44 <th><?php echo $_MIDCOM->i18n->get_string('subscription', 'midcom.helper.replicator'); ?></th> 44 45 <th><?php echo $_MIDCOM->i18n->get_string('exporter', 'midcom.helper.replicator'); ?></th> … … 48 49 <tbody> 49 50 <?php 51 $qm =& midcom_helper_replicator_queuemanager::get(); 50 52 foreach ($data['subscriptions'] as $subscription) 51 53 { 52 54 $transporter = midcom_helper_replicator_transporter::create($subscription); 55 $queued_items = $qm->list_path_items($qm->get_subscription_basedir($subscription)); 56 $quarantined_items = $qm->list_path_items($qm->get_subscription_quarantine_basedir($subscription)); 53 57 ?> 54 58 <tr> 59 <td><?php echo count($queued_items) . ' / ' . count($quarantined_items); ?></td> 55 60 <td><a href="&(prefix);edit/&(subscription.guid);/">&(subscription.title);</a></th> 56 61 <td><?php echo $_MIDCOM->i18n->get_string($data['schemadb'][$subscription->exporter]->description, 'midcom.helper.replicator'); ?></td> 57 <td ><?php echo $transporter->get_information(); ?></td>62 <td class="subscription_info"><?php echo $transporter->get_information(); ?></td> 58 63 </tr> 59 64 <?php
