Quick Search:

View

Revision:

Diff

Diff from 1498 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/services.php

Annotated File View

hpdl
1
1 <?php
2 /*
mattice
151
3   $Id: services.php 1498 2007-03-29 14:04:50Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2004 osCommerce
9
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1
13 */
14
15   class osC_Services {
16     var $services,
hpdl
368
17         $started_services,
18         $call_before_page_content = array(),
19         $call_after_page_content = array();
hpdl
1
20
21     function osC_Services() {
22       $this->services = explode(';', MODULE_SERVICES_INSTALLED);
23     }
24
25     function startServices() {
26       $this->started_services = array();
27
28       foreach ($this->services as $service) {
29         $this->startService($service);
30       }
31     }
32
33     function stopServices() {
34 /*
35   ugly workaround to force the output_compression/GZIP service module to be stopped last
36   to make sure all content in the buffer is compressed and sent to the client
37 */
38       if ($this->isStarted('output_compression')) {
39         $key = array_search('output_compression', $this->started_services);
40         unset($this->started_services[$key]);
41
42         $this->started_services[] = 'output_compression';
43       }
44
45       foreach ($this->started_services as $service) {
46         $this->stopService($service);
47       }
48     }
49
50     function startService($service) {
hpdl
1493
51       include('includes/modules/services/' . $service . '.php');
hpdl
1
52
53       if (@call_user_func(array('osC_Services_' . $service, 'start'))) {
54         $this->started_services[] = $service;
55       }
56     }
57
58     function stopService($service) {
59       @call_user_func(array('osC_Services_' . $service, 'stop'));
60     }
61
62
63     function isStarted($service) {
64       return in_array($service, $this->started_services);
65     }
hpdl
368
66
67     function addCallBeforePageContent($object, $method) {
68       $this->call_before_page_content[] = array($object, $method);
69     }
70
71     function addCallAfterPageContent($object, $method) {
72       $this->call_after_page_content[] = array($object, $method);
73     }
74
75     function hasBeforePageContentCalls() {
76       return !empty($this->call_before_page_content);
77     }
78
79     function hasAfterPageContentCalls() {
80       return !empty($this->call_after_page_content);
81     }
82
83     function getCallBeforePageContent() {
84       return $this->call_before_page_content;
85     }
86
87     function getCallAfterPageContent() {
88       return $this->call_after_page_content;
89     }
hpdl
1
90   }
91 ?>