[TEP-COMMIT] [CVS catalog] new service class to start and stop service modules

anonymous-OfajU3CKLf1/[email protected] 13 Apr 2004 08:02:55 -0000
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
Commit in catalog/catalog/includes/classes on MAIN

services.php +63 added 1.1

new service class to start and stop service modules

----------

catalog /catalog /includes /classes

services.php added at 1.1

diff -N services.php
--- /dev/null Tue Apr 13 10:02:53 2004
+++ /tmp/cvsAAA6DaWmM Tue Apr 13 10:02:53 2004
@@ -0,0 +1,63 @@

+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class osC_Services {
+ var $services,
+ $started_services;
+
+ function osC_Services() {
+ $this->services = explode(';', MODULE_SERVICES_INSTALLED);
+ }
+
+ function startServices() {
+ $this->started_services = array();
+
+ foreach ($this->services as $service) {
+ $this->startService($service);
+ }
+ }
+
+ function stopServices() {
+/*
+ ugly workaround to force the output_compression/GZIP service module to be stopped last
+ to make sure all content in the buffer is compressed and sent to the client
+*/
+ if ($this->isStarted('output_compression')) {
+ $key = array_search('output_compression', $this->started_services);
+ unset($this->started_services[$key]);
+
+ $this->started_services[] = 'output_compression';
+ }
+
+ foreach ($this->started_services as $service) {
+ $this->stopService($service);
+ }
+ }
+
+ function startService($service) {
+ include('includes/modules/services/' . $service . '.php');
+
+ if (@call_user_func(array('osC_Services_' . $service, 'start'))) {
+ $this->started_services[] = $service;
+ }
+ }
+
+ function stopService($service) {
+ @call_user_func(array('osC_Services_' . $service, 'stop'));
+ }
+
+
+ function isStarted($service) {
+ return in_array($service, $this->started_services);
+ }
+ }
+?>

CVSspam 0.2.8

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click