-
Notifications
You must be signed in to change notification settings - Fork 10
/
class.sphinxstatuslogger.php
57 lines (52 loc) · 2.11 KB
/
class.sphinxstatuslogger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* This class is an observer to the following classes
* -Service: class.sphinxsearchinstall.php
*
* This class handles all of the saving of configurations
*/
class SphinxStatusLogger implements SplObserver {
public $Sender;
public $View;
public function __construct($Sender, $View) {
$this->Sender = $Sender;
$this->View = $View;
}
public function Update(SplSubject $Subject) {
$Status = $Subject->getStatus(); //retrieve status array
$Latest = $Status[sizeof($Status) - 1];
$ClassName = GetValue('Name', $Latest);
$Priority = GetValue('Priority', $Latest);
$Name = GetValue('SettingsName', $Latest);
$Value = GetValue('Value', $Latest);
//echo SPHINX_PREFIX.$Name.$Value.', ';
switch ($ClassName) {
case 'Service': //class.sphinxsearchinstall.php
case 'Install':
default:
if ($Priority != SS_FATAL_ERROR)
SaveToConfig('Plugin.SphinxSearch.' . $Name, $Value); //save this to configuration
else {
if ($Name) //if this is given, assume that the value will be FALSE
SaveToConfig('Plugin.SphinxSearch.' . $Name, FALSE); //non recoverable error has occured
}
break;
}
// @todo if the logger is not created with a valid sender and view file for error messages, simply don't display them
if ($Priority == SS_FATAL_ERROR && ($this->Sender != null && $this->View != null)) {
$Msg = GetValue('Message', $Latest);
//If an error, must handle this immidiatl to stop program flow from continuing
if (isset($Msg))
$this->Sender->Form->AddError($Msg, $Name);
else {
$this->Sender->Form->AddError('An error has occured in ' . $ClassName);
}
if (is_null($this->Sender))
throw new Exception($Msg);
else{
$this->Sender->Render($this->View);
DIE; //this is important
}
}
}
}