/
bfox_tools_ajax_div.php
85 lines (63 loc) · 1.75 KB
/
bfox_tools_ajax_div.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
class BfoxToolsAjaxDiv extends BfoxAjaxDiv {
/**
* @var BfoxCoreController
*/
var $core;
private $toolContextName;
private $refContextName;
var $template;
function __construct($name, BfoxToolsController $tools, $toolContextName, $refContextName) {
$this->core = $tools->core;
parent::__construct($name);
$this->toolContextName = $toolContextName;
$this->refContextName = $refContextName;
$this->template = 'bfox-tool-content-' . $name;
}
function init() {
$this->id = $this->core->tools->idForToolAjaxDiv($this->name);
parent::init();
}
function setContextNames($toolContextName, $refContextName) {
$this->toolContextName = $toolContextName;
$this->refContextName = $refContextName;
}
/**
* @return BfoxToolContext
*/
function toolContext() {
return $this->core->tools->contextForName($this->toolContextName);
}
/**
* @return BfoxRefContext
*/
function refContext() {
return $this->core->refs->contextForName($this->refContextName);
}
function echoContent() {
global $bfox;
$bfox->refs->pushContext($this->refContext());
$bfox->tools->pushContext($this->toolContext());
require $this->core->tools->templatePath($this->template);
}
function echoInitialContent() {
$refContext = $this->refContext();
$this->addClass($refContext->dependencyName);
$toolContext = $this->toolContext();
$this->addClass($toolContext->dependencyName);
parent::echoInitialContent();
}
function sendResponse() {
if (isset($_REQUEST['ref'])) {
$ref = new BfoxRef($_REQUEST['ref']);
$refContext = $this->refContext();
$refContext->setRef($ref);
}
if (isset($_REQUEST['tool'])) {
$toolContext = $this->toolContext();
$toolContext->setActiveTool($_REQUEST['tool']);
}
parent::sendResponse();
}
}
?>